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 */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 23 | const char *ipa_ccm_idtag_name(uint8_t tag); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 24 | |
| 25 | /* parse a buffer of ID tags into a osmocom TLV style representation */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 26 | int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 27 | |
| 28 | /* parse an Unit ID in string format into the 'ipaccess_unit' data structure */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 29 | int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 30 | |
| 31 | /* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 32 | int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud, |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 33 | const struct tlv_parsed *tp); |
| 34 | |
| 35 | /* Send an IPA message to the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 36 | int ipa_send(int fd, const void *msg, size_t msglen); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 37 | |
| 38 | /* Send an IPA CCM PONG via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 39 | int ipa_ccm_send_pong(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 40 | |
| 41 | /* Send an IPA CCM ID_ACK via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 42 | int ipa_ccm_send_id_ack(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 43 | |
| 44 | /* Send an IPA CCM ID_REQ via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 45 | int ipa_ccm_send_id_req(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 46 | |
| 47 | /* Common handling of IPA CCM, BSC side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 48 | int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 49 | |
| 50 | /* Common handling of IPA CCM, BTS side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 51 | int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 52 | |
| 53 | /* prepend (push) an ipaccess_head_ext to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 54 | void ipa_prepend_header_ext(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 55 | |
| 56 | /* prepend (push) an ipaccess_head to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 57 | void ipa_prepend_header(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 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); |