a_iface: Centralize/wrap BSSAP / N-DATA transmission

We don't want multiple callers to osmo_sccp_tx_data_msg() each having
to hex-dump a log message about the to-be-transmitted message, with
half of the caller sitest missing that printing.  Let's centralize
all calls of osmo_sccp_tx_data_msg() in a wrapper function which
takes care of the related OSMO_ASSERT() and the related printing.

Change-Id: I6159ea72cc8e0650eda6c49544acd65e9c15e817
This commit is contained in:
Harald Welte 2019-02-18 12:23:43 +01:00
parent 2eaee70ada
commit 977b5486b1
4 changed files with 27 additions and 11 deletions

View File

@ -141,6 +141,16 @@ static struct bsc_context *get_bsc_context_by_sccp_addr(const struct osmo_sccp_a
return NULL;
}
/* wrapper around osmo_sccp_tx_data_msg(): Transmit a fully encoded BSSAP (DTAP or BSSMAP) message */
static int a_iface_tx_bssap(const struct ran_conn *conn, struct msgb *msg)
{
OSMO_ASSERT(conn);
OSMO_ASSERT(conn->a.scu);
LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", msgb_hexdump_l2(msg));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
}
/* Send DTAP message via A-interface, take ownership of msg */
int a_iface_tx_dtap(struct msgb *msg)
{
@ -151,7 +161,6 @@ int a_iface_tx_dtap(struct msgb *msg)
OSMO_ASSERT(msg);
conn = (struct ran_conn *)msg->dst;
OSMO_ASSERT(conn);
OSMO_ASSERT(conn->a.scu);
LOGPCONN(conn, LOGL_DEBUG, "Passing DTAP message (DLCI=0x%02x) from MSC to BSC\n", link_id);
@ -167,9 +176,8 @@ int a_iface_tx_dtap(struct msgb *msg)
return -EINVAL;
}
LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", msgb_hexdump_l2(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 a_iface_tx_bssap(conn, msg_resp);
}
/* Send Cipher mode command via A-interface */
@ -186,9 +194,7 @@ int a_iface_tx_cipher_mode(const struct ran_conn *conn,
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));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);
return a_iface_tx_bssap(conn, msg_resp);
}
/* Page a subscriber via A-interface */
@ -407,9 +413,7 @@ int a_iface_tx_assignment(const struct gsm_trans *trans)
memcpy(&rtp_addr, &rtp_addr_in, sizeof(rtp_addr_in));
msg = gsm0808_create_ass(&ct, NULL, &rtp_addr, &scl, NULL);
LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", msgb_hexdump_l2(msg));
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
return a_iface_tx_bssap(conn, msg);
}
/* Send clear command via A-interface */
@ -425,7 +429,7 @@ int a_iface_tx_clear_cmd(struct ran_conn *conn)
csfb_ind = true;
msg = gsm0808_create_clear_command2(GSM0808_CAUSE_CALL_CONTROL, csfb_ind);
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
return a_iface_tx_bssap(conn, msg);
}
int a_iface_tx_classmark_request(const struct ran_conn *conn)
@ -435,7 +439,7 @@ int a_iface_tx_classmark_request(const struct ran_conn *conn)
LOGPCONN(conn, LOGL_INFO, "Tx BSSMAP CLASSMARK REQUEST to BSC\n");
msg = gsm0808_create_classmark_request();
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
return a_iface_tx_bssap(conn, msg);
}
/* Callback function: Close all open connections */

View File

@ -2452,6 +2452,7 @@ DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: vlr_loc
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: Set Ciphering Mode
DMM IMSI-901700000004620: to determine whether A5/3 is supported, first ask for a Classmark Update to obtain Classmark 2
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: Tx BSSMAP CLASSMARK REQUEST to BSC
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: N-DATA.req([])
BSC <--BSSAP-BSS-MANAGEMENT-- MSC: CLASSMARK REQ [L3]> 00 01 58
DMM RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: state_chg to RAN_CONN_S_WAIT_CLASSMARK_UPDATE
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: state_chg to VLR_ULA_S_WAIT_CIPH
@ -2987,6 +2988,7 @@ DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: vlr_loc
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: Set Ciphering Mode
DMM IMSI-901700000004620: to determine whether A5/3 is supported, first ask for a Classmark Update to obtain Classmark 2
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: Tx BSSMAP CLASSMARK REQUEST to BSC
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: N-DATA.req([])
BSC <--BSSAP-BSS-MANAGEMENT-- MSC: CLASSMARK REQ [L3]> 00 01 58
DMM RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: state_chg to RAN_CONN_S_WAIT_CLASSMARK_UPDATE
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: state_chg to VLR_ULA_S_WAIT_CIPH
@ -3295,6 +3297,7 @@ DVLR Process_Access_Request_VLR(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGI
DVLR Process_Access_Request_VLR(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGING_RESP){PR_ARQ_S_WAIT_AUTH}: Set Ciphering Mode
DMM IMSI-901700000004620:MSISDN-42342: to determine whether A5/3 is supported, first ask for a Classmark Update to obtain Classmark 2
DBSSAP RAN_conn(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGING_RESP){RAN_CONN_S_AUTH_CIPH}: Tx BSSMAP CLASSMARK REQUEST to BSC
DBSSAP RAN_conn(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGING_RESP){RAN_CONN_S_AUTH_CIPH}: N-DATA.req([])
BSC <--BSSAP-BSS-MANAGEMENT-- MSC: CLASSMARK REQ [L3]> 00 01 58
DMM RAN_conn(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGING_RESP){RAN_CONN_S_AUTH_CIPH}: state_chg to RAN_CONN_S_WAIT_CLASSMARK_UPDATE
DVLR Process_Access_Request_VLR(IMSI-901700000004620:MSISDN-42342:GERAN-A-0:PAGING_RESP){PR_ARQ_S_WAIT_AUTH}: state_chg to PR_ARQ_S_WAIT_CIPH

View File

@ -686,6 +686,7 @@ DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: vlr_loc
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: Set Ciphering Mode
DMM IMSI-901700000004620: to determine whether A5/3 is supported, first ask for a Classmark Update to obtain Classmark 2
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: Tx BSSMAP CLASSMARK REQUEST to BSC
DBSSAP RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: N-DATA.req([])
BSC <--BSSAP-BSS-MANAGEMENT-- MSC: CLASSMARK REQ [L3]> 00 01 58
DMM RAN_conn(IMSI-901700000004620:GERAN-A-0:LU){RAN_CONN_S_AUTH_CIPH}: state_chg to RAN_CONN_S_WAIT_CLASSMARK_UPDATE
DVLR vlr_lu_fsm(IMSI-901700000004620:GERAN-A-0:LU){VLR_ULA_S_WAIT_AUTH}: state_chg to VLR_ULA_S_WAIT_CIPH

View File

@ -193,6 +193,12 @@ void conn_conclude_cm_service_req(struct ran_conn *conn,
enum osmo_rat_type rx_from_ran = OSMO_RAT_GERAN_A;
/* SCCP user stub to make a_iface_tx_bssap() happy during test case execution */
struct osmo_sccp_user {
uint8_t foo;
};
static struct osmo_sccp_user g_scu;
struct ran_conn *conn_new(void)
{
struct ran_conn *conn;
@ -203,6 +209,8 @@ struct ran_conn *conn_new(void)
.conn_id = 42,
};
conn->iu.ue_ctx = ue_ctx;
} else {
conn->a.scu = &g_scu;
}
return conn;
}