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 | |
Harald Welte | 7bc88bb | 2017-04-15 19:05:33 +0200 | [diff] [blame] | 40 | |
| 41 | struct msgb *ipa_ccm_make_id_resp(const struct ipaccess_unit *dev, |
| 42 | const uint8_t *ies_req, unsigned int num_ies_req); |
| 43 | |
| 44 | struct msgb *ipa_ccm_make_id_resp_from_req(const struct ipaccess_unit *dev, |
| 45 | const uint8_t *data, unsigned int len); |
| 46 | |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 47 | /* Send an IPA message to the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 48 | int ipa_send(int fd, const void *msg, size_t msglen); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 49 | |
| 50 | /* Send an IPA CCM PONG via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 51 | int ipa_ccm_send_pong(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 52 | |
| 53 | /* Send an IPA CCM ID_ACK via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 54 | int ipa_ccm_send_id_ack(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 55 | |
| 56 | /* Send an IPA CCM ID_REQ via the given FD */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 57 | int ipa_ccm_send_id_req(int fd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 58 | |
| 59 | /* Common handling of IPA CCM, BSC side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 60 | int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 61 | |
| 62 | /* Common handling of IPA CCM, BTS side */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 63 | 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] | 64 | |
| 65 | /* prepend (push) an ipaccess_head_ext to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 66 | void ipa_prepend_header_ext(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 67 | |
| 68 | /* prepend (push) an ipaccess_head to the msgb */ |
Harald Welte | e391996 | 2014-08-20 22:28:23 +0200 | [diff] [blame] | 69 | void ipa_prepend_header(struct msgb *msg, int proto); |
Harald Welte | 28aa991 | 2014-08-20 22:06:04 +0200 | [diff] [blame] | 70 | |
| 71 | struct msgb *ipa_msg_alloc(int headroom); |
| 72 | |
| 73 | int ipa_msg_recv(int fd, struct msgb **rmsg); |
| 74 | int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg); |