]> git.ipfire.org Git - thirdparty/dhcpcd.git/blob - if-options.h
Release dhcpcd-5.0.5
[thirdparty/dhcpcd.git] / if-options.h
1 /*
2 * dhcpcd - DHCP client daemon
3 * Copyright (c) 2006-2009 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 "bc:def:h:i:kl:m:no:pqr:s:t:u:v:xy:z:ABC:DEF:GI:KLN:O:Q:TVX: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 48
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
73 extern const struct option cf_options[];
74
75 struct if_options {
76 int metric;
77 uint8_t requestmask[256 / 8];
78 uint8_t requiremask[256 / 8];
79 uint8_t nomask[256 / 8];
80 uint8_t dstmask[256 / 8];
81 uint32_t leasetime;
82 time_t timeout;
83 time_t reboot;
84 int options;
85
86 struct in_addr req_addr;
87 struct in_addr req_mask;
88 struct rt *routes;
89 char **config;
90
91 char **environ;
92 char script[PATH_MAX];
93
94 char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */
95 int fqdn;
96 uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2];
97 char clientid[CLIENTID_MAX_LEN + 2];
98 uint8_t userclass[USERCLASS_MAX_LEN + 2];
99 uint8_t vendor[VENDOR_MAX_LEN + 2];
100
101 size_t blacklist_len;
102 in_addr_t *blacklist;
103 size_t arping_len;
104 in_addr_t *arping;
105 char *fallback;
106 };
107
108 struct if_options *read_config(const char *,
109 const char *, const char *, const char *);
110 int add_options(struct if_options *, int, char **);
111 void free_options(struct if_options *);
112
113 #endif