ipa: add ipaccess_tlv_to_unitdata()
this function takes the parsed TLVs of an IPA ID RESP message and
fills a 'struct ipaccess_unit'.
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index f62e4b0..b124121 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -39,6 +39,7 @@
#include <osmocom/core/select.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/msgb.h>
+#include <osmocom/core/macaddr.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/talloc.h>
#include <osmocom/abis/e1_input.h>
@@ -163,6 +164,50 @@
return 0;
}
+int ipaccess_tlv_to_unitdata(struct ipaccess_unit *ud,
+ const struct tlv_parsed *tp)
+{
+ int rc = 0;
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_SERNR, 1))
+ ud->serno = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_SERNR));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_UNITNAME, 1))
+ ud->unit_name = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_UNITNAME));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_LOCATION1, 1))
+ ud->location1 = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_LOCATION1));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_LOCATION2, 1))
+ ud->location2 = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_LOCATION2));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_EQUIPVERS, 1))
+ ud->equipvers = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_EQUIPVERS));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_SWVERSION, 1))
+ ud->swversion = talloc_strdup(ud, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_SWVERSION));
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_MACADDR, 17)) {
+ rc = osmo_macaddr_parse(ud->mac_addr, (char *)
+ TLVP_VAL(tp, IPAC_IDTAG_MACADDR));
+ if (rc < 0)
+ goto out;
+ }
+
+ if (TLVP_PRES_LEN(tp, IPAC_IDTAG_UNIT, 1))
+ rc = ipaccess_parse_unitid((char *)
+ TLVP_VAL(tp, IPAC_IDTAG_UNIT), ud);
+
+out:
+ return rc;
+}
+
static int ipaccess_send(int fd, const void *msg, size_t msglen)
{
int ret;