llc: Introduce function to log XID fields and use upon Rx/Tx

Change-Id: I8c6b07305c0bcecb4e1681967884a3e62c813592
This commit is contained in:
Pau Espin 2023-07-26 19:01:35 +02:00
parent f4fca416e2
commit 7a75a16350
4 changed files with 40 additions and 0 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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));
}
}
}

View File

@ -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