MT#13895 support binding to a single interface address

mr4.0.1
Richard Fuchs 11 years ago
parent 6b98414e5a
commit 71b7293b7f

@ -118,6 +118,7 @@ static int window = 1000; /* u-sec prior to target that we will let audio go */
static int codec = AST_FORMAT_SLINEAR; /* negotiated codec */
static int port = 4569;
static unsigned long interface = 0;
static int refreshreq = 300; /* requested refresh */
static int refresh = 300; /* negotiated refresh, initialize equal to refreshreq */
static int codecreq = AST_FORMAT_SLINEAR; /* requested codec */
@ -341,6 +342,12 @@ setconfigline(char *line)
port = atoi(line);
printlog(LOG_INFO, "Setting port = %d\n", port);
}
if (strncasecmp(line, "interface", 9) == 0) {
line += 9;
while (*line == '\t' || *line == ' ') line++;
interface = inet_addr(line);
printlog(LOG_INFO, "Setting interface = %lu\n", interface);
}
if (strncasecmp(line, "refresh", 7) == 0) {
line += 7;
while (*line == '\t' || *line == ' ') line++;
@ -877,8 +884,9 @@ iaxmodem(const char *config, int nondaemon)
setegid(uucp_gid);
seteuid(uucp_uid);
if ((port = iax_init(port) < 0)) {
printlog(LOG_ERROR, "Fatal error: failed to initialize iax with port %d\n", port);
if ((port = iax_init(port, interface) < 0)) {
printlog(LOG_ERROR, "Fatal error: failed to initialize iax with port %d and interface %lu\n",
port, interface);
cleanup(-1);
}
iaxnetfd = iax_get_fd();

@ -138,7 +138,7 @@ extern "C"
/* Called to initialize IAX structures and sockets. Returns actual
portnumber (which it will try preferred portno first, but if not
take what it can get */
extern int iax_init(int preferredportno);
extern int iax_init(int preferredportno, unsigned long interface);
/* Get filedescriptor for IAX to use with select or gtk_input_add */
extern int iax_get_fd(void);

@ -911,7 +911,7 @@ void iax_set_jb_target_extra( long value )
jb_target_extra = value ;
}
int iax_init(int preferredportno)
int iax_init(int preferredportno, unsigned long interface)
{
int portno = preferredportno;
@ -943,7 +943,7 @@ int iax_init(int preferredportno)
preferredportno = 0;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
sin.sin_addr.s_addr = interface;
sin.sin_port = htons((short)preferredportno);
if (bind(netfd, (struct sockaddr *) &sin, sizeof(sin)) < 0)
{

@ -389,7 +389,7 @@ main(int argc, char *argv[])
return -1;
}
if ( (port = iax_init(0) < 0)) {
if ( (port = iax_init(0, 0) < 0)) {
fprintf(stderr, "Fatal error: failed to initialize iax with port %d\n", port);
return -1;
}

@ -270,7 +270,7 @@ main(int argc, char *argv[])
/* initialize the audio in buffer structures */
memset(&whin,0,sizeof(whin));
if ( (port = iax_init(0) < 0)) {
if ( (port = iax_init(0, 0) < 0)) {
fprintf(stderr, "Fatal error: failed to initialize iax with port %d\n", port);
return -1;
}

Loading…
Cancel
Save