blob: dbd9f37e83634fc48e924846faf6cb3ec490865a [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 Freyther4a98cad2009-12-30 05:56:49 +01005#include "linuxlist.h"
Holger Hans Peter Freyther0e7b0732009-10-22 15:48:59 +02006
Harald Welte87ed5cd2009-12-23 22:47:53 +01007#define IPA_TCP_PORT_OML 3002
8#define IPA_TCP_PORT_RSL 3003
9
Harald Welte4f361fc2009-02-15 15:32:53 +000010struct ipaccess_head {
Sylvain Munautd7d1c992009-10-29 16:33:59 +010011 u_int16_t len; /* network byte order */
Harald Welte4f361fc2009-02-15 15:32:53 +000012 u_int8_t proto;
13 u_int8_t data[0];
14} __attribute__ ((packed));
15
16enum ipaccess_proto {
17 IPAC_PROTO_RSL = 0x00,
18 IPAC_PROTO_IPACCESS = 0xfe,
Holger Hans Peter Freytherf734a142009-09-30 06:26:38 +020019 IPAC_PROTO_SCCP = 0xfd,
Harald Welte4f361fc2009-02-15 15:32:53 +000020 IPAC_PROTO_OML = 0xff,
21};
22
23enum ipaccess_msgtype {
24 IPAC_MSGT_PING = 0x00,
25 IPAC_MSGT_PONG = 0x01,
26 IPAC_MSGT_ID_GET = 0x04,
27 IPAC_MSGT_ID_RESP = 0x05,
28 IPAC_MSGT_ID_ACK = 0x06,
29};
30
31enum ipaccess_id_tags {
32 IPAC_IDTAG_SERNR = 0x00,
33 IPAC_IDTAG_UNITNAME = 0x01,
34 IPAC_IDTAG_LOCATION1 = 0x02,
35 IPAC_IDTAG_LOCATION2 = 0x03,
36 IPAC_IDTAG_EQUIPVERS = 0x04,
37 IPAC_IDTAG_SWVERSION = 0x05,
38 IPAC_IDTAG_IPADDR = 0x06,
39 IPAC_IDTAG_MACADDR = 0x07,
40 IPAC_IDTAG_UNIT = 0x08,
41};
42
Holger Hans Peter Freyther34e97492009-08-10 07:54:02 +020043int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa);
44
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +020045/*
46 * methods for parsing and sending a message
47 */
48int ipaccess_rcvmsg_base(struct msgb *msg, struct bsc_fd *bfd);
49struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error);
50void ipaccess_prepend_header(struct msgb *msg, int proto);
Holger Hans Peter Freyther301e6282010-01-13 09:06:46 +010051int ipaccess_send_id_ack(int fd);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +020052
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +010053/*
54 * Firmware specific header
55 */
56struct sdp_firmware {
57 char magic[4];
58 char more_magic[2];
59 u_int16_t more_more_magic;
60 u_int32_t header_length;
61 u_int32_t file_length;
62 char sw_part[20];
63 char text1[64];
64 char time[12];
65 char date[14];
66 char text2[10];
67 char version[20];
68 u_int8_t dummy[2];
69 u_int16_t part_length;
70 /* stuff i don't know */
71} __attribute__((packed));
72
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +010073struct sdp_header_entry {
74 u_int16_t something1;
75 char text1[64];
76 char time[12];
77 char date[14];
78 char text2[10];
79 char version[20];
80 u_int32_t length;
81 u_int32_t addr1;
82 u_int32_t addr2;
83 u_int32_t start;
84} __attribute__((packed));
85
Holger Hans Peter Freyther0183edd2009-12-30 06:13:36 +010086struct sdp_header_item {
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +010087 struct sdp_header_entry header_entry;
88 struct llist_head entry;
89};
90
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +010091struct sdp_header {
92 struct sdp_firmware firmware_info;
Holger Hans Peter Freytherc9f8a6d2009-12-30 06:10:56 +010093
94 /* for more_magic a list of sdp_header_entry_list */
95 struct llist_head header_list;
96
97 /* the entry of the sdp_header */
98 struct llist_head entry;
Holger Hans Peter Freyther4a98cad2009-12-30 05:56:49 +010099};
100
101int ipaccess_analyze_file(int fd, const unsigned int st_size, const unsigned base_offset, struct llist_head *list);
102
Harald Welte4f361fc2009-02-15 15:32:53 +0000103#endif /* _IPACCESS_H */