pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40282?usp=email )
Change subject: sccp: Introduce LOGPSCI() log macro ......................................................................
sccp: Introduce LOGPSCI() log macro
Change-Id: I0f04ff064d3693c6d71aa4977e0c593c7f157f7e --- M src/sccp_internal.h M src/sccp_sclc.c M src/sccp_scoc.c M src/sccp_scrc.c M src/sccp_user.c 5 files changed, 46 insertions(+), 43 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/82/40282/1
diff --git a/src/sccp_internal.h b/src/sccp_internal.h index 45df22d..1421c64 100644 --- a/src/sccp_internal.h +++ b/src/sccp_internal.h @@ -1,5 +1,7 @@ #pragma once
+#include <inttypes.h> + #include <osmocom/core/fsm.h> #include <osmocom/core/prim.h> #include <osmocom/core/linuxlist.h> @@ -56,6 +58,11 @@
uint32_t max_optional_data; }; +#define _LOGPSCI(sci, subsys, level, fmt, args ...) \ + _LOGSS7((sci)->ss7, subsys, level, "SCCP(rctx=%" PRIu32 ") " fmt, (sci)->route_ctx, ## args) +#define LOGPSCI(sci, level, fmt, args ...) \ + _LOGPSCI(sci, DLSCCP, level, fmt, ## args) +
struct osmo_sccp_user { /*! \brief entry in list of sccp users of \ref osmo_sccp_instance */ diff --git a/src/sccp_sclc.c b/src/sccp_sclc.c index e0a2844..75afb96 100644 --- a/src/sccp_sclc.c +++ b/src/sccp_sclc.c @@ -190,7 +190,7 @@ uint32_t protocol_class;
if (!data_ie) { - LOGP(DLSCCP, LOGL_ERROR, "SCCP/SUA CLDT without user data?!?\n"); + LOGPSCI(inst, LOGL_ERROR, "SCCP/SUA CLDT without user data?!?\n"); return -1; }
@@ -212,8 +212,8 @@
if (!scu) { /* FIXME: Send destination unreachable? */ - LOGP(DLSUA, LOGL_NOTICE, "Received SUA message for unequipped SSN %u\n", - param->called_addr.ssn); + _LOGPSCI(inst, DLSUA, LOGL_NOTICE, "Received SUA message for unequipped SSN %u\n", + param->called_addr.ssn); msgb_free(upmsg); return 0; } @@ -238,7 +238,7 @@ struct osmo_sccp_user *scu;
if (!data_ie) { - LOGP(DLSCCP, LOGL_ERROR, "SCCP/SUA CLDR without user data?!?\n"); + LOGPSCI(inst, LOGL_ERROR, "SCCP/SUA CLDR without user data?!?\n"); return -1; }
@@ -258,8 +258,8 @@ param->called_addr.pc); if (!scu) { /* FIXME: Send destination unreachable? */ - LOGP(DLSUA, LOGL_NOTICE, "Received CLDR for unequipped SSN %u\n", - param->called_addr.ssn); + _LOGPSCI(inst, DLSUA, LOGL_NOTICE, "Received CLDR for unequipped SSN %u\n", + param->called_addr.ssn); msgb_free(upmsg); return 0; } @@ -294,8 +294,8 @@ rc = sclc_rx_cldr(inst, xua); break; default: - LOGP(DLSUA, LOGL_NOTICE, "Received unknown/unsupported " - "message %s\n", xua_hdr_dump(xua, &xua_dialect_sua)); + _LOGPSCI(sccp, DLSUA, LOGL_NOTICE, "Received unknown/unsupported message %s\n", + xua_hdr_dump(xua, &xua_dialect_sua)); break; }
diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c index 8222bde..f2ea766 100644 --- a/src/sccp_scoc.c +++ b/src/sccp_scoc.c @@ -437,8 +437,8 @@ } else if (conn->conn_id > it->conn_id) { n = &((*n)->rb_right); } else { - LOGP(DLSCCP, LOGL_ERROR, - "Trying to reserve already reserved conn_id %u\n", conn->conn_id); + LOGPSCI(inst, LOGL_ERROR, "Trying to reserve already reserved conn_id %u\n", + conn->conn_id); return -EEXIST; } } @@ -1546,14 +1546,14 @@
rc = sua_addr_parse(&called_addr, xua, SUA_IEI_DEST_ADDR); if (rc < 0) { - LOGP(DLSCCP, LOGL_ERROR, "Cannot find SCCP User for XUA " + LOGPSCI(inst, LOGL_ERROR, "Cannot find SCCP User for XUA " "Message %s without valid DEST_ADDR\n", xua_hdr_dump(xua, &xua_dialect_sua)); return NULL; }
if (!(called_addr.presence & OSMO_SCCP_ADDR_T_SSN)) { - LOGP(DLSCCP, LOGL_ERROR, "Cannot resolve SCCP User for " + LOGPSCI(inst, LOGL_ERROR, "Cannot resolve SCCP User for " "XUA Message %s without SSN in CalledAddr\n", xua_hdr_dump(xua, &xua_dialect_sua)); return NULL; @@ -1572,8 +1572,8 @@ uint32_t conn_id; struct sccp_connection *conn;
- LOGP(DLSCCP, LOGL_NOTICE, "SCRC Routing Failure for message %s\n", - xua_hdr_dump(xua, &xua_dialect_sua)); + LOGPSCI(inst, LOGL_NOTICE, "SCRC Routing Failure for message %s\n", + xua_hdr_dump(xua, &xua_dialect_sua));
/* try to dispatch to connection FSM (if any) */ conn_id = xua_msg_get_u32(xua, SUA_IEI_DEST_REF); @@ -1738,8 +1738,7 @@ tx_relco_from_xua(inst, xua); break; default: - LOGP(DLSCCP, LOGL_NOTICE, "Unhandled %s\n", - xua_hdr_dump(xua, &xua_dialect_sua)); + LOGPSCI(inst, LOGL_NOTICE, "Unhandled %s\n", xua_hdr_dump(xua, &xua_dialect_sua)); break; } } @@ -1830,8 +1829,7 @@ /* this shouldn't happen, as the caller should * have already verified that a local user is * equipped for this SSN */ - LOGP(DLSCCP, LOGL_ERROR, "Cannot find user for " - "CORE ?!?\n"); + LOGPSCI(inst, LOGL_ERROR, "Cannot find user for CORE ?!?\n"); return; } /* Allocate new connection */ @@ -1843,8 +1841,8 @@ conn_id = xua_msg_get_u32(xua, SUA_IEI_DEST_REF); conn = conn_find_by_id(inst, conn_id); if (!conn) { - LOGP(DLSCCP, LOGL_NOTICE, "Received %s: Cannot find connection for " - "local reference %u\n", xua_hdr_dump(xua, &xua_dialect_sua), conn_id); + LOGPSCI(inst, LOGL_NOTICE, "Received %s: Cannot find connection for " + "local reference %u\n", xua_hdr_dump(xua, &xua_dialect_sua), conn_id); sccp_scoc_rx_unass_local_ref(inst, xua); return; } diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index 63ded9d..543a464 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -87,7 +87,7 @@ /* 1) encode the SUA in xua_msg to SCCP message */ msg = osmo_sua_to_sccp(sua); if (!msg) { - LOGP(DLSCCP, LOGL_ERROR, "Cannot encode SUA to SCCP\n"); + LOGPSCI(inst, LOGL_ERROR, "Cannot encode SUA to SCCP\n"); return -1; }
@@ -101,8 +101,8 @@ param->opc = sua->mtp.opc; else { if (!osmo_ss7_pc_is_valid(s7i->cfg.primary_pc)) { - LOGP(DLSCCP, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n", - s7i->cfg.id); + LOGPSCI(inst, LOGL_ERROR, "SS7 instance %u: no primary point-code set\n", + s7i->cfg.id); return -1; } param->opc = s7i->cfg.primary_pc; @@ -140,8 +140,7 @@ if (called->presence & OSMO_SCCP_ADDR_T_PC) xua->mtp.dpc = called->pc; if (!xua->mtp.dpc) { - LOGP(DLSCCP, LOGL_ERROR, "MTP-TRANSFER.req from SCCP " - "without DPC?!? called=%s\n", + LOGPSCI(inst, LOGL_ERROR, "MTP-TRANSFER.req from SCCP without DPC?!? called=%s\n", osmo_sccp_addr_dump(called)); return -1; } @@ -155,8 +154,8 @@ rt = ss7_instance_lookup_route(inst->ss7, &rtlabel); if (!rt) { char buf[256]; - LOGP(DLSCCP, LOGL_ERROR, "MTP-TRANSFER.req from SCCP for %s: no route!\n", - ss7_route_label_to_str(buf, sizeof(buf), inst->ss7, &rtlabel)); + LOGPSCI(inst, LOGL_ERROR, "MTP-TRANSFER.req from SCCP for %s: no route!\n", + ss7_route_label_to_str(buf, sizeof(buf), inst->ss7, &rtlabel)); return -1; }
@@ -169,12 +168,12 @@ case OSMO_SS7_ASP_PROT_IPA: return sua2sccp_tx_m3ua(inst, xua); default: - LOGP(DLSCCP, LOGL_ERROR, "MTP-TRANSFER.req for " + LOGPSCI(inst, LOGL_ERROR, "MTP-TRANSFER.req for " "unknown protocol %u\n", as->cfg.proto); break; } } else if (rt->dest.linkset) { - LOGP(DLSCCP, LOGL_ERROR, "MTP-TRANSFER.req from SCCP for " + LOGPSCI(inst, LOGL_ERROR, "MTP-TRANSFER.req from SCCP for " "linkset %s unsupported\n", rt->dest.linkset->cfg.name); } else { OSMO_ASSERT(0); @@ -292,7 +291,7 @@ if (translated.ri != OSMO_SCCP_RI_SSN_PC && translated.ri != OSMO_SCCP_RI_SSN_IP) { /* TODO: GT Routing */ - LOGP(DLSCCP, LOGL_NOTICE, "GT Routing not implemented yet\n"); + LOGPSCI(inst, LOGL_NOTICE, "GT Routing not implemented yet\n"); #if 1 /* Prevent endless recursion, see OS#2666. */ sccp_sclc_rx_scrc_rout_fail(inst, xua, @@ -335,9 +334,8 @@ /* Is subsystem equipped? */ if (!scu) { /* Error: unequipped user */ - LOGP(DLSCCP, LOGL_NOTICE, - "Unable to find user for SSN=%u PC=%s\n", - called->ssn, osmo_ss7_pointcode_print(inst->ss7, called->pc)); + LOGPSCI(inst, LOGL_NOTICE, "Unable to find user for SSN=%u PC=%s\n", + called->ssn, osmo_ss7_pointcode_print(inst->ss7, called->pc)); return scrc_node_4(inst, xua, SCCP_RETURN_CAUSE_UNEQUIPPED_USER); } @@ -412,7 +410,7 @@ { struct osmo_sccp_addr called;
- LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua)); + LOGPSCI(inst, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua));
sua_addr_parse(&called, xua, SUA_IEI_DEST_ADDR);
@@ -434,7 +432,7 @@ { struct osmo_sccp_addr called;
- LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua)); + LOGPSCI(inst, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua));
sua_addr_parse(&called, xua, SUA_IEI_DEST_ADDR);
@@ -483,7 +481,7 @@ uint32_t proto_class; struct xua_msg_part *hop_ctr_part;
- LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua)); + LOGPSCI(inst, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua)); /* TODO: SCCP or nodal congestion? */
/* CR or CL message? */ diff --git a/src/sccp_user.c b/src/sccp_user.c index 62ae9ed..e283f29 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -108,14 +108,14 @@
scu = sccp_user_find(inst, ssn, pc); if (scu) { - LOGP(DLSCCP, LOGL_ERROR, - "Cannot bind user '%s' to SSN=%u PC=%s, this SSN and PC" - " is already bound by '%s'\n", - name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc), scu->name); + LOGPSCI(inst, LOGL_ERROR, + "Cannot bind user '%s' to SSN=%u PC=%s, this SSN and PC" + " is already bound by '%s'\n", + name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc), scu->name); return NULL; }
- LOGP(DLSCCP, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%s\n", + LOGPSCI(inst, LOGL_INFO, "Binding user '%s' to SSN=%u PC=%s\n", name, ssn, osmo_ss7_pointcode_print(inst->ss7, pc));
scu = talloc_zero(inst, struct osmo_sccp_user); @@ -216,7 +216,7 @@ /* Convert from SCCP to SUA in xua_msg format */ xua = osmo_sccp_to_xua(oph->msg); if (!xua) { - LOGP(DLSCCP, LOGL_ERROR, "Couldn't convert SCCP to SUA: %s\n", + LOGPSCI(inst, LOGL_ERROR, "Couldn't convert SCCP to SUA: %s\n", msgb_hexdump(oph->msg)); rc = -1; break; @@ -227,7 +227,7 @@ xua_msg_free(xua); break; default: - LOGP(DLSCCP, LOGL_ERROR, "Unknown primitive %u:%u receivd\n", + LOGPSCI(inst, LOGL_ERROR, "Unknown primitive %u:%u receivd\n", oph->primitive, oph->operation); rc = -1; }