blob: 2878676f8970bc0dec787e7ece6623343a6fdbf0 [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
8/* internal (host-only) data structure */
9struct ipaccess_unit {
10 uint16_t site_id;
11 uint16_t bts_id;
12 uint16_t trx_id;
13 char *unit_name;
14 char *equipvers;
15 char *swversion;
16 uint8_t mac_addr[6];
17 char *location1;
18 char *location2;
19 char *serno;
20};
21
22/* obtain the human-readable name of an IPA CCM ID TAG */
Harald Weltee3919962014-08-20 22:28:23 +020023const char *ipa_ccm_idtag_name(uint8_t tag);
Harald Welte28aa9912014-08-20 22:06:04 +020024
25/* parse a buffer of ID tags into a osmocom TLV style representation */
Harald Weltee3919962014-08-20 22:28:23 +020026int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
Harald Welte28aa9912014-08-20 22:06:04 +020027
28/* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
Harald Weltee3919962014-08-20 22:28:23 +020029int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
Harald Welte28aa9912014-08-20 22:06:04 +020030
31/* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
Harald Weltee3919962014-08-20 22:28:23 +020032int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
Harald Welte28aa9912014-08-20 22:06:04 +020033 const struct tlv_parsed *tp);
34
35/* Send an IPA message to the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020036int ipa_send(int fd, const void *msg, size_t msglen);
Harald Welte28aa9912014-08-20 22:06:04 +020037
38/* Send an IPA CCM PONG via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020039int ipa_ccm_send_pong(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020040
41/* Send an IPA CCM ID_ACK via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020042int ipa_ccm_send_id_ack(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020043
44/* Send an IPA CCM ID_REQ via the given FD */
Harald Weltee3919962014-08-20 22:28:23 +020045int ipa_ccm_send_id_req(int fd);
Harald Welte28aa9912014-08-20 22:06:04 +020046
47/* Common handling of IPA CCM, BSC side */
Harald Weltee3919962014-08-20 22:28:23 +020048int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020049
50/* Common handling of IPA CCM, BTS side */
Harald Weltee3919962014-08-20 22:28:23 +020051int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
Harald Welte28aa9912014-08-20 22:06:04 +020052
53/* prepend (push) an ipaccess_head_ext to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020054void ipa_prepend_header_ext(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020055
56/* prepend (push) an ipaccess_head to the msgb */
Harald Weltee3919962014-08-20 22:28:23 +020057void ipa_prepend_header(struct msgb *msg, int proto);
Harald Welte28aa9912014-08-20 22:06:04 +020058
59struct msgb *ipa_msg_alloc(int headroom);
60
61int ipa_msg_recv(int fd, struct msgb **rmsg);
62int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);