blob: 1d00d97921e26d4206a9b2300a876b12c73e2faa [file] [log] [blame]
Jonathan Santos03fd8d02011-05-25 13:54:02 -04001#ifndef _IPACCESS_H
2#define _IPACCESS_H
3
4#include "e1_input.h"
5#include "gsm_subscriber.h"
6#include <osmocore/linuxlist.h>
7
8#define IPA_TCP_PORT_OML 3002
9#define IPA_TCP_PORT_RSL 3003
10
11struct ipaccess_head {
12 u_int16_t len; /* network byte order */
13 u_int8_t proto;
14 u_int8_t data[0];
15} __attribute__ ((packed));
16
17struct ipaccess_head_ext {
18 uint8_t proto;
19 uint8_t data[0];
20} __attribute__ ((packed));
21
22enum ipaccess_proto {
23 IPAC_PROTO_RSL = 0x00,
24 IPAC_PROTO_IPACCESS = 0xfe,
25 IPAC_PROTO_SCCP = 0xfd,
26 IPAC_PROTO_OML = 0xff,
27
28
29 /* OpenBSC extensions */
30 IPAC_PROTO_OSMO = 0xee,
31 IPAC_PROTO_MGCP_OLD = 0xfc,
32};
33
34enum ipaccess_msgtype {
35 IPAC_MSGT_PING = 0x00,
36 IPAC_MSGT_PONG = 0x01,
37 IPAC_MSGT_ID_GET = 0x04,
38 IPAC_MSGT_ID_RESP = 0x05,
39 IPAC_MSGT_ID_ACK = 0x06,
40
41 /* OpenBSC extension */
42 IPAC_MSGT_SCCP_OLD = 0xff,
43};
44
45enum ipaccess_id_tags {
46 IPAC_IDTAG_SERNR = 0x00,
47 IPAC_IDTAG_UNITNAME = 0x01,
48 IPAC_IDTAG_LOCATION1 = 0x02,
49 IPAC_IDTAG_LOCATION2 = 0x03,
50 IPAC_IDTAG_EQUIPVERS = 0x04,
51 IPAC_IDTAG_SWVERSION = 0x05,
52 IPAC_IDTAG_IPADDR = 0x06,
53 IPAC_IDTAG_MACADDR = 0x07,
54 IPAC_IDTAG_UNIT = 0x08,
55};
56
57struct ipac_msgt_sccp_state {
58 uint8_t src_ref[3];
59 uint8_t dst_ref[3];
60 uint8_t trans_id;
61 uint8_t invoke_id;
62 char imsi[GSM_IMSI_LENGTH];
63} __attribute__((packed));
64
65int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa);
66
67/*
68 * methods for parsing and sending a message
69 */
70int ipaccess_rcvmsg_base(struct msgb *msg, struct bsc_fd *bfd);
71struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error);
72void ipaccess_prepend_header(struct msgb *msg, int proto);
73int ipaccess_send_id_ack(int fd);
74int ipaccess_send_id_req(int fd);
75
76int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
77
78int ipaccess_drop_oml(struct gsm_bts *bts);
79int ipaccess_drop_rsl(struct gsm_bts_trx *trx);
80
81/*
82 * Firmware specific header
83 */
84struct sdp_firmware {
85 char magic[4];
86 char more_magic[2];
87 u_int16_t more_more_magic;
88 u_int32_t header_length;
89 u_int32_t file_length;
90 char sw_part[20];
91 char text1[64];
92 char time[12];
93 char date[14];
94 char text2[10];
95 char version[20];
96 u_int16_t table_offset;
97 /* stuff i don't know */
98} __attribute__((packed));
99
100struct sdp_header_entry {
101 u_int16_t something1;
102 char text1[64];
103 char time[12];
104 char date[14];
105 char text2[10];
106 char version[20];
107 u_int32_t length;
108 u_int32_t addr1;
109 u_int32_t addr2;
110 u_int32_t start;
111} __attribute__((packed));
112
113struct sdp_header_item {
114 struct sdp_header_entry header_entry;
115 struct llist_head entry;
116 off_t absolute_offset;
117};
118
119struct sdp_header {
120 struct sdp_firmware firmware_info;
121
122 /* for more_magic a list of sdp_header_entry_list */
123 struct llist_head header_list;
124
125 /* the entry of the sdp_header */
126 struct llist_head entry;
127};
128
129int ipaccess_analyze_file(int fd, const unsigned int st_size, const unsigned base_offset, struct llist_head *list);
130
131#endif /* _IPACCESS_H */