pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28819 )
Change subject: sbcap: Log info about messages received and trasmitted
......................................................................
sbcap: Log info about messages received and trasmitted
Change-Id: Ifd1eca79bf4fac63de8066cd6a18004138d51d04
---
M include/osmocom/sbcap/sbcap_common.h
M src/sbcap/sbcap_common.c
M src/sbcap_link.c
M src/sbcap_link_fsm.c
4 files changed, 65 insertions(+), 20 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/include/osmocom/sbcap/sbcap_common.h b/include/osmocom/sbcap/sbcap_common.h
index 91a95eb..40da3ba 100644
--- a/include/osmocom/sbcap/sbcap_common.h
+++ b/include/osmocom/sbcap/sbcap_common.h
@@ -137,12 +137,14 @@
struct msgb *sbcap_encode(SBcAP_SBC_AP_PDU_t *pdu);
SBcAP_SBC_AP_PDU_t *sbcap_decode(const struct msgb *msg);
+const char *sbcap_procedure_code_str(SBcAP_ProcedureCode_t pc);
const char *sbcap_cause_str(SBcAP_Cause_t cause);
void sbcap_set_log_area(int log_area);
SBcAP_ProcedureCode_t sbcap_pdu_get_procedure_code(const SBcAP_SBC_AP_PDU_t *pdu);
SBcAP_Criticality_t sbcap_pdu_get_criticality(const SBcAP_SBC_AP_PDU_t *pdu);
+const char *sbcap_pdu_get_name(const SBcAP_SBC_AP_PDU_t *pdu);
void *sbcap_as_find_ie(void *void_list, SBcAP_ProtocolIE_ID_t ie_id);
diff --git a/src/sbcap/sbcap_common.c b/src/sbcap/sbcap_common.c
index 0596b53..ddc0fed 100644
--- a/src/sbcap/sbcap_common.c
+++ b/src/sbcap/sbcap_common.c
@@ -30,6 +30,22 @@
int _sbcap_DSBCAP = 0;
#define DSBCAP _sbcap_DSBCAP
+static const struct value_string sbcap_procedure_code_vals[] = {
+ { SBcAP_ProcedureId_Write_Replace_Warning, "Write-Replace-Warning" },
+ { SBcAP_ProcedureId_Stop_Warning, "Stop-Warning" },
+ { SBcAP_ProcedureId_Error_Indication, "Error-Indication" },
+ {
SBcAP_ProcedureId_Write_Replace_Warning_Indication, "Write-Replace-Warning-Indication"
},
+ { SBcAP_ProcedureId_Stop_Warning_Indication, "Stop-Warning-Indication" },
+ { SBcAP_ProcedureId_PWS_Restart_Indication, "PWS-Restart-Indication" },
+ { SBcAP_ProcedureId_PWS_Failure_Indication, "PWS-Failure-Indication" },
+ { 0, NULL }
+};
+
+const char *sbcap_procedure_code_str(SBcAP_ProcedureCode_t pc)
+{
+ return get_value_string(sbcap_procedure_code_vals, pc);
+}
+
static const struct value_string sbcap_cause_vals[] = {
{ SBcAP_Cause_message_accepted, "message accepted" },
{ SBcAP_Cause_parameter_not_recognised, "parameter not recognised" },
@@ -141,6 +157,27 @@
}
}
+const char *sbcap_pdu_get_name(const SBcAP_SBC_AP_PDU_t *pdu)
+{
+ static char pdu_name[256] = "<unknown>";
+ struct osmo_strbuf sb = { .buf = pdu_name, .len = sizeof(pdu_name) };
+ SBcAP_ProcedureCode_t pc = sbcap_pdu_get_procedure_code(pdu);
+
+ OSMO_STRBUF_PRINTF(sb, "%s", sbcap_procedure_code_str(pc));
+
+ switch (pc) {
+ case SBcAP_ProcedureId_Write_Replace_Warning:
+ case SBcAP_ProcedureId_Stop_Warning:
+ OSMO_STRBUF_PRINTF(sb, "%s",
+ pdu->present == SBcAP_SBC_AP_PDU_PR_initiatingMessage
+ ? "-Request" : "-Response");
+ break;
+ default:
+ break;
+ }
+ return pdu_name;
+}
+
void *sbcap_as_find_ie(void *void_list, SBcAP_ProtocolIE_ID_t ie_id)
{
A_SEQUENCE_OF(SBcAP_ProtocolIE_ID_t) *li = (void *)void_list;
diff --git a/src/sbcap_link.c b/src/sbcap_link.c
index 8a3af59..91fa75c 100644
--- a/src/sbcap_link.c
+++ b/src/sbcap_link.c
@@ -157,13 +157,13 @@
if (rc == 0)
goto out;
- LOGPSBCAPC(link, LOGL_DEBUG, "Received SBc-AP %s\n", msgb_hexdump(msg));
+ LOGPSBCAPC(link, LOGL_DEBUG, "Rx SBc-AP %s\n", msgb_hexdump(msg));
/* decode + dispatch message */
pdu = sbcap_decode(msg);
if (pdu) {
- LOGPSBCAPC(link, LOGL_INFO, "Received SBc-AP %d\n",
- pdu->present);
+ LOGPSBCAPC(link, LOGL_INFO, "Rx SBc-AP %s\n",
+ sbcap_pdu_get_name(pdu));
g_cbc->sbcap.mgr->rx_cb(link, pdu);
} else {
LOGPSBCAPC(link, LOGL_ERROR, "Unable to decode %s\n", msgb_hexdump(msg));
@@ -274,13 +274,13 @@
if (rc == 0)
goto out;
- LOGPSBCAPC(link, LOGL_DEBUG, "Received SBc-AP %s\n", msgb_hexdump(msg));
+ LOGPSBCAPC(link, LOGL_DEBUG, "Rx SBc-AP %s\n", msgb_hexdump(msg));
/* decode + dispatch message */
pdu = sbcap_decode(msg);
if (pdu) {
- LOGPSBCAPC(link, LOGL_INFO, "Received SBc-AP %d\n",
- pdu->present);
+ LOGPSBCAPC(link, LOGL_INFO, "Rx SBc-AP %s\n",
+ sbcap_pdu_get_name(pdu));
cbc->rx_cb(link, pdu);
} else {
LOGPSBCAPC(link, LOGL_ERROR, "Unable to decode %s\n", msgb_hexdump(msg));
@@ -389,16 +389,19 @@
}
if (!link) {
- LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg: no connection\n");
+ LOGP(DSBcAP, LOGL_NOTICE, "Cannot transmit msg %s: no connection\n",
+ sbcap_pdu_get_name(pdu));
return;
}
- LOGPSBCAPC(link, LOGL_INFO, "Transmitting msg\n");
+ LOGPSBCAPC(link, LOGL_INFO, "Tx msg %s\n",
+ sbcap_pdu_get_name(pdu));
OSMO_ASSERT(link->conn);
msg = sbcap_encode(pdu);
if (!msg)
goto ret_free;
- LOGPSBCAPC(link, LOGL_DEBUG, "Encoded message: %s\n", msgb_hexdump(msg));
+ LOGPSBCAPC(link, LOGL_DEBUG, "Encoded message %s: %s\n",
+ sbcap_pdu_get_name(pdu), msgb_hexdump(msg));
if (link->is_client)
osmo_stream_cli_send(link->cli_conn, msg);
else
diff --git a/src/sbcap_link_fsm.c b/src/sbcap_link_fsm.c
index 01e3631..2813611 100644
--- a/src/sbcap_link_fsm.c
+++ b/src/sbcap_link_fsm.c
@@ -193,7 +193,8 @@
if (!ie)
return -1;
if (ie->size != 2) {
- LOGPSBCAPC(link, LOGL_ERROR, "get_msg_id wrong size %zu\n", ie->size);
+ LOGPSBCAPC(link, LOGL_ERROR, "get_msg_id(%s) wrong size %zu\n",
+ sbcap_pdu_get_name(pdu), ie->size);
return -1;
}
return osmo_load16be(ie->buf);
@@ -235,8 +236,8 @@
}
}
- LOGPSBCAPC(link, LOGL_ERROR, "Rx ERROR_IND (cause=%ld, diagnostics=%d
[proc_code=%ld, trigger_msg=%ld criticality=%ld])\n",
- cause, !!ie_diag, proc_code, trigger_msg, criticality);
+ LOGPSBCAPC(link, LOGL_ERROR, "Rx %s (cause=%ld, diagnostics=%d [proc_code=%ld,
trigger_msg=%ld criticality=%ld])\n",
+ sbcap_pdu_get_name(pdu), cause, !!ie_diag, proc_code, trigger_msg, criticality);
return 0;
}
@@ -255,15 +256,16 @@
case SBcAP_ProcedureId_Write_Replace_Warning:
case SBcAP_ProcedureId_Stop_Warning:
LOGPSBCAPC(link, LOGL_ERROR,
- "SBcAP initiatingMessage procedure=%ld MME->CBC not expected\n",
- pdu->choice.initiatingMessage.procedureCode);
+ "SBcAP %s MME->CBC not expected\n",
+ sbcap_pdu_get_name(pdu));
return -EINVAL;
case SBcAP_ProcedureId_PWS_Restart_Indication:
return osmo_fsm_inst_dispatch(link->fi, SBcAP_LINK_E_RX_RESTART, pdu);
case SBcAP_ProcedureId_Error_Indication:
return cbc_sbcap_link_rx_error_ind(link, pdu);
case SBcAP_ProcedureId_PWS_Failure_Indication:
- LOGPSBCAPC(link, LOGL_NOTICE, "Rx PWS Failure Indication not implemented
yet\n");
+ LOGPSBCAPC(link, LOGL_NOTICE, "Rx %s not implemented yet\n",
+ sbcap_pdu_get_name(pdu));
return 0;
case SBcAP_ProcedureId_Stop_Warning_Indication:
case SBcAP_ProcedureId_Write_Replace_Warning_Indication:
@@ -276,7 +278,8 @@
cbc_sbcap_link_tx(link, err_ind_pdu);
else
LOGPSBCAPC(link, LOGL_ERROR,
- "Tx SBc-AP Error-Indication: msg gen failed\n");
+ "Tx SBc-AP %s: msg gen failed\n",
+ sbcap_pdu_get_name(err_ind_pdu));
return 0;
}
break;
@@ -311,8 +314,8 @@
/* look-up smscb_message */
smscb = cbc_message_by_id(msg_id);
if (!smscb) {
- LOGPSBCAPC(link, LOGL_ERROR, "Rx SBc-AP msg for unknown message-id
0x%04x\n",
- msg_id);
+ LOGPSBCAPC(link, LOGL_ERROR, "Rx SBc-AP %s for unknown message-id 0x%04x\n",
+ sbcap_pdu_get_name(pdu), msg_id);
/* TODO: inform peer? */
return 0;
}
@@ -320,8 +323,8 @@
/* look-up smscb_message_peer */
mp = cbc_message_peer_get(smscb, link->peer);
if (!mp) {
- LOGPSBCAPC(link, LOGL_ERROR, "Rx SBc-AP msg for message-id 0x%04x without peer
%s\n",
- msg_id, link->peer->name);
+ LOGPSBCAPC(link, LOGL_ERROR, "Rx SBc-AP %s for message-id 0x%04x without peer
%s\n",
+ sbcap_pdu_get_name(pdu), msg_id, link->peer->name);
/* TODO: inform peer? */
return 0;
}
--
To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28819
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc
Gerrit-Branch: master
Gerrit-Change-Id: Ifd1eca79bf4fac63de8066cd6a18004138d51d04
Gerrit-Change-Number: 28819
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged