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
changes/03/22203/2
Alexander Couzens 2 years ago
parent ef646b07e2
commit 0f27b1bd39
  1. 25
      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);

Loading…
Cancel
Save