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.
diff --git a/openbsc/src/mgcp/mgcp_network.c b/openbsc/src/mgcp/mgcp_network.c
index 729a89c..ea95c61 100644
--- a/openbsc/src/mgcp/mgcp_network.c
+++ b/openbsc/src/mgcp/mgcp_network.c
@@ -394,3 +394,25 @@
 	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;
+}