Introduce new BSSAP logging category/subsystem

Having all BSSAP related logs in the "DMSC" category is overly
generic, and dosn't provide useful granularity.

Change-Id: Id1e52dad03840dfd026fb23f3845a8771c8cc308
---
M include/osmocom/msc/a_iface.h
M include/osmocom/msc/debug.h
M src/libcommon/debug.c
M src/libmsc/a_iface.c
M src/libmsc/a_iface_bssap.c
5 files changed, 49 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/38/6338/2

diff --git a/include/osmocom/msc/a_iface.h b/include/osmocom/msc/a_iface.h
index 9133e1b..3098b51 100644
--- a/include/osmocom/msc/a_iface.h
+++ b/include/osmocom/msc/a_iface.h
@@ -26,12 +26,12 @@
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 
 #define LOGPCONN(conn, level, fmt, args...) \
-       LOGP(DMSC, level, "(subscr %s, conn_id %d) " fmt, \
+       LOGP(DBSSAP, level, "(subscr %s, conn_id %d) " fmt, \
             vlr_subscr_name(conn ? conn->vsub : NULL), conn ? conn->a.conn_id 
: -1, \
             ## args)
 
 #define LOGPBSCCONN(conn, level, fmt, args...) \
-       LOGP(DMSC, level, "(conn_id %u) " fmt, conn ? conn->conn_id : 
(uint32_t)(-1), ## args)
+       LOGP(DBSSAP, level, "(conn_id %u) " fmt, conn ? conn->conn_id : 
(uint32_t)(-1), ## args)
 
 /* A struct to keep a context information about the BSCs we are associated 
with */
 struct bsc_context {
diff --git a/include/osmocom/msc/debug.h b/include/osmocom/msc/debug.h
index f99dba5..384453e 100644
--- a/include/osmocom/msc/debug.h
+++ b/include/osmocom/msc/debug.h
@@ -24,6 +24,7 @@
        DRANAP,
        DVLR,
        DIUCS,
+       DBSSAP,
        Debug_LastEntry,
 };
 
diff --git a/src/libcommon/debug.c b/src/libcommon/debug.c
index 8c0e787..fbdab80 100644
--- a/src/libcommon/debug.c
+++ b/src/libcommon/debug.c
@@ -122,6 +122,12 @@
                .description = "Iu-CS Protocol",
                .enabled = 1, .loglevel = LOGL_DEBUG,
        },
+       [DBSSAP] = {
+               .name = "DBSSAP",
+               .description = "BSSAP Protocol (A Interface)",
+               .enabled = 1, .loglevel = LOGL_NOTICE,
+       },
+
 };
 
 static int filter_fn(const struct log_context *ctx, struct log_target *tar)
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 5605ad1..e2fe3c6 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -134,7 +134,7 @@
 
        ss7 = osmo_ss7_instance_find(gsm_network->a.cs7_instance);
        OSMO_ASSERT(ss7);
-       LOGP(DMSC, LOGL_NOTICE, "The calling BSC (%s) is unknown to this MSC 
...\n",
+       LOGP(DBSSAP, LOGL_NOTICE, "The calling BSC (%s) is unknown to this MSC 
...\n",
             osmo_sccp_addr_name(ss7, addr));
        return NULL;
 }
@@ -182,7 +182,7 @@
        OSMO_ASSERT(conn);
        LOGPCONN(conn, LOGL_DEBUG, "Tx BSSMAP CIPHER MODE COMMAND to BSC, %u 
ciphers (%s)",
                 ei->perm_algo_len, osmo_hexdump_nospc(ei->perm_algo, 
ei->perm_algo_len));
-       LOGPC(DMSC, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, 
ei->key_len));
+       LOGPC(DBSSAP, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, 
ei->key_len));
 
        msg_resp = gsm0808_create_cipher(ei, include_imeisv ? &crm : NULL);
        LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", 
msgb_hexdump_l2(msg_resp));
@@ -211,7 +211,7 @@
        /* Deliver paging request to all known BSCs */
        llist_for_each_entry(bsc_ctx, &gsm_network->a.bscs, list) {
                if (a_reset_conn_ready(bsc_ctx->reset)) {
-                       LOGP(DMSC, LOGL_DEBUG,
+                       LOGP(DBSSAP, LOGL_DEBUG,
                             "Tx BSSMAP paging message from MSC %s to BSC %s 
(imsi=%s, tmsi=0x%08x, lac=%u)\n",
                             osmo_sccp_addr_name(ss7, &bsc_ctx->msc_addr),
                             osmo_sccp_addr_name(ss7, &bsc_ctx->bsc_addr), 
imsi, tmsi, lac);
@@ -220,7 +220,7 @@
                                                  &bsc_ctx->msc_addr, 
&bsc_ctx->bsc_addr, msg);
                        page_count++;
                } else {
-                       LOGP(DMSC, LOGL_DEBUG,
+                       LOGP(DBSSAP, LOGL_DEBUG,
                             "Connection down, dropping paging from MSC %s to 
BSC %s (imsi=%s, tmsi=0x%08x, lac=%u)\n",
                             osmo_sccp_addr_name(ss7, &bsc_ctx->msc_addr),
                             osmo_sccp_addr_name(ss7, &bsc_ctx->bsc_addr), 
imsi, tmsi, lac);
@@ -228,7 +228,7 @@
        }
 
        if (page_count <= 0)
-               LOGP(DMSC, LOGL_ERROR, "Could not deliver paging because none 
of the associated BSCs is available!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Could not deliver paging because none 
of the associated BSCs is available!\n");
 
        return page_count;
 }
@@ -265,7 +265,7 @@
        }
 
        /* If nothing matches, tag the result as invalid */
-       LOGP(DMSC, LOGL_ERROR, "Invalid permitted speech version: %d\n", 
speech_ver);
+       LOGP(DBSSAP, LOGL_ERROR, "Invalid permitted speech version: %d\n", 
speech_ver);
        return 0xFF;
 }
 
@@ -288,7 +288,7 @@
                return GSM0808_SPEECH_HALF_PREF;
        }
 
-       LOGP(DMSC, LOGL_ERROR, "Invalid radio channel preference: %d; 
defaulting to full rate.\n",
+       LOGP(DBSSAP, LOGL_ERROR, "Invalid radio channel preference: %d; 
defaulting to full rate.\n",
             radio);
        return GSM0808_SPEECH_FULL_BM;
 }
@@ -440,7 +440,7 @@
        /* Send reset to the remote BSC */
        ss7 = osmo_ss7_instance_find(gsm_network->a.cs7_instance);
        OSMO_ASSERT(ss7);
-       LOGP(DMSC, LOGL_NOTICE, "Tx BSSMAP RESET to BSC %s\n", 
osmo_sccp_addr_name(ss7, &bsc_ctx->bsc_addr));
+       LOGP(DBSSAP, LOGL_NOTICE, "Tx BSSMAP RESET to BSC %s\n", 
osmo_sccp_addr_name(ss7, &bsc_ctx->bsc_addr));
        msg = gsm0808_create_reset();
        osmo_sccp_tx_unitdata_msg(bsc_ctx->sccp_user, &bsc_ctx->msc_addr,
                                  &bsc_ctx->bsc_addr, msg);
@@ -455,7 +455,7 @@
 
        ss7 = osmo_ss7_instance_find(gsm_network->a.cs7_instance);
        OSMO_ASSERT(ss7);
-       LOGP(DMSC, LOGL_NOTICE, "Adding new BSC connection for BSC %s...\n", 
osmo_sccp_addr_name(ss7, bsc_addr));
+       LOGP(DBSSAP, LOGL_NOTICE, "Adding new BSC connection for BSC %s...\n", 
osmo_sccp_addr_name(ss7, bsc_addr));
 
        /* Generate and fill up a new bsc context */
        bsc_ctx = talloc_zero(gsm_network, struct bsc_context);
@@ -520,7 +520,7 @@
                } else {
                        /* This BSC is already known to us, check if we have 
been through reset yet */
                        if (a_reset_conn_ready(a_conn_info.bsc->reset) == 
false) {
-                               LOGP(DMSC, LOGL_NOTICE, "Refusing 
N-CONNECT.ind(%u, %s), BSC not reset yet\n",
+                               LOGP(DBSSAP, LOGL_NOTICE, "Refusing 
N-CONNECT.ind(%u, %s), BSC not reset yet\n",
                                     scu_prim->u.connect.conn_id, 
msgb_hexdump_l2(oph->msg));
                                rc = osmo_sccp_tx_disconn(scu, 
a_conn_info.conn_id, &a_conn_info.bsc->msc_addr,
                                                          
SCCP_RETURN_CAUSE_UNQUALIFIED);
@@ -529,11 +529,11 @@
 
                        osmo_sccp_tx_conn_resp(scu, 
scu_prim->u.connect.conn_id, &scu_prim->u.connect.called_addr, NULL, 0);
                        if (msgb_l2len(oph->msg) > 0) {
-                               LOGP(DMSC, LOGL_DEBUG, "N-CONNECT.ind(%u, 
%s)\n",
+                               LOGP(DBSSAP, LOGL_DEBUG, "N-CONNECT.ind(%u, 
%s)\n",
                                     scu_prim->u.connect.conn_id, 
msgb_hexdump_l2(oph->msg));
                                rc = a_sccp_rx_dt(scu, &a_conn_info, oph->msg);
                        } else
-                               LOGP(DMSC, LOGL_DEBUG, "N-CONNECT.ind(%u)\n", 
scu_prim->u.connect.conn_id);
+                               LOGP(DBSSAP, LOGL_DEBUG, "N-CONNECT.ind(%u)\n", 
scu_prim->u.connect.conn_id);
 
                        record_bsc_con(scu, a_conn_info.bsc, 
scu_prim->u.connect.conn_id);
                }
@@ -543,13 +543,13 @@
                /* Handle incoming connection oriented data */
                bsc_con = find_bsc_con(scu_prim->u.data.conn_id);
                if (!bsc_con) {
-                       LOGP(DMSC, LOGL_ERROR, "N-DATA.ind(%u, %s) for unknown 
conn_id\n",
+                       LOGP(DBSSAP, LOGL_ERROR, "N-DATA.ind(%u, %s) for 
unknown conn_id\n",
                                scu_prim->u.data.conn_id, 
msgb_hexdump_l2(oph->msg));
                        break;
                }
                a_conn_info.conn_id = scu_prim->u.data.conn_id;
                a_conn_info.bsc = bsc_con->bsc;
-               LOGP(DMSC, LOGL_DEBUG, "N-DATA.ind(%u, %s)\n",
+               LOGP(DBSSAP, LOGL_DEBUG, "N-DATA.ind(%u, %s)\n",
                     scu_prim->u.data.conn_id, msgb_hexdump_l2(oph->msg));
                a_sccp_rx_dt(scu, &a_conn_info, oph->msg);
                break;
@@ -563,7 +563,7 @@
                                                
&scu_prim->u.unitdata.calling_addr, scu);
                        /* if this not an inbound RESET, trigger an outbound 
RESET */
                        if (!bssmap_is_reset(oph->msg)) {
-                               LOGP(DMSC, LOGL_NOTICE, "Ignoring 
N-UNITDATA.ind(%s), BSC not reset yet\n",
+                               LOGP(DBSSAP, LOGL_NOTICE, "Ignoring 
N-UNITDATA.ind(%s), BSC not reset yet\n",
                                        msgb_hexdump_l2(oph->msg));
                                a_start_reset(a_conn_info.bsc, false);
                                break;
@@ -571,17 +571,17 @@
                } else {
                        /* This BSC is already known to us, check if we have 
been through reset yet */
                        if (a_reset_conn_ready(a_conn_info.bsc->reset) == 
false) {
-                               LOGP(DMSC, LOGL_NOTICE, "Ignoring 
N-UNITDATA.ind(%s), BSC not reset yet\n",
+                               LOGP(DBSSAP, LOGL_NOTICE, "Ignoring 
N-UNITDATA.ind(%s), BSC not reset yet\n",
                                        msgb_hexdump_l2(oph->msg));
                                break;
                        }
                }
-               DEBUGP(DMSC, "N-UNITDATA.ind(%s)\n", msgb_hexdump_l2(oph->msg));
+               DEBUGP(DBSSAP, "N-UNITDATA.ind(%s)\n", 
msgb_hexdump_l2(oph->msg));
                a_sccp_rx_udt(scu, &a_conn_info, oph->msg);
                break;
 
        default:
-               LOGP(DMSC, LOGL_ERROR, "Unhandled SIGTRAN operation %s on 
primitive %u\n",
+               LOGP(DBSSAP, LOGL_ERROR, "Unhandled SIGTRAN operation %s on 
primitive %u\n",
                     get_value_string(osmo_prim_op_names, oph->operation), 
oph->primitive);
                break;
        }
@@ -623,7 +623,7 @@
        OSMO_ASSERT(network);
 
        /* FIXME: Remove hardcoded parameters, use parameters in parameter list 
*/
-       LOGP(DMSC, LOGL_NOTICE, "Initalizing SCCP connection to stp...\n");
+       LOGP(DBSSAP, LOGL_NOTICE, "Initalizing SCCP connection to stp...\n");
 
        /* Set GSM network variable, there can only be
         * one network by design */
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index 61e1d4e..01cb71d 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -111,7 +111,7 @@
        ss7 = osmo_ss7_instance_find(network->a.cs7_instance);
        OSMO_ASSERT(ss7);
 
-       LOGP(DMSC, LOGL_NOTICE, "Rx BSSMAP RESET from BSC %s, sending RESET 
ACK\n",
+       LOGP(DBSSAP, LOGL_NOTICE, "Rx BSSMAP RESET from BSC %s, sending RESET 
ACK\n",
             osmo_sccp_addr_name(ss7, &a_conn_info->bsc->bsc_addr));
        osmo_sccp_tx_unitdata_msg(scu, &a_conn_info->bsc->msc_addr, 
&a_conn_info->bsc->bsc_addr,
                                  gsm0808_create_reset_ack());
@@ -137,12 +137,12 @@
        OSMO_ASSERT(ss7);
 
        if (a_conn_info->bsc->reset == NULL) {
-               LOGP(DMSC, LOGL_ERROR, "Received RESET ACK from an unknown BSC 
%s, ignoring...\n",
+               LOGP(DBSSAP, LOGL_ERROR, "Received RESET ACK from an unknown 
BSC %s, ignoring...\n",
                     osmo_sccp_addr_name(ss7, &a_conn_info->bsc->bsc_addr));
                goto fail;
        }
 
-       LOGP(DMSC, LOGL_NOTICE, "Received RESET ACK from BSC %s\n",
+       LOGP(DBSSAP, LOGL_NOTICE, "Received RESET ACK from BSC %s\n",
                osmo_sccp_addr_name(ss7, &a_conn_info->bsc->bsc_addr));
 
        /* Confirm that we managed to get the reset ack message
@@ -160,12 +160,12 @@
         * can be received via UNITDATA */
 
        if (msgb_l3len(msg) < 1) {
-               LOGP(DMSC, LOGL_NOTICE, "Error: No data received -- discarding 
message!\n");
+               LOGP(DBSSAP, LOGL_NOTICE, "Error: No data received -- 
discarding message!\n");
                msgb_free(msg);
                return;
        }
 
-       LOGP(DMSC, LOGL_DEBUG, "Rx BSSMAP UDT %s\n", 
gsm0808_bssmap_name(msg->l3h[0]));
+       LOGP(DBSSAP, LOGL_DEBUG, "Rx BSSMAP UDT %s\n", 
gsm0808_bssmap_name(msg->l3h[0]));
 
        switch (msg->l3h[0]) {
        case BSS_MAP_MSG_RESET:
@@ -175,7 +175,7 @@
                bssmap_rx_reset_ack(scu, a_conn_info, msg);
                break;
        default:
-               LOGP(DMSC, LOGL_NOTICE, "Unimplemented message format: %s -- 
message discarded!\n",
+               LOGP(DBSSAP, LOGL_NOTICE, "Unimplemented message format: %s -- 
message discarded!\n",
                     gsm0808_bssmap_name(msg->l3h[0]));
                msgb_free(msg);
        }
@@ -192,17 +192,17 @@
        OSMO_ASSERT(a_conn_info);
        OSMO_ASSERT(msg);
 
-       LOGP(DMSC, LOGL_DEBUG, "Rx BSSMAP UDT: %s\n", msgb_hexdump_l2(msg));
+       LOGP(DBSSAP, LOGL_DEBUG, "Rx BSSMAP UDT: %s\n", msgb_hexdump_l2(msg));
 
        if (msgb_l2len(msg) < sizeof(*bs)) {
-               LOGP(DMSC, LOGL_ERROR, "Error: Header is too short -- 
discarding message!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Error: Header is too short -- 
discarding message!\n");
                msgb_free(msg);
                return;
        }
 
        bs = (struct bssmap_header *)msgb_l2(msg);
        if (bs->length < msgb_l2len(msg) - sizeof(*bs)) {
-               LOGP(DMSC, LOGL_ERROR, "Error: Message is too short -- 
discarding message!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Error: Message is too short -- 
discarding message!\n");
                msgb_free(msg);
                return;
        }
@@ -213,7 +213,7 @@
                bssmap_rcvmsg_udt(scu, a_conn_info, msg);
                break;
        default:
-               LOGP(DMSC, LOGL_ERROR,
+               LOGP(DBSSAP, LOGL_ERROR,
                     "Error: Unimplemented message type: %s -- message 
discarded!\n", gsm0808_bssmap_name(bs->type));
                msgb_free(msg);
        }
@@ -235,7 +235,7 @@
 
        tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, msgb_l3len(msg) - 1, 
0, 0);
        if (!TLVP_PRESENT(&tp, GSM0808_IE_CAUSE)) {
-               LOGP(DMSC, LOGL_ERROR, "Cause code is missing -- discarding 
message!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Cause code is missing -- discarding 
message!\n");
                goto fail;
        }
        cause = TLVP_VAL(&tp, GSM0808_IE_CAUSE)[0];
@@ -289,15 +289,15 @@
        struct gsm_network *network = a_conn_info->network;
        struct gsm_subscriber_connection *conn;
 
-       LOGP(DMSC, LOGL_INFO, "Rx BSSMAP COMPLETE L3 INFO (conn_id=%i)\n", 
a_conn_info->conn_id);
+       LOGP(DBSSAP, LOGL_INFO, "Rx BSSMAP COMPLETE L3 INFO (conn_id=%i)\n", 
a_conn_info->conn_id);
 
        tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, msgb_l3len(msg) - 1, 
0, 0);
        if (!TLVP_PRESENT(&tp, GSM0808_IE_CELL_IDENTIFIER)) {
-               LOGP(DMSC, LOGL_ERROR, "Mandatory CELL IDENTIFIER not present 
-- discarding message!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Mandatory CELL IDENTIFIER not present 
-- discarding message!\n");
                goto fail;
        }
        if (!TLVP_PRESENT(&tp, GSM0808_IE_LAYER_3_INFORMATION)) {
-               LOGP(DMSC, LOGL_ERROR, "Mandatory LAYER 3 INFORMATION not 
present -- discarding message!\n");
+               LOGP(DBSSAP, LOGL_ERROR, "Mandatory LAYER 3 INFORMATION not 
present -- discarding message!\n");
                goto fail;
        }
 
@@ -308,18 +308,18 @@
        data_length = TLVP_LEN(&tp, GSM0808_IE_CELL_IDENTIFIER);
        data = TLVP_VAL(&tp, GSM0808_IE_CELL_IDENTIFIER);
        if (sizeof(lai_ci) != data_length) {
-               LOGP(DMSC, LOGL_ERROR,
+               LOGP(DBSSAP, LOGL_ERROR,
                     "Unable to parse element CELL IDENTIFIER (wrong field 
length) -- discarding message!\n");
                goto fail;
        }
        memcpy(&lai_ci, data, sizeof(lai_ci));
        if (lai_ci.ident != CELL_IDENT_WHOLE_GLOBAL) {
-               LOGP(DMSC, LOGL_ERROR,
+               LOGP(DBSSAP, LOGL_ERROR,
                     "Unable to parse element CELL IDENTIFIER (wrong cell 
identification discriminator) -- discarding message!\n");
                goto fail;
        }
        if (gsm48_decode_lai(&lai_ci.lai, &mcc, &mnc, &lac) != 0) {
-               LOGP(DMSC, LOGL_ERROR,
+               LOGP(DBSSAP, LOGL_ERROR,
                     "Unable to parse element CELL IDENTIFIER (lai decoding 
failed) -- discarding message!\n");
                goto fail;
        }
@@ -580,7 +580,7 @@
        struct gsm_subscriber_connection *conn;
 
        if (msgb_l3len(msg) < 1) {
-               LOGP(DMSC, LOGL_NOTICE, "Error: No data received -- discarding 
message!\n");
+               LOGP(DBSSAP, LOGL_NOTICE, "Error: No data received -- 
discarding message!\n");
                msgb_free(msg);
                return -1;
        }
@@ -597,7 +597,7 @@
 
        conn = subscr_conn_lookup_a(a_conn_info->network, a_conn_info->conn_id);
        if (!conn) {
-               LOGP(DMSC, LOGL_ERROR, "Couldn't find subscr_conn for 
conn_id=%d\n", a_conn_info->conn_id);
+               LOGP(DBSSAP, LOGL_ERROR, "Couldn't find subscr_conn for 
conn_id=%d\n", a_conn_info->conn_id);
                msgb_free(msg);
                return -EINVAL;
        }
@@ -660,7 +660,7 @@
        OSMO_ASSERT(msg);
 
        if (msgb_l2len(msg) < sizeof(struct bssmap_header)) {
-               LOGP(DMSC, LOGL_NOTICE, "The header is too short -- discarding 
message!\n");
+               LOGP(DBSSAP, LOGL_NOTICE, "The header is too short -- 
discarding message!\n");
                msgb_free(msg);
                return -EINVAL;
        }
@@ -672,7 +672,7 @@
        case BSSAP_MSG_DTAP:
                return rx_dtap(scu, a_conn_info, msg);
        default:
-               LOGP(DMSC, LOGL_ERROR, "Unimplemented BSSAP msg type: %s\n", 
gsm0808_bssap_name(msg->l2h[0]));
+               LOGP(DBSSAP, LOGL_ERROR, "Unimplemented BSSAP msg type: %s\n", 
gsm0808_bssap_name(msg->l2h[0]));
                msgb_free(msg);
                return -EINVAL;
        }

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id1e52dad03840dfd026fb23f3845a8771c8cc308
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder

Reply via email to