1 /* $NetBSD: dhcpcd.h,v 1.13 2015/08/21 10:39:00 roy Exp $ */
4 * dhcpcd - DHCP client daemon
5 * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/socket.h>
37 #ifdef HAVE_SYS_QUEUE_H
38 #include <sys/queue.h>
43 #include "if-options.h"
46 #define IF_SSIDSIZE 33
47 #define PROFILE_LEN 64
51 #define LINK_UNKNOWN 0
54 #define IF_DATA_IPV4 0
56 #define IF_DATA_IPV4LL 2
57 #define IF_DATA_DHCP 3
58 #define IF_DATA_IPV6 4
59 #define IF_DATA_IPV6ND 5
60 #define IF_DATA_DHCP6 6
63 /* If the interface does not support carrier status (ie PPP),
64 * dhcpcd can poll it for the relevant flags periodically */
65 #define IF_POLL_UP 100 /* milliseconds */
68 /* QNX carries defines for, but does not actually support PF_LINK */
73 struct dhcpcd_ctx
*ctx
;
74 TAILQ_ENTRY(interface
) next
;
75 char name
[IF_NAMESIZE
];
77 char alias
[IF_NAMESIZE
];
82 unsigned char hwaddr
[HWADDR_LEN
];
87 uint8_t ssid
[IF_SSIDSIZE
];
88 unsigned int ssid_len
;
90 char profile
[PROFILE_LEN
];
91 struct if_options
*options
;
92 void *if_data
[IF_DATA_MAX
];
94 TAILQ_HEAD(if_head
, interface
);
98 char pidfile
[sizeof(PIDFILE
) + IF_NAMESIZE
+ 1];
100 unsigned long long options
;
105 int ifac
; /* allowed interfaces */
106 char **ifav
; /* allowed interfaces */
107 int ifdc
; /* denied interfaces */
108 char **ifdv
; /* denied interfaces */
109 int ifc
; /* listed interfaces */
110 char **ifv
; /* listed interfaces */
111 int ifcc
; /* configured interfaces */
112 char **ifcv
; /* configured interfaces */
115 struct if_head
*ifaces
;
118 #if defined(INET6) && defined(BSD)
132 int control_unpriv_fd
;
133 struct fd_list_head control_fds
;
134 char control_sock
[sizeof(CONTROLSOCKET
) + IF_NAMESIZE
];
137 /* DHCP Enterprise options, RFC3925 */
138 struct dhcp_opt
*vivso
;
141 char *randomstate
; /* original state */
144 struct dhcp_opt
*dhcp_opts
;
145 size_t dhcp_opts_len
;
146 struct rt_head
*ipv4_routes
;
147 struct rt_head
*ipv4_kroutes
;
152 /* Our aggregate option buffer.
153 * We ONLY use this when options are split, which for most purposes is
154 * practically never. See RFC3396 for details. */
158 unsigned char secret
[SECRET_LEN
];
161 struct dhcp_opt
*nd_opts
;
163 struct dhcp_opt
*dhcp6_opts
;
164 size_t dhcp6_opts_len
;
165 struct ipv6_ctx
*ipv6
;
180 extern const int dhcpcd_signals
[];
181 extern const size_t dhcpcd_signals_len
;
184 int dhcpcd_ifafwaiting(const struct interface
*);
185 int dhcpcd_afwaiting(const struct dhcpcd_ctx
*);
186 pid_t
dhcpcd_daemonise(struct dhcpcd_ctx
*);
188 int dhcpcd_handleargs(struct dhcpcd_ctx
*, struct fd_list
*, int, char **);
189 void dhcpcd_handlecarrier(struct dhcpcd_ctx
*, int, unsigned int, const char *);
190 int dhcpcd_handleinterface(void *, int, const char *);
191 void dhcpcd_handlehwaddr(struct dhcpcd_ctx
*, const char *,
192 const unsigned char *, uint8_t);
193 void dhcpcd_dropinterface(struct interface
*, const char *);
194 int dhcpcd_selectprofile(struct interface
*, const char *);
196 void dhcpcd_startinterface(void *);
197 void dhcpcd_initstate(struct interface
*, unsigned long long);