2 * dhcpcd - DHCP client daemon
3 * Copyright (c) 2006-2009 Roy Marples <roy@marples.name>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/socket.h>
33 #include <netinet/in.h>
38 /* Don't set any optional arguments here so we retain POSIX
39 * compatibility with getopt */
40 #define IF_OPTS "bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GI:KLN:O:Q:S:TVW:X:Z:"
42 #define DEFAULT_TIMEOUT 30
43 #define DEFAULT_REBOOT 10
45 #define HOSTNAME_MAX_LEN 250 /* 255 - 3 (FQDN) - 2 (DNS enc) */
46 #define VENDORCLASSID_MAX_LEN 48
47 #define CLIENTID_MAX_LEN 48
48 #define USERCLASS_MAX_LEN 255
49 #define VENDOR_MAX_LEN 255
51 #define DHCPCD_ARP (1 << 0)
52 #define DHCPCD_RELEASE (1 << 1)
53 #define DHCPCD_DOMAIN (1 << 2)
54 #define DHCPCD_GATEWAY (1 << 3)
55 #define DHCPCD_STATIC (1 << 4)
56 #define DHCPCD_DEBUG (1 << 5)
57 #define DHCPCD_LASTLEASE (1 << 7)
58 #define DHCPCD_INFORM (1 << 8)
59 #define DHCPCD_REQUEST (1 << 9)
60 #define DHCPCD_IPV4LL (1 << 10)
61 #define DHCPCD_DUID (1 << 11)
62 #define DHCPCD_PERSISTENT (1 << 12)
63 #define DHCPCD_DAEMONISE (1 << 14)
64 #define DHCPCD_DAEMONISED (1 << 15)
65 #define DHCPCD_TEST (1 << 16)
66 #define DHCPCD_MASTER (1 << 17)
67 #define DHCPCD_HOSTNAME (1 << 18)
68 #define DHCPCD_CLIENTID (1 << 19)
69 #define DHCPCD_LINK (1 << 20)
70 #define DHCPCD_QUIET (1 << 21)
71 #define DHCPCD_BACKGROUND (1 << 22)
72 #define DHCPCD_VENDORRAW (1 << 23)
73 #define DHCPCD_TIMEOUT_IPV4LL (1 << 24)
74 #define DHCPCD_WAITIP (1 << 25)
75 #define DHCPCD_WAITUP (1 << 26)
76 #define DHCPCD_CSR_WARNED (1 << 27)
78 extern const struct option cf_options
[];
82 uint8_t requestmask
[256 / 8];
83 uint8_t requiremask
[256 / 8];
84 uint8_t nomask
[256 / 8];
85 uint8_t dstmask
[256 / 8];
91 struct in_addr req_addr
;
92 struct in_addr req_mask
;
97 char script
[PATH_MAX
];
99 char hostname
[HOSTNAME_MAX_LEN
+ 1]; /* We don't store the length */
101 uint8_t vendorclassid
[VENDORCLASSID_MAX_LEN
+ 2];
102 char clientid
[CLIENTID_MAX_LEN
+ 2];
103 uint8_t userclass
[USERCLASS_MAX_LEN
+ 2];
104 uint8_t vendor
[VENDOR_MAX_LEN
+ 2];
106 size_t blacklist_len
;
107 in_addr_t
*blacklist
;
108 size_t whitelist_len
;
109 in_addr_t
*whitelist
;
115 struct if_options
*read_config(const char *,
116 const char *, const char *, const char *);
117 int add_options(struct if_options
*, int, char **);
118 void free_options(struct if_options
*);