blob: 851b58e0ad0d63f585870ac6cebb14c2872fbf30 [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");
Harald Welte5a7740d2018-08-01 17:29:48 +020031int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset)
Neels Hofmeyr137efc92021-09-29 15:22:28 +020032 OSMO_DEPRECATED_OUTSIDE("Use ipa_ccm_id_{get,resp}_parse instead");
Harald Welte7869baf2018-07-31 20:25:48 +020033
34/* parse payload of IPA CCM ID GET into a osmocom TLV style representation */
35int ipa_ccm_id_get_parse(struct tlv_parsed *dec, const uint8_t *buf, unsigned int len);
36
37/* parse payload of IPA CCM ID RESP into a osmocom TLV style representation */
38int ipa_ccm_id_resp_parse(struct tlv_parsed *dec, const uint8_t *buf, unsigned int len);
Harald Welte28aa9912014-08-20 22:06:04 +020039
40/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020041int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020042
43/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020044int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020045 const struct tlv_parsed *tp);
46
Harald Welte7bc88bb2017-04-15 19:05:33 +020047
48struct msgb *ipa_ccm_make_id_resp(const struct ipaccess_unit *dev,
49 const uint8_t *ies_req, unsigned int num_ies_req);
50
51struct msgb *ipa_ccm_make_id_resp_from_req(const struct ipaccess_unit *dev,
52 const uint8_t *data, unsigned int len);
53
Harald Welte28aa9912014-08-20 22:06:04 +020054/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020055int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020056
57/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020058int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020059
60/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020061int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020062
63/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020064int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020065
66/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020067int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020068
69/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020070int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020071
72/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020073void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020074
75/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020076void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020077
78struct msgb *ipa_msg_alloc(int headroom);
79
80int ipa_msg_recv(int fd, struct msgb **rmsg);
81int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);