Index: cfg_file.y =================================================================== RCS file: /cvsroot/vtun/vtun/cfg_file.y,v retrieving revision 1.1.1.2.2.13.2.2 diff -r1.1.1.2.2.13.2.2 cfg_file.y 74c74 < %token K_OPTIONS K_DEFAULT K_PORT K_PERSIST K_TIMEOUT --- > %token K_OPTIONS K_DEFAULT K_PORT K_BINDADDR K_PERSIST K_TIMEOUT 145,146c145,146 < if(vtun.svr_port == -1) < vtun.svr_port = $2; --- > if(vtun.bind_addr.port == -1) > vtun.bind_addr.port = $2; 148a149,150 > | K_BINDADDR '{' bindaddr_option '}' > 196a199,220 > bindaddr_option: > K_ADDR WORD { > vtun.bind_addr.name = strdup($2); > vtun.bind_addr.type = VTUN_ADDR_NAME; > } > > | K_IFACE WORD { > vtun.bind_addr.name = strdup($2); > vtun.bind_addr.type = VTUN_ADDR_IFACE; > } > > | K_IFACE STRING { > vtun.bind_addr.name = strdup($2); > vtun.bind_addr.type = VTUN_ADDR_IFACE; > } > > | K_ERROR { > cfg_error("Unknown option '%s'",$1); > YYABORT; > } > ; > Index: cfg_kwords.h =================================================================== RCS file: /cvsroot/vtun/vtun/cfg_kwords.h,v retrieving revision 1.1.1.1.2.3.2.6 diff -r1.1.1.1.2.3.2.6 cfg_kwords.h 38a39 > { "bindaddr", K_BINDADDR }, Index: main.c =================================================================== RCS file: /cvsroot/vtun/vtun/main.c,v retrieving revision 1.1.1.2.2.8.2.2 diff -r1.1.1.2.2.8.2.2 main.c 75c75 < vtun.svr_port = -1; --- > vtun.bind_addr.port = -1; 108c108 < vtun.svr_port = atoi(optarg); --- > vtun.bind_addr.port = atoi(optarg); 154,155c154,155 < if(vtun.svr_port == -1) < vtun.svr_port = VTUN_PORT; --- > if(vtun.bind_addr.port == -1) > vtun.bind_addr.port = VTUN_PORT; Index: netlib.c =================================================================== RCS file: /cvsroot/vtun/vtun/netlib.c,v retrieving revision 1.7.2.4 diff -r1.7.2.4 netlib.c 210d209 < struct hostent * hent; 221,242c220,221 < memset(addr, 0, sizeof(struct sockaddr_in)); < addr->sin_family = AF_INET; < switch( host->src_addr.type ){ < case VTUN_ADDR_IFACE: < if( !( addr->sin_addr.s_addr = getifaddr(host->src_addr.name)) ){ < vtun_syslog(LOG_ERR,"Can't get address of interface %s", < host->src_addr.name); < return -1; < } < break; < case VTUN_ADDR_NAME: < if( !(hent = gethostbyname(host->src_addr.name)) ){ < vtun_syslog(LOG_ERR,"Can't resolv local address %s", < host->src_addr.name); < return -1; < } < addr->sin_addr.s_addr = *(unsigned long *)hent->h_addr; < break; < default: < addr->sin_addr.s_addr = INADDR_ANY; < break; < } --- > if (generic_addr(addr, &host->src_addr) < 0) > return -1; 244,245d222 < if( host->src_addr.port ) < addr->sin_port = htons(host->src_addr.port); 258c235 < addr->sin_port = htons(vtun.svr_port); --- > addr->sin_port = htons(vtun.bind_addr.port); 271c248 < host->sopt.rport = vtun.svr_port; --- > host->sopt.rport = vtun.bind_addr.port; 274a252,290 > > /* Set address by interface name, ip address or hostname */ > int generic_addr(struct sockaddr_in *addr, struct vtun_addr *vaddr) > { > struct hostent *hent; > memset(addr, 0, sizeof(struct sockaddr_in)); > > addr->sin_family = AF_INET; > > switch (vaddr->type) { > case VTUN_ADDR_IFACE: > if (!(addr->sin_addr.s_addr = > getifaddr(vaddr->name))) { > vtun_syslog(LOG_ERR, > "Can't get address of interface %s", > vaddr->name); > return -1; > } > break; > case VTUN_ADDR_NAME: > if (!(hent = gethostbyname(vaddr->name))) { > vtun_syslog(LOG_ERR, > "Can't resolv local address %s", > vaddr->name); > return -1; > } > addr->sin_addr.s_addr = *(unsigned long *) hent->h_addr; > break; > default: > addr->sin_addr.s_addr = INADDR_ANY; > break; > } > > if (vaddr->port) > addr->sin_port = htons(vaddr->port); > > return 0; > } > Index: netlib.h =================================================================== RCS file: /cvsroot/vtun/vtun/netlib.h,v retrieving revision 1.2.2.1 diff -r1.2.2.1 netlib.h 39a40 > int generic_addr(struct sockaddr_in *addr, struct vtun_addr *vaddr); Index: server.c =================================================================== RCS file: /cvsroot/vtun/vtun/server.c,v retrieving revision 1.4.2.5.2.2 diff -r1.4.2.5.2.2 server.c 93c93 < host->sopt.lport = vtun.svr_port; --- > host->sopt.lport = vtun.bind_addr.port; 121,127c121,126 < my_addr.sin_addr.s_addr = INADDR_ANY; < my_addr.sin_port = htons(vtun.svr_port); < if (NULL != vtun.svr_addr) { /* Set to NULL near main.c:74 so if not NULL, we know it changed */ < /* currently we are ONLY accepting iface names for the addr. Later we'll do IPs too. */ < if ( !(my_addr.sin_addr.s_addr = getifaddr (vtun.svr_addr))) { < vtun_syslog(LOG_ERR,"Can't resolve server interface: %s; using INADDR_ANY", vtun.svr_addr); < } --- > > /* Set listen address */ > if( generic_addr(&my_addr, &vtun.bind_addr) < 0) > { > vtun_syslog(LOG_ERR, "Can't fill in listen socket"); > exit(1); 155c154 < set_title("waiting for connections on port %d", vtun.svr_port); --- > set_title("waiting for connections on port %d", vtun.bind_addr.port); Index: vtun.h =================================================================== RCS file: /cvsroot/vtun/vtun/vtun.h,v retrieving revision 1.7.2.6.2.4 diff -r1.7.2.6.2.4 vtun.h 205c205 < int svr_port; /* Server's port */ --- > struct vtun_addr bind_addr; /* Server should listen on this address */ Index: vtund.conf =================================================================== RCS file: /cvsroot/vtun/vtun/vtund.conf,v retrieving revision 1.1.1.2.2.4.2.2 diff -r1.1.1.2.2.4.2.2 vtund.conf 40a41,59 > # bindaddr - Server listen address. Used to force vtund to bind > # to the specific address and port in server mode. > # Format: > # bindaddr { > # option .....; > # }; > # > # 'bindaddr' options: > # > # iface - Use interface address as the listen address. > # Format: > # iface if_name; > # > # addr - Listen address. > # Format: > # addr ip_address; > # addr host_name; > # > # ----------- 214c233 < # to the specific address and port. --- > # to the specific address and port in client mode. 253c272,273 < port 5000; # Listen on this port. --- > port 5000; # Listen on this port. > bindaddr { iface lo; }; # Listen only on loopback device. Index: vtund.conf.5 =================================================================== RCS file: /cvsroot/vtun/vtun/vtund.conf.5,v retrieving revision 1.1.2.6.2.1 diff -r1.1.2.6.2.1 vtund.conf.5 57a58,74 > .IP \fBbindaddr\ \fIlist\fR > server listen address. Used to force vtund to bind to the specific > address and port in server mode. Format: > .nf > \fBbindaddr\fR { > \fIoption \fIvalue\fR; > }; > .fi > .IP > \fBbindaddr\fR options: > .RS > .IP \fBiface\ \fIif_name\fR > use interface address \fIif_name\fR as the bind address. > .IP \fBaddr\ \fIaddr\fR > bind address. Can be either IP address or host name. > .RE >