blob: cabee1399f65dbd311a5ef61e1d258d8da72e8dd [file] [log] [blame]
Harald Welte28aa9912014-08-20 22:06:04 +02001#pragma once
2
3#include <stdint.h>
4
5#include <osmocom/core/msgb.h>
6#include <osmocom/gsm/tlv.h>
7
Jacob Erlbeck3cd67532014-12-22 10:58:45 +01008struct osmo_fd;
9
Harald Welte28aa9912014-08-20 22:06:04 +020010/* internal (host-only) data structure */
11struct 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 Weltee3919962014-08-20 22:28:23 +020025const char *ipa_ccm_idtag_name(uint8_t tag);
Harald Welte28aa9912014-08-20 22:06:04 +020026
27/* parse a buffer of ID tags into a osmocom TLV style representation */
Harald Weltee3919962014-08-20 22:28:23 +020028int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
Harald Welte28aa9912014-08-20 22:06:04 +020029
Holger Hans Peter Freytherf558ed42015-06-02 15:52:06 +020030/* Is the TAG included in the length field? */
31int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset);
32
Harald Welte28aa9912014-08-20 22:06:04 +020033/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020034int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020035
36/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020037int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020038 const struct tlv_parsed *tp);
39
Harald Welte7bc88bb2017-04-15 19:05:33 +020040
41struct msgb *ipa_ccm_make_id_resp(const struct ipaccess_unit *dev,
42 const uint8_t *ies_req, unsigned int num_ies_req);
43
44struct msgb *ipa_ccm_make_id_resp_from_req(const struct ipaccess_unit *dev,
45 const uint8_t *data, unsigned int len);
46
Harald Welte28aa9912014-08-20 22:06:04 +020047/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020048int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020049
50/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020051int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020052
53/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020054int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020055
56/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020057int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020058
59/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020060int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020061
62/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020063int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020064
65/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020066void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020067
68/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020069void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020070
71struct msgb *ipa_msg_alloc(int headroom);
72
73int ipa_msg_recv(int fd, struct msgb **rmsg);
74int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);