summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-11-12 17:14:18 +0100
committerlaforge <laforge@osmocom.org>2019-11-12 21:35:24 +0000
commit535e43268cef88439320a4cf8b614c976ff78a4f (patch)
treed5e1f37452b9b59c48a04ecaed17d221d58be97b
parent30275e13ef6060bc81e5969e7c202f6464b558fa (diff)
xua: Avoid multiline log in xua_msg_dump()
In general we want to avoid multiline log messages since they make parsing more difficult. Also output in VTY over telnet looks strange (indentation incremented at each new line). Change-Id: Id9084d0e0f976bb374186db93d6ff8062b99e238
-rw-r--r--src/xua_msg.c8
-rw-r--r--tests/xua/xua_test.ok61
2 files changed, 15 insertions, 54 deletions
diff --git a/src/xua_msg.c b/src/xua_msg.c
index ed0cdc7..91adcf1 100644
--- a/src/xua_msg.c
+++ b/src/xua_msg.c
@@ -496,18 +496,18 @@ char *xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect)
static char buf[1024];
struct xua_msg_part *part;
const struct xua_msg_class *xmc = NULL;
-
+ bool comma = false;
if (dialect)
xmc = dialect->class[xua->hdr.msg_class];
buf[0] = '\0';
- append_to_buf(buf, NULL, "HDR=(%s,V=%u,LEN=%u)",
+ append_to_buf(buf, &comma, "HDR=(%s,V=%u,LEN=%u)",
xua_hdr_dump(xua, dialect),
xua->hdr.version, xua->hdr.msg_length);
- buf[0] = ' ';
+
llist_for_each_entry(part, &xua->headers, entry)
- append_to_buf(buf, NULL, "\n\tPART(T=%s,L=%u,D=%s)",
+ append_to_buf(buf, NULL, " PART(T=%s,L=%u,D=%s)",
xua_class_iei_name(xmc, part->tag), part->len,
osmo_hexdump_nospc(part->dat, part->len));
return buf;
diff --git a/tests/xua/xua_test.ok b/tests/xua/xua_test.ok
index f93b41e..6738cc0 100644
--- a/tests/xua/xua_test.ok
+++ b/tests/xua/xua_test.ok
@@ -18,116 +18,77 @@ OUT:TT=0,NPL=1,NAI=4,DIG=919969679389
=> BSSMAP-RESET
SCCP Input: [L2]> 09 00 03 05 07 02 42 fe 02 42 fe 06 00 04 30 04 01 20
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000000),
- PART(T=Destination Address,L=12,D=0002000180030008000000fe),
- PART(T=Source Address,L=12,D=0002000180030008000000fe),
- PART(T=Data,L=6,D=000430040120)
+Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000000), PART(T=Destination Address,L=12,D=0002000180030008000000fe), PART(T=Source Address,L=12,D=0002000180030008000000fe), PART(T=Data,L=6,D=000430040120)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 09 00 03 05 07 02 42 fe 02 42 fe 06 00 04 30 04 01 20
=> BSSMAP-RESET-ACK
SCCP Input: [L2]> 09 00 03 07 0b 04 43 01 00 fe 04 43 5c 00 fe 03 00 01 31
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000000),
- PART(T=Destination Address,L=20,D=00020003800200080000000180030008000000fe),
- PART(T=Source Address,L=20,D=00020003800200080000005c80030008000000fe),
- PART(T=Data,L=3,D=000131)
+Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000000), PART(T=Destination Address,L=20,D=00020003800200080000000180030008000000fe), PART(T=Source Address,L=20,D=00020003800200080000005c80030008000000fe), PART(T=Data,L=3,D=000131)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 09 00 03 07 0b 04 43 01 00 fe 04 43 5c 00 fe 03 00 01 31
=> BSSMAP-PAGING
SCCP Input: [L2]> 09 00 03 07 0b 04 43 01 00 fe 04 43 5c 00 fe 10 00 0e 52 08 08 29 47 10 02 01 31 97 61 1a 01 06
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000000),
- PART(T=Destination Address,L=20,D=00020003800200080000000180030008000000fe),
- PART(T=Source Address,L=20,D=00020003800200080000005c80030008000000fe),
- PART(T=Data,L=16,D=000e52080829471002013197611a0106)
+Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000000), PART(T=Destination Address,L=20,D=00020003800200080000000180030008000000fe), PART(T=Source Address,L=20,D=00020003800200080000005c80030008000000fe), PART(T=Data,L=16,D=000e52080829471002013197611a0106)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 09 00 03 07 0b 04 43 01 00 fe 04 43 5c 00 fe 10 00 0e 52 08 08 29 47 10 02 01 31 97 61 1a 01 06
=> BSSMAP-UDT
SCCP Input: [L2]> 09 00 03 05 07 02 42 fe 02 42 fe 10 00 0e 52 08 08 29 47 10 02 01 31 97 61 1a 01 06
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000000),
- PART(T=Destination Address,L=12,D=0002000180030008000000fe),
- PART(T=Source Address,L=12,D=0002000180030008000000fe),
- PART(T=Data,L=16,D=000e52080829471002013197611a0106)
+Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000000), PART(T=Destination Address,L=12,D=0002000180030008000000fe), PART(T=Source Address,L=12,D=0002000180030008000000fe), PART(T=Data,L=16,D=000e52080829471002013197611a0106)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 09 00 03 05 07 02 42 fe 02 42 fe 10 00 0e 52 08 08 29 47 10 02 01 31 97 61 1a 01 06
=> BSSMAP-CR
SCCP Input: [L2]> 01 01 02 03 02 02 04 02 42 fe 0f 1f 00 1d 57 05 08 00 72 f4 80 20 12 c3 50 17 10 05 24 11 03 33 19 a2 08 29 47 10 02 01 31 97 61 00
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:CORE,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000002),
- PART(T=Source Reference,L=4,D=00010203),
- PART(T=Destination Address,L=12,D=0002000180030008000000fe),
- PART(T=Data,L=31,D=001d5705080072f4802012c3501710052411033319a2082947100201319761)
+Decoded SUA: HDR=(CO:CORE,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000002), PART(T=Source Reference,L=4,D=00010203), PART(T=Destination Address,L=12,D=0002000180030008000000fe), PART(T=Data,L=31,D=001d5705080072f4802012c3501710052411033319a2082947100201319761)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 01 01 02 03 02 02 04 02 42 fe 0f 1f 00 1d 57 05 08 00 72 f4 80 20 12 c3 50 17 10 05 24 11 03 33 19 a2 08 29 47 10 02 01 31 97 61 00
=> BSSMAP-CC
SCCP Input: [L2]> 02 01 02 03 00 00 03 02 01 00
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:COAK,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000002),
- PART(T=Destination Reference,L=4,D=00010203),
- PART(T=Source Reference,L=4,D=00000003)
+Decoded SUA: HDR=(CO:COAK,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000002), PART(T=Destination Reference,L=4,D=00010203), PART(T=Source Reference,L=4,D=00000003)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 02 01 02 03 00 00 03 02 01 00
=> BSSMAP-DTAP
SCCP Input: [L2]> 06 00 00 03 00 01 0f 01 00 0c 03 05 5c 08 11 81 33 66 02 13 45 f4
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:CODT,V=0,LEN=0),
- PART(T=Destination Reference,L=4,D=00000003),
- PART(T=Segmentation,L=4,D=00000000),
- PART(T=Data,L=15,D=01000c03055c0811813366021345f4)
+Decoded SUA: HDR=(CO:CODT,V=0,LEN=0), PART(T=Destination Reference,L=4,D=00000003), PART(T=Segmentation,L=4,D=00000000), PART(T=Data,L=15,D=01000c03055c0811813366021345f4)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 06 00 00 03 00 01 0f 01 00 0c 03 05 5c 08 11 81 33 66 02 13 45 f4
=> BSSMAP-CLEAR
SCCP Input: [L2]> 06 00 00 03 00 01 06 00 04 20 04 01 09
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:CODT,V=0,LEN=0),
- PART(T=Destination Reference,L=4,D=00000003),
- PART(T=Segmentation,L=4,D=00000000),
- PART(T=Data,L=6,D=000420040109)
+Decoded SUA: HDR=(CO:CODT,V=0,LEN=0), PART(T=Destination Reference,L=4,D=00000003), PART(T=Segmentation,L=4,D=00000000), PART(T=Data,L=6,D=000420040109)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 06 00 00 03 00 01 06 00 04 20 04 01 09
=> BSSMAP-RELEASED
SCCP Input: [L2]> 04 00 00 03 01 02 03 00 01 0f 02 23 42 00
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:RELRE,V=0,LEN=0),
- PART(T=Destination Reference,L=4,D=00000003),
- PART(T=Source Reference,L=4,D=00010203),
- PART(T=Cause,L=4,D=00000300),
- PART(T=Data,L=2,D=2342)
+Decoded SUA: HDR=(CO:RELRE,V=0,LEN=0), PART(T=Destination Reference,L=4,D=00000003), PART(T=Source Reference,L=4,D=00010203), PART(T=Cause,L=4,D=00000300), PART(T=Data,L=2,D=2342)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 04 00 00 03 01 02 03 00 01 0f 02 23 42 00
=> BSSMAP-RELEASE_COMPLETE
SCCP Input: [L2]> 05 01 02 03 00 00 03
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CO:RELCO,V=0,LEN=0),
- PART(T=Destination Reference,L=4,D=00010203),
- PART(T=Source Reference,L=4,D=00000003)
+Decoded SUA: HDR=(CO:RELCO,V=0,LEN=0), PART(T=Destination Reference,L=4,D=00010203), PART(T=Source Reference,L=4,D=00000003)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 05 01 02 03 00 00 03
=> TCAP
SCCP Input: [L2]> 09 81 03 0d 18 0a 12 07 00 12 04 53 84 09 00 17 0b 12 06 00 12 04 44 87 20 00 20 65 9a 65 81 97 48 04 26 00 01 98 49 04 51 01 03 df 6c 81 88 a1 81 85 02 01 44 02 01 07 30 80 a7 80 a0 80 04 01 2b 30 80 30 12 83 01 10 84 01 07 85 07 91 44 57 76 67 16 97 86 01 20 30 06 82 01 18 84 01 04 00 00 00 00 a3 06 04 01 42 84 01 05 a3 06 04 01 51 84 01 05 a3 06 04 01 31 84 01 05 a3 09 04 01 12 84 01 05 82 01 02 a3 09 04 01 11 84 01 05 81 01 01 a3 06 04 01 14 84 01 00 a3 0b 04 01 41 84 01 04 30 03 83 01 10 a3 0b 04 01 41 84 01 04 30 03 82 01 18 00 00 00 00
Transcoding message SCCP -> XUA
-Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0),
- PART(T=Protocol Class,L=4,D=00000081),
- PART(T=Destination Address,L=32,D=0001000580010014000000040a00010453840900170000008003000800000007),
- PART(T=Source Address,L=32,D=0001000580010014000000040c00010444872000206500008003000800000006),
- PART(T=Data,L=154,D=6581974804260001984904510103df6c8188a181850201440201073080a780a08004012b30803012830110840107850791445776671697860120300682011884010400000000a306040142840105a306040151840105a306040131840105a309040112840105820102a309040111840105810101a306040114840100a30b0401418401043003830110a30b040141840104300382011800000000)
+Decoded SUA: HDR=(CL:CLDT,V=0,LEN=0), PART(T=Protocol Class,L=4,D=00000081), PART(T=Destination Address,L=32,D=0001000580010014000000040a00010453840900170000008003000800000007), PART(T=Source Address,L=32,D=0001000580010014000000040c00010444872000206500008003000800000006), PART(T=Data,L=154,D=6581974804260001984904510103df6c8188a181850201440201073080a780a08004012b30803012830110840107850791445776671697860120300682011884010400000000a306040142840105a306040151840105a306040131840105a309040112840105820102a309040111840105810101a306040114840100a30b0401418401043003830110a30b040141840104300382011800000000)
Re-Encoding decoded SUA to SCCP
SCCP Output: [L2]> 09 81 03 0d 18 0a 12 07 00 12 04 53 84 09 00 17 0b 12 06 00 12 04 44 87 20 00 20 65 9a 65 81 97 48 04 26 00 01 98 49 04 51 01 03 df 6c 81 88 a1 81 85 02 01 44 02 01 07 30 80 a7 80 a0 80 04 01 2b 30 80 30 12 83 01 10 84 01 07 85 07 91 44 57 76 67 16 97 86 01 20 30 06 82 01 18 84 01 04 00 00 00 00 a3 06 04 01 42 84 01 05 a3 06 04 01 51 84 01 05 a3 06 04 01 31 84 01 05 a3 09 04 01 12 84 01 05 82 01 02 a3 09 04 01 11 84 01 05 81 01 01 a3 06 04 01 14 84 01 00 a3 0b 04 01 41 84 01 04 30 03 83 01 10 a3 0b 04 01 41 84 01 04 30 03 82 01 18 00 00 00 00
Parsing M3UA Message