aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc_msc_ip.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 08:41:52 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 08:41:52 +0200
commitfd876b7488a8ae924f1a09144265d4474495408f (patch)
tree0c6ecb0d6434d84e6101dd0e8636371405974742 /openbsc/src/bsc_msc_ip.c
parent2ffe7aa340abd2333584730ff6471064b6fcaa1c (diff)
bsc_msc_ip: Use the autobind functionality of the kernel
We do not care about the source port for the callagent relay and can use the autobind functionality of the kernel to pick a port for us...
Diffstat (limited to 'openbsc/src/bsc_msc_ip.c')
-rw-r--r--openbsc/src/bsc_msc_ip.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c
index 0fcfdbe37..166726342 100644
--- a/openbsc/src/bsc_msc_ip.c
+++ b/openbsc/src/bsc_msc_ip.c
@@ -637,7 +637,6 @@ static void mgcp_forward(struct msgb *msg)
static int mgcp_create_port(void)
{
int on;
- int port;
struct sockaddr_in addr;
mgcp_agent.bfd.fd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -649,26 +648,10 @@ static int mgcp_create_port(void)
on = 1;
setsockopt(mgcp_agent.bfd.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
- /* try to bind the socket */
+ /* connect to the remote by using autobind */
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- for (port = 2727; port < 3000; ++port) {
- addr.sin_port = htons(port);
- if (bind(mgcp_agent.bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) == 0)
- break;
- perror("foo");
- }
-
- if (port >= 3000) {
- LOGP(DMGCP, LOGL_FATAL, "Failed to bind to any port.\n");
- close(mgcp_agent.bfd.fd);
- mgcp_agent.bfd.fd = -1;
- return -1;
- }
-
- /* connect to the remote */
addr.sin_port = htons(2427);
if (connect(mgcp_agent.bfd.fd, (struct sockaddr *) & addr, sizeof(addr)) < 0) {
LOGP(DMGCP, LOGL_FATAL, "Failed to connect to local MGCP GW. %d\n", errno);