blob: 314ca90280e3a283b7d91a094a9bfac68270f35b [file] [log] [blame]
Harald Welte4f361fc2009-02-15 15:32:53 +00001#ifndef _IPACCESS_H
2#define _IPACCESS_H
3
Holger Hans Peter Freyther0e7b0732009-10-22 15:48:59 +02004#include "e1_input.h"
Holger Hans Peter Freytherec8a4e22010-10-14 22:56:06 +02005#include "gsm_subscriber.h"
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +01006#include <osmocom/core/linuxlist.h>
Holger Hans Peter Freyther0e7b0732009-10-22 15:48:59 +02007
Harald Welte87ed5cd2009-12-23 22:47:53 +01008#define IPA_TCP_PORT_OML 3002
9#define IPA_TCP_PORT_RSL 3003
10
Harald Welte4f361fc2009-02-15 15:32:53 +000011struct ipaccess_head {
Sylvain Munautd7d1c992009-10-29 16:33:59 +010012 u_int16_t len; /* network byte order */
Harald Welte4f361fc2009-02-15 15:32:53 +000013 u_int8_t proto;
14 u_int8_t data[0];
15} __attribute__ ((packed));
16
Holger Hans Peter Freyther368a0a72011-01-07 16:54:46 +010017struct ipaccess_head_ext {
18 uint8_t proto;
19 uint8_t data[0];
20} __attribute__ ((packed));
21
Harald Welte4f361fc2009-02-15 15:32:53 +000022enum ipaccess_proto {
23 IPAC_PROTO_RSL = 0x00,
24 IPAC_PROTO_IPACCESS = 0xfe,
Holger Hans Peter Freytherf734a142009-09-30 06:26:38 +020025 IPAC_PROTO_SCCP = 0xfd,
Harald Welte4f361fc2009-02-15 15:32:53 +000026 IPAC_PROTO_OML = 0xff,
Holger Hans Peter Freyther19c530c2010-10-13 23:52:01 +020027
Holger Hans Peter Freyther368a0a72011-01-07 16:54:46 +010028
Holger Hans Peter Freyther19c530c2010-10-13 23:52:01 +020029 /* OpenBSC extensions */
Holger Hans Peter Freyther368a0a72011-01-07 16:54:46 +010030 IPAC_PROTO_OSMO = 0xee,
31 IPAC_PROTO_MGCP_OLD = 0xfc,
Harald Welte4f361fc2009-02-15 15:32:53 +000032};
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,
Holger Hans Peter Freytherec8a4e22010-10-14 22:56:06 +020040
41 /* OpenBSC extension */
Holger Hans Peter Freyther368a0a72011-01-07 16:54:46 +010042 IPAC_MSGT_SCCP_OLD = 0xff,
Harald Welte4f361fc2009-02-15 15:32:53 +000043};
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
Holger Hans Peter Freytherec8a4e22010-10-14 22:56:06 +020057struct 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
Holger Hans Peter Freyther34e97492009-08-10 07:54:02 +020065int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa);
66
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +020067/*
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);
Holger Hans Peter Freyther301e6282010-01-13 09:06:46 +010073int ipaccess_send_id_ack(int fd);
Holger Hans Peter Freyther3bc856b2010-02-07 12:04:07 +010074int ipaccess_send_id_req(int fd);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +020075
Holger Hans Peter Freytherd3d5be12010-02-09 14:37:23 +010076int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
77
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +020078int ipaccess_drop_oml(struct gsm_bts *bts);
79int ipaccess_drop_rsl(struct gsm_bts_trx *trx);
Holger Hans Peter Freytherd3d5be12010-02-09 14:37:23 +010080
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +010081/*
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];
Holger Hans Peter Freyther57e93002010-03-22 09:59:57 +010096 u_int16_t table_offset;
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +010097 /* stuff i don't know */
98} __attribute__((packed));
99
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +0100100struct 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
Holger Hans Peter Freyther0183edd2009-12-30 06:13:36 +0100113struct sdp_header_item {
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +0100114 struct sdp_header_entry header_entry;
115 struct llist_head entry;
Holger Hans Peter Freyther38722cc2010-03-22 11:22:54 +0100116 off_t absolute_offset;
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +0100117};
118
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +0100119struct sdp_header {
120 struct sdp_firmware firmware_info;
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +0100121
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;
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +0100127};
128
129int ipaccess_analyze_file(int fd, const unsigned int st_size, const unsigned base_offset, struct llist_head *list);
130
Harald Welte4f361fc2009-02-15 15:32:53 +0000131#endif /* _IPACCESS_H */