log: a_iface.c: revisit logging, use LOGPCONN

Add LOGPBSCCONN for struct bsc_conn.

Use LOGPCONN or LOGPBSCCONN whereever possible.

Tweak a few log messages and remove one redundant log.

Change-Id: If9cb0e7a5cef2ec37a1a7c548aecf11a11c22eec
This commit is contained in:
Neels Hofmeyr 2017-12-18 05:17:25 +01:00 committed by Harald Welte
parent 26c218d0e7
commit 04960b15ec
1 changed files with 18 additions and 19 deletions

View File

@ -48,6 +48,9 @@
vlr_subscr_name(conn ? conn->vsub : NULL), conn ? conn->a.conn_id : -1, \ vlr_subscr_name(conn ? conn->vsub : NULL), conn ? conn->a.conn_id : -1, \
## args) ## args)
#define LOGPBSCCONN(conn, level, fmt, args...) \
LOGP(DMSC, level, "(conn_id %u) " fmt, conn ? conn->conn_id : (uint32_t)(-1), ## args)
/* A pointer to the GSM network we work with. By the current paradigm, /* A pointer to the GSM network we work with. By the current paradigm,
* there can only be one gsm_network per MSC. The pointer is set once * there can only be one gsm_network per MSC. The pointer is set once
* when calling a_init() */ * when calling a_init() */
@ -87,12 +90,9 @@ void a_delete_bsc_con(uint32_t conn_id)
struct bsc_conn *conn; struct bsc_conn *conn;
struct bsc_conn *conn_temp; struct bsc_conn *conn_temp;
LOGP(DMSC, LOGL_DEBUG,
"Removing connection from active sccp-connection list (conn_id=%i)\n",
conn_id);
llist_for_each_entry_safe(conn, conn_temp, &active_connections, list) { llist_for_each_entry_safe(conn, conn_temp, &active_connections, list) {
if (conn->conn_id == conn_id) { if (conn->conn_id == conn_id) {
LOGPBSCCONN(conn, LOGL_DEBUG, "Removing A-interface conn\n");
llist_del(&conn->list); llist_del(&conn->list);
talloc_free(conn); talloc_free(conn);
} }
@ -148,7 +148,7 @@ int a_iface_tx_dtap(struct msgb *msg)
OSMO_ASSERT(conn); OSMO_ASSERT(conn);
OSMO_ASSERT(conn->a.scu); OSMO_ASSERT(conn->a.scu);
LOGP(DMSC, LOGL_DEBUG, "Passing DTAP message from MSC to BSC (conn_id=%i)\n", conn->a.conn_id); LOGPCONN(conn, LOGL_DEBUG, "Passing DTAP message from MSC to BSC\n");
msg->l3h = msg->data; msg->l3h = msg->data;
msg_resp = gsm0808_create_dtap(msg, link_id); msg_resp = gsm0808_create_dtap(msg, link_id);
@ -158,12 +158,11 @@ int a_iface_tx_dtap(struct msgb *msg)
msgb_free(msg); msgb_free(msg);
if (!msg_resp) { if (!msg_resp) {
LOGP(DMSC, LOGL_ERROR, "Unable to generate BSSMAP DTAP message!\n"); LOGPCONN(conn, LOGL_ERROR, "Unable to generate BSSMAP DTAP message!\n");
return -EINVAL; return -EINVAL;
} else }
LOGP(DMSC, LOGL_DEBUG, "Message will be sent as BSSMAP DTAP message!\n");
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg_resp->data, msg_resp->len)); LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", osmo_hexdump(msg_resp->data, msg_resp->len));
/* osmo_sccp_tx_data_msg() takes ownership of msg_resp */ /* osmo_sccp_tx_data_msg() takes ownership of msg_resp */
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp); return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);
} }
@ -182,7 +181,7 @@ int a_iface_tx_cipher_mode(const struct gsm_subscriber_connection *conn,
LOGPC(DMSC, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, ei->key_len)); LOGPC(DMSC, LOGL_DEBUG, " key %s\n", osmo_hexdump_nospc(ei->key, ei->key_len));
msg_resp = gsm0808_create_cipher(ei, include_imeisv ? &crm : NULL); msg_resp = gsm0808_create_cipher(ei, include_imeisv ? &crm : NULL);
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg_resp->data, msg_resp->len)); LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", osmo_hexdump(msg_resp->data, msg_resp->len));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp); return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);
} }
@ -271,7 +270,7 @@ static uint8_t convert_Abis_sv_to_A_sv(int speech_ver)
} }
/* If nothing matches, tag the result as invalid */ /* If nothing matches, tag the result as invalid */
LOGP(DMSC, LOGL_ERROR, "Invalid permitted speech version / rate detected, discarding.\n"); LOGP(DMSC, LOGL_ERROR, "Invalid permitted speech version: %d\n", speech_ver);
return 0xFF; return 0xFF;
} }
@ -294,7 +293,8 @@ static uint8_t convert_Abis_prev_to_A_pref(int radio)
return GSM0808_SPEECH_HALF_PREF; return GSM0808_SPEECH_HALF_PREF;
} }
LOGP(DMSC, LOGL_ERROR, "Invalid speech version / rate combination preference, defaulting to full rate.\n"); LOGP(DMSC, LOGL_ERROR, "Invalid radio channel preference: %d; defaulting to full rate.\n",
radio);
return GSM0808_SPEECH_FULL_BM; return GSM0808_SPEECH_FULL_BM;
} }
@ -377,19 +377,19 @@ int a_iface_tx_assignment(const struct gsm_trans *trans)
conn = trans->conn; conn = trans->conn;
OSMO_ASSERT(conn); OSMO_ASSERT(conn);
LOGP(DMSC, LOGL_ERROR, "Sending assignment command to BSC (conn_id %u)\n", conn->a.conn_id); LOGPCONN(conn, LOGL_ERROR, "Sending Assignment Command to BSC\n");
/* Channel type */ /* Channel type */
rc = enc_channel_type(&ct, &trans->bearer_cap); rc = enc_channel_type(&ct, &trans->bearer_cap);
if (rc < 0) { if (rc < 0) {
LOGP(DMSC, LOGL_ERROR, "Faild to generate channel type -- assignment not sent!\n"); LOGPCONN(conn, LOGL_ERROR, "Not sending Assignment to BSC: failed to generate channel type\n");
return -EINVAL; return -EINVAL;
} }
/* Speech codec list */ /* Speech codec list */
rc = enc_speech_codec_list(&scl, &ct); rc = enc_speech_codec_list(&scl, &ct);
if (rc < 0) { if (rc < 0) {
LOGP(DMSC, LOGL_ERROR, "Faild to generate Speech codec list -- assignment not sent!\n"); LOGPCONN(conn, LOGL_ERROR, "Not sending Assignment to BSC: failed to generate speech codec list\n");
return -EINVAL; return -EINVAL;
} }
@ -404,7 +404,7 @@ int a_iface_tx_assignment(const struct gsm_trans *trans)
msg = gsm0808_create_ass(&ct, NULL, &rtp_addr, &scl, ci_ptr); msg = gsm0808_create_ass(&ct, NULL, &rtp_addr, &scl, ci_ptr);
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg->data, msg->len)); LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", osmo_hexdump(msg->data, msg->len));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg); return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
} }
@ -413,7 +413,7 @@ int a_iface_tx_clear_cmd(struct gsm_subscriber_connection *conn)
{ {
struct msgb *msg; struct msgb *msg;
LOGP(DMSC, LOGL_NOTICE, "Sending clear command to BSC (conn_id=%u)\n", conn->a.conn_id); LOGPCONN(conn, LOGL_NOTICE, "Sending Clear command to BSC\n");
msg = gsm0808_create_clear_command(GSM0808_CAUSE_CALL_CONTROL); msg = gsm0808_create_clear_command(GSM0808_CAUSE_CALL_CONTROL);
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg); return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
@ -552,8 +552,7 @@ void a_clear_all(struct osmo_sccp_user *scu, const struct osmo_sccp_addr *bsc_ad
/* Clear only A connections and connections that actually /* Clear only A connections and connections that actually
* belong to the specified BSC */ * belong to the specified BSC */
if (conn->via_ran == RAN_GERAN_A && memcmp(bsc_addr, &conn->a.bsc_addr, sizeof(conn->a.bsc_addr)) == 0) { if (conn->via_ran == RAN_GERAN_A && memcmp(bsc_addr, &conn->a.bsc_addr, sizeof(conn->a.bsc_addr)) == 0) {
LOGP(DMSC, LOGL_NOTICE, "Dropping orphaned subscriber connection (conn_id %i)\n", LOGPCONN(conn, LOGL_NOTICE, "Dropping orphaned subscriber connection\n");
conn->a.conn_id);
msc_clear_request(conn, GSM48_CC_CAUSE_SWITCH_CONG); msc_clear_request(conn, GSM48_CC_CAUSE_SWITCH_CONG);
/* If there is still an SCCP connection active, remove it now */ /* If there is still an SCCP connection active, remove it now */