blob: ec143d0e98fc8e24002b21e501acbf6b4ab9668e [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
Harald Welte7869baf2018-07-31 20:25:48 +020029int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
30 OSMO_DEPRECATED("Use ipa_ccm_id_{get,resp}_parse instead");
31
32/* parse payload of IPA CCM ID GET into a osmocom TLV style representation */
33int ipa_ccm_id_get_parse(struct tlv_parsed *dec, const uint8_t *buf, unsigned int len);
34
35/* parse payload of IPA CCM ID RESP into a osmocom TLV style representation */
36int ipa_ccm_id_resp_parse(struct tlv_parsed *dec, const uint8_t *buf, unsigned int len);
Harald Welte28aa9912014-08-20 22:06:04 +020037
Holger Hans Peter Freytherf558ed42015-06-02 15:52:06 +020038/* Is the TAG included in the length field? */
39int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset);
40
Harald Welte28aa9912014-08-20 22:06:04 +020041/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020042int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020043
44/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020045int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020046 const struct tlv_parsed *tp);
47
Harald Welte7bc88bb2017-04-15 19:05:33 +020048
49struct msgb *ipa_ccm_make_id_resp(const struct ipaccess_unit *dev,
50 const uint8_t *ies_req, unsigned int num_ies_req);
51
52struct msgb *ipa_ccm_make_id_resp_from_req(const struct ipaccess_unit *dev,
53 const uint8_t *data, unsigned int len);
54
Harald Welte28aa9912014-08-20 22:06:04 +020055/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020056int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020057
58/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020059int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020060
61/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020062int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020063
64/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020065int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020066
67/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020068int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020069
70/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020071int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020072
73/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020074void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020075
76/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020077void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020078
79struct msgb *ipa_msg_alloc(int headroom);
80
81int ipa_msg_recv(int fd, struct msgb **rmsg);
82int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);