32#define IF_LINE_LENGTH 1024
112 log_fatal (
"Can't register interface object type: %s",
162#if defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && defined(SIOCGLIFFLAGS)
167#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
168# define lifc_len iflc_len
169# define lifc_buf iflc_buf
170# define lifc_req iflc_req
171# define LIFCONF if_laddrconf
173# define ISC_HAVE_LIFC_FAMILY 1
174# define ISC_HAVE_LIFC_FLAGS 1
175# define LIFCONF lifconf
178#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
179# define lifr_addr iflr_addr
180# define lifr_name iflr_name
181# define lifr_dstaddr iflr_dstaddr
182# define lifr_flags iflr_flags
183# define sockaddr_storage sockaddr_ext
184# define ss_family sa_family
185# define LIFREQ if_laddrreq
187# define LIFREQ lifreq
191# if defined(LIFNAMSIZ)
192# define IF_NAMESIZE LIFNAMSIZ
193# elif defined(IFNAMSIZ)
194# define IF_NAMESIZE IFNAMSIZ
196# define IF_NAMESIZE 16
199#elif !defined(__linux) && !defined(HAVE_IFADDRS_H)
200# define SIOCGLIFCONF SIOCGIFCONF
201# define SIOCGLIFFLAGS SIOCGIFFLAGS
203# define LIFCONF ifconf
204# define lifr_name ifr_name
205# define lifr_addr ifr_addr
206# define lifr_flags ifr_flags
207# define lifc_len ifc_len
208# define lifc_buf ifc_buf
209# define lifc_req ifc_req
211# define ss_family __ss_family
215#if defined(SIOCGLIFCONF) && defined(SIOCGLIFFLAGS)
252#ifdef ISC_PLATFORM_HAVELIFNUM
260 log_error(
"Error creating socket to list interfaces; %m");
265#ifdef ISC_PLATFORM_HAVELIFNUM
270 log_error(
"Error finding total number of interfaces; %m");
276#ifdef ISC_PLATFORM_HAVELIFNUM
286#ifdef ISC_HAVE_LIFC_FAMILY
292 log_fatal(
"Out of memory getting interface list.");
296 log_error(
"Error getting interfaces configuration list; %m");
319#if defined(sun) || defined(__linux)
337 log_error(
"Interface name '%s' too long",
p->lifr_name);
349 memcpy(&
info->addr, &
p->lifr_addr,
sizeof(
p->lifr_addr));
351#if defined(sun) || defined(__linux)
366 log_error(
"Error getting interface flags for '%s'; %m",
427 log_error(
"Error getting interfaces; %m");
449 log_error(
"Interface name '%s' too long",
501 log_fatal(
"Out of memory saving IPv4 address "
504 iface->address_count = 0;
505 iface->address_max = 4;
506 }
else if (
iface->address_count >=
iface->address_max) {
513 log_fatal(
"Out of memory saving IPv4 address "
523 iface->addresses[
iface->address_count++] = *addr;
539 log_fatal(
"Out of memory saving IPv6 address "
542 iface->v6address_count = 0;
543 iface->v6address_max = 8;
544 }
else if (
iface->v6address_count >=
iface->v6address_max) {
551 log_fatal(
"Out of memory saving IPv6 address "
561 iface->v6addresses[
iface->v6address_count++] = *addr;
580 char abuf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
596 log_fatal(
"Can't get list of interfaces.");
646 log_fatal(
"Error allocating interface %s: %s",
660 (*dhcp_interface_discovery_hook)(
tmp);
686 (*dhcp_interface_setup_hook)(
tmp, &addr);
714 (*dhcp_interface_setup_hook)(
tmp, &addr);
721 log_fatal(
"Error getting interface information.");
813 log_info(
"No subnet declaration for %s (%s).",
816 "no IPv4 addresses" :
820 if (
tmp->v6addresses !=
NULL) {
822 &
tmp->v6addresses[0],
828 log_info(
"No subnet6 declaration for %s (%s).",
834 log_info (
"** Ignoring requests on %s. %s",
835 tmp -> name,
"If this is not what");
836 log_info (
" you want, please write %s",
839 "a subnet6 declaration" :
841 "a subnet declaration");
842 log_info (
" in your dhcpd.conf file %s",
843 "for the network segment");
846 tmp -> name,
"is attached. **");
853 "subnet6 declaration for this" :
855 "subnet declaration for this");
856 log_error (
"subnet. You cannot prevent %s",
858 log_error (
"from listening on this subnet %s",
860 log_fatal (
"operating system does not %s.",
861 "support this capability");
874 if (
tmp->address_count > 0) {
877 &
tmp->addresses[0].s_addr, 4);
878 }
else if (
tmp->v6address_count > 0) {
881 &
tmp->v6addresses[0].s6_addr,
886 "address",
tmp->name);
930 if ((
tmp -> rfdesc >= 0) &&
932 log_error (
"Can't set close-on-exec on %s: %m",
934 if ((
tmp -> wfdesc !=
tmp -> rfdesc) &&
935 (
tmp -> wfdesc >= 0) &&
937 log_error (
"Can't set close-on-exec on %s: %m",
956 if (
tmp -> rfdesc == -1)
962#define UPSTREAM(ifp) \
963 ((ifp->flags & INTERFACE_STREAMS) == INTERFACE_UPSTREAM)
964#define DOWNSTREAM(ifp) \
965 ((ifp->flags & INTERFACE_STREAMS) == INTERFACE_DOWNSTREAM)
1005 log_fatal (
"Can't register I/O handle for %s: %s",
1027 log_fatal (
"Not configured to listen on any interfaces!");
1036#if defined (F_SETFD)
1039 log_error (
"Can't set close-on-exec on fallback: %m");
1042 log_error (
"Can't set close-on-exec on fallback: %m");
1065 log_fatal (
"Error allocating fallback interface: %s",
1133#if defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO)
1157 from.sin_port,
ifrom, &hfrom);
1187 log_error(
"receive_packet6() failed on %s: %m",
ip->name);
1216 (*dhcpv6_packet_handler)(
ip, buf,
1240 value -> u.buffer.len <
sizeof interface -> name) {
1241 memcpy (interface -> name,
1242 value -> u.buffer.value,
1243 value -> u.buffer.len);
1251 if (h ->
inner && h ->
inner -> type -> set_value) {
1252 status = ((*(h ->
inner -> type -> set_value))
1279 if (interface -> ifp) {
1281 interface -> ifp = 0;
1283 if (interface -> next)
1285 if (interface -> rbuf) {
1287 interface -> rbuf = (
unsigned char *)0;
1289 if (interface -> client)
1311 if (!
strcmp (name,
"update")) {
1313 if (
ip == interface)
1319 if (
ip == interface)
1326 if (h ->
inner && h ->
inner -> type -> signal_handler) {
1327 status = ((*(h ->
inner -> type -> signal_handler))
1359 if (h ->
inner && h ->
inner -> type -> stuff_values) {
1360 status = ((*(h ->
inner -> type -> stuff_values))
1402 interface = interface -> next) {
1405 len =
s - &
interface -> name [0];
1408 if ((
tv ->
value -> u.buffer.len == len &&
1409 !
memcmp (interface -> name,
1410 (
char *)
tv ->
value -> u.buffer.value,
1416 interface;
interface = interface -> next) {
1419 len =
s - &
interface -> name [0];
1422 if ((
tv ->
value -> u.buffer.len == len &&
1423 !
memcmp (interface -> name,
1425 tv ->
value -> u.buffer.value,
1435 }
else if (!interface) {
1479 if (
ip == interface) {
1510 (*dhcp_interface_shutdown_hook) (interface);
1549 log_error (
"interface_stash: allocation failed ");
1569#if defined (TRACING)
void trace_interface_input(trace_type_t *, unsigned, char *)
void trace_interface_register(trace_type_t *, struct interface_info *)
void trace_outpacket_input(trace_type_t *, unsigned, char *)
void trace_inpacket_input(trace_type_t *, unsigned, char *)
void trace_interface_stop(trace_type_t *)
void trace_outpacket_stop(trace_type_t *)
void trace_inpacket_stop(trace_type_t *)
#define DHCP_FIXED_NON_UDP
void if_reinitialize_receive(struct interface_info *)
void maybe_setup_fallback(void)
#define INTERFACE_RUNNING
#define DISCOVER_REQUESTED
trace_type_t * inpacket_trace
#define INTERFACE_REQUESTED
void interface_trace_setup(void)
int supports_multiple_interfaces(struct interface_info *)
void if_deregister_send(struct interface_info *)
trace_type_t * outpacket_trace
#define DISCOVER_SERVER46
#define INTERFACE_STREAMS
void try_hw_addr(struct interface_info *info)
void if_reinitialize_send(struct interface_info *)
void if_register_linklocal6(struct interface_info *info)
void if_deregister6(struct interface_info *info)
ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, struct sockaddr_in *, struct hardware *)
void get_hw_addr(struct interface_info *info)
void(* dhcpv6_packet_handler)(struct interface_info *, const char *, int, int, const struct iaddr *, isc_boolean_t)
struct in6_addr local_address6
void if_register_receive(struct interface_info *)
void if_register6(struct interface_info *info, int do_multicast)
#define INTERFACE_AUTOMATIC
#define DISCOVER_UNCONFIGURED
void if_deregister_receive(struct interface_info *)
trace_type_t * interface_trace
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)
void if_register_send(struct interface_info *)
isc_result_t got_one_v6(omapi_object_t *)
isc_result_t dhcp_interface_get_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_value_t **value)
void end_iface_scan(struct iface_conf_list *ifaces)
struct interface_info * interfaces
isc_result_t dhcp_interface_create(omapi_object_t **lp, omapi_object_t *id)
isc_result_t interface_initialize(omapi_object_t *ipo, const char *file, int line)
struct interface_info * fallback_interface
int setup_fallback(struct interface_info **fp, const char *file, int line)
struct in_addr limited_broadcast
void discover_interfaces(int state)
void add_ipv4_addr_to_interface(struct interface_info *iface, const struct in_addr *addr)
int begin_iface_scan(struct iface_conf_list *ifaces)
isc_result_t dhcp_interface_destroy(omapi_object_t *h, const char *file, int line)
int(* dhcp_interface_discovery_hook)(struct interface_info *)
int quiet_interface_discovery
int(* dhcp_interface_setup_hook)(struct interface_info *, struct iaddr *)
isc_result_t interface_setup()
void reinitialize_interfaces()
isc_result_t dhcp_interface_set_value(omapi_object_t *h, omapi_object_t *id, omapi_data_string_t *name, omapi_typed_data_t *value)
struct interface_info ** interface_vector
isc_result_t dhcp_interface_stuff_values(omapi_object_t *c, omapi_object_t *id, omapi_object_t *h)
isc_result_t dhcp_interface_lookup(omapi_object_t **ip, omapi_object_t *id, omapi_object_t *ref)
void(* bootp_packet_handler)(struct interface_info *, struct dhcp_packet *, unsigned, unsigned int, struct iaddr, struct hardware *)
void interface_stash(struct interface_info *tptr)
struct in_addr local_address
int(* dhcp_interface_shutdown_hook)(struct interface_info *)
struct interface_info * dummy_interfaces
void interface_snorf(struct interface_info *tmp, int ir)
int interfaces_invalidated
omapi_object_type_t * dhcp_type_interface
isc_result_t got_one(omapi_object_t *h)
int if_readsocket(omapi_object_t *h)
int next_iface(struct iface_info *info, int *err, struct iface_conf_list *ifaces)
isc_result_t dhcp_interface_signal_handler(omapi_object_t *h, const char *name, va_list ap)
isc_result_t dhcp_interface_remove(omapi_object_t *lp, omapi_object_t *id)
isc_result_t(* dhcp_interface_startup_hook)(struct interface_info *)
#define ISC_R_NOTIMPLEMENTED
isc_result_t omapi_value_dereference(omapi_value_t **, const char *, int)
isc_result_t omapi_connection_put_string(omapi_object_t *, const char *)
#define OMAPI_OBJECT_ALLOC(name, stype, type)
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 *))
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
isc_result_t omapi_unregister_io_object(omapi_object_t *)
isc_result_t omapi_handle_td_lookup(omapi_object_t **, omapi_typed_data_t *)
isc_result_t omapi_object_type_register(omapi_object_type_t **, const char *, isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t *, const char *, va_list), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t **, const char *, int), isc_result_t(*)(size_t), size_t, isc_result_t(*)(omapi_object_t *, const char *, int), int)
isc_result_t omapi_object_reference(omapi_object_t **, omapi_object_t *, const char *, int)
int omapi_ds_strcmp(omapi_data_string_t *, const char *)
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
isc_result_t omapi_get_value_str(omapi_object_t *, omapi_object_t *, const char *, omapi_value_t **)
isc_result_t omapi_connection_put_name(omapi_object_t *, const char *)
int log_error(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
#define DHCP_R_INVALIDARG
#define DHCP_R_KEYCONFLICT
struct interface_info * interface
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct sockaddr_storage addr
struct interface_info * next
struct subnet * next_sibling
struct iaddr interface_address
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)