ISC DHCP  4.4.1
A reference DHCPv4 and DHCPv6 implementation
socket.c
Go to the documentation of this file.
1 /* socket.c
2 
3  BSD socket interface code... */
4 
5 /*
6  * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 1995-2003 by Internet Software Consortium
8  *
9  * This Source Code Form is subject to the terms of the Mozilla Public
10  * License, v. 2.0. If a copy of the MPL was not distributed with this
11  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  *
21  * Internet Systems Consortium, Inc.
22  * 950 Charter Street
23  * Redwood City, CA 94063
24  * <info@isc.org>
25  * https://www.isc.org/
26  *
27  */
28 
29 /* SO_BINDTODEVICE support added by Elliot Poger (poger@leland.stanford.edu).
30  * This sockopt allows a socket to be bound to a particular interface,
31  * thus enabling the use of DHCPD on a multihomed host.
32  * If SO_BINDTODEVICE is defined in your system header files, the use of
33  * this sockopt will be automatically enabled.
34  * I have implemented it under Linux; other systems should be doable also.
35  */
36 
37 #include "dhcpd.h"
38 #include <isc/util.h>
39 #include <errno.h>
40 #include <sys/ioctl.h>
41 #include <sys/uio.h>
42 #include <sys/uio.h>
43 
44 #if defined(sun) && defined(USE_V4_PKTINFO)
45 #include <sys/sysmacros.h>
46 #include <net/if.h>
47 #include <sys/sockio.h>
48 #include <net/if_dl.h>
49 #include <sys/dlpi.h>
50 #endif
51 
52 #ifdef USE_SOCKET_FALLBACK
53 # if !defined (USE_SOCKET_SEND)
54 # define if_register_send if_register_fallback
55 # define send_packet send_fallback
56 # define if_reinitialize_send if_reinitialize_fallback
57 # endif
58 #endif
59 
60 #if defined(DHCPv6)
61 /*
62  * XXX: this is gross. we need to go back and overhaul the API for socket
63  * handling.
64  */
65 static int no_global_v6_socket = 0;
66 static unsigned int global_v6_socket_references = 0;
67 static int global_v6_socket = -1;
68 #if defined(RELAY_PORT)
69 static unsigned int relay_port_v6_socket_references = 0;
70 static int relay_port_v6_socket = -1;
71 #endif
72 
73 static void if_register_multicast(struct interface_info *info);
74 #endif
75 
76 /*
77  * We can use a single socket for AF_INET (similar to AF_INET6) on all
78  * interfaces configured for DHCP if the system has support for IP_PKTINFO
79  * and IP_RECVPKTINFO (for example Solaris 11).
80  */
81 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
82 static unsigned int global_v4_socket_references = 0;
83 static int global_v4_socket = -1;
84 #endif
85 
86 /*
87  * If we can't bind() to a specific interface, then we can only have
88  * a single socket. This variable insures that we don't try to listen
89  * on two sockets.
90  */
91 #if !defined(SO_BINDTODEVICE) && !defined(USE_FALLBACK)
92 static int once = 0;
93 #endif /* !defined(SO_BINDTODEVICE) && !defined(USE_FALLBACK) */
94 
95 /* Reinitializes the specified interface after an address change. This
96  is not required for packet-filter APIs. */
97 
98 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
99 void if_reinitialize_send (info)
100  struct interface_info *info;
101 {
102 #if 0
103 #ifndef USE_SOCKET_RECEIVE
104  once = 0;
105  close (info -> wfdesc);
106 #endif
107  if_register_send (info);
108 #endif
109 }
110 #endif
111 
112 #ifdef USE_SOCKET_RECEIVE
113 void if_reinitialize_receive (info)
114  struct interface_info *info;
115 {
116 #if 0
117  once = 0;
118  close (info -> rfdesc);
119  if_register_receive (info);
120 #endif
121 }
122 #endif
123 
124 #if defined (USE_SOCKET_SEND) || \
125  defined (USE_SOCKET_RECEIVE) || \
126  defined (USE_SOCKET_FALLBACK)
127 /* Generic interface registration routine... */
128 int
129 if_register_socket(struct interface_info *info, int family,
130  int *do_multicast, struct in6_addr *linklocal6)
131 {
132  struct sockaddr_storage name;
133  int name_len;
134  int sock;
135  int flag;
136  int domain;
137 #ifdef DHCPv6
138  struct sockaddr_in6 *addr6;
139 #endif
140  struct sockaddr_in *addr;
141 
142  /* INSIST((family == AF_INET) || (family == AF_INET6)); */
143 
144 #if !defined(SO_BINDTODEVICE) && !defined(USE_FALLBACK)
145  /* Make sure only one interface is registered. */
146  if (once) {
147  log_fatal ("The standard socket API can only support %s",
148  "hosts with a single network interface.");
149  }
150  once = 1;
151 #endif
152 
153  /*
154  * Set up the address we're going to bind to, depending on the
155  * address family.
156  */
157  memset(&name, 0, sizeof(name));
158  switch (family) {
159 #ifdef DHCPv6
160  case AF_INET6:
161  addr6 = (struct sockaddr_in6 *)&name;
162  addr6->sin6_family = AF_INET6;
163  addr6->sin6_port = local_port;
164 #if defined(RELAY_PORT)
165  if (relay_port &&
167  addr6->sin6_port = relay_port;
168 #endif
169  /* A server feature */
170  if (bind_local_address6) {
171  memcpy(&addr6->sin6_addr,
173  sizeof(addr6->sin6_addr));
174  }
175  /* A client feature */
176  if (linklocal6) {
177  memcpy(&addr6->sin6_addr,
178  linklocal6,
179  sizeof(addr6->sin6_addr));
180  }
181  if (IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr)) {
182  addr6->sin6_scope_id = if_nametoindex(info->name);
183  }
184 #ifdef HAVE_SA_LEN
185  addr6->sin6_len = sizeof(*addr6);
186 #endif
187  name_len = sizeof(*addr6);
188  domain = PF_INET6;
189  if ((info->flags & INTERFACE_STREAMS) == INTERFACE_UPSTREAM) {
190  *do_multicast = 0;
191  }
192  break;
193 #endif /* DHCPv6 */
194 
195  case AF_INET:
196  default:
197  addr = (struct sockaddr_in *)&name;
198  addr->sin_family = AF_INET;
199  addr->sin_port = relay_port ? relay_port : local_port;
200  memcpy(&addr->sin_addr,
201  &local_address,
202  sizeof(addr->sin_addr));
203 #ifdef HAVE_SA_LEN
204  addr->sin_len = sizeof(*addr);
205 #endif
206  name_len = sizeof(*addr);
207  domain = PF_INET;
208  break;
209  }
210 
211  /* Make a socket... */
212  sock = socket(domain, SOCK_DGRAM, IPPROTO_UDP);
213  if (sock < 0) {
214  log_fatal("Can't create dhcp socket: %m");
215  }
216 
217  /* Set the REUSEADDR option so that we don't fail to start if
218  we're being restarted. */
219  flag = 1;
220  if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
221  (char *)&flag, sizeof(flag)) < 0) {
222  log_fatal("Can't set SO_REUSEADDR option on dhcp socket: %m");
223  }
224 
225  /* Set the BROADCAST option so that we can broadcast DHCP responses.
226  We shouldn't do this for fallback devices, and we can detect that
227  a device is a fallback because it has no ifp structure. */
228  if (info->ifp &&
229  (setsockopt(sock, SOL_SOCKET, SO_BROADCAST,
230  (char *)&flag, sizeof(flag)) < 0)) {
231  log_fatal("Can't set SO_BROADCAST option on dhcp socket: %m");
232  }
233 
234 #if defined(DHCPv6) && defined(SO_REUSEPORT)
235  /*
236  * We only set SO_REUSEPORT on AF_INET6 sockets, so that multiple
237  * daemons can bind to their own sockets and get data for their
238  * respective interfaces. This does not (and should not) affect
239  * DHCPv4 sockets; we can't yet support BSD sockets well, much
240  * less multiple sockets. Make sense only with multicast.
241  * RedHat defines SO_REUSEPORT with a kernel which does not support
242  * it and returns ENOPROTOOPT so in this case ignore the error.
243  */
244  if ((local_family == AF_INET6) && *do_multicast) {
245  flag = 1;
246  if ((setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
247  (char *)&flag, sizeof(flag)) < 0) &&
248  (errno != ENOPROTOOPT)) {
249  log_fatal("Can't set SO_REUSEPORT option on dhcp "
250  "socket: %m");
251  }
252  }
253 #endif
254 
255  /* Bind the socket to this interface's IP address. */
256  if (bind(sock, (struct sockaddr *)&name, name_len) < 0) {
257  log_error("Can't bind to dhcp address: %m");
258  log_error("Please make sure there is no other dhcp server");
259  log_error("running and that there's no entry for dhcp or");
260  log_error("bootp in /etc/inetd.conf. Also make sure you");
261  log_error("are not running HP JetAdmin software, which");
262  log_fatal("includes a bootp server.");
263  }
264 
265 #if defined(SO_BINDTODEVICE)
266  /* Bind this socket to this interface. */
267  if ((local_family != AF_INET6) && (info->ifp != NULL) &&
268  setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
269  (char *)(info -> ifp), sizeof(*(info -> ifp))) < 0) {
270  log_fatal("setsockopt: SO_BINDTODEVICE: %m");
271  }
272 #endif
273 
274  /* IP_BROADCAST_IF instructs the kernel which interface to send
275  * IP packets whose destination address is 255.255.255.255. These
276  * will be treated as subnet broadcasts on the interface identified
277  * by ip address (info -> primary_address). This is only known to
278  * be defined in SCO system headers, and may not be defined in all
279  * releases.
280  */
281 #if defined(SCO) && defined(IP_BROADCAST_IF)
282  if (info->address_count &&
283  setsockopt(sock, IPPROTO_IP, IP_BROADCAST_IF, &info->addresses[0],
284  sizeof(info->addresses[0])) < 0)
285  log_fatal("Can't set IP_BROADCAST_IF on dhcp socket: %m");
286 #endif
287 
288 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
289  /*
290  * If we turn on IP_RECVPKTINFO we will be able to receive
291  * the interface index information of the received packet.
292  */
293  if (family == AF_INET) {
294  int on = 1;
295  if (setsockopt(sock, IPPROTO_IP, IP_RECVPKTINFO,
296  &on, sizeof(on)) != 0) {
297  log_fatal("setsockopt: IPV_RECVPKTINFO: %m");
298  }
299  }
300 #endif
301 
302 #ifdef DHCPv6
303  /*
304  * If we turn on IPV6_PKTINFO, we will be able to receive
305  * additional information, such as the destination IP address.
306  * We need this to spot unicast packets.
307  */
308  if (family == AF_INET6) {
309  int on = 1;
310 #ifdef IPV6_RECVPKTINFO
311  /* RFC3542 */
312  if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO,
313  &on, sizeof(on)) != 0) {
314  log_fatal("setsockopt: IPV6_RECVPKTINFO: %m");
315  }
316 #else
317  /* RFC2292 */
318  if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO,
319  &on, sizeof(on)) != 0) {
320  log_fatal("setsockopt: IPV6_PKTINFO: %m");
321  }
322 #endif
323  }
324 
325 #endif /* DHCPv6 */
326 
327  return sock;
328 }
329 
330 #ifdef DHCPv6
331 void set_multicast_hop_limit(struct interface_info* info, int hop_limit) {
332  if (setsockopt(info->wfdesc, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
333  &hop_limit, sizeof(int)) < 0) {
334  log_fatal("setMulticaseHopLimit: IPV6_MULTICAST_HOPS: %m");
335  }
336 
337  log_debug("Setting hop count limit to %d for interface %s",
338  hop_limit, info->name);
339 
340 }
341 #endif /* DHCPv6 */
342 
343 #endif /* USE_SOCKET_SEND || USE_SOCKET_RECEIVE || USE_SOCKET_FALLBACK */
344 
345 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
346 void if_register_send (info)
347  struct interface_info *info;
348 {
349 #ifndef USE_SOCKET_RECEIVE
350  info->wfdesc = if_register_socket(info, AF_INET, 0, NULL);
351  /* If this is a normal IPv4 address, get the hardware address. */
352  if (strcmp(info->name, "fallback") != 0)
353  get_hw_addr(info);
354 #if defined (USE_SOCKET_FALLBACK)
355  /* Fallback only registers for send, but may need to receive as
356  well. */
357  info->rfdesc = info->wfdesc;
358 #endif
359 #else
360  info->wfdesc = info->rfdesc;
361 #endif
363  log_info ("Sending on Socket/%s%s%s",
364  info->name,
365  (info->shared_network ? "/" : ""),
366  (info->shared_network ?
367  info->shared_network->name : ""));
368 }
369 
370 #if defined (USE_SOCKET_SEND)
371 void if_deregister_send (info)
372  struct interface_info *info;
373 {
374 #ifndef USE_SOCKET_RECEIVE
375  close (info -> wfdesc);
376 #endif
377  info -> wfdesc = -1;
378 
380  log_info ("Disabling output on Socket/%s%s%s",
381  info -> name,
382  (info -> shared_network ? "/" : ""),
383  (info -> shared_network ?
384  info -> shared_network -> name : ""));
385 }
386 #endif /* USE_SOCKET_SEND */
387 #endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
388 
389 #ifdef USE_SOCKET_RECEIVE
390 void if_register_receive (info)
391  struct interface_info *info;
392 {
393 
394 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
395  if (global_v4_socket_references == 0) {
396  global_v4_socket = if_register_socket(info, AF_INET, 0, NULL);
397  if (global_v4_socket < 0) {
398  /*
399  * if_register_socket() fatally logs if it fails to
400  * create a socket, this is just a sanity check.
401  */
402  log_fatal("Failed to create AF_INET socket %s:%d",
403  MDL);
404  }
405  }
406 
407  info->rfdesc = global_v4_socket;
408  global_v4_socket_references++;
409 #else
410  /* If we're using the socket API for sending and receiving,
411  we don't need to register this interface twice. */
412  info->rfdesc = if_register_socket(info, AF_INET, 0, NULL);
413 #endif /* IP_PKTINFO... */
414  /* If this is a normal IPv4 address, get the hardware address. */
415  if (strcmp(info->name, "fallback") != 0)
416  get_hw_addr(info);
417 
419  log_info ("Listening on Socket/%s%s%s",
420  info->name,
421  (info->shared_network ? "/" : ""),
422  (info->shared_network ?
423  info->shared_network->name : ""));
424 }
425 
426 void if_deregister_receive (info)
427  struct interface_info *info;
428 {
429 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
430  /* Dereference the global v4 socket. */
431  if ((info->rfdesc == global_v4_socket) &&
432  (global_v4_socket_references > 0)) {
433  global_v4_socket_references--;
434  info->rfdesc = -1;
435  } else {
436  log_fatal("Impossible condition at %s:%d", MDL);
437  }
438 
439  if (global_v4_socket_references == 0) {
440  close(global_v4_socket);
441  global_v4_socket = -1;
442  }
443 #else
444  close(info->rfdesc);
445  info->rfdesc = -1;
446 #endif /* IP_PKTINFO... */
448  log_info ("Disabling input on Socket/%s%s%s",
449  info -> name,
450  (info -> shared_network ? "/" : ""),
451  (info -> shared_network ?
452  info -> shared_network -> name : ""));
453 }
454 #endif /* USE_SOCKET_RECEIVE */
455 
456 
457 #ifdef DHCPv6
458 /*
459  * This function joins the interface to DHCPv6 multicast groups so we will
460  * receive multicast messages.
461  */
462 static void
463 if_register_multicast(struct interface_info *info) {
464  int sock = info->rfdesc;
465  struct ipv6_mreq mreq;
466 
467  if (inet_pton(AF_INET6, All_DHCP_Relay_Agents_and_Servers,
468  &mreq.ipv6mr_multiaddr) <= 0) {
469  log_fatal("inet_pton: unable to convert '%s'",
471  }
472  mreq.ipv6mr_interface = if_nametoindex(info->name);
473  if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
474  &mreq, sizeof(mreq)) < 0) {
475  log_fatal("setsockopt: IPV6_JOIN_GROUP: %m");
476  }
477 
478  /*
479  * The relay agent code sets the streams so you know which way
480  * is up and down. But a relay agent shouldn't join to the
481  * Server address, or else you get fun loops. So up or down
482  * doesn't matter, we're just using that config to sense this is
483  * a relay agent.
484  */
485  if ((info->flags & INTERFACE_STREAMS) == 0) {
486  if (inet_pton(AF_INET6, All_DHCP_Servers,
487  &mreq.ipv6mr_multiaddr) <= 0) {
488  log_fatal("inet_pton: unable to convert '%s'",
490  }
491  mreq.ipv6mr_interface = if_nametoindex(info->name);
492  if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
493  &mreq, sizeof(mreq)) < 0) {
494  log_fatal("setsockopt: IPV6_JOIN_GROUP: %m");
495  }
496  }
497 }
498 
499 void
500 if_register6(struct interface_info *info, int do_multicast) {
501  /* Bounce do_multicast to a stack variable because we may change it. */
502  int req_multi = do_multicast;
503 
504  if (no_global_v6_socket) {
505  log_fatal("Impossible condition at %s:%d", MDL);
506  }
507 
508 #if defined(RELAY_PORT)
509  if (!relay_port ||
511 #endif
512  if (global_v6_socket_references == 0) {
513  global_v6_socket = if_register_socket(info, AF_INET6,
514  &req_multi, NULL);
515  if (global_v6_socket < 0) {
516  /*
517  * if_register_socket() fatally logs if it fails to
518  * create a socket, this is just a sanity check.
519  */
520  log_fatal("Impossible condition at %s:%d", MDL);
521  } else if (bind_local_address6) {
522  char addr6_str[INET6_ADDRSTRLEN];
523 
524  if (inet_ntop(AF_INET6,
526  addr6_str,
527  sizeof(addr6_str)) == NULL) {
528  log_fatal("inet_ntop: unable to convert "
529  "local-address6");
530  }
531  log_info("Bound to [%s]:%d",
532  addr6_str,
533  (int) ntohs(local_port));
534  } else {
535  log_info("Bound to *:%d", (int) ntohs(local_port));
536  }
537  }
538 
539  info->rfdesc = global_v6_socket;
540  info->wfdesc = global_v6_socket;
541  global_v6_socket_references++;
542 
543 #if defined(RELAY_PORT)
544  } else {
545  /*
546  * If relay port is defined, we need to register one
547  * IPv6 UPD socket to handle upstream server or relay agent
548  * with a non-547 UDP local port.
549  */
550  if ((relay_port_v6_socket_references == 0) &&
551  ((info->flags & INTERFACE_STREAMS) == INTERFACE_UPSTREAM)) {
552  relay_port_v6_socket = if_register_socket(info, AF_INET6,
553  &req_multi, NULL);
554  if (relay_port_v6_socket < 0) {
555  log_fatal("Impossible condition at %s:%d", MDL);
556  } else {
557  log_info("Bound to relay port *:%d",
558  (int) ntohs(relay_port));
559  }
560  }
561  info->rfdesc = relay_port_v6_socket;
562  info->wfdesc = relay_port_v6_socket;
563  relay_port_v6_socket_references++;
564  }
565 #endif
566 
567  if (req_multi)
568  if_register_multicast(info);
569 
570  get_hw_addr(info);
571 
573  if (info->shared_network != NULL) {
574  log_info("Listening on Socket/%d/%s/%s",
575  global_v6_socket, info->name,
576  info->shared_network->name);
577  log_info("Sending on Socket/%d/%s/%s",
578  global_v6_socket, info->name,
579  info->shared_network->name);
580  } else {
581  log_info("Listening on Socket/%s", info->name);
582  log_info("Sending on Socket/%s", info->name);
583  }
584  }
585 }
586 
587 /*
588  * Register an IPv6 socket bound to the link-local address of
589  * the argument interface (used by clients on a multiple interface box,
590  * vs. a server or a relay using the global IPv6 socket and running
591  * *only* in a single instance).
592  */
593 void
595  int sock;
596  int count;
597  struct in6_addr *addr6 = NULL;
598  int req_multi = 0;
599 
600  if (global_v6_socket >= 0) {
601  log_fatal("Impossible condition at %s:%d", MDL);
602  }
603 
604  no_global_v6_socket = 1;
605 
606  /* get the (?) link-local address */
607  for (count = 0; count < info->v6address_count; count++) {
608  addr6 = &info->v6addresses[count];
609  if (IN6_IS_ADDR_LINKLOCAL(addr6))
610  break;
611  }
612 
613  if (!addr6) {
614  log_fatal("no link-local IPv6 address for %s", info->name);
615  }
616 
617  sock = if_register_socket(info, AF_INET6, &req_multi, addr6);
618 
619  if (sock < 0) {
620  log_fatal("if_register_socket for %s fails", info->name);
621  }
622 
623  info->rfdesc = sock;
624  info->wfdesc = sock;
625 
626  get_hw_addr(info);
627 
629  if (info->shared_network != NULL) {
630  log_info("Listening on Socket/%d/%s/%s",
631  global_v6_socket, info->name,
632  info->shared_network->name);
633  log_info("Sending on Socket/%d/%s/%s",
634  global_v6_socket, info->name,
635  info->shared_network->name);
636  } else {
637  log_info("Listening on Socket/%s", info->name);
638  log_info("Sending on Socket/%s", info->name);
639  }
640  }
641 }
642 
643 void
644 if_deregister6(struct interface_info *info) {
645  /* client case */
646  if (no_global_v6_socket) {
647  close(info->rfdesc);
648  info->rfdesc = -1;
649  info->wfdesc = -1;
650  } else if ((info->rfdesc == global_v6_socket) &&
651  (info->wfdesc == global_v6_socket) &&
652  (global_v6_socket_references > 0)) {
653  /* Dereference the global v6 socket. */
654  global_v6_socket_references--;
655  info->rfdesc = -1;
656  info->wfdesc = -1;
657 #if defined(RELAY_PORT)
658  } else if (relay_port &&
659  (info->rfdesc == relay_port_v6_socket) &&
660  (info->wfdesc == relay_port_v6_socket) &&
661  (relay_port_v6_socket_references > 0)) {
662  /* Dereference the relay port v6 socket. */
663  relay_port_v6_socket_references--;
664  info->rfdesc = -1;
665  info->wfdesc = -1;
666 #endif
667  } else {
668  log_fatal("Impossible condition at %s:%d", MDL);
669  }
670 
672  if (info->shared_network != NULL) {
673  log_info("Disabling input on Socket/%s/%s", info->name,
674  info->shared_network->name);
675  log_info("Disabling output on Socket/%s/%s", info->name,
676  info->shared_network->name);
677  } else {
678  log_info("Disabling input on Socket/%s", info->name);
679  log_info("Disabling output on Socket/%s", info->name);
680  }
681  }
682 
683  if (!no_global_v6_socket) {
684  if (global_v6_socket_references == 0) {
685  close(global_v6_socket);
686  global_v6_socket = -1;
687 
688  log_info("Unbound from *:%d",
689  (int) ntohs(local_port));
690  }
691 #if defined(RELAY_PORT)
692  if (relay_port && (relay_port_v6_socket_references == 0)) {
693  close(relay_port_v6_socket);
694  relay_port_v6_socket = -1;
695 
696  log_info("Unbound from relay port *:%d",
697  (int) ntohs(relay_port));
698  }
699 #endif
700  }
701 }
702 #endif /* DHCPv6 */
703 
704 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_FALLBACK)
705 ssize_t send_packet (interface, packet, raw, len, from, to, hto)
706  struct interface_info *interface;
707  struct packet *packet;
708  struct dhcp_packet *raw;
709  size_t len;
710  struct in_addr from;
711  struct sockaddr_in *to;
712  struct hardware *hto;
713 {
714  int result;
715 #ifdef IGNORE_HOSTUNREACH
716  int retry = 0;
717  do {
718 #endif
719 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
720  struct in_pktinfo pktinfo;
721 
722  if (interface->ifp != NULL) {
723  memset(&pktinfo, 0, sizeof (pktinfo));
724  pktinfo.ipi_ifindex = interface->ifp->ifr_index;
725  if (setsockopt(interface->wfdesc, IPPROTO_IP,
726  IP_PKTINFO, (char *)&pktinfo,
727  sizeof(pktinfo)) < 0)
728  log_fatal("setsockopt: IP_PKTINFO: %m");
729  }
730 #endif
731  result = sendto (interface -> wfdesc, (char *)raw, len, 0,
732  (struct sockaddr *)to, sizeof *to);
733 #ifdef IGNORE_HOSTUNREACH
734  } while (to -> sin_addr.s_addr == htonl (INADDR_BROADCAST) &&
735  result < 0 &&
736  (errno == EHOSTUNREACH ||
737  errno == ECONNREFUSED) &&
738  retry++ < 10);
739 #endif
740  if (result < 0) {
741  log_error ("send_packet: %m");
742  if (errno == ENETUNREACH)
743  log_error ("send_packet: please consult README file%s",
744  " regarding broadcast address.");
745  }
746  return result;
747 }
748 
749 #endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
750 
751 #ifdef DHCPv6
752 /*
753  * Solaris 9 is missing the CMSG_LEN and CMSG_SPACE macros, so we will
754  * synthesize them (based on the BIND 9 technique).
755  */
756 
757 #ifndef CMSG_LEN
758 static size_t CMSG_LEN(size_t len) {
759  size_t hdrlen;
760  /*
761  * Cast NULL so that any pointer arithmetic performed by CMSG_DATA
762  * is correct.
763  */
764  hdrlen = (size_t)CMSG_DATA(((struct cmsghdr *)NULL));
765  return hdrlen + len;
766 }
767 #endif /* !CMSG_LEN */
768 
769 #ifndef CMSG_SPACE
770 static size_t CMSG_SPACE(size_t len) {
771  struct msghdr msg;
772  struct cmsghdr *cmsgp;
773 
774  /*
775  * XXX: The buffer length is an ad-hoc value, but should be enough
776  * in a practical sense.
777  */
778  union {
779  struct cmsghdr cmsg_sizer;
780  u_int8_t pktinfo_sizer[sizeof(struct cmsghdr) + 1024];
781  } dummybuf;
782 
783  memset(&msg, 0, sizeof(msg));
784  msg.msg_control = &dummybuf;
785  msg.msg_controllen = sizeof(dummybuf);
786 
787  cmsgp = (struct cmsghdr *)&dummybuf;
788  cmsgp->cmsg_len = CMSG_LEN(len);
789 
790  cmsgp = CMSG_NXTHDR(&msg, cmsgp);
791  if (cmsgp != NULL) {
792  return (char *)cmsgp - (char *)msg.msg_control;
793  } else {
794  return 0;
795  }
796 }
797 #endif /* !CMSG_SPACE */
798 
799 #endif /* DHCPv6 */
800 
801 #if defined(DHCPv6) || \
802  (defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && \
803  defined(USE_V4_PKTINFO))
804 /*
805  * For both send_packet6() and receive_packet6() we need to allocate
806  * space for the cmsg header information. We do this once and reuse
807  * the buffer. We also need the control buf for send_packet() and
808  * receive_packet() when we use a single socket and IP_PKTINFO to
809  * send the packet out the correct interface.
810  */
811 static void *control_buf = NULL;
812 static size_t control_buf_len = 0;
813 
814 static void
815 allocate_cmsg_cbuf(void) {
816  control_buf_len = CMSG_SPACE(sizeof(struct in6_pktinfo));
817  control_buf = dmalloc(control_buf_len, MDL);
818  return;
819 }
820 #endif /* DHCPv6, IP_PKTINFO ... */
821 
822 #ifdef DHCPv6
823 /*
824  * For both send_packet6() and receive_packet6() we need to use the
825  * sendmsg()/recvmsg() functions rather than the simpler send()/recv()
826  * functions.
827  *
828  * In the case of send_packet6(), we need to do this in order to insure
829  * that the reply packet leaves on the same interface that it arrived
830  * on.
831  *
832  * In the case of receive_packet6(), we need to do this in order to
833  * get the IP address the packet was sent to. This is used to identify
834  * whether a packet is multicast or unicast.
835  *
836  * Helpful man pages: recvmsg, readv (talks about the iovec stuff), cmsg.
837  *
838  * Also see the sections in RFC 3542 about IPV6_PKTINFO.
839  */
840 
841 /* Send an IPv6 packet */
842 ssize_t send_packet6(struct interface_info *interface,
843  const unsigned char *raw, size_t len,
844  struct sockaddr_in6 *to) {
845  struct msghdr m;
846  struct iovec v;
847  struct sockaddr_in6 dst;
848  int result;
849  struct in6_pktinfo *pktinfo;
850  struct cmsghdr *cmsg;
851  unsigned int ifindex;
852 
853  /*
854  * If necessary allocate space for the control message header.
855  * The space is common between send and receive.
856  */
857 
858  if (control_buf == NULL) {
859  allocate_cmsg_cbuf();
860  if (control_buf == NULL) {
861  log_error("send_packet6: unable to allocate cmsg header");
862  return(ENOMEM);
863  }
864  }
865  memset(control_buf, 0, control_buf_len);
866 
867  /*
868  * Initialize our message header structure.
869  */
870  memset(&m, 0, sizeof(m));
871 
872  /*
873  * Set the target address we're sending to.
874  * Enforce the scope ID for bogus BSDs.
875  */
876  memcpy(&dst, to, sizeof(dst));
877  m.msg_name = &dst;
878  m.msg_namelen = sizeof(dst);
879  ifindex = if_nametoindex(interface->name);
880  if (no_global_v6_socket)
881  dst.sin6_scope_id = ifindex;
882 
883  /*
884  * Set the data buffer we're sending. (Using this wacky
885  * "scatter-gather" stuff... we only have a single chunk
886  * of data to send, so we declare a single vector entry.)
887  */
888  v.iov_base = (char *)raw;
889  v.iov_len = len;
890  m.msg_iov = &v;
891  m.msg_iovlen = 1;
892 
893  /*
894  * Setting the interface is a bit more involved.
895  *
896  * We have to create a "control message", and set that to
897  * define the IPv6 packet information. We could set the
898  * source address if we wanted, but we can safely let the
899  * kernel decide what that should be.
900  */
901  m.msg_control = control_buf;
902  m.msg_controllen = control_buf_len;
903  cmsg = CMSG_FIRSTHDR(&m);
904  INSIST(cmsg != NULL);
905  cmsg->cmsg_level = IPPROTO_IPV6;
906  cmsg->cmsg_type = IPV6_PKTINFO;
907  cmsg->cmsg_len = CMSG_LEN(sizeof(*pktinfo));
908  pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
909  memset(pktinfo, 0, sizeof(*pktinfo));
910  pktinfo->ipi6_addr = local_address6;
911  pktinfo->ipi6_ifindex = ifindex;
912 
913  result = sendmsg(interface->wfdesc, &m, 0);
914  if (result < 0) {
915  log_error("send_packet6: %m");
916  }
917  return result;
918 }
919 #endif /* DHCPv6 */
920 
921 #ifdef USE_SOCKET_RECEIVE
922 ssize_t receive_packet (interface, buf, len, from, hfrom)
923  struct interface_info *interface;
924  unsigned char *buf;
925  size_t len;
926  struct sockaddr_in *from;
927  struct hardware *hfrom;
928 {
929 #if !(defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO))
930  SOCKLEN_T flen = sizeof *from;
931 #endif
932  int result;
933 
934  /*
935  * The normal Berkeley socket interface doesn't give us any way
936  * to know what hardware interface we received the message on,
937  * but we should at least make sure the structure is emptied.
938  */
939  memset(hfrom, 0, sizeof(*hfrom));
940 
941 #ifdef IGNORE_HOSTUNREACH
942  int retry = 0;
943  do {
944 #endif
945 
946 #if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
947  struct msghdr m;
948  struct iovec v;
949  struct cmsghdr *cmsg;
950  struct in_pktinfo *pktinfo;
951  unsigned int ifindex;
952 
953  /*
954  * If necessary allocate space for the control message header.
955  * The space is common between send and receive.
956  */
957  if (control_buf == NULL) {
958  allocate_cmsg_cbuf();
959  if (control_buf == NULL) {
960  log_error("receive_packet: unable to allocate cmsg "
961  "header");
962  return(ENOMEM);
963  }
964  }
965  memset(control_buf, 0, control_buf_len);
966 
967  /*
968  * Initialize our message header structure.
969  */
970  memset(&m, 0, sizeof(m));
971 
972  /*
973  * Point so we can get the from address.
974  */
975  m.msg_name = from;
976  m.msg_namelen = sizeof(*from);
977 
978  /*
979  * Set the data buffer we're receiving. (Using this wacky
980  * "scatter-gather" stuff... but we that doesn't really make
981  * sense for us, so we use a single vector entry.)
982  */
983  v.iov_base = buf;
984  v.iov_len = len;
985  m.msg_iov = &v;
986  m.msg_iovlen = 1;
987 
988  /*
989  * Getting the interface is a bit more involved.
990  *
991  * We set up some space for a "control message". We have
992  * previously asked the kernel to give us packet
993  * information (when we initialized the interface), so we
994  * should get the interface index from that.
995  */
996  m.msg_control = control_buf;
997  m.msg_controllen = control_buf_len;
998 
999  result = recvmsg(interface->rfdesc, &m, 0);
1000 
1001  if (result >= 0) {
1002  /*
1003  * If we did read successfully, then we need to loop
1004  * through the control messages we received and
1005  * find the one with our inteface index.
1006  */
1007  cmsg = CMSG_FIRSTHDR(&m);
1008  while (cmsg != NULL) {
1009  if ((cmsg->cmsg_level == IPPROTO_IP) &&
1010  (cmsg->cmsg_type == IP_PKTINFO)) {
1011  pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
1012  ifindex = pktinfo->ipi_ifindex;
1013  /*
1014  * We pass the ifindex back to the caller
1015  * using the unused hfrom parameter avoiding
1016  * interface changes between sockets and
1017  * the discover code.
1018  */
1019  memcpy(hfrom->hbuf, &ifindex, sizeof(ifindex));
1020  return (result);
1021  }
1022  cmsg = CMSG_NXTHDR(&m, cmsg);
1023  }
1024 
1025  /*
1026  * We didn't find the necessary control message
1027  * flag it as an error
1028  */
1029  result = -1;
1030  errno = EIO;
1031  }
1032 #else
1033  result = recvfrom(interface -> rfdesc, (char *)buf, len, 0,
1034  (struct sockaddr *)from, &flen);
1035 #endif /* IP_PKTINFO ... */
1036 #ifdef IGNORE_HOSTUNREACH
1037  } while (result < 0 &&
1038  (errno == EHOSTUNREACH ||
1039  errno == ECONNREFUSED) &&
1040  retry++ < 10);
1041 #endif
1042  return (result);
1043 }
1044 
1045 #endif /* USE_SOCKET_RECEIVE */
1046 
1047 #ifdef DHCPv6
1048 ssize_t
1049 receive_packet6(struct interface_info *interface,
1050  unsigned char *buf, size_t len,
1051  struct sockaddr_in6 *from, struct in6_addr *to_addr,
1052  unsigned int *if_idx)
1053 {
1054  struct msghdr m;
1055  struct iovec v;
1056  int result;
1057  struct cmsghdr *cmsg;
1058  struct in6_pktinfo *pktinfo;
1059 
1060  /*
1061  * If necessary allocate space for the control message header.
1062  * The space is common between send and receive.
1063  */
1064  if (control_buf == NULL) {
1065  allocate_cmsg_cbuf();
1066  if (control_buf == NULL) {
1067  log_error("receive_packet6: unable to allocate cmsg "
1068  "header");
1069  return(ENOMEM);
1070  }
1071  }
1072  memset(control_buf, 0, control_buf_len);
1073 
1074  /*
1075  * Initialize our message header structure.
1076  */
1077  memset(&m, 0, sizeof(m));
1078 
1079  /*
1080  * Point so we can get the from address.
1081  */
1082  m.msg_name = from;
1083  m.msg_namelen = sizeof(*from);
1084 
1085  /*
1086  * Set the data buffer we're receiving. (Using this wacky
1087  * "scatter-gather" stuff... but we that doesn't really make
1088  * sense for us, so we use a single vector entry.)
1089  */
1090  v.iov_base = buf;
1091  v.iov_len = len;
1092  m.msg_iov = &v;
1093  m.msg_iovlen = 1;
1094 
1095  /*
1096  * Getting the interface is a bit more involved.
1097  *
1098  * We set up some space for a "control message". We have
1099  * previously asked the kernel to give us packet
1100  * information (when we initialized the interface), so we
1101  * should get the destination address from that.
1102  */
1103  m.msg_control = control_buf;
1104  m.msg_controllen = control_buf_len;
1105 
1106  result = recvmsg(interface->rfdesc, &m, 0);
1107 
1108  if (result >= 0) {
1109  /*
1110  * If we did read successfully, then we need to loop
1111  * through the control messages we received and
1112  * find the one with our destination address.
1113  */
1114  cmsg = CMSG_FIRSTHDR(&m);
1115  while (cmsg != NULL) {
1116  if ((cmsg->cmsg_level == IPPROTO_IPV6) &&
1117  (cmsg->cmsg_type == IPV6_PKTINFO)) {
1118  pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
1119  *to_addr = pktinfo->ipi6_addr;
1120  *if_idx = pktinfo->ipi6_ifindex;
1121 
1122  return (result);
1123  }
1124  cmsg = CMSG_NXTHDR(&m, cmsg);
1125  }
1126 
1127  /*
1128  * We didn't find the necessary control message
1129  * flag is as an error
1130  */
1131  result = -1;
1132  errno = EIO;
1133  }
1134 
1135  return (result);
1136 }
1137 #endif /* DHCPv6 */
1138 
1139 #if defined (USE_SOCKET_FALLBACK)
1140 /* This just reads in a packet and silently discards it. */
1141 
1142 isc_result_t fallback_discard (object)
1143  omapi_object_t *object;
1144 {
1145  char buf [1540];
1146  struct sockaddr_in from;
1147  SOCKLEN_T flen = sizeof from;
1148  int status;
1149  struct interface_info *interface;
1150 
1151  if (object -> type != dhcp_type_interface)
1152  return DHCP_R_INVALIDARG;
1153  interface = (struct interface_info *)object;
1154 
1155  status = recvfrom (interface -> wfdesc, buf, sizeof buf, 0,
1156  (struct sockaddr *)&from, &flen);
1157 #if defined (DEBUG)
1158  /* Only report fallback discard errors if we're debugging. */
1159  if (status < 0) {
1160  log_error ("fallback_discard: %m");
1161  return ISC_R_UNEXPECTED;
1162  }
1163 #else
1164  /* ignore the fact that status value is never used */
1165  IGNORE_UNUSED(status);
1166 #endif
1167  return ISC_R_SUCCESS;
1168 }
1169 #endif /* USE_SOCKET_FALLBACK */
1170 
1171 #if defined (USE_SOCKET_SEND)
1173  struct interface_info *ip;
1174 {
1175  return 0;
1176 }
1177 
1179  struct interface_info *ip;
1180 {
1181 #if defined (SOCKET_CAN_RECEIVE_UNICAST_UNCONFIGURED)
1182  return 1;
1183 #else
1184  return 0;
1185 #endif
1186 }
1187 
1189  struct interface_info *ip;
1190 {
1191 #if defined(SO_BINDTODEVICE) || \
1192  (defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && \
1193  defined(USE_V4_PKTINFO))
1194  return(1);
1195 #else
1196  return(0);
1197 #endif
1198 }
1199 
1200 /* If we have SO_BINDTODEVICE, set up a fallback interface; otherwise,
1201  do not. */
1202 
1203 void maybe_setup_fallback ()
1204 {
1205 #if defined (USE_SOCKET_FALLBACK)
1206  isc_result_t status;
1207  struct interface_info *fbi = (struct interface_info *)0;
1208  if (setup_fallback (&fbi, MDL)) {
1209  fbi -> wfdesc = if_register_socket (fbi, AF_INET, 0, NULL);
1210  fbi -> rfdesc = fbi -> wfdesc;
1211  log_info ("Sending on Socket/%s%s%s",
1212  fbi -> name,
1213  (fbi -> shared_network ? "/" : ""),
1214  (fbi -> shared_network ?
1215  fbi -> shared_network -> name : ""));
1216 
1217  status = omapi_register_io_object ((omapi_object_t *)fbi,
1218  if_readsocket, 0,
1219  fallback_discard, 0, 0);
1220  if (status != ISC_R_SUCCESS)
1221  log_fatal ("Can't register I/O handle for %s: %s",
1222  fbi -> name, isc_result_totext (status));
1223  interface_dereference (&fbi, MDL);
1224  }
1225 #endif
1226 }
1227 
1228 
1229 #if defined(sun) && defined(USE_V4_PKTINFO)
1230 /* This code assumes the existence of SIOCGLIFHWADDR */
1231 void
1232 get_hw_addr(const char *name, struct hardware *hw) {
1233  struct sockaddr_dl *dladdrp;
1234  int sock, i;
1235  struct lifreq lifr;
1236 
1237  memset(&lifr, 0, sizeof (lifr));
1238  (void) strlcpy(lifr.lifr_name, name, sizeof (lifr.lifr_name));
1239  /*
1240  * Check if the interface is a virtual or IPMP interface - in those
1241  * cases it has no hw address, so generate a random one.
1242  */
1243  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ||
1244  ioctl(sock, SIOCGLIFFLAGS, &lifr) < 0) {
1245  if (sock != -1)
1246  (void) close(sock);
1247 
1248 #ifdef DHCPv6
1249  /*
1250  * If approrpriate try this with an IPv6 socket
1251  */
1252  if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) >= 0 &&
1253  ioctl(sock, SIOCGLIFFLAGS, &lifr) >= 0) {
1254  goto flag_check;
1255  }
1256  if (sock != -1)
1257  (void) close(sock);
1258 #endif
1259  log_fatal("Couldn't get interface flags for %s: %m", name);
1260 
1261  }
1262 
1263  flag_check:
1264  if (lifr.lifr_flags & (IFF_VIRTUAL|IFF_IPMP)) {
1265  hw->hlen = sizeof (hw->hbuf);
1266  srandom((long)gethrtime());
1267 
1268  hw->hbuf[0] = HTYPE_IPMP;
1269  for (i = 1; i < hw->hlen; ++i) {
1270  hw->hbuf[i] = random() % 256;
1271  }
1272 
1273  if (sock != -1)
1274  (void) close(sock);
1275  return;
1276  }
1277 
1278  if (ioctl(sock, SIOCGLIFHWADDR, &lifr) < 0)
1279  log_fatal("Couldn't get interface hardware address for %s: %m",
1280  name);
1281  dladdrp = (struct sockaddr_dl *)&lifr.lifr_addr;
1282  hw->hlen = dladdrp->sdl_alen+1;
1283  switch (dladdrp->sdl_type) {
1284  case DL_CSMACD: /* IEEE 802.3 */
1285  case DL_ETHER:
1286  hw->hbuf[0] = HTYPE_ETHER;
1287  break;
1288  case DL_TPR:
1289  hw->hbuf[0] = HTYPE_IEEE802;
1290  break;
1291  case DL_FDDI:
1292  hw->hbuf[0] = HTYPE_FDDI;
1293  break;
1294  case DL_IB:
1295  hw->hbuf[0] = HTYPE_INFINIBAND;
1296  break;
1297  default:
1298  log_fatal("%s: unsupported DLPI MAC type %lu", name,
1299  (unsigned long)dladdrp->sdl_type);
1300  }
1301 
1302  memcpy(hw->hbuf+1, LLADDR(dladdrp), hw->hlen-1);
1303 
1304  if (sock != -1)
1305  (void) close(sock);
1306 }
1307 #endif /* defined(sun) */
1308 
1309 #endif /* USE_SOCKET_SEND */
void if_register_send(struct interface_info *)
#define IGNORE_UNUSED(x)
Definition: cdefs.h:67
isc_result_t omapi_register_io_object(omapi_object_t *, int(*)(omapi_object_t *), int(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *))
Definition: dispatch.c:198
#define SIOCGLIFFLAGS
Definition: discover.c:198
struct shared_network * shared_network
Definition: dhcpd.h:1369
u_int8_t hlen
Definition: dhcpd.h:492
int if_readsocket(omapi_object_t *h)
Definition: discover.c:1043
char name[IFNAMSIZ]
Definition: dhcpd.h:1393
void if_reinitialize_send(struct interface_info *)
#define All_DHCP_Relay_Agents_and_Servers
Definition: dhcp6.h:189
#define MDL
Definition: omapip.h:567
#define DHCP_R_INVALIDARG
Definition: result.h:48
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
int can_receive_unicast_unconfigured(struct interface_info *)
struct in_addr * addresses
Definition: dhcpd.h:1373
int setup_fallback(struct interface_info **fp, const char *file, int line)
Definition: discover.c:1054
int log_error(const char *,...) __attribute__((__format__(__printf__
void if_deregister_receive(struct interface_info *)
void get_hw_addr(struct interface_info *info)
void maybe_setup_fallback(void)
void if_deregister_send(struct interface_info *)
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int bind_local_address6
#define HTYPE_ETHER
Definition: dhcp.h:75
void if_deregister6(struct interface_info *info)
void if_register_linklocal6(struct interface_info *info)
#define HTYPE_INFINIBAND
Definition: dhcp.h:78
ssize_t send_packet6(struct interface_info *, const unsigned char *, size_t, struct sockaddr_in6 *)
u_int16_t local_port
Definition: dhclient.c:94
Definition: dhcpd.h:405
Definition: ip.h:47
ssize_t send_packet(struct interface_info *, struct packet *, struct dhcp_packet *, size_t, struct in_addr, struct sockaddr_in *, struct hardware *)
omapi_object_type_t * dhcp_type_interface
Definition: discover.c:80
int int log_info(const char *,...) __attribute__((__format__(__printf__
void * dmalloc(size_t, const char *, int)
Definition: alloc.c:57
u_int32_t flags
Definition: dhcpd.h:1407
int v6address_count
Definition: dhcpd.h:1380
void if_register6(struct interface_info *info, int do_multicast)
int local_family
Definition: discover.c:56
int quiet_interface_discovery
Definition: discover.c:44
#define HTYPE_FDDI
Definition: dhcp.h:77
#define HTYPE_IPMP
Definition: dhcp.h:79
#define All_DHCP_Servers
Definition: dhcp6.h:190
int supports_multiple_interfaces(struct interface_info *)
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
Definition: dhcpd.h:493
int address_count
Definition: dhcpd.h:1376
#define INTERFACE_UPSTREAM
Definition: dhcpd.h:1412
void set_multicast_hop_limit(struct interface_info *info, int hop_limit)
struct in_addr local_address
Definition: discover.c:57
ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, struct sockaddr_in *, struct hardware *)
#define HTYPE_IEEE802
Definition: dhcp.h:76
#define INTERFACE_DOWNSTREAM
Definition: dhcpd.h:1411
u_int16_t relay_port
Definition: discover.c:47
char * name
Definition: dhcpd.h:1046
#define SOCKLEN_T
Definition: osdep.h:280
void if_reinitialize_receive(struct interface_info *)
int can_unicast_without_arp(struct interface_info *)
void if_register_receive(struct interface_info *)
struct in6_addr local_address6
isc_result_t fallback_discard(omapi_object_t *)
#define INTERFACE_STREAMS
Definition: dhcpd.h:1413
struct ifreq * ifp
Definition: dhcpd.h:1403
int if_register_socket(struct interface_info *, int, int *, struct in6_addr *)
ssize_t receive_packet6(struct interface_info *interface, unsigned char *buf, size_t len, struct sockaddr_in6 *from, struct in6_addr *to_addr, unsigned int *if_index)
struct in6_addr * v6addresses
Definition: dhcpd.h:1378