aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/include/openbsc/ipaccess.h
blob: 388ad643a976ade3e22c74911c3e3a421b343b7f (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef _IPACCESS_H
#define _IPACCESS_H

#include "e1_input.h"
#include "gsm_subscriber.h"
#include <osmocom/core/linuxlist.h>

#define IPA_TCP_PORT_OML	3002
#define IPA_TCP_PORT_RSL	3003

struct ipaccess_head {
	uint16_t len;	/* network byte order */
	uint8_t proto;
	uint8_t data[0];
} __attribute__ ((packed));

struct ipaccess_head_ext {
	uint8_t proto;
	uint8_t data[0];
} __attribute__ ((packed));

enum ipaccess_proto {
	IPAC_PROTO_RSL		= 0x00,
	IPAC_PROTO_IPACCESS	= 0xfe,
	IPAC_PROTO_SCCP		= 0xfd,
	IPAC_PROTO_OML		= 0xff,


	/* OpenBSC extensions */
	IPAC_PROTO_OSMO		= 0xee,
	IPAC_PROTO_MGCP_OLD	= 0xfc,
};

enum ipaccess_proto_ext {
	IPAC_PROTO_EXT_CTRL	= 0x00,
	IPAC_PROTO_EXT_MGCP	= 0x01,
	IPAC_PROTO_EXT_LAC	= 0x02,
};

enum ipaccess_msgtype {
	IPAC_MSGT_PING		= 0x00,
	IPAC_MSGT_PONG		= 0x01,
	IPAC_MSGT_ID_GET	= 0x04,
	IPAC_MSGT_ID_RESP	= 0x05,
	IPAC_MSGT_ID_ACK	= 0x06,

	/* OpenBSC extension */
	IPAC_MSGT_SCCP_OLD	= 0xff,
};

enum ipaccess_id_tags {
	IPAC_IDTAG_SERNR		= 0x00,
	IPAC_IDTAG_UNITNAME		= 0x01,
	IPAC_IDTAG_LOCATION1		= 0x02,
	IPAC_IDTAG_LOCATION2		= 0x03,
	IPAC_IDTAG_EQUIPVERS		= 0x04,
	IPAC_IDTAG_SWVERSION		= 0x05,
	IPAC_IDTAG_IPADDR		= 0x06,
	IPAC_IDTAG_MACADDR		= 0x07,
	IPAC_IDTAG_UNIT			= 0x08,
};

struct ipac_msgt_sccp_state {
	uint8_t	src_ref[3];
	uint8_t	dst_ref[3];
	uint8_t trans_id;
	uint8_t invoke_id;
	char		imsi[GSM_IMSI_LENGTH];
} __attribute__((packed));

/*
 * @add_remove 0 for remove, 1 for add, 3 to asK
 * @nr_lacs Number of extra lacs inside this package
 * @lac One lac entry
 */
struct ipac_ext_lac_cmd {
	uint8_t add_remove;
	uint8_t nr_extra_lacs;
	uint16_t lac;
	uint8_t data[0];
} __attribute__((packed));

int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa);

/*
 * methods for parsing and sending a message
 */
int ipaccess_rcvmsg_base(struct msgb *msg, struct bsc_fd *bfd);
struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error);
void ipaccess_prepend_header(struct msgb *msg, int proto);
void ipaccess_prepend_header_ext(struct msgb *msg, int proto);
int ipaccess_send_pong(int fd);
int ipaccess_send_id_ack(int fd);
int ipaccess_send_id_req(int fd);

const char *ipaccess_idtag_name(uint8_t tag);
int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
int ipaccess_parse_unitid(const char *str, uint16_t *site_id, uint16_t *bts_id, uint16_t *trx_id);

int ipaccess_drop_oml(struct gsm_bts *bts);
int ipaccess_drop_rsl(struct gsm_bts_trx *trx);

/*
 * Firmware specific header
 */
struct sdp_firmware {
	char magic[4];
	char more_magic[2];
	uint16_t more_more_magic;
	uint32_t header_length;
	uint32_t file_length;
	char sw_part[20];
	char text1[64];
	char time[12];
	char date[14];
	char text2[10];
	char version[20];
	uint16_t table_offset;
	/* stuff i don't know */
} __attribute__((packed));

struct sdp_header_entry {
	uint16_t something1;
	char text1[64];
	char time[12];
	char date[14];
	char text2[10];
	char version[20];
	uint32_t length;
	uint32_t addr1;
	uint32_t addr2;
	uint32_t start;
} __attribute__((packed));

struct sdp_header_item {
	struct sdp_header_entry header_entry;
	struct llist_head entry;
	off_t absolute_offset;
};

struct sdp_header {
	struct sdp_firmware firmware_info;

	/* for more_magic a list of sdp_header_entry_list */
	struct llist_head header_list;

	/* the entry of the sdp_header */
	struct llist_head entry;
};

int ipaccess_analyze_file(int fd, const unsigned int st_size, const unsigned base_offset, struct llist_head *list);

#endif /* _IPACCESS_H */