Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2473

to look at the new patch set (#2).

gprs: add value strings for NS PDU type

Add value strings for Service Control PDUs according to 3GPP TS 48.016 §9
and use them for logging.

Change-Id: I0ea3a45f35d68619d4cfa9735ef77abd9f9f0d58
Related: SYS#3610
---
M include/osmocom/gprs/protocol/gsm_08_16.h
M src/gb/gprs_ns.c
M src/gb/libosmogb.map
3 files changed, 29 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/2473/2

diff --git a/include/osmocom/gprs/protocol/gsm_08_16.h 
b/include/osmocom/gprs/protocol/gsm_08_16.h
index 8b2ac56..56ed594 100644
--- a/include/osmocom/gprs/protocol/gsm_08_16.h
+++ b/include/osmocom/gprs/protocol/gsm_08_16.h
@@ -18,6 +18,8 @@
        uint8_t data[0];        /*!< variable-length payload */
 } __attribute__((packed));
 
+extern const struct value_string gprs_ns_pdu_strings[];
+
 /*! \brief NS PDU Type (TS 08.16, Section 10.3.7, Table 14) */
 enum ns_pdu_type {
        NS_PDUT_UNITDATA        = 0x00,
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 0649899..7b497c2 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -296,6 +296,30 @@
        osmo_signal_dispatch(SS_L_NS, S_NS_REPLACED, &nssd);
 }
 
+const struct value_string gprs_ns_pdu_strings[] = {
+       /* 3GPP TS 48.016 §9.2 Network Service Control PDUs */
+       { NS_PDUT_UNITDATA,     "NS-UNITDATA" },        /* §9.2.1 */
+       { NS_PDUT_RESET,        "NS-RESET" },           /* §9.2.5 */
+       { NS_PDUT_RESET_ACK,    "NS-RESET-ACK" },       /* §9.2.6 */
+       { NS_PDUT_BLOCK,        "NS-BLOCK" },           /* §9.2.3 */
+       { NS_PDUT_BLOCK_ACK,    "NS-BLOCK-ACK" },       /* §9.2.4 */
+       { NS_PDUT_UNBLOCK,      "NS-UNBLOCK" },         /* §9.2.8 */
+       { NS_PDUT_UNBLOCK_ACK,  "NS-UNBLOCK-ACK" },     /* §9.2.9 */
+       { NS_PDUT_STATUS,       "NS-STATUS" },          /* §9.2.7 */
+       { NS_PDUT_ALIVE,        "NS-ALIVE" },           /* §9.2.1 */
+       { NS_PDUT_ALIVE_ACK,    "NS-ALIVE-ACK" },       /* §9.2.2 */
+       /* 3GPP TS 48.016 §9.3 Sub-Network Service Control PDUs */
+       { SNS_PDUT_ACK,                 "SNS-ACK" },            /* §9.3.1 */
+       { SNS_PDUT_ADD,                 "SNS-ADD" },            /* §9.3.2 */
+       { SNS_PDUT_CHANGE_WEIGHT,       "SNS-CHANGEWEIGHT" },   /* §9.3.3 */
+       { SNS_PDUT_CONFIG,              "SNS-CONFIG" },         /* §9.3.4 */
+       { SNS_PDUT_CONFIG_ACK,          "SNS-CONFIG-ACK" },     /* §9.3.5 */
+       { SNS_PDUT_DELETE,              "SNS-DELETE" },         /* §9.3.6 */
+       { SNS_PDUT_SIZE,                "SNS-SIZE" },           /* §9.3.7 */
+       { SNS_PDUT_SIZE_ACK,            "SNS-SIZE-ACK" },       /* §9.3.8 */
+       { 0, NULL }
+};
+
 /* Section 10.3.2, Table 13 */
 static const struct value_string ns_cause_str[] = {
        { NS_CAUSE_TRANSIT_FAIL,        "Transit network failure" },
@@ -1216,9 +1240,9 @@
        if (nsh->pdu_type != NS_PDUT_RESET) {
                /* Since we have no NSVC, we have to use a fake */
                log_set_context(LOG_CTX_GB_NSVC, fallback_nsvc);
-               LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x "
+               LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type %s "
                     "from %s for non-existing NS-VC\n",
-                    nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc));
+                    get_value_string(gprs_ns_pdu_strings, nsh->pdu_type), 
gprs_ns_ll_str(fallback_nsvc));
                fallback_nsvc->nsvci = fallback_nsvc->nsei = 0xfffe;
                fallback_nsvc->nsvci_is_valid = 0;
                fallback_nsvc->state = NSE_S_ALIVE;
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index 9aec280..3ec3ee5 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -38,6 +38,7 @@
 bssgp_vty_init;
 bssgp_nsi;
 
+gprs_ns_pdu_strings;
 gprs_ns_cause_str;
 gprs_ns_destroy;
 gprs_ns_close;

-- 
To view, visit https://gerrit.osmocom.org/2473
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0ea3a45f35d68619d4cfa9735ef77abd9f9f0d58
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder

Reply via email to