Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | |
| 5 | #include <osmocom/core/msgb.h> |
| 6 | #include <osmocom/gsm/tlv.h> |
| 7 | |
| 8 | /* internal (host-only) data structure */ |
| 9 | struct ipaccess_unit { |
| 10 | uint16_t site_id; |
| 11 | uint16_t bts_id; |
| 12 | uint16_t trx_id; |
| 13 | char *unit_name; |
| 14 | char *equipvers; |
| 15 | char *swversion; |
| 16 | uint8_t mac_addr[6]; |
| 17 | char *location1; |
| 18 | char *location2; |
| 19 | char *serno; |
| 20 | }; |
| 21 | |
| 22 | /* obtain the human-readable name of an IPA CCM ID TAG */ |
| 23 | const char *ipaccess_idtag_name(uint8_t tag); |
| 24 | |
| 25 | /* parse a buffer of ID tags into a osmocom TLV style representation */ |
| 26 | int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len); |
| 27 | |
| 28 | /* parse an Unit ID in string format into the 'ipaccess_unit' data structure */ |
| 29 | int ipaccess_parse_unitid(const char *str, struct ipaccess_unit *unit_data); |
| 30 | |
| 31 | /* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */ |
| 32 | int ipaccess_tlv_to_unitdata(struct ipaccess_unit *ud, |
| 33 | const struct tlv_parsed *tp); |
| 34 | |
| 35 | /* Send an IPA message to the given FD */ |
| 36 | int ipaccess_send(int fd, const void *msg, size_t msglen); |
| 37 | |
| 38 | /* Send an IPA CCM PONG via the given FD */ |
| 39 | int ipaccess_send_pong(int fd); |
| 40 | |
| 41 | /* Send an IPA CCM ID_ACK via the given FD */ |
| 42 | int ipaccess_send_id_ack(int fd); |
| 43 | |
| 44 | /* Send an IPA CCM ID_REQ via the given FD */ |
| 45 | int ipaccess_send_id_req(int fd); |
| 46 | |
| 47 | /* Common handling of IPA CCM, BSC side */ |
| 48 | int ipaccess_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); |
| 49 | |
| 50 | /* Common handling of IPA CCM, BTS side */ |
| 51 | int ipaccess_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd); |
| 52 | |
| 53 | /* prepend (push) an ipaccess_head_ext to the msgb */ |
| 54 | void ipaccess_prepend_header_ext(struct msgb *msg, int proto); |
| 55 | |
| 56 | /* prepend (push) an ipaccess_head to the msgb */ |
| 57 | void ipaccess_prepend_header(struct msgb *msg, int proto); |
| 58 | |
| 59 | struct msgb *ipa_msg_alloc(int headroom); |
| 60 | |
| 61 | int ipa_msg_recv(int fd, struct msgb **rmsg); |
| 62 | int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg); |