aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-07-26 19:01:35 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-07-26 20:22:56 +0200
commit7a75a1635039675292197edd8f28efb710b79d10 (patch)
treea8e6c4dba9ca86e478ff7bd8ae674649bb90a780
parentf4fca416e2f619b37146e2a026afa83d0f5eae90 (diff)
llc: Introduce function to log XID fields and use upon Rx/Tx
-rw-r--r--include/osmocom/gprs/llc/llc_private.h2
-rw-r--r--src/llc/llc.c4
-rw-r--r--src/llc/llc_xid.c30
-rw-r--r--tests/llc/llc_prim_test.err4
4 files changed, 40 insertions, 0 deletions
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 @@ int gprs_llc_xid_encode(uint8_t *data, size_t data_len,
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 @@ static int gprs_llc_lle_generate_xid(struct gprs_llc_lle *lle, uint8_t *bytes, i
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 @@ static int gprs_llc_lle_process_xid_ind(struct gprs_llc_lle *lle,
}
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 @@ struct gprs_llc_xid_field *gprs_llc_xid_deepcopy(void *ctx,
}
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 LLME(e1c5d364/e1c5d364){ASSIGNED} LLGMM-RESET.request
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