laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33947 )
Change subject: llc: Introduce function to log XID fields and use upon Rx/Tx
......................................................................
llc: Introduce function to log XID fields and use upon Rx/Tx
Change-Id: I8c6b07305c0bcecb4e1681967884a3e62c813592
---
M include/osmocom/gprs/llc/llc_private.h
M src/llc/llc.c
M src/llc/llc_xid.c
M tests/llc/llc_prim_test.err
4 files changed, 49 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/osmocom/gprs/llc/llc_private.h
b/include/osmocom/gprs/llc/llc_private.h
index b2b9047..e5c197e 100644
--- a/include/osmocom/gprs/llc/llc_private.h
+++ b/include/osmocom/gprs/llc/llc_private.h
@@ -345,6 +345,8 @@
struct gprs_llc_xid_field *gprs_llc_xid_deepcopy(void *ctx,
const struct gprs_llc_xid_field *src_xid,
size_t src_xid_len);
+void gprs_llc_dump_xid_fields(const struct gprs_llc_xid_field *xid_fields,
+ size_t xid_fields_len, unsigned int logl);
/* llc_pdu.c: */
int gprs_llc_pdu_decode(struct gprs_llc_pdu_decoded *pdu,
diff --git a/src/llc/llc.c b/src/llc/llc.c
index 93a11ec..827b067 100644
--- a/src/llc/llc.c
+++ b/src/llc/llc.c
@@ -471,6 +471,8 @@
xid_fields_len--;
}
+ gprs_llc_dump_xid_fields(xid_fields, xid_fields_len, LOGL_DEBUG);
+
/* Store generated XID for later reference */
talloc_free(lle->xid);
lle->xid = xid_fields;
@@ -562,6 +564,8 @@
}
xid_fields_len = rc;
+ gprs_llc_dump_xid_fields(xid_fields, xid_fields_len, LOGL_DEBUG);
+
/* FIXME: Check the incoming XID parameters for
* for validity. Currently we just blindly
* accept all XID fields by just echoing them.
diff --git a/src/llc/llc_xid.c b/src/llc/llc_xid.c
index 9280416..c46083d 100644
--- a/src/llc/llc_xid.c
+++ b/src/llc/llc_xid.c
@@ -320,3 +320,33 @@
}
return dst_xid;
}
+
+/* Dump a list with XID fields (Debug) */
+void gprs_llc_dump_xid_fields(const struct gprs_llc_xid_field *xid_fields,
+ size_t xid_fields_len, unsigned int logl)
+{
+ unsigned int i;
+
+ OSMO_ASSERT(xid_fields);
+
+ for (i = 0; i < xid_fields_len; i++) {
+ const struct gprs_llc_xid_field *xid_field = &xid_fields[i];
+ const uint8_t len = gprs_llc_xid_field_get_len(xid_field);
+ if (len > 0) {
+ if (gprs_llc_xid_type_is_variable_len(xid_field->type)) {
+ OSMO_ASSERT(xid_field->var.val);
+ LOGLLC(logl, "XID: type %s, data_len=%d, data=%s\n",
+ gprs_llc_xid_type_name(xid_field->type),
+ xid_field->var.val_len,
+ osmo_hexdump_nospc(xid_field->var.val, xid_field->var.val_len));
+ } else {
+ LOGLLC(logl, "XID: type %s, val_len=%d, val=%u\n",
+ gprs_llc_xid_type_name(xid_field->type),
+ len, xid_field->val);
+ }
+ } else {
+ LOGLLC(logl, "XID: type %s, data_len=0\n",
+ gprs_llc_xid_type_name(xid_field->type));
+ }
+ }
+}
diff --git a/tests/llc/llc_prim_test.err b/tests/llc/llc_prim_test.err
index 7cc72f5..27867c4 100644
--- a/tests/llc/llc_prim_test.err
+++ b/tests/llc/llc_prim_test.err
@@ -22,5 +22,9 @@
DLGLOBAL INFO Rx from upper layers: LL-ESTABLISH.request
DLGLOBAL ERROR LLE(e1c5d364/e1c5d364,SNDCP3){UNASSIGNED} Tx SABM: ABM mode not supported
yet!
DLGLOBAL INFO Rx from upper layers: LL-XID.request
+DLGLOBAL DEBUG XID: type LLC-Version, val_len=1, val=0
+DLGLOBAL DEBUG XID: type N201-U, val_len=2, val=500
+DLGLOBAL DEBUG XID: type N201-I, val_len=2, val=1503
+DLGLOBAL DEBUG XID: type L3-Params, data_len=20,
data=7869642d6c332d64756d6d792d62756666657200
DLGLOBAL NOTICE LLE(e1c5d364/e1c5d364,SNDCP3){UNASSIGNED} Sending XID type L3-Params (30
bytes) request to MS...
DLGLOBAL INFO Rx from upper layers: LL-UNITDATA.request
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33947
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I8c6b07305c0bcecb4e1681967884a3e62c813592
Gerrit-Change-Number: 33947
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged