1 diff -up ntp-4.2.4p4/include/ntpd.h.multilisten ntp-4.2.4p4/include/ntpd.h
2 --- ntp-4.2.4p4/include/ntpd.h.multilisten 2006-12-28 13:03:06.000000000 +0100
3 +++ ntp-4.2.4p4/include/ntpd.h 2007-10-25 14:48:46.000000000 +0200
4 @@ -79,6 +79,8 @@ extern void enable_broadcast P((struct
5 extern void enable_multicast_if P((struct interface *, struct sockaddr_storage *));
6 extern void interface_dump P((struct interface *));
8 +extern void add_specific_interface P((const char *));
9 +extern void init_specific_interface P((void));
10 extern void interface_update P((interface_receiver_t, void *));
11 extern void init_io P((void));
12 extern void input_handler P((l_fp *));
13 diff -up ntp-4.2.4p4/ntpd/ntp_io.c.multilisten ntp-4.2.4p4/ntpd/ntp_io.c
14 --- ntp-4.2.4p4/ntpd/ntp_io.c.multilisten 2007-08-18 22:24:44.000000000 +0200
15 +++ ntp-4.2.4p4/ntpd/ntp_io.c 2007-10-25 14:48:46.000000000 +0200
17 #endif /* IPv6 Support */
19 extern int listen_to_virtual_ips;
20 -extern const char *specific_interface;
22 +/* interface names to listen on */
23 +struct specific_interface {
25 + ISC_LINK(struct specific_interface) link;
28 +ISC_LIST(struct specific_interface) specific_interface_list;
31 #if defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP)
32 #if defined(CMSG_FIRSTHDR)
33 @@ -924,14 +932,15 @@ address_okay(struct interface *iface) {
35 * Check if the interface is specified
37 - if (specific_interface != NULL) {
38 - if (strcasecmp(iface->name, specific_interface) == 0) {
39 - DPRINTF(4, ("address_okay: specific interface name matched - OK\n"));
42 - DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n"));
45 + if (ISC_LIST_HEAD(specific_interface_list)) {
46 + struct specific_interface *iface_;
47 + for (iface_ = ISC_LIST_HEAD(specific_interface_list); iface_ != NULL; iface_ = ISC_LIST_NEXT(iface_, link))
48 + if (strcasecmp(iface->name, iface_->name) == 0) {
49 + DPRINTF(4, ("address_okay: specific interface name matched - OK\n"));
52 + DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n"));
56 if (listen_to_virtual_ips == 0 &&
57 @@ -1044,6 +1053,23 @@ refresh_interface(struct interface * int
58 #endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
62 +add_specific_interface (const char *if_name)
64 + struct specific_interface *iface;
66 + iface = (struct specific_interface *)emalloc(sizeof(struct specific_interface));
67 + iface->name = if_name;
68 + ISC_LINK_INIT(iface, link);
69 + ISC_LIST_APPEND(specific_interface_list, iface, link);
73 +init_specific_interface (void)
75 + ISC_LIST_INIT(specific_interface_list);
79 * interface_update - externally callable update function
81 diff -up ntp-4.2.4p4/ntpd/cmd_args.c.multilisten ntp-4.2.4p4/ntpd/cmd_args.c
82 --- ntp-4.2.4p4/ntpd/cmd_args.c.multilisten 2007-08-18 22:24:43.000000000 +0200
83 +++ ntp-4.2.4p4/ntpd/cmd_args.c 2007-10-25 14:50:44.000000000 +0200
85 * Definitions of things either imported from or exported to outside
87 extern char const *progname;
88 -extern const char *specific_interface;
89 extern short default_ai_family;
92 diff -up ntp-4.2.4p4/ntpd/ntpd.c.multilisten ntp-4.2.4p4/ntpd/ntpd.c
93 --- ntp-4.2.4p4/ntpd/ntpd.c.multilisten 2007-10-25 14:48:46.000000000 +0200
94 +++ ntp-4.2.4p4/ntpd/ntpd.c 2007-10-25 14:48:46.000000000 +0200
95 @@ -156,7 +156,6 @@ volatile int debug = 0; /* No debugging
98 int listen_to_virtual_ips = 1;
99 -const char *specific_interface = NULL; /* interface name or IP address to bind to */
102 * No-fork flag. If set, we do not become a background daemon.
103 @@ -537,18 +536,14 @@ ntpdmain(
104 if (HAVE_OPT( NOVIRTUALIPS ))
105 listen_to_virtual_ips = 0;
107 + init_specific_interface();
109 if (HAVE_OPT( INTERFACE )) {
111 int ifacect = STACKCT_OPT( INTERFACE );
112 - char** ifaces = STACKLST_OPT( INTERFACE );
113 + const char** ifaces = STACKLST_OPT( INTERFACE );
115 - /* malloc space for the array of names */
116 - while (ifacect-- > 0) {
117 - next_iface = *ifaces++;
120 - specific_interface = OPT_ARG( INTERFACE );
122 + while (ifacect-- > 0)
123 + add_specific_interface(*ifaces++);
126 if (HAVE_OPT( NICE ))