• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * dhcpcd - DHCP client daemon
3  * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
4  * All rights reserved
5 
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
14  *
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
25  * SUCH DAMAGE.
26  */
27 
28 #ifndef IF_OPTIONS_H
29 #define IF_OPTIONS_H
30 
31 #include <sys/socket.h>
32 #include <net/if.h>
33 #include <netinet/in.h>
34 
35 #include <getopt.h>
36 #include <limits.h>
37 
38 /* Don't set any optional arguments here so we retain POSIX
39  * compatibility with getopt */
40 #define IF_OPTS "abc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:ABC:DEF:GHI:JKLO:Q:S:TUVW:X:Z:"
41 
42 #define DEFAULT_TIMEOUT		30
43 #define DEFAULT_REBOOT		10
44 
45 #define HOSTNAME_MAX_LEN	250	/* 255 - 3 (FQDN) - 2 (DNS enc) */
46 #define VENDORCLASSID_MAX_LEN	255
47 #define CLIENTID_MAX_LEN	48
48 #define USERCLASS_MAX_LEN	255
49 #define VENDOR_MAX_LEN		255
50 
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)
77 #define DHCPCD_XID_HWADDR	(1 << 28)
78 #define DHCPCD_BROADCAST	(1 << 29)
79 #define DHCPCD_DUMPLEASE	(1 << 30)
80 
81 extern const struct option cf_options[];
82 
83 struct if_options {
84 	int metric;
85 	uint8_t requestmask[256 / 8];
86 	uint8_t requiremask[256 / 8];
87 	uint8_t nomask[256 / 8];
88 	uint8_t dstmask[256 / 8];
89 	uint32_t leasetime;
90 	time_t timeout;
91 	time_t reboot;
92 	int options;
93 
94 	struct in_addr req_addr;
95 	struct in_addr req_mask;
96 	struct rt *routes;
97 	char **config;
98 
99 	char **environ;
100 	char script[PATH_MAX];
101 
102 	char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */
103 	int fqdn;
104 	uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2];
105 	char clientid[CLIENTID_MAX_LEN + 2];
106 	uint8_t userclass[USERCLASS_MAX_LEN + 2];
107 	uint8_t vendor[VENDOR_MAX_LEN + 2];
108 
109 	size_t blacklist_len;
110 	in_addr_t *blacklist;
111 	size_t whitelist_len;
112 	in_addr_t *whitelist;
113 	size_t arping_len;
114 	in_addr_t *arping;
115 	char *fallback;
116 };
117 
118 struct if_options *read_config(const char *,
119     const char *, const char *, const char *);
120 int add_options(struct if_options *, int, char **);
121 void free_options(struct if_options *);
122 
123 #endif
124