From f138f917ec7b535e0d71b8e70c71be7816e572da Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 5 Aug 2010 08:08:17 +0800 Subject: 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. --- openbsc/src/mgcp/mgcp_network.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'openbsc/src/mgcp/mgcp_network.c') 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; +} -- cgit v1.2.3