diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-04-04 15:53:38 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-04-04 15:53:38 +0200 |
commit | e51cf4f946820e688f9992ab405b7ed34a863d3a (patch) | |
tree | 91db3c21beb8955ef3884754ca608baf980f297f /openbsc | |
parent | 749ba7f5ad4be88b0bf2a845558475e95685b780 (diff) |
bsc_msc_ip.c: Use another kernel feature to bind to a random port
Diffstat (limited to 'openbsc')
-rw-r--r-- | openbsc/src/bsc_msc_ip.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/openbsc/src/bsc_msc_ip.c b/openbsc/src/bsc_msc_ip.c index 9cb341c7d..0275df734 100644 --- a/openbsc/src/bsc_msc_ip.c +++ b/openbsc/src/bsc_msc_ip.c @@ -658,15 +658,9 @@ static int mgcp_create_port(void) memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + addr.sin_port = 0; - 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) { + if (bind(mgcp_agent.bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { LOGP(DMGCP, LOGL_FATAL, "Failed to bind to any port.\n"); close(mgcp_agent.bfd.fd); mgcp_agent.bfd.fd = -1; |