mgcp: Synchronize conn mode bits and output enabled flags
This patch changes implementation and the mgcp_connection_mode enum
in a way that net_end.output_enabled (bts_end.output_enabled) flag
always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of
conn_mode.
Based on this, the conn_mode bits are then used instead of the
output_enabled fields within mgcp_protocol.c.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 9055bdb..5c88c9d 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -504,28 +504,10 @@
ret = -1;
}
- switch (endp->conn_mode) {
- case MGCP_CONN_NONE:
- endp->net_end.output_enabled = 0;
- endp->bts_end.output_enabled = 0;
- break;
-
- case MGCP_CONN_RECV_ONLY:
- endp->net_end.output_enabled = 0;
- endp->bts_end.output_enabled = 1;
- break;
-
- case MGCP_CONN_SEND_ONLY:
- endp->net_end.output_enabled = 1;
- endp->bts_end.output_enabled = 0;
- break;
-
- default:
- endp->net_end.output_enabled = 1;
- endp->bts_end.output_enabled = 1;
- break;
- }
-
+ endp->net_end.output_enabled =
+ endp->conn_mode & MGCP_CONN_SEND_ONLY ? 1 : 0;
+ endp->bts_end.output_enabled =
+ endp->conn_mode & MGCP_CONN_RECV_ONLY ? 1 : 0;
return ret;
}
@@ -877,7 +859,7 @@
if (p->cfg->change_cb)
p->cfg->change_cb(tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX);
- if (endp->bts_end.output_enabled && tcfg->keepalive_interval != 0)
+ if (endp->conn_mode & MGCP_CONN_RECV_ONLY && tcfg->keepalive_interval != 0)
mgcp_send_dummy(endp);
create_transcoder(endp);
@@ -979,7 +961,8 @@
if (p->cfg->change_cb)
p->cfg->change_cb(endp->tcfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX);
- if (endp->bts_end.output_enabled && endp->tcfg->keepalive_interval != 0)
+ if (endp->conn_mode & MGCP_CONN_RECV_ONLY &&
+ endp->tcfg->keepalive_interval != 0)
mgcp_send_dummy(endp);
if (silent)