libosmogsm  0.9.3
Osmocom GSM library
include/osmocom/gsm/ipa.h
00001 #pragma once
00002 
00003 #include <stdint.h>
00004 
00005 #include <osmocom/core/msgb.h>
00006 #include <osmocom/gsm/tlv.h>
00007 
00008 struct osmo_fd;
00009 
00010 /* internal (host-only) data structure */
00011 struct ipaccess_unit {
00012         uint16_t site_id;
00013         uint16_t bts_id;
00014         uint16_t trx_id;
00015         char *unit_name;
00016         char *equipvers;
00017         char *swversion;
00018         uint8_t mac_addr[6];
00019         char *location1;
00020         char *location2;
00021         char *serno;
00022 };
00023 
00024 /* obtain the human-readable name of an IPA CCM ID TAG */
00025 const char *ipa_ccm_idtag_name(uint8_t tag);
00026 
00027 /* parse a buffer of ID tags into a osmocom TLV style representation */
00028 int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len);
00029 
00030 /* Is the TAG included in the length field? */
00031 int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset);
00032 
00033 /* parse an Unit ID in string format into the 'ipaccess_unit' data structure */
00034 int ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data);
00035 
00036 /* fill a 'struct ipaccess_unit' based on a parsed IDTAG TLV */
00037 int ipa_ccm_tlv_to_unitdata(struct ipaccess_unit *ud,
00038                              const struct tlv_parsed *tp);
00039 
00040 /* Send an IPA message to the given FD */
00041 int ipa_send(int fd, const void *msg, size_t msglen);
00042 
00043 /* Send an IPA CCM PONG via the given FD */
00044 int ipa_ccm_send_pong(int fd);
00045 
00046 /* Send an IPA CCM ID_ACK via the given FD */
00047 int ipa_ccm_send_id_ack(int fd);
00048 
00049 /* Send an IPA CCM ID_REQ via the given FD */
00050 int ipa_ccm_send_id_req(int fd);
00051 
00052 /* Common handling of IPA CCM, BSC side */
00053 int ipa_ccm_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd);
00054 
00055 /* Common handling of IPA CCM, BTS side */
00056 int ipa_ccm_rcvmsg_bts_base(struct msgb *msg, struct osmo_fd *bfd);
00057 
00058 /* prepend (push) an ipaccess_head_ext to the msgb */
00059 void ipa_prepend_header_ext(struct msgb *msg, int proto);
00060 
00061 /* prepend (push) an ipaccess_head to the msgb */
00062 void ipa_prepend_header(struct msgb *msg, int proto);
00063 
00064 struct msgb *ipa_msg_alloc(int headroom);
00065 
00066 int ipa_msg_recv(int fd, struct msgb **rmsg);
00067 int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg);