From 0f27b1bd397f5b54fdfabf447d6fca7f30ac2580 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Thu, 14 Jan 2021 03:35:19 +0100 Subject: mncc: Introduce mncc_rtp_write similiar to mncc_write Concentrate the write() to the socket in 2 places. One for struct gsm_mncc and one for struct gsm_mncc_rtp. Improve debugging as now all function debug print the MNCC primitiv. Change-Id: Ia84602955b913a3bb13de7a6a92048799f2e1955 --- src/mncc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/mncc.c b/src/mncc.c index d3d218b..83cfe3b 100644 --- a/src/mncc.c +++ b/src/mncc.c @@ -156,23 +156,30 @@ static int mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t c return mncc_write(conn, &mncc); } -static int mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref) +static int mncc_rtp_write(struct mncc_connection *conn, struct gsm_mncc_rtp *rtp) { int rc; - struct gsm_mncc_rtp mncc = { 0, }; - - mncc.msg_type = msg_type; - mncc.callref = callref; - rc = write(conn->fd.fd, &mncc, sizeof(mncc)); - if (rc != sizeof(mncc)) { - LOGP(DMNCC, LOGL_ERROR, "Failed to send message for call(%u)\n", callref); + rc = write(conn->fd.fd, &rtp, sizeof(rtp)); + LOGP(DMNCC, LOGL_DEBUG, "MNCC sent message type: %s\n", osmo_mncc_name(rtp->msg_type)); + if (rc != sizeof(*rtp)) { + LOGP(DMNCC, LOGL_ERROR, "Failed to send message for call(%u)\n", rtp->callref); close_connection(conn); } return rc; } +static int mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref) +{ + struct gsm_mncc_rtp mncc = { 0, }; + + mncc.msg_type = msg_type; + mncc.callref = callref; + + return mncc_rtp_write(conn, &mncc); +} + /* Send a MNCC_RTP_CONNECT to the MSC for the given call legs */ static bool send_rtp_connect(struct mncc_call_leg *leg, struct call_leg *other) { @@ -195,7 +202,7 @@ static bool send_rtp_connect(struct mncc_call_leg *leg, struct call_leg *other) LOGP(DMNCC, LOGL_DEBUG, "SEND rtp_connect: IP=(%s) PORT=(%u)\n", osmo_sockaddr_ntop((const struct sockaddr*)&other->addr, ip_addr), osmo_sockaddr_port((const struct sockaddr*)&other->addr)); - rc = write(leg->conn->fd.fd, &mncc, sizeof(mncc)); + rc = mncc_rtp_write(leg->conn, &mncc); if (rc != sizeof(mncc)) { LOGP(DMNCC, LOGL_ERROR, "Failed to send message for call(%u)\n", leg->callref); -- cgit v1.2.3