From ed287f2b878cadd49d2673cb650f0d603ddb0d9c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sun, 24 Dec 2017 16:22:39 +0100 Subject: osmo_sccp_addr_name / _dump: drop 'NO_GT' output Do not print the GTI if gti is set to OSMO_SCCP_GTI_NO_GT and no GT is present in the address. If addr->gt.gti is set to OSMO_SCCP_GTI_NO_GT, i.e. currently always, osmo_sccp_addr_name() and osmo_sccp_addr_dump() output ",GTI=NO_GT" in every address dump, which is useless clutter. Drop that. However, if a Global Title is flagged in addr->presence, still output the GTI to highlight situations where GTI might mismatch the presence of a GT. Change-Id: I9f87b2b703223ecb5d0442b6199c5b779fe544a1 --- src/sccp_helpers.c | 6 ++++-- tests/xua/xua_test.ok | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/sccp_helpers.c b/src/sccp_helpers.c index cafca94..b7446e0 100644 --- a/src/sccp_helpers.c +++ b/src/sccp_helpers.c @@ -300,7 +300,8 @@ char *osmo_sccp_addr_dump(const struct osmo_sccp_addr *addr) append_to_buf(buf, sizeof(buf), &comma, "SSN=%u", addr->ssn); if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) append_to_buf(buf, sizeof(buf), &comma, "IP=%s", inet_ntoa(addr->ip.v4)); - append_to_buf(buf, sizeof(buf), &comma, "GTI=%u", addr->gt.gti); + if (addr->gt.gti != OSMO_SCCP_GTI_NO_GT || addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, sizeof(buf), &comma, "GTI=%u", addr->gt.gti); if (addr->presence & OSMO_SCCP_ADDR_T_GT) append_to_buf(buf, sizeof(buf), &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); @@ -323,7 +324,8 @@ char *osmo_sccp_addr_name(const struct osmo_ss7_instance *ss7, const struct osmo append_to_buf(buf, sizeof(buf), &comma, "SSN=%s", osmo_sccp_ssn_name(addr->ssn)); if (addr->presence & OSMO_SCCP_ADDR_T_IPv4) append_to_buf(buf, sizeof(buf), &comma, "IP=%s", inet_ntoa(addr->ip.v4)); - append_to_buf(buf, sizeof(buf), &comma, "GTI=%s", osmo_sccp_gti_name(addr->gt.gti)); + if (addr->gt.gti != OSMO_SCCP_GTI_NO_GT || addr->presence & OSMO_SCCP_ADDR_T_GT) + append_to_buf(buf, sizeof(buf), &comma, "GTI=%s", osmo_sccp_gti_name(addr->gt.gti)); if (addr->presence & OSMO_SCCP_ADDR_T_GT) append_to_buf(buf, sizeof(buf), &comma, "GT=(%s)", osmo_sccp_gt_dump(&addr->gt)); diff --git a/tests/xua/xua_test.ok b/tests/xua/xua_test.ok index 472c02b..83b8b8d 100644 --- a/tests/xua/xua_test.ok +++ b/tests/xua/xua_test.ok @@ -7,8 +7,8 @@ sccp_addr_parse test case 1 expected: RI=1,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919869299992) parsed: RI=1,SSN=8,GTI=4,GT=(TT=0,NPL=1,NAI=4,DIG=919869299992) sccp_addr_parse test case 2 -expected: RI=2,SSN=254,GTI=0 -parsed: RI=2,SSN=254,GTI=0 +expected: RI=2,SSN=254 +parsed: RI=2,SSN=254 Testing Decoded GT -> SUA encoding IN: TT=0,NPL=1,NAI=4,DIG=919969679389 0400000001000000040000003931393936393637393338390000000000000000000000000000000000000000 @@ -135,25 +135,25 @@ Parsing Nested M3UA Routing Key IE Testing SCCP Address Encode/Decode => NOGT-PC1024 -input addr: RI=2,PC=1024,GTI=0 +input addr: RI=2,PC=1024 rc=3, expected rc=3 encoded addr: 410004 expected addr: 410004 -decod addr: RI=2,PC=1024,GTI=0 +decod addr: RI=2,PC=1024 => NOGT-PC16383 -input addr: RI=2,PC=16383,GTI=0 +input addr: RI=2,PC=16383 rc=3, expected rc=3 encoded addr: 41ff3f expected addr: 41ff3f -decod addr: RI=2,PC=16383,GTI=0 +decod addr: RI=2,PC=16383 => NOGT-PC16383-SSN90 -input addr: RI=2,PC=16383,SSN=90,GTI=0 +input addr: RI=2,PC=16383,SSN=90 rc=4, expected rc=4 encoded addr: 43ff3f5a expected addr: 43ff3f5a -decod addr: RI=2,PC=16383,SSN=90,GTI=0 +decod addr: RI=2,PC=16383,SSN=90 => GT-PC16383-NAIONLY input addr: RI=2,PC=16383,GTI=1,GT=() -- cgit v1.2.3