From: Max msuraev@sysmocom.de
--- include/osmocom/gprs/gprs_bssgp.h | 1 + src/gb/gprs_bssgp_util.c | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h index c0b3f65..b70487c 100644 --- a/include/osmocom/gprs/gprs_bssgp.h +++ b/include/osmocom/gprs/gprs_bssgp.h @@ -14,6 +14,7 @@ extern struct gprs_ns_inst *bssgp_nsi; struct msgb *bssgp_msgb_alloc(void); struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name); const char *bssgp_cause_str(enum gprs_bssgp_cause cause); +const char *bssgp_pdu_str(enum bssgp_pdu_type pdu); /* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */ int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei, uint16_t bvci, uint16_t ns_bvci); diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c index 19ae23a..6fff362 100644 --- a/src/gb/gprs_bssgp_util.c +++ b/src/gb/gprs_bssgp_util.c @@ -62,11 +62,57 @@ static const struct value_string bssgp_cause_strings[] = { { 0, NULL }, };
+static const struct value_string bssgp_pdu_strings[] = { + { BSSGP_PDUT_DL_UNITDATA, "DL-UNITDATA" }, + { BSSGP_PDUT_UL_UNITDATA, "UL-UNITDATA" }, + { BSSGP_PDUT_RA_CAPABILITY, "RA-CAPABILITY" }, + { BSSGP_PDUT_PTM_UNITDATA, "PTM-UNITDATA" }, + { BSSGP_PDUT_PAGING_PS, "PAGING-PS" }, + { BSSGP_PDUT_PAGING_CS, "PAGING-CS" }, + { BSSGP_PDUT_RA_CAPA_UDPATE, "RA-CAPABILITY-UPDATE" }, + { BSSGP_PDUT_RA_CAPA_UPDATE_ACK, "RA-CAPABILITY-UPDATE-ACK" }, + { BSSGP_PDUT_RADIO_STATUS, "RADIO-STATUS" }, + { BSSGP_PDUT_SUSPEND, "SUSPEND" }, + { BSSGP_PDUT_SUSPEND_ACK, "SUSPEND-ACK" }, + { BSSGP_PDUT_SUSPEND_NACK, "SUSPEND-NACK" }, + { BSSGP_PDUT_RESUME, "RESUME" }, + { BSSGP_PDUT_RESUME_ACK, "RESUME-ACK" }, + { BSSGP_PDUT_RESUME_NACK, "RESUME-NACK" }, + { BSSGP_PDUT_BVC_BLOCK, "BVC-BLOCK" }, + { BSSGP_PDUT_BVC_BLOCK_ACK, "BVC-BLOCK-ACK" }, + { BSSGP_PDUT_BVC_RESET, "BVC-RESET" }, + { BSSGP_PDUT_BVC_RESET_ACK, "BVC-RESET-ACK" }, + { BSSGP_PDUT_BVC_UNBLOCK, "BVC-UNBLOCK" }, + { BSSGP_PDUT_BVC_UNBLOCK_ACK, "BVC-UNBLOCK-ACK" }, + { BSSGP_PDUT_FLOW_CONTROL_BVC, "FLOW-CONTROL-BVC" }, + { BSSGP_PDUT_FLOW_CONTROL_BVC_ACK, "FLOW-CONTROL-BVC-ACK" }, + { BSSGP_PDUT_FLOW_CONTROL_MS, "FLOW-CONTROL-MS" }, + { BSSGP_PDUT_FLOW_CONTROL_MS_ACK, "FLOW-CONTROL-MS-ACK" }, + { BSSGP_PDUT_FLUSH_LL, "FLUSH-LL" }, + { BSSGP_PDUT_FLUSH_LL_ACK, "FLUSH-LL-ACK" }, + { BSSGP_PDUT_LLC_DISCARD, "LLC DISCARDED" }, + { BSSGP_PDUT_SGSN_INVOKE_TRACE, "SGSN-INVOKE-TRACE" }, + { BSSGP_PDUT_STATUS, "STATUS" }, + { BSSGP_PDUT_DOWNLOAD_BSS_PFC, "DOWNLOAD-BSS-PFC" }, + { BSSGP_PDUT_CREATE_BSS_PFC, "CREATE-BSS-PFC" }, + { BSSGP_PDUT_CREATE_BSS_PFC_ACK, "CREATE-BSS-PFC-ACK" }, + { BSSGP_PDUT_CREATE_BSS_PFC_NACK, "CREATE-BSS-PFC-NACK" }, + { BSSGP_PDUT_MODIFY_BSS_PFC, "MODIFY-BSS-PFC" }, + { BSSGP_PDUT_MODIFY_BSS_PFC_ACK, "MODIFY-BSS-PFC-ACK" }, + { BSSGP_PDUT_DELETE_BSS_PFC, "DELETE-BSS-PFC" }, + { BSSGP_PDUT_DELETE_BSS_PFC_ACK, "DELETE-BSS-PFC-ACK" }, + { 0, NULL }, +}; + const char *bssgp_cause_str(enum gprs_bssgp_cause cause) { return get_value_string(bssgp_cause_strings, cause); }
+const char *bssgp_pdu_str(enum bssgp_pdu_type pdu) +{ + return get_value_string(bssgp_pdu_strings, pdu); +}
struct msgb *bssgp_msgb_alloc(void) {
From: Max msuraev@sysmocom.de
Print string representation of Cause IE and PDU type in addition to numerical value. --- src/gb/gprs_bssgp.c | 28 ++++++++++++++-------------- src/gb/gprs_bssgp_bss.c | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index e3e69c9..c19f05a 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -896,8 +896,8 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_CREATE_BSS_PFC_NACK: case BSSGP_PDUT_MODIFY_BSS_PFC: case BSSGP_PDUT_DELETE_BSS_PFC_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] " - "implemented\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) not [yet] " + "implemented\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg); break; /* those only exist in the SGSN -> BSS direction */ @@ -907,14 +907,14 @@ static int bssgp_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_RA_CAPA_UPDATE_ACK: case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK: case BSSGP_PDUT_FLOW_CONTROL_MS_ACK: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x only exists " - "in DL\n", bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) only exists " + "in DL\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x unknown\n", - bctx->bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u PDU type 0x%02x (%s) unknown\n", + bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -999,14 +999,14 @@ static int bssgp_rx_sign(struct msgb *msg, struct tlv_parsed *tp, case BSSGP_PDUT_BVC_BLOCK_ACK: case BSSGP_PDUT_BVC_UNBLOCK_ACK: case BSSGP_PDUT_SGSN_INVOKE_TRACE: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x only exists " - "in DL\n", bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) only exists " + "in DL\n", bvci, pdu_type, bssgp_pdu_str(pdu_type)); bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); rc = -EINVAL; break; default: - DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x unknown\n", - bvci, pdu_type); + DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) unknown\n", + bvci, pdu_type, bssgp_pdu_str(pdu_type)); rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg); break; } @@ -1066,8 +1066,8 @@ int bssgp_rcvmsg(struct msgb *msg) if (!bctx && bvci != BVCI_SIGNALLING && pdu_type != BSSGP_PDUT_BVC_RESET) { LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU " - "type %u for unknown BVCI\n", msgb_nsei(msg), bvci, - pdu_type); + "type %u (%s) for unknown BVCI\n", msgb_nsei(msg), bvci, + pdu_type, bssgp_pdu_str(pdu_type)); return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg); }
@@ -1079,9 +1079,9 @@ int bssgp_rcvmsg(struct msgb *msg) rc = bssgp_rx_ptp(msg, &tp, bctx); else LOGP(DBSSGP, LOGL_NOTICE, - "NSEI=%u/BVCI=%u Cannot handle PDU type %u for " + "NSEI=%u/BVCI=%u Cannot handle PDU type %u (%s) for " "unknown BVCI, NS BVCI %u\n", - msgb_nsei(msg), bvci, pdu_type, ns_bvci); + msgb_nsei(msg), bvci, pdu_type, , bssgp_pdu_str(pdu_type), ns_bvci);
return rc; } diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 3a9012e..955e2b4 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -135,7 +135,7 @@ static struct msgb *common_tx_radio_status(struct bssgp_bvc_ctx *bctx) static int common_tx_radio_status2(struct msgb *msg, uint8_t cause) { msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause); - LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u\n", cause); + LOGPC(DBSSGP, LOGL_NOTICE, "CAUSE=%u (%s)\n", cause, bssgp_cause_str(cause));
return gprs_ns_sendmsg(bssgp_nsi, msg); } @@ -247,7 +247,7 @@ int bssgp_tx_bvc_block(struct bssgp_bvc_ctx *bctx, uint8_t cause) uint16_t _bvci = htons(bctx->bvci);
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-BLOCK " - "CAUSE=%u\n", bctx->bvci, cause); + "CAUSE=%u (%s)\n", bctx->bvci, cause, bssgp_cause_str(cause));
msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */ @@ -287,7 +287,7 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause) uint16_t _bvci = htons(bvci);
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP (BVCI=%u) Tx BVC-RESET " - "CAUSE=%u\n", bvci, cause); + "CAUSE=%u (%s)\n", bvci, cause, bssgp_cause_str(cause));
msgb_nsei(msg) = bctx->nsei; msgb_bvci(msg) = 0; /* Signalling */
On Wed, Mar 09, 2016 at 12:29:24PM +0100, msuraev@sysmocom.de wrote:
Print string representation of Cause IE and PDU type in addition to numerical value.
thanks. I'd like to merge, but
DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x not [yet] "
"implemented\n", bctx->bvci, pdu_type);
DEBUGP(DBSSGP, "BSSGP BVCI=%u Rx PDU type 0x%02x (%s) not [yet] "
"implemented\n", bctx->bvci, pdu_type, bssgp_pdu_str(pdu_type));
pleaes remove the 0x%02x numeric printing. The %s via bssgp_pdu_str() will automatically fall back to printing the numeric type as "unknown 0x%x" when it is unknown, as part of the value_string implementation, IIRC.
From: Max msuraev@sysmocom.de
It's useful for debugging and is similar to existing nsvc reset vty command. --- src/gb/gprs_bssgp_vty.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c index 080867b..4f53ae7 100644 --- a/src/gb/gprs_bssgp_vty.c +++ b/src/gb/gprs_bssgp_vty.c @@ -113,6 +113,29 @@ static void dump_bssgp(struct vty *vty, int stats) } }
+DEFUN(bvc_reset, bvc_reset_cmd, + "bvc reset nsei <0-65535> bvci <0-65535>", + "Initiate BVC RESET procedure for a given NSEI and BVCI\n") +{ + uint16_t nsei = atoi(argv[0]), bvci = atoi(argv[1]); + struct bssgp_bvc_ctx *bvc; + + if (!strcmp(argv[0], "reset")) + return CMD_WARNING; + + if (argc != 2) + return CMD_WARNING; + + bvc = btsctx_by_bvci_nsei(bvci, nsei); + if (!bvc) { + vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE); + return CMD_WARNING; + } + int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV); + vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE); + return CMD_SUCCESS; +} + #define BSSGP_STR "Show information about the BSSGP protocol\n"
DEFUN(show_bssgp, show_bssgp_cmd, "show bssgp", @@ -185,6 +208,7 @@ int bssgp_vty_init(void) install_element_ve(&show_bssgp_stats_cmd); install_element_ve(&show_bvc_cmd); install_element_ve(&logging_fltr_bvc_cmd); + install_element_ve(&bvc_reset_cmd);
install_element(CFG_LOG_NODE, &logging_fltr_bvc_cmd);
Hi Max,
On Wed, Mar 09, 2016 at 12:29:25PM +0100, msuraev@sysmocom.de wrote:
vty_out(vty, "No BVC for NSEI %d BVCI %d%s", nsei, bvci, VTY_NEWLINE);
- vty_out(vty, "Sent BVC RESET for NSEI %d BVCI %d: %d%s", nsei, bvci, r, VTY_NEWLINE);
* long lines were not wrapped * compilation causes warning:
gprs_bssgp_vty.c: In function 'bvc_reset': gprs_bssgp_vty.c:134:10: warning: implicit declaration of function 'bssgp_tx_bvc_reset' [-Wimplicit-function-declaration] int r = bssgp_tx_bvc_reset(bvc, bvci, BSSGP_CAUSE_OML_INTERV);
please always make sure to check if patches cause new warnings before submitting them.
thanks, applied.