Revert "bsc_msc_ip: Use the autobind functionality of the kernel"

The autobind is not working as I wanted it to work. So we will
revert this for now and then try something else.

This reverts commit fd876b7488.
This commit is contained in:
Holger Hans Peter Freyther 2010-04-04 15:24:11 +02:00
parent c33701c4e5
commit 860c8955c3
1 changed files with 18 additions and 1 deletions

View File

@ -642,6 +642,7 @@ 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);
@ -653,10 +654,26 @@ static int mgcp_create_port(void)
on = 1;
setsockopt(mgcp_agent.bfd.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
/* connect to the remote by using autobind */
/* try to bind the socket */
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);