Review at  https://gerrit.osmocom.org/2725

Print human-readable BSSGP PDU type

Change-Id: Ief4b5ce4e4020edaf771eaa24f4382ec368dd18c
---
M src/gprs_bssgp_pcu.cpp
1 file changed, 9 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/25/2725/1

diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 7c325ae..e73a8c0 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -209,7 +209,7 @@
 static int gprs_bssgp_pcu_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, 
struct bssgp_bvc_ctx *bctx)
 {
        struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) 
msgb_bssgph(msg);
-       uint8_t pdu_type = bgph->pdu_type;
+       enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
        unsigned rc = 0;
 
        if (!bctx)
@@ -248,7 +248,7 @@
                LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_FLOW_CONTROL_MS_ACK\n");
                break;
        default:
-               LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u PDU type 0x%02x 
unknown\n", bctx->bvci, pdu_type);
+               LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u PDU type 0x%02x 
unknown\n", bctx->bvci, bssgp_pdu_str(pdu_type));
                rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
                break;
        }
@@ -259,9 +259,10 @@
 static int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, 
struct bssgp_bvc_ctx *bctx)
 {
        struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) 
msgb_bssgph(msg);
+       enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
        int rc = 0;
        int bvci = bctx ? bctx->bvci : -1;
-       switch (bgph->pdu_type) {
+       switch (pdu_type) {
        case BSSGP_PDUT_STATUS:
                /* Some exception has occurred */
                DEBUGP(DBSSGP, "BSSGP BVCI=%d Rx BVC STATUS\n", bvci);
@@ -311,8 +312,8 @@
                LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_SGSN_INVOKE_TRACE\n");
                break;
        default:
-               LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%d Rx PDU type 0x%02x 
unknown\n",
-                       bvci, bgph->pdu_type);
+               LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%d Rx PDU type %s 
unknown\n",
+                    bvci, bssgp_pdu_str(pdu_type));
                rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
                break;
        }
@@ -324,7 +325,7 @@
        struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) 
msgb_bssgph(msg);
        struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
        struct tlv_parsed tp;
-       uint8_t pdu_type = bgph->pdu_type;
+       enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
        uint16_t ns_bvci = msgb_bvci(msg);
        int data_len;
        int rc = 0;
@@ -358,8 +359,8 @@
         && pdu_type != BSSGP_PDUT_PAGING_PS)
        {
                LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU "
-                       "type %u for unknown BVCI\n", msgb_nsei(msg), ns_bvci,
-                       pdu_type);
+                       "type %s for unknown BVCI\n", msgb_nsei(msg), ns_bvci,
+                       bssgp_pdu_str(pdu_type));
                return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief4b5ce4e4020edaf771eaa24f4382ec368dd18c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msur...@sysmocom.de>

Reply via email to