forked from harpreet-s/xgoldmon
-
Notifications
You must be signed in to change notification settings - Fork 6
/
xgoldmon.h
84 lines (71 loc) · 2.39 KB
/
xgoldmon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* (C) 2013 by Tobias Engel <[email protected]>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef XGOLDMON_H
#define XGOLDMON_H
#include <stdint.h>
#include <stdio.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/gsmtap_util.h>
struct xglog_msg {
uint16_t len;
uint8_t unknown[14];
uint8_t seqno;
uint8_t data[];
} __attribute__((packed));
struct xglog_hdr {
uint8_t type;
uint8_t seqno;
uint16_t len;
uint8_t unknown;
struct xglog_msg msg;
} __attribute__((packed));
struct rmsg_act {
// id contains values for data indices 2, 5, 7 and 12. -1 indicates
// "don't care"
int16_t id[4];
uint8_t gsmtap_chan;
uint16_t msg_start_offset;
uint16_t msg_len;
uint16_t msg_len_offset;
struct msgb *(*action)(uint8_t gsmtap_chan,
uint8_t *msg_start,
uint16_t msg_len,
uint8_t **searchmsg_p);
};
struct phone2ltable {
char *ptype;
struct rmsg_act *ltable;
int unescape;
};
#define hexdump(buf, len) hexdump_addr(buf, len, 0)
#define DBG(level, statement) do { if(dbglevel >= level) { statement; } } while(0)
#define IDMATCH(vt, vd) ((vt) == -1 || (vt) == (vd))
// fixme: doesn't work for SACCH messages (too long)
#define SEARCHLEN 20 // 23 - 3 bytes lapdm header
#define READLOG_UNESCAPE 1
extern struct rmsg_act note2_ltable[];
extern struct rmsg_act s3_ltable[];
extern struct rmsg_act s2_ltable[];
extern struct phone2ltable p2t[];
extern int dbglevel;
void hexdump_addr(uint8_t *buf, int len, uint32_t addr_start);
void parse_logmsg(FILE *f, int printlog, struct phone2ltable *ltable, struct gsmtap_inst *gti);
struct xglog_hdr *read_logmsg(FILE *f, int unescape);
#endif