diff -up ntp-4.2.4p4/include/ntpd.h.multilisten ntp-4.2.4p4/include/ntpd.h --- ntp-4.2.4p4/include/ntpd.h.multilisten 2006-12-28 13:03:06.000000000 +0100 +++ ntp-4.2.4p4/include/ntpd.h 2007-10-25 14:48:46.000000000 +0200 @@ -79,6 +79,8 @@ extern void enable_broadcast P((struct extern void enable_multicast_if P((struct interface *, struct sockaddr_storage *)); extern void interface_dump P((struct interface *)); +extern void add_specific_interface P((const char *)); +extern void init_specific_interface P((void)); extern void interface_update P((interface_receiver_t, void *)); extern void init_io P((void)); extern void input_handler P((l_fp *)); diff -up ntp-4.2.4p4/ntpd/ntp_io.c.multilisten ntp-4.2.4p4/ntpd/ntp_io.c --- ntp-4.2.4p4/ntpd/ntp_io.c.multilisten 2007-08-18 22:24:44.000000000 +0200 +++ ntp-4.2.4p4/ntpd/ntp_io.c 2007-10-25 14:48:46.000000000 +0200 @@ -66,7 +66,15 @@ #endif /* IPv6 Support */ extern int listen_to_virtual_ips; -extern const char *specific_interface; + +/* interface names to listen on */ +struct specific_interface { + const char *name; + ISC_LINK(struct specific_interface) link; +}; + +ISC_LIST(struct specific_interface) specific_interface_list; + #if defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP) #if defined(CMSG_FIRSTHDR) @@ -924,14 +932,15 @@ address_okay(struct interface *iface) { /* * Check if the interface is specified */ - if (specific_interface != NULL) { - if (strcasecmp(iface->name, specific_interface) == 0) { - DPRINTF(4, ("address_okay: specific interface name matched - OK\n")); - return (ISC_TRUE); - } else { - DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n")); - return (ISC_FALSE); - } + if (ISC_LIST_HEAD(specific_interface_list)) { + struct specific_interface *iface_; + for (iface_ = ISC_LIST_HEAD(specific_interface_list); iface_ != NULL; iface_ = ISC_LIST_NEXT(iface_, link)) + if (strcasecmp(iface->name, iface_->name) == 0) { + DPRINTF(4, ("address_okay: specific interface name matched - OK\n")); + return (ISC_TRUE); + } + DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n")); + return (ISC_FALSE); } else { if (listen_to_virtual_ips == 0 && @@ -1044,6 +1053,23 @@ refresh_interface(struct interface * int #endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */ } +void +add_specific_interface (const char *if_name) +{ + struct specific_interface *iface; + + iface = (struct specific_interface *)emalloc(sizeof(struct specific_interface)); + iface->name = if_name; + ISC_LINK_INIT(iface, link); + ISC_LIST_APPEND(specific_interface_list, iface, link); +} + +void +init_specific_interface (void) +{ + ISC_LIST_INIT(specific_interface_list); +} + /* * interface_update - externally callable update function */ diff -up ntp-4.2.4p4/ntpd/cmd_args.c.multilisten ntp-4.2.4p4/ntpd/cmd_args.c --- ntp-4.2.4p4/ntpd/cmd_args.c.multilisten 2007-08-18 22:24:43.000000000 +0200 +++ ntp-4.2.4p4/ntpd/cmd_args.c 2007-10-25 14:50:44.000000000 +0200 @@ -22,7 +22,6 @@ * Definitions of things either imported from or exported to outside */ extern char const *progname; -extern const char *specific_interface; extern short default_ai_family; #ifdef HAVE_NETINFO diff -up ntp-4.2.4p4/ntpd/ntpd.c.multilisten ntp-4.2.4p4/ntpd/ntpd.c --- ntp-4.2.4p4/ntpd/ntpd.c.multilisten 2007-10-25 14:48:46.000000000 +0200 +++ ntp-4.2.4p4/ntpd/ntpd.c 2007-10-25 14:48:46.000000000 +0200 @@ -156,7 +156,6 @@ volatile int debug = 0; /* No debugging #endif int listen_to_virtual_ips = 1; -const char *specific_interface = NULL; /* interface name or IP address to bind to */ /* * No-fork flag. If set, we do not become a background daemon. @@ -537,18 +536,14 @@ ntpdmain( if (HAVE_OPT( NOVIRTUALIPS )) listen_to_virtual_ips = 0; + init_specific_interface(); + if (HAVE_OPT( INTERFACE )) { -#if 0 int ifacect = STACKCT_OPT( INTERFACE ); - char** ifaces = STACKLST_OPT( INTERFACE ); + const char** ifaces = STACKLST_OPT( INTERFACE ); - /* malloc space for the array of names */ - while (ifacect-- > 0) { - next_iface = *ifaces++; - } -#else - specific_interface = OPT_ARG( INTERFACE ); -#endif + while (ifacect-- > 0) + add_specific_interface(*ifaces++); } if (HAVE_OPT( NICE ))