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 | |
Jacob Erlbeck | 3cd6753 | 2014-12-22 10:58:45 +0100 | [diff] [blame] | 8 | struct osmo_fd; |
| 9 | |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 10 | /* internal (host-only) data structure */ |
| 11 | struct ipaccess_unit { |
| 12 | uint16_t site_id; |
| 13 | uint16_t bts_id; |
| 14 | uint16_t trx_id; |
| 15 | char *unit_name; |
| 16 | char *equipvers; |
| 17 | char *swversion; |
| 18 | uint8_t mac_addr[6]; |
| 19 | char *location1; |
| 20 | char *location2; |
| 21 | char *serno; |
| 22 | }; |
| 23 | |
| 24 | /* obtain the human-readable name of an IPA CCM ID TAG */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 25 | const char *ipa_ccm_idtag_name(uint8_t tag); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 26 | |
| 27 | /* parse a buffer of ID tags into a osmocom TLV style representation */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 28 | 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] | 29 | |
Holger Hans Peter Freyther | f558ed4 | 2015-06-02 15:52:06 +0200 | [diff] [blame] | 30 | /* Is the TAG included in the length field? */ |
| 31 | int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset); |
| 32 | |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 33 | /* 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] | 34 | int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 35 | |
| 36 | /* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 37 | int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud, |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 38 | const struct tlv_parsed *tp); |
| 39 | |
| 40 | /* Send an IPA message to the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 41 | int ipa_send(int fd, const void *msg, size_t msglen); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 42 | |
| 43 | /* Send an IPA CCM PONG via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 44 | int ipa_ccm_send_pong(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 45 | |
| 46 | /* Send an IPA CCM ID_ACK via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 47 | int ipa_ccm_send_id_ack(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 48 | |
| 49 | /* Send an IPA CCM ID_REQ via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 50 | int ipa_ccm_send_id_req(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 51 | |
| 52 | /* Common handling of IPA CCM, BSC side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 53 | int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 54 | |
| 55 | /* Common handling of IPA CCM, BTS side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 56 | 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] | 57 | |
| 58 | /* prepend (push) an ipaccess_head_ext to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 59 | void ipa_prepend_header_ext(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 60 | |
| 61 | /* prepend (push) an ipaccess_head to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 62 | void ipa_prepend_header(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 63 | |
| 64 | struct msgb *ipa_msg_alloc(int headroom); |
| 65 | |
| 66 | int ipa_msg_recv(int fd, struct msgb **rmsg); |
| 67 | int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg); |