aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp/mgcp_network.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 08:08:17 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 08:08:17 +0800
commitf138f917ec7b535e0d71b8e70c71be7816e572da (patch)
tree0eeb40a4776413600697b0fef3114761a752ed46 /openbsc/src/mgcp/mgcp_network.c
parent1be9f2fddcfd9ba02f9f3a8203fa79b3b4e9b3e2 (diff)
mgcp: Allow to dynamically allocate ports from a range..
Allow to switch to a dynamic port allocator and not reuse the ports for a long time... This should help with a crazy network sending two streams at the same time.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_network.c')
-rw-r--r--openbsc/src/mgcp/mgcp_network.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index 729a89c95..ea95c6182 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -394,3 +394,25 @@ int mgcp_bind_net_rtp_port(struct mgcp_endpoint *endp, int rtp_port)
endp->net_end.rtcp.cb = rtp_data_net;
return bind_rtp(endp->cfg, &endp->net_end, ENDPOINT_NUMBER(endp));
}
+
+int mgcp_free_rtp_port(struct mgcp_rtp_end *end)
+{
+ if (end->local_alloc != PORT_ALLOC_DYNAMIC) {
+ LOGP(DMGCP, LOGL_ERROR, "Should only be called for dynamic ports.\n");
+ return -1;
+ }
+
+ if (end->rtp.fd != -1) {
+ close(end->rtp.fd);
+ end->rtp.fd = -1;
+ bsc_unregister_fd(&end->rtp);
+ }
+
+ if (end->rtcp.fd != -1) {
+ close(end->rtcp.fd);
+ end->rtcp.fd = -1;
+ bsc_unregister_fd(&end->rtcp);
+ }
+
+ return 0;
+}