blob: 1227ee1795f94614a8dacc11a399c10c2e3fb7a2 [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
30/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020031int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020032
33/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020034int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020035 const struct tlv_parsed *tp);
36
37/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020038int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020039
40/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020041int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020042
43/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020044int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020045
46/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020047int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020048
49/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020050int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020051
52/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020053int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020054
55/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020056void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020057
58/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020059void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020060
61struct msgb *ipa_msg_alloc(int headroom);
62
63int ipa_msg_recv(int fd, struct msgb **rmsg);
64int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);