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