]>
Commit | Line | Data |
---|---|---|
6fca7355 ER |
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 *)); | |
7 | ||
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 | |
16 | @@ -66,7 +66,15 @@ | |
17 | #endif /* IPv6 Support */ | |
18 | ||
19 | extern int listen_to_virtual_ips; | |
20 | -extern const char *specific_interface; | |
21 | + | |
22 | +/* interface names to listen on */ | |
23 | +struct specific_interface { | |
24 | + const char *name; | |
25 | + ISC_LINK(struct specific_interface) link; | |
26 | +}; | |
27 | + | |
28 | +ISC_LIST(struct specific_interface) specific_interface_list; | |
29 | + | |
30 | ||
31 | #if defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP) | |
32 | #if defined(CMSG_FIRSTHDR) | |
33 | @@ -924,14 +932,15 @@ address_okay(struct interface *iface) { | |
34 | /* | |
35 | * Check if the interface is specified | |
36 | */ | |
37 | - if (specific_interface != NULL) { | |
38 | - if (strcasecmp(iface->name, specific_interface) == 0) { | |
39 | - DPRINTF(4, ("address_okay: specific interface name matched - OK\n")); | |
40 | - return (ISC_TRUE); | |
41 | - } else { | |
42 | - DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n")); | |
43 | - return (ISC_FALSE); | |
44 | - } | |
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")); | |
50 | + return (ISC_TRUE); | |
51 | + } | |
52 | + DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n")); | |
53 | + return (ISC_FALSE); | |
54 | } | |
55 | else { | |
56 | if (listen_to_virtual_ips == 0 && | |
57 | @@ -1044,6 +1053,23 @@ refresh_interface(struct interface * int | |
58 | #endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */ | |
59 | } | |
60 | ||
61 | +void | |
62 | +add_specific_interface (const char *if_name) | |
63 | +{ | |
64 | + struct specific_interface *iface; | |
65 | + | |
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); | |
70 | +} | |
71 | + | |
72 | +void | |
73 | +init_specific_interface (void) | |
74 | +{ | |
75 | + ISC_LIST_INIT(specific_interface_list); | |
76 | +} | |
77 | + | |
78 | /* | |
79 | * interface_update - externally callable update function | |
80 | */ | |
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 | |
84 | @@ -22,7 +22,6 @@ | |
85 | * Definitions of things either imported from or exported to outside | |
86 | */ | |
87 | extern char const *progname; | |
88 | -extern const char *specific_interface; | |
89 | extern short default_ai_family; | |
90 | ||
91 | #ifdef HAVE_NETINFO | |
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 | |
96 | #endif | |
97 | ||
98 | int listen_to_virtual_ips = 1; | |
99 | -const char *specific_interface = NULL; /* interface name or IP address to bind to */ | |
100 | ||
101 | /* | |
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; | |
106 | ||
107 | + init_specific_interface(); | |
108 | + | |
109 | if (HAVE_OPT( INTERFACE )) { | |
110 | -#if 0 | |
111 | int ifacect = STACKCT_OPT( INTERFACE ); | |
112 | - char** ifaces = STACKLST_OPT( INTERFACE ); | |
113 | + const char** ifaces = STACKLST_OPT( INTERFACE ); | |
114 | ||
115 | - /* malloc space for the array of names */ | |
116 | - while (ifacect-- > 0) { | |
117 | - next_iface = *ifaces++; | |
118 | - } | |
119 | -#else | |
120 | - specific_interface = OPT_ARG( INTERFACE ); | |
121 | -#endif | |
122 | + while (ifacect-- > 0) | |
123 | + add_specific_interface(*ifaces++); | |
124 | } | |
125 | ||
126 | if (HAVE_OPT( NICE )) |