Hi, I at last got myself a round tuit .. the attached patch is against inn-current of 20011028 and as such completely untested; I just made sure it compiles. OTOH, its 2.3.2 IPv6-enabled counterpart has been running on blackbush for over a month now, so there is a chance it won't just send you sky-high ;-) enjoy, spz PS: note the additional comment in hostReconfigure(). -- spz@serpens.de (S.P.Zeidler) -- Attached file included as plaintext by Listar -- --- host.c.orig Sun Oct 28 11:00:47 2001 +++ host.c Sun Oct 28 15:29:21 2001 @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,7 @@ { char *peerName; char *ipName; + char *bindaddrName; u_int articleTimeout; u_int responseTimeout; u_int initialConnections; @@ -507,12 +509,15 @@ params->peerName = xstrdup(params->peerName); if (params->ipName) params->ipName = xstrdup(params->ipName); + if (params->bindaddrName) + params->bindaddrName = xstrdup(params->bindaddrName); } else { /* Fill in defaults */ params->peerName=NULL; params->ipName=NULL; + params->bindaddrName=NULL; params->articleTimeout=ARTTOUT; params->responseTimeout=RESPTOUT; params->initialConnections=INIT_CXNS; @@ -548,6 +553,8 @@ FREE (params->peerName) ; if (params->ipName) FREE (params->ipName) ; + if (params->bindaddrName) + FREE (params->bindaddrName) ; FREE (params) ; } @@ -556,6 +563,10 @@ u_int i, absMaxCxns ; double oldBacklogFilter ; + /* some way down, without having used the h->params->ipName, we free it + in freeHostParams(h->params). Why strdup it here then? + */ + if (strcmp(h->params->ipName, params->ipName) != 0) { FREE (h->params->ipName) ; @@ -670,10 +681,13 @@ params = newHostParams(defaultParams); ASSERT(params->peerName == NULL); ASSERT(params->ipName == NULL); + ASSERT(params->bindaddrName == NULL); ASSERT(h->params->peerName != NULL); ASSERT(h->params->ipName != NULL); params->peerName = xstrdup(h->params->peerName); params->ipName = xstrdup(h->params->ipName); + if (h->params->bindaddrName != NULL) + params->bindaddrName = xstrdup(h->params->bindaddrName); hostReconfigure(h, params); h->removeOnReload = true; } @@ -1210,6 +1224,28 @@ return returnAddr ; } +int hostBindAddr (Host host, struct sockaddr_in *bindaddr) +{ + struct sockaddr_in ipAddr; + char *nodename; + char *msgstr[SMBUF] ; + int i; + + ASSERT(host->params != NULL); + ASSERT(bindaddr != NULL); + + /* see if the ipName we're given is a dotted quad (must be for inet_aton) */ + if ( !inet_aton (host->params->bindaddrName, + &((&ipAddr)->sin_addr)) ) + { + /* not an error, but just nothing to bind to */ + return (0); + } + (&ipAddr)->sin_family = AF_INET; + memcpy(bindaddr, &ipAddr, sizeof(ipAddr)) ; + + return (1); +} void gPrintHostInfo (FILE *fp, u_int indentAmt) { @@ -2613,6 +2649,8 @@ GETREAL(s,fp,"dynamic-backlog-low",0.0,100.0,REQ,p->dynBacklogLowWaterMark, inherit); GETREAL(s,fp,"dynamic-backlog-high",0.0,100.0,REQ,p->dynBacklogHighWaterMark, inherit); + getString (s,"bindaddress",&(p->bindaddrName),inherit); + l=p->lowPassLow; h=p->lowPassHigh; if (l > h) @@ -2692,6 +2730,9 @@ FREE (host->cxnSleeping) ; FREE (host->params->peerName) ; FREE (host->params->ipName) ; + + if (host->params->bindaddrName) + FREE (host->params->bindaddrName) ; if (host->ipAddrs) FREE (host->ipAddrs) ; --- host.h.orig Sun Oct 28 11:00:47 2001 +++ host.h Sun Oct 28 15:40:49 2001 @@ -107,6 +107,12 @@ /* return an IP address for the host */ struct in_addr *hostIpAddr (Host host) ; +#if defined (_NETINET_IN_H_) /* only gets used in connection.c which + includes netinet/in.h anyway */ +/* return our IP address to originate the connection from, if specified */ +int hostBindAddr (Host host, struct sockaddr_in *bindaddr); +#endif + /* * Functions used by the Connection to indicate Connection state. */ --- connection.c.orig Sun Oct 28 11:00:46 2001 +++ connection.c Sun Oct 28 14:08:56 2001 @@ -254,7 +254,6 @@ static u_int gCxnCount = 0 ; static u_int max_reconnect_period = MAX_RECON_PER ; static u_int init_reconnect_period = INIT_RECON_PER ; -static u_long bind_addr = INADDR_ANY; #if 0 static bool inited = false ; #endif @@ -366,7 +365,6 @@ char *sv ; int rval = 1 ; FILE *fp = (FILE *) data ; - struct in_addr addr ; if (getInteger (topScope,"max-reconnect-time",&iv,NO_INHERIT)) { @@ -396,19 +394,6 @@ iv = INIT_RECON_PER ; init_reconnect_period = (u_int) iv ; - if (getString (topScope,"bindaddress",&sv,NO_INHERIT)) - { - if (!inet_aton(sv,&addr)) - { - logOrPrint (LOG_ERR,fp,"innfeed unable to determine bind ip") ; - bind_addr = INADDR_ANY; - } - else - bind_addr = addr.s_addr; - } - else - bind_addr = INADDR_ANY; - return rval ; } @@ -573,13 +558,10 @@ } /* bind to a specified virtual host */ - if (bind_addr != INADDR_ANY) + if (hostBindAddr(cxn->myHost, &cxnSelf)) { - memset (&cxnSelf, 0, sizeof (cxnSelf)) ; - cxnSelf.sin_family = AF_INET ; - cxnSelf.sin_port = 0 ; - cxnSelf.sin_addr.s_addr = bind_addr; - if (bind (fd, (struct sockaddr *) &cxnSelf,sizeof (cxnSelf)) < 0) + if (bind (fd, (struct sockaddr *) &cxnSelf, + SA_LEN((struct sockaddr *) &cxnSelf)) < 0) { syslog (LOG_ERR,"bind: %m") ;