aboutsummaryrefslogtreecommitdiffstats
path: root/src/ipa.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2012-08-19 20:21:15 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-08-21 02:28:46 +0200
commitaa33e591dc133815e720c417d8706deedfe42b8a (patch)
tree873038b1fd8770a09cdca471fbd74b2270ed2945 /src/ipa.c
parent06f49051c6d6c56f36f15da6e18c947360946bef (diff)
ipa: add osmo_ipa_parse_msg_id_resp
Code extracted from ipa_stream_server.c.
Diffstat (limited to 'src/ipa.c')
-rw-r--r--src/ipa.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ipa.c b/src/ipa.c
index cd386ad..50bddd4 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -341,3 +341,41 @@ struct msgb *ipa_cli_id_ack(void)
return nmsg2;
}
+
+int
+osmo_ipa_parse_msg_id_resp(struct msgb *msg, struct ipaccess_unit *unit_data)
+{
+ struct tlv_parsed tlvp;
+ char *unitid;
+ int len, ret;
+
+ DEBUGP(DLINP, "ID_RESP\n");
+ /* parse tags, search for Unit ID */
+ ret = osmo_ipa_idtag_parse(&tlvp, (uint8_t *)msg->l2h + 2,
+ msgb_l2len(msg)-2);
+ if (ret < 0) {
+ LOGP(DLINP, LOGL_ERROR, "IPA response message "
+ "with malformed TLVs\n");
+ return -EINVAL;
+ }
+ if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT)) {
+ LOGP(DLINP, LOGL_ERROR, "IPA response message "
+ "without unit ID\n");
+ return -EINVAL;
+ }
+ len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT);
+ if (len < 1) {
+ LOGP(DLINP, LOGL_ERROR, "IPA response message "
+ "with too small unit ID\n");
+ return -EINVAL;
+ }
+ unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT);
+ unitid[len - 1] = '\0';
+
+ if (osmo_ipa_parse_unitid(unitid, unit_data) < 0) {
+ LOGP(DLINP, LOGL_ERROR, "failed to parse IPA IDTAG\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}