The code currently uses an encoded sequence of (hex) 10 20 30 40 50 60 as RAI, for which no bijective mapping to the set of representations MCC-MNC-LAC-RAC exists.
This patch changes the hard-coded RAI to 11 22 33 40 50 60 which maps to 112-332-16464-96 (and vice-versa).
Sponsored-by: On-Waves ehf --- openbsc/tests/gbproxy/gbproxy_test.c | 4 +- openbsc/tests/gbproxy/gbproxy_test.ok | 216 ++++++++++++++++----------------- 2 files changed, 110 insertions(+), 110 deletions(-)
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c index d32ac83..ea07a77 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.c +++ b/openbsc/tests/gbproxy/gbproxy_test.c @@ -142,8 +142,8 @@ static void send_bssgp_reset(struct gprs_ns_inst *nsi, struct sockaddr_in *src_a * BSSGP RESET */ unsigned char msg[22] = { 0x22, 0x04, 0x82, 0x4a, - 0x2e, 0x07, 0x81, 0x08, 0x08, 0x88, 0x10, 0x20, - 0x30, 0x40, 0x50, 0x60, 0x10, 0x00 + 0x2e, 0x07, 0x81, 0x08, 0x08, 0x88, 0x11, 0x22, + 0x33, 0x40, 0x50, 0x60, 0x10, 0x00 };
msg[3] = bvci / 256; diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok index 0942ca3..e677ec0 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.ok +++ b/openbsc/tests/gbproxy/gbproxy_test.ok @@ -82,16 +82,16 @@ result (ALIVE_ACK) = 0 Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -101,7 +101,7 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -159,16 +159,16 @@ result (ALIVE_ACK) = 0 Setup BSSGP: remote 0x01020304:2222, BVCI 0x2002(8194)
PROCESSING BVC_RESET from 0x01020304:2222 -00 00 00 00 22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -179,8 +179,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 20 02
@@ -242,8 +242,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Move BSS 2 to former BSS 1 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -291,8 +291,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Move BSS 1 to current BSS 2 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -340,8 +340,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Move BSS 2 to new port ---
Setup NS-VC: remote 0x01020304:4444, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -389,8 +389,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Move BSS 2 to former BSS 1 port ---
Setup NS-VC: remote 0x01020304:3333, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -441,8 +441,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Move BSS 1 to original BSS 1 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096) @@ -491,23 +491,23 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Reset BSS 1 with a new BVCI ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x1012(4114)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 12 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 12 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 12 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 12 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 12 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -519,9 +519,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 12
@@ -541,16 +541,16 @@ result (BVC_RESET_ACK) = 9 Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -562,9 +562,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -584,16 +584,16 @@ result (BVC_RESET_ACK) = 9 Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -605,9 +605,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -723,16 +723,16 @@ result (UNITDATA) = 4 Setup BSSGP: remote 0x01020304:3333, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:3333 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -744,10 +744,10 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 Gbproxy global: PROCESSING BVC_RESET_ACK from 0x05060708:32000 @@ -904,16 +904,16 @@ Current NS-VCIs: Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -932,22 +932,22 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Setup BVCI 2 ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x2002(8194)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 20 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -966,8 +966,8 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
PROCESSING UNITDATA from 0x01020304:1111 @@ -1079,16 +1079,16 @@ Current NS-VCIs: Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -1107,24 +1107,24 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Setup BVCI 3 ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x3002(12290)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 30 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 30 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 30 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 30 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 30 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -1143,9 +1143,9 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
@@ -1194,10 +1194,10 @@ MESSAGE to SGSN at 0x05060708:32000, msg length 4 result (UNITDATA) = 4
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 PROCESSING UNITDATA from 0x05060708:32000 00 00 20 02 @@ -1211,11 +1211,11 @@ NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 result (UNITDATA) = -22
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 3 ---
@@ -1302,16 +1302,16 @@ Current NS-VCIs: Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 10 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -1330,27 +1330,27 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Setup BVCI 4 ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x4002(16386)
PROCESSING BVC_RESET from 0x01020304:1111 -00 00 00 00 22 04 82 40 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
CALLBACK, event 0, msg length 22, bvci 0x0000 -22 04 82 40 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22 -22 04 82 40 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
MESSAGE to SGSN at 0x05060708:32000, msg length 26 -00 00 00 00 22 04 82 40 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 +00 00 00 00 22 04 82 40 02 07 81 08 08 88 11 22 33 40 50 60 10 00 00 00 00 00
result (BVC_RESET) = 26
@@ -1369,12 +1369,12 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
@@ -1423,12 +1423,12 @@ MESSAGE to SGSN at 0x05060708:32000, msg length 4 result (UNITDATA) = 4
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 PROCESSING UNITDATA from 0x05060708:32000 00 00 20 02 @@ -1442,12 +1442,12 @@ NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 result (UNITDATA) = -22
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 2 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 3 ---
@@ -1511,12 +1511,12 @@ result (UNITDATA) = 4
Gbproxy global: Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 10-32-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 10-32-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 2 - NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 NSEI mismatch : 1 ===== GbProxy test END
Currently the terms 'Routing area code' (RAC) and 'Location area code' (LAC) are used in several places where 'Routing area identification' (RAI) or 'Location area identification' (LAI) are meant in fact.
This patch replaces RAC/LAC by RAI/LAI and 'code' by 'identification' at these places.
Note that RAI := MCC MNC LAC RAC, and RAC := MCC MNC LAC (see GSM 03.03, sections 4.1 and 4.2).
Sponsored-by: On-Waves ehf --- openbsc/src/gprs/gb_proxy.c | 54 +++++++-------- openbsc/tests/gbproxy/gbproxy_test.ok | 120 ++++++++++++++++----------------- 2 files changed, 87 insertions(+), 87 deletions(-)
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c index 3c41529..4799344 100644 --- a/openbsc/src/gprs/gb_proxy.c +++ b/openbsc/src/gprs/gb_proxy.c @@ -45,8 +45,8 @@
enum gbprox_global_ctr { GBPROX_GLOB_CTR_INV_BVCI, - GBPROX_GLOB_CTR_INV_LAC, - GBPROX_GLOB_CTR_INV_RAC, + GBPROX_GLOB_CTR_INV_LAI, + GBPROX_GLOB_CTR_INV_RAI, GBPROX_GLOB_CTR_INV_NSEI, GBPROX_GLOB_CTR_PROTO_ERR_BSS, GBPROX_GLOB_CTR_PROTO_ERR_SGSN, @@ -59,8 +59,8 @@ enum gbprox_global_ctr {
static const struct rate_ctr_desc global_ctr_description[] = { { "inv-bvci", "Invalid BVC Identifier " }, - { "inv-lac", "Invalid Location Area Code " }, - { "inv-rac", "Invalid Routing Area Code " }, + { "inv-lai", "Invalid Location Area Identifier" }, + { "inv-rai", "Invalid Routing Area Identifier " }, { "inv-nsei", "No BVC established for NSEI " }, { "proto-err.bss", "BSSGP protocol error (BSS )" }, { "proto-err.sgsn", "BSSGP protocol error (SGSN)" }, @@ -154,8 +154,8 @@ static struct gbprox_peer *peer_by_nsei(uint16_t nsei) return NULL; }
-/* look-up a peer by its Routeing Area Code (RAC) */ -static struct gbprox_peer *peer_by_rac(const uint8_t *ra) +/* look-up a peer by its Routeing Area Identification (RAI) */ +static struct gbprox_peer *peer_by_rai(const uint8_t *ra) { struct gbprox_peer *peer; llist_for_each_entry(peer, &gbprox_bts_peers, list) { @@ -165,8 +165,8 @@ static struct gbprox_peer *peer_by_rac(const uint8_t *ra) return NULL; }
-/* look-up a peer by its Location Area Code (LAC) */ -static struct gbprox_peer *peer_by_lac(const uint8_t *la) +/* look-up a peer by its Location Area Identification (LAI) */ +static struct gbprox_peer *peer_by_lai(const uint8_t *la) { struct gbprox_peer *peer; llist_for_each_entry(peer, &gbprox_bts_peers, list) { @@ -389,11 +389,11 @@ static int gbprox_rx_sig_from_bss(struct msgb *msg, uint16_t nsei, switch (pdu_type) { case BSSGP_PDUT_SUSPEND: case BSSGP_PDUT_RESUME: - /* We implement RAC snooping during SUSPEND/RESUME, since - * it establishes a relationsip between BVCI/peer and the - * routeing area code. The snooped information is then - * used for routing the {SUSPEND,RESUME}_[N]ACK back to - * the correct BSSGP */ + /* We implement RAI snooping during SUSPEND/RESUME, since it + * establishes a relationsip between BVCI/peer and the routeing + * area identification. The snooped information is then used + * for routing the {SUSPEND,RESUME}_[N]ACK back to the correct + * BSSGP */ if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA)) goto err_mand_ie; from_peer = peer_by_nsei(nsei); @@ -403,7 +403,7 @@ static int gbprox_rx_sig_from_bss(struct msgb *msg, uint16_t nsei, sizeof(from_peer->ra)); gsm48_parse_ra(&raid, from_peer->ra); LOGP(DGPRS, LOGL_INFO, "NSEI=%u BSSGP SUSPEND/RESUME " - "RAC snooping: RAC %u-%u-%u-%u behind BVCI=%u\n", + "RAI snooping: RAI %u-%u-%u-%u behind BVCI=%u\n", nsei, raid.mcc, raid.mnc, raid.lac, raid.rac , from_peer->bvci); /* FIXME: This only supports one BSS per RA */ @@ -485,15 +485,15 @@ static int gbprox_rx_paging(struct msgb *msg, struct tlv_parsed *tp, bvci); errctr = GBPROX_GLOB_CTR_OTHER_ERR; } else if (TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) { - peer = peer_by_rac(TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); - LOGPC(DGPRS, LOGL_INFO, "routing by RAC to peer BVCI=%u\n", + peer = peer_by_rai(TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA)); + LOGPC(DGPRS, LOGL_INFO, "routing by RAI to peer BVCI=%u\n", peer ? peer->bvci : -1); - errctr = GBPROX_GLOB_CTR_INV_RAC; + errctr = GBPROX_GLOB_CTR_INV_RAI; } else if (TLVP_PRESENT(tp, BSSGP_IE_LOCATION_AREA)) { - peer = peer_by_lac(TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA)); - LOGPC(DGPRS, LOGL_INFO, "routing by LAC to peer BVCI=%u\n", + peer = peer_by_lai(TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA)); + LOGPC(DGPRS, LOGL_INFO, "routing by LAI to peer BVCI=%u\n", peer ? peer->bvci : -1); - errctr = GBPROX_GLOB_CTR_INV_LAC; + errctr = GBPROX_GLOB_CTR_INV_LAI; } else LOGPC(DGPRS, LOGL_INFO, "\n");
@@ -590,7 +590,7 @@ static int gbprox_rx_sig_from_sgsn(struct msgb *msg, uint32_t nsei, break; case BSSGP_PDUT_PAGING_PS: case BSSGP_PDUT_PAGING_CS: - /* process the paging request (LAC/RAC lookup) */ + /* process the paging request (LAI/RAI lookup) */ rc = gbprox_rx_paging(msg, &tp, nsei, ns_bvci); break; case BSSGP_PDUT_STATUS: @@ -616,10 +616,10 @@ static int gbprox_rx_sig_from_sgsn(struct msgb *msg, uint32_t nsei, case BSSGP_PDUT_SUSPEND_NACK: case BSSGP_PDUT_RESUME_ACK: case BSSGP_PDUT_RESUME_NACK: - /* RAC IE is mandatory */ + /* RAI IE is mandatory */ if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA)) goto err_mand_ie; - peer = peer_by_rac(TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA)); + peer = peer_by_rai(TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA)); if (!peer) goto err_no_peer; rc = gbprox_relay2peer(msg, peer, ns_bvci); @@ -666,9 +666,9 @@ err_mand_ie: ctr[GBPROX_GLOB_CTR_PROTO_ERR_SGSN]); return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); err_no_peer: - LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) cannot find peer based on RAC\n", + LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) cannot find peer based on RAI\n", nsei); - rate_ctr_inc(&get_global_ctrg()-> ctr[GBPROX_GLOB_CTR_INV_RAC]); + rate_ctr_inc(&get_global_ctrg()-> ctr[GBPROX_GLOB_CTR_INV_RAI]); return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg); }
@@ -853,7 +853,7 @@ int gbprox_dump_peers(FILE *stream, int indent, int verbose) gsm48_parse_ra(&raid, peer->ra);
rc = fprintf(stream, "%*s NSEI %u, BVCI %u, %sblocked, " - "RAC %u-%u-%u-%u\n", + "RAI %u-%u-%u-%u\n", indent, "", peer->nsei, peer->bvci, peer->blocked ? "" : "not ", @@ -921,7 +921,7 @@ static void gbprox_vty_print_peer(struct vty *vty, struct gbprox_peer *peer) gsm48_parse_ra(&raid, peer->ra);
vty_out(vty, "NSEI %5u, PTP-BVCI %5u, " - "RAC %u-%u-%u-%u", + "RAI %u-%u-%u-%u", peer->nsei, peer->bvci, raid.mcc, raid.mnc, raid.lac, raid.rac); if (peer->blocked) diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok index e677ec0..3b25922 100644 --- a/openbsc/tests/gbproxy/gbproxy_test.ok +++ b/openbsc/tests/gbproxy/gbproxy_test.ok @@ -101,7 +101,7 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -179,8 +179,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 20 02
@@ -242,8 +242,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Move BSS 2 to former BSS 1 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -291,8 +291,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Move BSS 1 to current BSS 2 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -340,8 +340,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Move BSS 2 to new port ---
Setup NS-VC: remote 0x01020304:4444, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -389,8 +389,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Move BSS 2 to former BSS 1 port ---
Setup NS-VC: remote 0x01020304:3333, NSVCI 0x2001(8193), NSEI 0x2000(8192) @@ -441,8 +441,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Move BSS 1 to original BSS 1 port ---
Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096) @@ -491,8 +491,8 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Reset BSS 1 with a new BVCI ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x1012(4114) @@ -519,9 +519,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 12
@@ -562,9 +562,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -605,9 +605,9 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 PROCESSING BVC_RESET_ACK from 0x05060708:32000 00 00 00 00 23 04 82 10 02
@@ -744,10 +744,10 @@ Current NS-VCIs: NS-VC Block count : 1
Peers: - NSEI 4096, BVCI 4114, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4114, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 Gbproxy global: PROCESSING BVC_RESET_ACK from 0x05060708:32000 @@ -932,7 +932,7 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Setup BVCI 2 ---
Setup BSSGP: remote 0x01020304:1111, BVCI 0x2002(8194) @@ -966,8 +966,8 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 4098, not blocked, RAI 112-332-16464-96 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
PROCESSING UNITDATA from 0x01020304:1111 @@ -1107,8 +1107,8 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Setup BVCI 3 ---
@@ -1143,9 +1143,9 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
@@ -1194,10 +1194,10 @@ MESSAGE to SGSN at 0x05060708:32000, msg length 4 result (UNITDATA) = 4
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 PROCESSING UNITDATA from 0x05060708:32000 00 00 20 02 @@ -1211,11 +1211,11 @@ NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 result (UNITDATA) = -22
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 3 ---
@@ -1330,11 +1330,11 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Setup BVCI 4 ---
@@ -1369,12 +1369,12 @@ MESSAGE to BSS at 0x01020304:1111, msg length 9 result (BVC_RESET_ACK) = 9
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 1 ---
@@ -1423,12 +1423,12 @@ MESSAGE to SGSN at 0x05060708:32000, msg length 4 result (UNITDATA) = 4
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 1 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 PROCESSING UNITDATA from 0x05060708:32000 00 00 20 02 @@ -1442,12 +1442,12 @@ NS UNITDATA MESSAGE to BSS, BVCI 0x2002, msg length 0 result (UNITDATA) = -22
Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 2 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 --- Send message from BSS 1 to SGSN and back, BVCI 3 ---
@@ -1511,12 +1511,12 @@ result (UNITDATA) = 4
Gbproxy global: Peers: - NSEI 8192, BVCI 16386, not blocked, RAC 112-332-16464-96 - NSEI 8192, BVCI 12290, not blocked, RAC 112-332-16464-96 - NSEI 4096, BVCI 8194, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96 + NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96 + NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96 NSEI mismatch : 2 NS Transmission error : 2 - NSEI 8192, BVCI 4098, not blocked, RAC 112-332-16464-96 + NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96 NSEI mismatch : 1 ===== GbProxy test END
On Mon, Jun 02, 2014 at 10:49:00AM +0200, Jacob Erlbeck wrote:
Note that RAI := MCC MNC LAC RAC, and RAC := MCC MNC LAC (see GSM
\ / ^^^^ LAI RAC LAI ??
- { "inv-rai", "Invalid Routing Area Identifier " },
+/* look-up a peer by its Routeing Area Identification (RAI) */
The spec you mention is using "routing". Please be consistent. Given the question about s,RAC,LAI, I am waiting for your feedback.
holger
On 04.06.2014 16:28, Holger Hans Peter Freyther wrote:
On Mon, Jun 02, 2014 at 10:49:00AM +0200, Jacob Erlbeck wrote:
Note that RAI := MCC MNC LAC RAC, and RAC := MCC MNC LAC (see GSM
\ / ^^^^ LAI RAC LAI ??
Oops, that was a typo of mine. Of course it's LAI := MCC MNC LAC.
- { "inv-rai", "Invalid Routing Area Identifier " },
+/* look-up a peer by its Routeing Area Identification (RAI) */
The spec you mention is using "routing". Please be consistent.
Unfortunately the specs themselves are not consistent with respect to this, GSM 08.18 is using the British variant. Thus the identifier in gsm_08_18.h also use the ROUTEING variant.
The C file already was mixing the British and the American English variants. This commit didn't add any 'rout(e)ing' term, it focused on the 'code' issue.
While I agree that we should strive for consistency, I'd rather put it into a specific commit when we've settled on which variant shall be taken.
Jacob
Given the question about s,RAC,LAI, I am waiting for your feedback.
holger
Currently LLC parsing is part of gprs_llc.c which needs large parts of the SGSN code parsing to fulfill its link dependencies.
This patch moves the functions that just do plain parsing, dumping, and FCS computation to a different file to avoid these dependencies if LLC stateful processing is not needed. It also exposes struct gprs_llc_hdr_parsed and enum gprs_llc_cmd publically.
Sponsored-by: On-Waves ehf --- openbsc/include/openbsc/gprs_llc.h | 41 ++++++ openbsc/src/gprs/Makefile.am | 2 +- openbsc/src/gprs/gprs_llc.c | 236 ---------------------------------- openbsc/src/gprs/gprs_llc_parse.c | 243 ++++++++++++++++++++++++++++++++++++ 4 files changed, 285 insertions(+), 237 deletions(-) create mode 100644 openbsc/src/gprs/gprs_llc_parse.c
diff --git a/openbsc/include/openbsc/gprs_llc.h b/openbsc/include/openbsc/gprs_llc.h index 4be7b1f..854b968 100644 --- a/openbsc/include/openbsc/gprs_llc.h +++ b/openbsc/include/openbsc/gprs_llc.h @@ -165,6 +165,39 @@ struct gprs_llc_llme {
extern struct llist_head gprs_llc_llmes;
+/* LLC low level types */ + +enum gprs_llc_cmd { + GPRS_LLC_NULL, + GPRS_LLC_RR, + GPRS_LLC_ACK, + GPRS_LLC_RNR, + GPRS_LLC_SACK, + GPRS_LLC_DM, + GPRS_LLC_DISC, + GPRS_LLC_UA, + GPRS_LLC_SABM, + GPRS_LLC_FRMR, + GPRS_LLC_XID, + GPRS_LLC_UI, +}; + +struct gprs_llc_hdr_parsed { + uint8_t sapi; + uint8_t is_cmd:1, + ack_req:1, + is_encrypted:1; + uint32_t seq_rx; + uint32_t seq_tx; + uint32_t fcs; + uint32_t fcs_calc; + uint8_t *data; + uint16_t data_len; + uint16_t crc_length; + enum gprs_llc_cmd cmd; +}; + + /* BSSGP-UL-UNITDATA.ind */ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv);
@@ -199,4 +232,12 @@ static inline int gprs_llc_is_retransmit(uint16_t nu, uint16_t vur) return 0 < delta && delta < 32; }
+/* LLC low level functions */ + +/* parse a GPRS LLC header, also check for invalid frames */ +int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, + uint8_t *llc_hdr, int len); +void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph); +int gprs_llc_fcs(uint8_t *data, unsigned int len); + #endif diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am index 90c376c..049d41d 100644 --- a/openbsc/src/gprs/Makefile.am +++ b/openbsc/src/gprs/Makefile.am @@ -19,7 +19,7 @@ osmo_gbproxy_LDADD = $(top_builddir)/src/libcommon/libcommon.a \
osmo_sgsn_SOURCES = gprs_gmm.c gprs_sgsn.c gprs_sndcp.c gprs_sndcp_vty.c \ sgsn_main.c sgsn_vty.c sgsn_libgtp.c \ - gprs_llc.c gprs_llc_vty.c crc24.c \ + gprs_llc.c gprs_llc_parse.c gprs_llc_vty.c crc24.c \ sgsn_ctrl.c osmo_sgsn_LDADD = \ $(top_builddir)/src/libctrl/libctrl.a \ diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c index 1e40dcb..70fe9dd 100644 --- a/openbsc/src/gprs/gprs_llc.c +++ b/openbsc/src/gprs/gprs_llc.c @@ -36,52 +36,6 @@ #include <openbsc/crc24.h> #include <openbsc/sgsn.h>
-enum gprs_llc_cmd { - GPRS_LLC_NULL, - GPRS_LLC_RR, - GPRS_LLC_ACK, - GPRS_LLC_RNR, - GPRS_LLC_SACK, - GPRS_LLC_DM, - GPRS_LLC_DISC, - GPRS_LLC_UA, - GPRS_LLC_SABM, - GPRS_LLC_FRMR, - GPRS_LLC_XID, - GPRS_LLC_UI, -}; - -static const struct value_string llc_cmd_strs[] = { - { GPRS_LLC_NULL, "NULL" }, - { GPRS_LLC_RR, "RR" }, - { GPRS_LLC_ACK, "ACK" }, - { GPRS_LLC_RNR, "RNR" }, - { GPRS_LLC_SACK, "SACK" }, - { GPRS_LLC_DM, "DM" }, - { GPRS_LLC_DISC, "DISC" }, - { GPRS_LLC_UA, "UA" }, - { GPRS_LLC_SABM, "SABM" }, - { GPRS_LLC_FRMR, "FRMR" }, - { GPRS_LLC_XID, "XID" }, - { GPRS_LLC_UI, "UI" }, - { 0, NULL } -}; - -struct gprs_llc_hdr_parsed { - uint8_t sapi; - uint8_t is_cmd:1, - ack_req:1, - is_encrypted:1; - uint32_t seq_rx; - uint32_t seq_tx; - uint32_t fcs; - uint32_t fcs_calc; - uint8_t *data; - uint16_t data_len; - uint16_t crc_length; - enum gprs_llc_cmd cmd; -}; - static struct gprs_llc_llme *llme_alloc(uint32_t tlli);
/* If the TLLI is foreign, return its local version */ @@ -292,22 +246,6 @@ static void llme_free(struct gprs_llc_llme *llme) talloc_free(llme); }
-#define LLC_ALLOC_SIZE 16384 -#define UI_HDR_LEN 3 -#define N202 4 -#define CRC24_LENGTH 3 - -static int gprs_llc_fcs(uint8_t *data, unsigned int len) -{ - uint32_t fcs_calc; - - fcs_calc = crc24_calc(INIT_CRC24, data, len); - fcs_calc = ~fcs_calc; - fcs_calc &= 0xffffff; - - return fcs_calc; -} - #if 0 /* FIXME: Unused code... */ static void t200_expired(void *data) @@ -550,20 +488,6 @@ static void rx_llc_xid(struct gprs_llc_lle *lle, } }
-static void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph) -{ - DEBUGP(DLLC, "LLC SAPI=%u %c %c FCS=0x%06x", - gph->sapi, gph->is_cmd ? 'C' : 'R', gph->ack_req ? 'A' : ' ', - gph->fcs); - - if (gph->cmd) - DEBUGPC(DLLC, "CMD=%s ", get_value_string(llc_cmd_strs, gph->cmd)); - - if (gph->data) - DEBUGPC(DLLC, "DATA "); - - DEBUGPC(DLLC, "\n"); -} static int gprs_llc_hdr_rx(struct gprs_llc_hdr_parsed *gph, struct gprs_llc_lle *lle) { @@ -634,166 +558,6 @@ static int gprs_llc_hdr_rx(struct gprs_llc_hdr_parsed *gph, return 0; }
-/* parse a GPRS LLC header, also check for invalid frames */ -static int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, - uint8_t *llc_hdr, int len) -{ - uint8_t *ctrl = llc_hdr+1; - - if (len <= CRC24_LENGTH) - return -EIO; - - ghp->crc_length = len - CRC24_LENGTH; - - ghp->ack_req = 0; - - /* Section 5.5: FCS */ - ghp->fcs = *(llc_hdr + len - 3); - ghp->fcs |= *(llc_hdr + len - 2) << 8; - ghp->fcs |= *(llc_hdr + len - 1) << 16; - - /* Section 6.2.1: invalid PD field */ - if (llc_hdr[0] & 0x80) - return -EIO; - - /* This only works for the MS->SGSN direction */ - if (llc_hdr[0] & 0x40) - ghp->is_cmd = 0; - else - ghp->is_cmd = 1; - - ghp->sapi = llc_hdr[0] & 0xf; - - /* Section 6.2.3: check for reserved SAPI */ - switch (ghp->sapi) { - case 0: - case 4: - case 6: - case 0xa: - case 0xc: - case 0xd: - case 0xf: - return -EINVAL; - } - - if ((ctrl[0] & 0x80) == 0) { - /* I (Information transfer + Supervisory) format */ - uint8_t k; - - ghp->data = ctrl + 3; - - if (ctrl[0] & 0x40) - ghp->ack_req = 1; - - ghp->seq_tx = (ctrl[0] & 0x1f) << 4; - ghp->seq_tx |= (ctrl[1] >> 4); - - ghp->seq_rx = (ctrl[1] & 0x7) << 6; - ghp->seq_rx |= (ctrl[2] >> 2); - - switch (ctrl[2] & 0x03) { - case 0: - ghp->cmd = GPRS_LLC_RR; - break; - case 1: - ghp->cmd = GPRS_LLC_ACK; - break; - case 2: - ghp->cmd = GPRS_LLC_RNR; - break; - case 3: - ghp->cmd = GPRS_LLC_SACK; - k = ctrl[3] & 0x1f; - ghp->data += 1 + k; - break; - } - ghp->data_len = (llc_hdr + len - 3) - ghp->data; - } else if ((ctrl[0] & 0xc0) == 0x80) { - /* S (Supervisory) format */ - ghp->data = NULL; - ghp->data_len = 0; - - if (ctrl[0] & 0x20) - ghp->ack_req = 1; - ghp->seq_rx = (ctrl[0] & 0x7) << 6; - ghp->seq_rx |= (ctrl[1] >> 2); - - switch (ctrl[1] & 0x03) { - case 0: - ghp->cmd = GPRS_LLC_RR; - break; - case 1: - ghp->cmd = GPRS_LLC_ACK; - break; - case 2: - ghp->cmd = GPRS_LLC_RNR; - break; - case 3: - ghp->cmd = GPRS_LLC_SACK; - break; - } - } else if ((ctrl[0] & 0xe0) == 0xc0) { - /* UI (Unconfirmed Inforamtion) format */ - ghp->cmd = GPRS_LLC_UI; - ghp->data = ctrl + 2; - ghp->data_len = (llc_hdr + len - 3) - ghp->data; - - ghp->seq_tx = (ctrl[0] & 0x7) << 6; - ghp->seq_tx |= (ctrl[1] >> 2); - if (ctrl[1] & 0x02) { - ghp->is_encrypted = 1; - /* FIXME: encryption */ - } - if (ctrl[1] & 0x01) { - /* FCS over hdr + all inf fields */ - } else { - /* FCS over hdr + N202 octets (4) */ - if (ghp->crc_length > UI_HDR_LEN + N202) - ghp->crc_length = UI_HDR_LEN + N202; - } - } else { - /* U (Unnumbered) format: 1 1 1 P/F M4 M3 M2 M1 */ - ghp->data = NULL; - ghp->data_len = 0; - - switch (ctrl[0] & 0xf) { - case GPRS_LLC_U_NULL_CMD: - ghp->cmd = GPRS_LLC_NULL; - break; - case GPRS_LLC_U_DM_RESP: - ghp->cmd = GPRS_LLC_DM; - break; - case GPRS_LLC_U_DISC_CMD: - ghp->cmd = GPRS_LLC_DISC; - break; - case GPRS_LLC_U_UA_RESP: - ghp->cmd = GPRS_LLC_UA; - break; - case GPRS_LLC_U_SABM_CMD: - ghp->cmd = GPRS_LLC_SABM; - break; - case GPRS_LLC_U_FRMR_RESP: - ghp->cmd = GPRS_LLC_FRMR; - break; - case GPRS_LLC_U_XID: - ghp->cmd = GPRS_LLC_XID; - ghp->data = ctrl + 1; - ghp->data_len = (llc_hdr + len - 3) - ghp->data; - break; - default: - return -EIO; - } - } - - /* FIXME: parse sack frame */ - if (ghp->cmd == GPRS_LLC_SACK) { - LOGP(DLLC, LOGL_NOTICE, "Unsupported SACK frame\n"); - return -EIO; - } - - return 0; -} - /* receive an incoming LLC PDU (BSSGP-UL-UNITDATA-IND, 7.2.4.2) */ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv) { diff --git a/openbsc/src/gprs/gprs_llc_parse.c b/openbsc/src/gprs/gprs_llc_parse.c new file mode 100644 index 0000000..b1f1a56 --- /dev/null +++ b/openbsc/src/gprs/gprs_llc_parse.c @@ -0,0 +1,243 @@ +/* GPRS LLC protocol implementation as per 3GPP TS 04.64 */ + +/* (C) 2009-2010 by Harald Welte laforge@gnumonks.org + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +#include <errno.h> +#include <stdint.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/timer.h> +#include <osmocom/core/talloc.h> +#include <osmocom/gprs/gprs_bssgp.h> + +#include <openbsc/gsm_data.h> +#include <openbsc/debug.h> +#include <openbsc/gprs_sgsn.h> +#include <openbsc/gprs_gmm.h> +#include <openbsc/gprs_llc.h> +#include <openbsc/crc24.h> + +static const struct value_string llc_cmd_strs[] = { + { GPRS_LLC_NULL, "NULL" }, + { GPRS_LLC_RR, "RR" }, + { GPRS_LLC_ACK, "ACK" }, + { GPRS_LLC_RNR, "RNR" }, + { GPRS_LLC_SACK, "SACK" }, + { GPRS_LLC_DM, "DM" }, + { GPRS_LLC_DISC, "DISC" }, + { GPRS_LLC_UA, "UA" }, + { GPRS_LLC_SABM, "SABM" }, + { GPRS_LLC_FRMR, "FRMR" }, + { GPRS_LLC_XID, "XID" }, + { GPRS_LLC_UI, "UI" }, + { 0, NULL } +}; + +#define LLC_ALLOC_SIZE 16384 +#define UI_HDR_LEN 3 +#define N202 4 +#define CRC24_LENGTH 3 + +int gprs_llc_fcs(uint8_t *data, unsigned int len) +{ + uint32_t fcs_calc; + + fcs_calc = crc24_calc(INIT_CRC24, data, len); + fcs_calc = ~fcs_calc; + fcs_calc &= 0xffffff; + + return fcs_calc; +} + +void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph) +{ + DEBUGP(DLLC, "LLC SAPI=%u %c %c FCS=0x%06x", + gph->sapi, gph->is_cmd ? 'C' : 'R', gph->ack_req ? 'A' : ' ', + gph->fcs); + + if (gph->cmd) + DEBUGPC(DLLC, "CMD=%s ", get_value_string(llc_cmd_strs, gph->cmd)); + + if (gph->data) + DEBUGPC(DLLC, "DATA "); + + DEBUGPC(DLLC, "\n"); +} + +/* parse a GPRS LLC header, also check for invalid frames */ +int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, + uint8_t *llc_hdr, int len) +{ + uint8_t *ctrl = llc_hdr+1; + + if (len <= CRC24_LENGTH) + return -EIO; + + ghp->crc_length = len - CRC24_LENGTH; + + ghp->ack_req = 0; + + /* Section 5.5: FCS */ + ghp->fcs = *(llc_hdr + len - 3); + ghp->fcs |= *(llc_hdr + len - 2) << 8; + ghp->fcs |= *(llc_hdr + len - 1) << 16; + + /* Section 6.2.1: invalid PD field */ + if (llc_hdr[0] & 0x80) + return -EIO; + + /* This only works for the MS->SGSN direction */ + if (llc_hdr[0] & 0x40) + ghp->is_cmd = 0; + else + ghp->is_cmd = 1; + + ghp->sapi = llc_hdr[0] & 0xf; + + /* Section 6.2.3: check for reserved SAPI */ + switch (ghp->sapi) { + case 0: + case 4: + case 6: + case 0xa: + case 0xc: + case 0xd: + case 0xf: + return -EINVAL; + } + + if ((ctrl[0] & 0x80) == 0) { + /* I (Information transfer + Supervisory) format */ + uint8_t k; + + ghp->data = ctrl + 3; + + if (ctrl[0] & 0x40) + ghp->ack_req = 1; + + ghp->seq_tx = (ctrl[0] & 0x1f) << 4; + ghp->seq_tx |= (ctrl[1] >> 4); + + ghp->seq_rx = (ctrl[1] & 0x7) << 6; + ghp->seq_rx |= (ctrl[2] >> 2); + + switch (ctrl[2] & 0x03) { + case 0: + ghp->cmd = GPRS_LLC_RR; + break; + case 1: + ghp->cmd = GPRS_LLC_ACK; + break; + case 2: + ghp->cmd = GPRS_LLC_RNR; + break; + case 3: + ghp->cmd = GPRS_LLC_SACK; + k = ctrl[3] & 0x1f; + ghp->data += 1 + k; + break; + } + ghp->data_len = (llc_hdr + len - 3) - ghp->data; + } else if ((ctrl[0] & 0xc0) == 0x80) { + /* S (Supervisory) format */ + ghp->data = NULL; + ghp->data_len = 0; + + if (ctrl[0] & 0x20) + ghp->ack_req = 1; + ghp->seq_rx = (ctrl[0] & 0x7) << 6; + ghp->seq_rx |= (ctrl[1] >> 2); + + switch (ctrl[1] & 0x03) { + case 0: + ghp->cmd = GPRS_LLC_RR; + break; + case 1: + ghp->cmd = GPRS_LLC_ACK; + break; + case 2: + ghp->cmd = GPRS_LLC_RNR; + break; + case 3: + ghp->cmd = GPRS_LLC_SACK; + break; + } + } else if ((ctrl[0] & 0xe0) == 0xc0) { + /* UI (Unconfirmed Inforamtion) format */ + ghp->cmd = GPRS_LLC_UI; + ghp->data = ctrl + 2; + ghp->data_len = (llc_hdr + len - 3) - ghp->data; + + ghp->seq_tx = (ctrl[0] & 0x7) << 6; + ghp->seq_tx |= (ctrl[1] >> 2); + if (ctrl[1] & 0x02) { + ghp->is_encrypted = 1; + /* FIXME: encryption */ + } + if (ctrl[1] & 0x01) { + /* FCS over hdr + all inf fields */ + } else { + /* FCS over hdr + N202 octets (4) */ + if (ghp->crc_length > UI_HDR_LEN + N202) + ghp->crc_length = UI_HDR_LEN + N202; + } + } else { + /* U (Unnumbered) format: 1 1 1 P/F M4 M3 M2 M1 */ + ghp->data = NULL; + ghp->data_len = 0; + + switch (ctrl[0] & 0xf) { + case GPRS_LLC_U_NULL_CMD: + ghp->cmd = GPRS_LLC_NULL; + break; + case GPRS_LLC_U_DM_RESP: + ghp->cmd = GPRS_LLC_DM; + break; + case GPRS_LLC_U_DISC_CMD: + ghp->cmd = GPRS_LLC_DISC; + break; + case GPRS_LLC_U_UA_RESP: + ghp->cmd = GPRS_LLC_UA; + break; + case GPRS_LLC_U_SABM_CMD: + ghp->cmd = GPRS_LLC_SABM; + break; + case GPRS_LLC_U_FRMR_RESP: + ghp->cmd = GPRS_LLC_FRMR; + break; + case GPRS_LLC_U_XID: + ghp->cmd = GPRS_LLC_XID; + ghp->data = ctrl + 1; + ghp->data_len = (llc_hdr + len - 3) - ghp->data; + break; + default: + return -EIO; + } + } + + /* FIXME: parse sack frame */ + if (ghp->cmd == GPRS_LLC_SACK) { + LOGP(DLLC, LOGL_NOTICE, "Unsupported SACK frame\n"); + return -EIO; + } + + return 0; +}