aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-07-26 19:12:49 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-07-26 20:23:00 +0200
commit5aa16e1c8d2bf6335aab7300706e699c283cf7b1 (patch)
treeaa23797bc4dfafab032a0bf1c57504fe6c9bcc69
parent7a75a1635039675292197edd8f28efb710b79d10 (diff)
llc: Apply N201-I & N201-U requested by the network
-rw-r--r--src/llc/llc.c15
-rw-r--r--src/llc/llc_ll.c5
-rw-r--r--tests/llc/llc_prim_test.c48
-rw-r--r--tests/llc/llc_prim_test.err11
-rw-r--r--tests/llc/llc_prim_test.ok1
5 files changed, 79 insertions, 1 deletions
diff --git a/src/llc/llc.c b/src/llc/llc.c
index 827b067..e5e9538 100644
--- a/src/llc/llc.c
+++ b/src/llc/llc.c
@@ -573,6 +573,21 @@ static int gprs_llc_lle_process_xid_ind(struct gprs_llc_lle *lle,
* when a MS submits values which defer from
* the default! */
+ for (i = 0; i < xid_fields_len; i++) {
+ switch (xid_fields[i].type) {
+ case OSMO_GPRS_LLC_XID_T_N201_U:
+ LOGLLE(lle, LOGL_INFO, "Peer requested N201-U=%u\n", xid_fields[i].val);
+ lle->params.n201_u = xid_fields[i].val;
+ break;
+ case OSMO_GPRS_LLC_XID_T_N201_I:
+ LOGLLE(lle, LOGL_INFO, "Peer requested N201-I=%u\n", xid_fields[i].val);
+ lle->params.n201_i = xid_fields[i].val;
+ break;
+ default:
+ continue;
+ }
+ }
+
/* Store last received XID-Ind from peer: */
lle->rx_xid = gprs_llc_xid_deepcopy(lle->llme, xid_fields, xid_fields_len);
OSMO_ASSERT(lle->rx_xid);
diff --git a/src/llc/llc_ll.c b/src/llc/llc_ll.c
index b907299..0ba690b 100644
--- a/src/llc/llc_ll.c
+++ b/src/llc/llc_ll.c
@@ -180,6 +180,8 @@ int gprs_llc_lle_submit_prim_ll_xid_ind(struct gprs_llc_lle *lle,
if (llc_prim_tx->ll.l3_pdu_len > 0)
memcpy(llc_prim_tx->ll.l3_pdu, xid_field_request_l3->var.val,
llc_prim_tx->ll.l3_pdu_len);
+ llc_prim_tx->ll.xid.n201_i = lle->params.n201_i;
+ llc_prim_tx->ll.xid.n201_u = lle->params.n201_u;
return gprs_llc_prim_call_up_cb(llc_prim_tx);
}
@@ -197,7 +199,8 @@ int gprs_llc_lle_submit_prim_ll_xid_cnf(struct gprs_llc_lle *lle,
if (llc_prim_tx->ll.l3_pdu_len > 0)
memcpy(llc_prim_tx->ll.l3_pdu, xid_field_response_l3->var.val,
llc_prim_tx->ll.l3_pdu_len);
-
+ llc_prim_tx->ll.xid.n201_i = lle->params.n201_i;
+ llc_prim_tx->ll.xid.n201_u = lle->params.n201_u;
/* TODO: do something with following. Is it actually needed? */
(void)xid_field_request_l3;
diff --git a/tests/llc/llc_prim_test.c b/tests/llc/llc_prim_test.c
index b9e2e0e..a7f132a 100644
--- a/tests/llc/llc_prim_test.c
+++ b/tests/llc/llc_prim_test.c
@@ -160,6 +160,40 @@ GSM A-I/F DTAP - Identity Request
*/
static uint8_t pdu_gmm_id_req[] = { 0x08, 0x15, 0x02 };
+/*
+MS-SGSN LLC (Mobile Station - Serving GPRS Support Node Logical Link Control) SAPI: User data 3
+ Address field SAPI: LL3
+ 0... .... = Protocol Discriminator_bit: OK
+ .1.. .... = Command/Response bit: DownLink/UpLink = Command/Response
+ .... 0011 = SAPI: User data 3 (3)
+ Unnumbered frame: XID
+ 111. .... = U format: 0x7
+ ...1 .... = P/F bit: True
+ .... 1011 = Command/Response: XID (0xb)
+ FCS: 0x4e7c8c (correct)
+ Information Field: Length = 8
+ XID Parameter Type: Version (LLC version number) - Value: 0
+ 0... .... = XL Bit: 0x0
+ .000 00.. = Type: 0
+ .... ..01 = Length: 1
+ 0000 0000 = Parameter Byte: 0x00
+ XID Parameter Type: N201-U (max info field length for U and UI frames) - Value: 500
+ 0... .... = XL Bit: 0x0
+ .001 01.. = Type: 5
+ .... ..10 = Length: 2
+ 0000 0001 = Parameter Byte: 0x01
+ 1111 0100 = Parameter Byte: 0xf4
+ XID Parameter Type: N201-I (max info field length for I frames) - Value: 1503
+ 0... .... = XL Bit: 0x0
+ .001 10.. = Type: 6
+ .... ..10 = Length: 2
+ 0000 0101 = Parameter Byte: 0x05
+ 1101 1111 = Parameter Byte: 0xdf
+*/
+static uint8_t pdu_llc_xid_cmd_dl[] = {
+ 0x43, 0xfb, 0x01, 0x00, 0x16, 0x01, 0xf4, 0x1a, 0x05, 0xdf, 0x8c, 0x7c, 0x4e };
+
+
static void test_llc_prim_ms(void)
{
struct osmo_gprs_llc_prim *llc_prim;
@@ -187,6 +221,20 @@ static void test_llc_prim_ms(void)
rc = osmo_gprs_llc_prim_lower_up(llc_prim);
OSMO_ASSERT(rc == 0);
+ /* 3GPP TS 24.007 Appendix C.6: PDP Act Req + Acc happens here in upper
+ layers ... as a result, SNDCP submits LL-ESTABLISH-REQ: */
+ char xid_l3_pars[] = "xid-l3-dummy-buffer";
+ llc_prim = osmo_gprs_llc_prim_alloc_ll_establish_req(tlli, OSMO_GPRS_LLC_SAPI_SNDCP3, (uint8_t *)xid_l3_pars, sizeof(xid_l3_pars));
+ OSMO_ASSERT(llc_prim);
+ rc = osmo_gprs_llc_prim_upper_down(llc_prim);
+ OSMO_ASSERT(rc == -ENOTSUP); /* ABM mode not supported yet. */
+
+ /* Networks sends us a XID command: */
+ llc_prim = osmo_gprs_llc_prim_alloc_grr_unitdata_ind(tlli, pdu_llc_xid_cmd_dl, sizeof(pdu_llc_xid_cmd_dl));
+ OSMO_ASSERT(llc_prim);
+ rc = osmo_gprs_llc_prim_lower_up(llc_prim);
+ OSMO_ASSERT(rc == 0);
+
/* Test GMM asking LLC to transmit a response for a Paging Request: */
llc_prim = osmo_gprs_llc_prim_alloc_llgmm_trigger_req(tlli, OSMO_GPRS_LLC_LLGM_TRIGGER_PAGE_RESP);
OSMO_ASSERT(llc_prim);
diff --git a/tests/llc/llc_prim_test.err b/tests/llc/llc_prim_test.err
index 27867c4..022dfac 100644
--- a/tests/llc/llc_prim_test.err
+++ b/tests/llc/llc_prim_test.err
@@ -3,6 +3,17 @@ DLGLOBAL NOTICE Rx LL-UNITDATA.request: unknown TLLI 0xf43cec71, creating LLME o
DLGLOBAL INFO Rx from lower layers: GRR-UNITDATA.indication
DLGLOBAL DEBUG Rx GRR-UNITDATA.indication: SAPI=1 (GMM), UI func=UI C/R=0 PM=0 E=0 IP=0 N(U)=0 FCS=f218e2
DLGLOBAL DEBUG LLE(ffffffff/f43cec71,GMM){UNASSIGNED} Rx SAPI=1 (GMM), UI func=UI C/R=0 PM=0 E=0 IP=0 N(U)=0 FCS=f218e2
+DLGLOBAL INFO Rx from upper layers: LL-ESTABLISH.request
+DLGLOBAL ERROR LLE(ffffffff/f43cec71,SNDCP3){UNASSIGNED} Tx SABM: ABM mode not supported yet!
+DLGLOBAL INFO Rx from lower layers: GRR-UNITDATA.indication
+DLGLOBAL DEBUG Rx GRR-UNITDATA.indication: SAPI=3 (SNDCP3), U func=XID C/R=1 P/F=1 FCS=4e7c8c
+DLGLOBAL DEBUG LLE(ffffffff/f43cec71,SNDCP3){UNASSIGNED} Rx SAPI=3 (SNDCP3), U func=XID C/R=1 P/F=1 FCS=4e7c8c
+DLGLOBAL NOTICE LLE(ffffffff/f43cec71,SNDCP3){UNASSIGNED} Received XID indication from MS.
+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 INFO LLE(ffffffff/f43cec71,SNDCP3){UNASSIGNED} Peer requested N201-U=500
+DLGLOBAL INFO LLE(ffffffff/f43cec71,SNDCP3){UNASSIGNED} Peer requested N201-I=1503
DLGLOBAL INFO Rx from upper layers: LLGMM-TRIGGER.request
DLGLOBAL INFO LLME(ffffffff/f43cec71){UNASSIGNED} LLGMM-TRIGGER.request
DLGLOBAL INFO Rx from upper layers: LLGMM-TRIGGER.request
diff --git a/tests/llc/llc_prim_test.ok b/tests/llc/llc_prim_test.ok
index ee381e6..6ca45d9 100644
--- a/tests/llc/llc_prim_test.ok
+++ b/tests/llc/llc_prim_test.ok
@@ -1,6 +1,7 @@
==== test_llc_prim_ms() [start] ====
test_llc_prim_down_cb(): Rx GRR-UNITDATA.request l3=[01 c0 01 08 01 02 e5 e0 01 0a 00 05 f4 f4 3c ec 71 32 f4 07 00 05 00 17 19 33 43 2b 37 15 9e f9 88 79 cb a2 8c 66 21 e7 26 88 b1 98 87 9c 00 17 05 22 96 cc ]
test_llc_prim_up_cb(): Rx LL-UNITDATA.indication TLLI=0xf43cec71 SAPI=GMM l3=[08 01 01 d5 71 00 00 08 29 26 24 00 00 00 00 71 62 f2 24 6c 84 44 04 11 e5 10 00 ]
+test_llc_prim_down_cb(): Rx GRR-UNITDATA.request l3=[03 fb 01 00 16 01 f4 1a 05 df 68 40 d9 ]
test_llc_prim_down_cb(): Rx GRR-UNITDATA.request l3=[01 c0 05 4a 85 74 ]
test_llc_prim_down_cb(): Rx GRR-UNITDATA.request l3=[01 c0 09 ce 0d f7 ]
test_llc_prim_down_cb(): Rx GRR-UNITDATA.request l3=[01 e0 1c a2 b3 ]