blob: 7e1d7237e8a7a054bc64c06d796a14c52bad12f5 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file ipa.h */
2
Harald Welte28aa9912014-08-20 22:06:04 +02003#pragma once
4
5#include <stdint.h>
6
7#include <osmocom/core/msgb.h>
8#include <osmocom/gsm/tlv.h>
9
Jacob Erlbeck3cd67532014-12-22 10:58:45 +010010struct osmo_fd;
11
Harald Welte28aa9912014-08-20 22:06:04 +020012/* internal (host-only) data structure */
13struct 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 Weltee3919962014-08-20 22:28:23 +020027const char *ipa_ccm_idtag_name(uint8_t tag);
Harald Welte28aa9912014-08-20 22:06:04 +020028
29/* parse a buffer of ID tags into a osmocom TLV style representation */
Harald Weltee3919962014-08-20 22:28:23 +020030int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
Harald Welte28aa9912014-08-20 22:06:04 +020031
Holger Hans Peter Freytherf558ed42015-06-02 15:52:06 +020032/* Is the TAG included in the length field? */
33int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset);
34
Harald Welte28aa9912014-08-20 22:06:04 +020035/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020036int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020037
38/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020039int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020040 const struct tlv_parsed *tp);
41
Harald Welte7bc88bb2017-04-15 19:05:33 +020042
43struct msgb *ipa_ccm_make_id_resp(const struct ipaccess_unit *dev,
44 const uint8_t *ies_req, unsigned int num_ies_req);
45
46struct msgb *ipa_ccm_make_id_resp_from_req(const struct ipaccess_unit *dev,
47 const uint8_t *data, unsigned int len);
48
Harald Welte28aa9912014-08-20 22:06:04 +020049/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020050int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020051
52/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020053int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020054
55/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020056int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020057
58/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020059int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020060
61/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020062int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020063
64/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020065int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020066
67/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020068void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020069
70/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020071void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020072
73struct msgb *ipa_msg_alloc(int headroom);
74
75int ipa_msg_recv(int fd, struct msgb **rmsg);
76int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);