Mercurial > hg > dhcpcd
annotate src/if-options.c @ 5574:2a519da0f1a2 draft
DHCP: Split hardware address randomisation out of anonymous option
A 3rd party might want to control the randomisation.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 28 Dec 2020 00:02:26 +0000 |
| parents | 0c4608a6cc2a |
| children |
| rev | line source |
|---|---|
|
4548
c7df03794de3
Add SPDX identifiers to all dhcpcd source files.
Yegor Yefremov <yegorslists@googlemail.com>
parents:
4522
diff
changeset
|
1 /* SPDX-License-Identifier: BSD-2-Clause */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2 /* |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3 * dhcpcd - DHCP client daemon |
| 4922 | 4 * Copyright (c) 2006-2020 Roy Marples <roy@marples.name> |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
5 * All rights reserved |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
7 * Redistribution and use in source and binary forms, with or without |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
8 * modification, are permitted provided that the following conditions |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
9 * are met: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
10 * 1. Redistributions of source code must retain the above copyright |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
11 * notice, this list of conditions and the following disclaimer. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
13 * notice, this list of conditions and the following disclaimer in the |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
14 * documentation and/or other materials provided with the distribution. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
15 * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
26 * SUCH DAMAGE. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
27 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
28 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
29 #include <sys/param.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
30 #include <sys/types.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
31 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
32 #include <arpa/inet.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
33 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
34 #include <ctype.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
35 #include <errno.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
36 #include <getopt.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
37 #include <grp.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
38 #include <inttypes.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
39 #include <limits.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
40 #include <paths.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
41 #include <stdio.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
42 #include <stdlib.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
43 #include <string.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
44 #include <unistd.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
45 #include <time.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
46 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
47 #include "config.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
48 #include "common.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
49 #include "dhcp.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
50 #include "dhcp6.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
51 #include "dhcpcd-embedded.h" |
|
5456
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
52 #include "duid.h" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
53 #include "if.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
54 #include "if-options.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
55 #include "ipv4.h" |
| 4010 | 56 #include "logerr.h" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
57 #include "sa.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
58 |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
59 #define IN_CONFIG_BLOCK(ifo) ((ifo)->options & DHCPCD_FORKED) |
|
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
60 #define SET_CONFIG_BLOCK(ifo) ((ifo)->options |= DHCPCD_FORKED) |
|
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
61 #define CLEAR_CONFIG_BLOCK(ifo) ((ifo)->options &= ~DHCPCD_FORKED) |
|
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
62 |
|
5411
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
63 static unsigned long long default_options; |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
64 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
65 const struct option cf_options[] = { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
66 {"background", no_argument, NULL, 'b'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
67 {"script", required_argument, NULL, 'c'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
68 {"debug", no_argument, NULL, 'd'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
69 {"env", required_argument, NULL, 'e'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
70 {"config", required_argument, NULL, 'f'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
71 {"reconfigure", no_argument, NULL, 'g'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
72 {"hostname", optional_argument, NULL, 'h'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
73 {"vendorclassid", optional_argument, NULL, 'i'}, |
|
4016
8522be3abe19
logfile argument is not optional.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
74 {"logfile", required_argument, NULL, 'j'}, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
75 {"release", no_argument, NULL, 'k'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
76 {"leasetime", required_argument, NULL, 'l'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
77 {"metric", required_argument, NULL, 'm'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
78 {"rebind", no_argument, NULL, 'n'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
79 {"option", required_argument, NULL, 'o'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
80 {"persistent", no_argument, NULL, 'p'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
81 {"quiet", no_argument, NULL, 'q'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
82 {"request", optional_argument, NULL, 'r'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
83 {"inform", optional_argument, NULL, 's'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
84 {"inform6", optional_argument, NULL, O_INFORM6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
85 {"timeout", required_argument, NULL, 't'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
86 {"userclass", required_argument, NULL, 'u'}, |
|
5076
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
87 #ifndef SMALL |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
88 {"msuserclass", required_argument, NULL, O_MSUSERCLASS}, |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
89 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
90 {"vendor", required_argument, NULL, 'v'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
91 {"waitip", optional_argument, NULL, 'w'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
92 {"exit", no_argument, NULL, 'x'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
93 {"allowinterfaces", required_argument, NULL, 'z'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
94 {"reboot", required_argument, NULL, 'y'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
95 {"noarp", no_argument, NULL, 'A'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
96 {"nobackground", no_argument, NULL, 'B'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
97 {"nohook", required_argument, NULL, 'C'}, |
|
5456
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
98 {"duid", optional_argument, NULL, 'D'}, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
99 {"lastlease", no_argument, NULL, 'E'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
100 {"fqdn", optional_argument, NULL, 'F'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
101 {"nogateway", no_argument, NULL, 'G'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
102 {"xidhwaddr", no_argument, NULL, 'H'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
103 {"clientid", optional_argument, NULL, 'I'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
104 {"broadcast", no_argument, NULL, 'J'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
105 {"nolink", no_argument, NULL, 'K'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
106 {"noipv4ll", no_argument, NULL, 'L'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
107 {"master", no_argument, NULL, 'M'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
108 {"renew", no_argument, NULL, 'N'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
109 {"nooption", required_argument, NULL, 'O'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
110 {"printpidfile", no_argument, NULL, 'P'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
111 {"require", required_argument, NULL, 'Q'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
112 {"static", required_argument, NULL, 'S'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
113 {"test", no_argument, NULL, 'T'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
114 {"dumplease", no_argument, NULL, 'U'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
115 {"variables", no_argument, NULL, 'V'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
116 {"whitelist", required_argument, NULL, 'W'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
117 {"blacklist", required_argument, NULL, 'X'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
118 {"denyinterfaces", required_argument, NULL, 'Z'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
119 {"oneshot", no_argument, NULL, '1'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
120 {"ipv4only", no_argument, NULL, '4'}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
121 {"ipv6only", no_argument, NULL, '6'}, |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
122 {"anonymous", no_argument, NULL, O_ANONYMOUS}, |
|
5574
2a519da0f1a2
DHCP: Split hardware address randomisation out of anonymous option
Roy Marples <roy@marples.name>
parents:
5551
diff
changeset
|
123 {"randomise_hwaddr",no_argument, NULL, O_RANDOMISE_HWADDR}, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
124 {"arping", required_argument, NULL, O_ARPING}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
125 {"destination", required_argument, NULL, O_DESTINATION}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
126 {"fallback", required_argument, NULL, O_FALLBACK}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
127 {"ipv6rs", no_argument, NULL, O_IPV6RS}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
128 {"noipv6rs", no_argument, NULL, O_NOIPV6RS}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
129 {"ipv6ra_autoconf", no_argument, NULL, O_IPV6RA_AUTOCONF}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
130 {"ipv6ra_noautoconf", no_argument, NULL, O_IPV6RA_NOAUTOCONF}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
131 {"ipv6ra_fork", no_argument, NULL, O_IPV6RA_FORK}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
132 {"ipv4", no_argument, NULL, O_IPV4}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
133 {"noipv4", no_argument, NULL, O_NOIPV4}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
134 {"ipv6", no_argument, NULL, O_IPV6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
135 {"noipv6", no_argument, NULL, O_NOIPV6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
136 {"noalias", no_argument, NULL, O_NOALIAS}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
137 {"iaid", required_argument, NULL, O_IAID}, |
|
5550
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
138 {"ia_na", optional_argument, NULL, O_IA_NA}, |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
139 {"ia_ta", optional_argument, NULL, O_IA_TA}, |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
140 {"ia_pd", optional_argument, NULL, O_IA_PD}, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
141 {"hostname_short", no_argument, NULL, O_HOSTNAME_SHORT}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
142 {"dev", required_argument, NULL, O_DEV}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
143 {"nodev", no_argument, NULL, O_NODEV}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
144 {"define", required_argument, NULL, O_DEFINE}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
145 {"definend", required_argument, NULL, O_DEFINEND}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
146 {"define6", required_argument, NULL, O_DEFINE6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
147 {"embed", required_argument, NULL, O_EMBED}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
148 {"encap", required_argument, NULL, O_ENCAP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
149 {"vendopt", required_argument, NULL, O_VENDOPT}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
150 {"vendclass", required_argument, NULL, O_VENDCLASS}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
151 {"authprotocol", required_argument, NULL, O_AUTHPROTOCOL}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
152 {"authtoken", required_argument, NULL, O_AUTHTOKEN}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
153 {"noauthrequired", no_argument, NULL, O_AUTHNOTREQUIRED}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
154 {"dhcp", no_argument, NULL, O_DHCP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
155 {"nodhcp", no_argument, NULL, O_NODHCP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
156 {"dhcp6", no_argument, NULL, O_DHCP6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
157 {"nodhcp6", no_argument, NULL, O_NODHCP6}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
158 {"controlgroup", required_argument, NULL, O_CONTROLGRP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
159 {"slaac", required_argument, NULL, O_SLAAC}, |
| 4067 | 160 {"gateway", no_argument, NULL, O_GATEWAY}, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
161 {"reject", required_argument, NULL, O_REJECT}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
162 {"bootp", no_argument, NULL, O_BOOTP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
163 {"nodelay", no_argument, NULL, O_NODELAY}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
164 {"noup", no_argument, NULL, O_NOUP}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
165 {"lastleaseextend", no_argument, NULL, O_LASTLEASE_EXTEND}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
166 {"inactive", no_argument, NULL, O_INACTIVE}, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
167 {"mudurl", required_argument, NULL, O_MUDURL}, |
|
4415
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
168 {"link_rcvbuf", required_argument, NULL, O_LINK_RCVBUF}, |
| 5535 | 169 {"configure", no_argument, NULL, O_CONFIGURE}, |
| 170 {"noconfigure", no_argument, NULL, O_NOCONFIGURE}, | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
171 {NULL, 0, NULL, '\0'} |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
172 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
173 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
174 static char * |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
175 add_environ(char ***array, const char *value, int uniq) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
176 { |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
177 char **newlist, **list = *array; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
178 size_t i = 0, l, lv; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
179 char *match = NULL, *p, *n; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
180 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
181 match = strdup(value); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
182 if (match == NULL) { |
| 4010 | 183 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
184 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
185 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
186 p = strchr(match, '='); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
187 if (p == NULL) { |
| 4010 | 188 logerrx("%s: no assignment: %s", __func__, value); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
189 free(match); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
190 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
191 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
192 *p++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
193 l = strlen(match); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
194 |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
195 while (list && list[i]) { |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
196 if (match && strncmp(list[i], match, l) == 0) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
197 if (uniq) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
198 n = strdup(value); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
199 if (n == NULL) { |
| 4010 | 200 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
201 free(match); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
202 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
203 } |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
204 free(list[i]); |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
205 list[i] = n; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
206 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
207 /* Append a space and the value to it */ |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
208 l = strlen(list[i]); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
209 lv = strlen(p); |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
210 n = realloc(list[i], l + lv + 2); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
211 if (n == NULL) { |
| 4010 | 212 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
213 free(match); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
214 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
215 } |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
216 list[i] = n; |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
217 list[i][l] = ' '; |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
218 memcpy(list[i] + l + 1, p, lv); |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
219 list[i][l + lv + 1] = '\0'; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
220 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
221 free(match); |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
222 return list[i]; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
223 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
224 i++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
225 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
226 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
227 free(match); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
228 n = strdup(value); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
229 if (n == NULL) { |
| 4010 | 230 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
231 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
232 } |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
233 newlist = reallocarray(list, i + 2, sizeof(char *)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
234 if (newlist == NULL) { |
| 4010 | 235 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
236 free(n); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
237 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
238 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
239 newlist[i] = n; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
240 newlist[i + 1] = NULL; |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
241 *array = newlist; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
242 return newlist[i]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
243 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
244 |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
245 #define PARSE_STRING 0 |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
246 #define PARSE_STRING_NULL 1 |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
247 #define PARSE_HWADDR 2 |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
248 #define parse_string(a, b, c) parse_str((a), (b), (c), PARSE_STRING) |
|
5075
58e0b04c816d
options: Define parse_nstring and use it
Roy Marples <roy@marples.name>
parents:
5050
diff
changeset
|
249 #define parse_nstring(a, b, c) parse_str((a), (b), (c), PARSE_STRING_NULL) |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
250 #define parse_hwaddr(a, b, c) parse_str((a), (b), (c), PARSE_HWADDR) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
251 static ssize_t |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
252 parse_str(char *sbuf, size_t slen, const char *str, int flags) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
253 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
254 size_t l; |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
255 const char *p, *end; |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
256 int i; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
257 char c[4], cmd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
258 |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
259 end = str + strlen(str); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
260 /* If surrounded by quotes then it's a string */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
261 if (*str == '"') { |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
262 p = end - 1; |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
263 if (*p == '"') { |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
264 str++; |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
265 end = p; |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
266 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
267 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
268 l = (size_t)hwaddr_aton(NULL, str); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
269 if ((ssize_t) l != -1 && l > 1) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
270 if (l > slen) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
271 errno = ENOBUFS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
272 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
273 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
274 hwaddr_aton((uint8_t *)sbuf, str); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
275 return (ssize_t)l; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
276 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
277 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
278 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
279 /* Process escapes */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
280 l = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
281 /* If processing a string on the clientid, first byte should be |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
282 * 0 to indicate a non hardware type */ |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
283 if (flags == PARSE_HWADDR && *str) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
284 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
285 *sbuf++ = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
286 l++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
287 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
288 c[3] = '\0'; |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
289 while (str < end) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
290 if (++l > slen && sbuf) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
291 errno = ENOBUFS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
292 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
293 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
294 if (*str == '\\') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
295 str++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
296 switch((cmd = *str++)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
297 case '\0': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
298 str--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
299 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
300 case 'b': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
301 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
302 *sbuf++ = '\b'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
303 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
304 case 'n': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
305 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
306 *sbuf++ = '\n'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
307 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
308 case 'r': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
309 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
310 *sbuf++ = '\r'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
311 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
312 case 't': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
313 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
314 *sbuf++ = '\t'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
315 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
316 case 'x': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
317 /* Grab a hex code */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
318 c[1] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
319 for (i = 0; i < 2; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
320 if (isxdigit((unsigned char)*str) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
321 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
322 c[i] = *str++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
323 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
324 if (c[1] != '\0' && sbuf) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
325 c[2] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
326 *sbuf++ = (char)strtol(c, NULL, 16); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
327 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
328 l--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
329 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
330 case '0': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
331 /* Grab an octal code */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
332 c[2] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
333 for (i = 0; i < 3; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
334 if (*str < '0' || *str > '7') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
335 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
336 c[i] = *str++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
337 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
338 if (c[2] != '\0' && sbuf) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
339 i = (int)strtol(c, NULL, 8); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
340 if (i > 255) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
341 i = 255; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
342 *sbuf ++= (char)i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
343 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
344 l--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
345 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
346 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
347 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
348 *sbuf++ = cmd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
349 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
350 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
351 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
352 if (sbuf) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
353 *sbuf++ = *str; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
354 str++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
355 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
356 } |
|
4909
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
357 if (flags == PARSE_STRING_NULL) { |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
358 l++; |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
359 if (sbuf != NULL) { |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
360 if (l > slen) { |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
361 errno = ENOBUFS; |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
362 return -1; |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
363 } |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
364 *sbuf = '\0'; |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
365 } |
|
f223903fc46d
options: Fix allocating the script option
Roy Marples <roy@marples.name>
parents:
4836
diff
changeset
|
366 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
367 return (ssize_t)l; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
368 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
369 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
370 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
371 parse_iaid1(uint8_t *iaid, const char *arg, size_t len, int n) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
372 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
373 int e; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
374 uint32_t narg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
375 ssize_t s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
376 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
377 narg = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
378 if (e == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
379 if (n) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
380 narg = htonl(narg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
381 memcpy(iaid, &narg, sizeof(narg)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
382 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
383 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
384 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
385 if ((s = parse_string((char *)iaid, len, arg)) < 1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
386 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
387 if (s < 4) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
388 iaid[3] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
389 if (s < 3) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
390 iaid[2] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
391 if (s < 2) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
392 iaid[1] = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
393 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
394 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
395 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
396 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
397 parse_iaid(uint8_t *iaid, const char *arg, size_t len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
398 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
399 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
400 return parse_iaid1(iaid, arg, len, 1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
401 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
402 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
403 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
404 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
405 parse_uint32(uint32_t *i, const char *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
406 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
407 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
408 return parse_iaid1((uint8_t *)i, arg, sizeof(uint32_t), 0); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
409 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
410 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
411 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
412 static char ** |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
413 splitv(int *argc, char **argv, const char *arg) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
414 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
415 char **n, **v = argv; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
416 char *o = strdup(arg), *p, *t, *nt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
417 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
418 if (o == NULL) { |
| 4010 | 419 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
420 return v; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
421 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
422 p = o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
423 while ((t = strsep(&p, ", "))) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
424 nt = strdup(t); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
425 if (nt == NULL) { |
| 4010 | 426 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
427 free(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
428 return v; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
429 } |
| 4007 | 430 n = reallocarray(v, (size_t)(*argc) + 1, sizeof(char *)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
431 if (n == NULL) { |
| 4010 | 432 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
433 free(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
434 free(nt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
435 return v; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
436 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
437 v = n; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
438 v[(*argc)++] = nt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
439 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
440 free(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
441 return v; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
442 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
443 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
444 #ifdef INET |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
445 static int |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
446 parse_addr(struct in_addr *addr, struct in_addr *net, const char *arg) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
447 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
448 char *p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
449 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
450 if (arg == NULL || *arg == '\0') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
451 if (addr != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
452 addr->s_addr = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
453 if (net != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
454 net->s_addr = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
455 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
456 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
457 if ((p = strchr(arg, '/')) != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
458 int e; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
459 intmax_t i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
460 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
461 *p++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
462 i = strtoi(p, NULL, 10, 0, 32, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
463 if (e != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
464 (net != NULL && inet_cidrtoaddr((int)i, net) != 0)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
465 { |
| 5494 | 466 logerrx("invalid CIDR: %s", p); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
467 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
468 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
469 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
470 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
471 if (addr != NULL && inet_aton(arg, addr) == 0) { |
| 5494 | 472 logerrx("invalid IP address: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
473 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
474 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
475 if (p != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
476 *--p = '/'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
477 else if (net != NULL && addr != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
478 net->s_addr = ipv4_getnetmask(addr->s_addr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
479 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
480 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
481 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
482 static int |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
483 parse_addr(__unused struct in_addr *addr, __unused struct in_addr *net, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
484 __unused const char *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
485 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
486 |
| 4010 | 487 logerrx("No IPv4 support"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
488 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
489 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
490 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
491 |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
492 static void |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
493 set_option_space(struct dhcpcd_ctx *ctx, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
494 const char *arg, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
495 const struct dhcp_opt **d, size_t *dl, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
496 const struct dhcp_opt **od, size_t *odl, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
497 struct if_options *ifo, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
498 uint8_t *request[], uint8_t *require[], uint8_t *no[], uint8_t *reject[]) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
499 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
500 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
501 #if !defined(INET) && !defined(INET6) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
502 UNUSED(ctx); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
503 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
504 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
505 #ifdef INET6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
506 if (strncmp(arg, "nd_", strlen("nd_")) == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
507 *d = ctx->nd_opts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
508 *dl = ctx->nd_opts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
509 *od = ifo->nd_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
510 *odl = ifo->nd_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
511 *request = ifo->requestmasknd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
512 *require = ifo->requiremasknd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
513 *no = ifo->nomasknd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
514 *reject = ifo->rejectmasknd; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
515 return; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
516 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
517 |
|
4349
f87c2ed9ff46
DHCP6: Remove #defines for functions when DHCP6 is disabled
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
518 #ifdef DHCP6 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
519 if (strncmp(arg, "dhcp6_", strlen("dhcp6_")) == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
520 *d = ctx->dhcp6_opts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
521 *dl = ctx->dhcp6_opts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
522 *od = ifo->dhcp6_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
523 *odl = ifo->dhcp6_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
524 *request = ifo->requestmask6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
525 *require = ifo->requiremask6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
526 *no = ifo->nomask6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
527 *reject = ifo->rejectmask6; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
528 return; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
529 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
530 #endif |
|
5112
899adcd7f449
Fix build without INET or INET6
Roy Marples <roy@marples.name>
parents:
5090
diff
changeset
|
531 #else |
|
899adcd7f449
Fix build without INET or INET6
Roy Marples <roy@marples.name>
parents:
5090
diff
changeset
|
532 UNUSED(arg); |
|
4349
f87c2ed9ff46
DHCP6: Remove #defines for functions when DHCP6 is disabled
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
533 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
534 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
535 #ifdef INET |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
536 *d = ctx->dhcp_opts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
537 *dl = ctx->dhcp_opts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
538 *od = ifo->dhcp_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
539 *odl = ifo->dhcp_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
540 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
541 *d = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
542 *dl = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
543 *od = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
544 *odl = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
545 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
546 *request = ifo->requestmask; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
547 *require = ifo->requiremask; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
548 *no = ifo->nomask; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
549 *reject = ifo->rejectmask; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
550 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
551 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
552 void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
553 free_dhcp_opt_embenc(struct dhcp_opt *opt) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
554 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
555 size_t i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
556 struct dhcp_opt *o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
557 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
558 free(opt->var); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
559 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
560 for (i = 0, o = opt->embopts; i < opt->embopts_len; i++, o++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
561 free_dhcp_opt_embenc(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
562 free(opt->embopts); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
563 opt->embopts_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
564 opt->embopts = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
565 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
566 for (i = 0, o = opt->encopts; i < opt->encopts_len; i++, o++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
567 free_dhcp_opt_embenc(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
568 free(opt->encopts); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
569 opt->encopts_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
570 opt->encopts = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
571 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
572 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
573 static char * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
574 strwhite(const char *s) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
575 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
576 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
577 if (s == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
578 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
579 while (*s != ' ' && *s != '\t') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
580 if (*s == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
581 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
582 s++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
583 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
584 return UNCONST(s); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
585 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
586 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
587 static char * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
588 strskipwhite(const char *s) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
589 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
590 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
591 if (s == NULL || *s == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
592 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
593 while (*s == ' ' || *s == '\t') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
594 s++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
595 if (*s == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
596 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
597 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
598 return UNCONST(s); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
599 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
600 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
601 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
602 /* Find the end pointer of a string. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
603 static char * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
604 strend(const char *s) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
605 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
606 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
607 s = strskipwhite(s); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
608 if (s == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
609 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
610 if (*s != '"') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
611 return strchr(s, ' '); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
612 s++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
613 for (; *s != '"' ; s++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
614 if (*s == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
615 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
616 if (*s == '\\') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
617 if (*(++s) == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
618 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
619 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
620 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
621 return UNCONST(++s); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
622 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
623 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
624 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
625 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
626 parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
627 int opt, const char *arg, struct dhcp_opt **ldop, struct dhcp_opt **edop) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
628 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
629 int e, i, t; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
630 long l; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
631 unsigned long u; |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
632 char *p = NULL, *bp, *fp, *np; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
633 ssize_t s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
634 struct in_addr addr, addr2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
635 in_addr_t *naddr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
636 struct rt *rt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
637 const struct dhcp_opt *d, *od; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
638 uint8_t *request, *require, *no, *reject; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
639 struct dhcp_opt **dop, *ndop; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
640 size_t *dop_len, dl, odl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
641 struct vivco *vivco; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
642 struct group *grp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
643 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
644 struct token *token; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
645 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
646 #ifdef _REENTRANT |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
647 struct group grpbuf; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
648 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
649 #ifdef DHCP6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
650 size_t sl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
651 struct if_ia *ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
652 uint8_t iaid[4]; |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
653 #ifndef SMALL |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
654 struct if_sla *sla, *slap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
655 #endif |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
656 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
657 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
658 dop = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
659 dop_len = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
660 #ifdef INET6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
661 i = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
662 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
663 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
664 /* Add a guard for static analysers. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
665 * This should not be needed really because of the argument_required option |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
666 * in the options declaration above. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
667 #define ARG_REQUIRED if (arg == NULL) goto arg_required |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
668 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
669 switch(opt) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
670 case 'f': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
671 case 'g': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
672 case 'n': /* FALLTHROUGH */ |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
673 case 'q': /* FALLTHROUGH */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
674 case 'x': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
675 case 'N': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
676 case 'P': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
677 case 'T': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
678 case 'U': /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
679 case 'V': /* We need to handle non interface options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
680 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
681 case 'b': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
682 ifo->options |= DHCPCD_BACKGROUND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
683 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
684 case 'c': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
685 ARG_REQUIRED; |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
686 if (IN_CONFIG_BLOCK(ifo)) { |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
687 logerrx("%s: per interface scripts" |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
688 " are no longer supported", |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
689 ifname); |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
690 return -1; |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
691 } |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
692 if (ctx->script != dhcpcd_default_script) |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
693 free(ctx->script); |
|
5075
58e0b04c816d
options: Define parse_nstring and use it
Roy Marples <roy@marples.name>
parents:
5050
diff
changeset
|
694 s = parse_nstring(NULL, 0, arg); |
|
4419
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
695 if (s == 0) { |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
696 ctx->script = NULL; |
|
4416
76e8268ead9c
script: Fix not running when empty string or /dev/null
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
697 break; |
|
76e8268ead9c
script: Fix not running when empty string or /dev/null
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
698 } |
|
4419
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
699 dl = (size_t)s; |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
700 if (s == -1 || (ctx->script = malloc(dl)) == NULL) { |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
701 ctx->script = NULL; |
| 4010 | 702 logerr(__func__); |
|
4419
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
703 return -1; |
|
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
704 } |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
705 s = parse_nstring(ctx->script, dl, arg); |
|
4559
c9da6ac27892
options: Fix a static analysis error
Roy Marples <roy@marples.name>
parents:
4558
diff
changeset
|
706 if (s == -1 || |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
707 ctx->script[0] == '\0' || |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
708 strcmp(ctx->script, "/dev/null") == 0) |
|
4419
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
709 { |
|
5255
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
710 free(ctx->script); |
|
ee23398a68db
dhcpcd: Move the script file from per interface to global context
Roy Marples <roy@marples.name>
parents:
5216
diff
changeset
|
711 ctx->script = NULL; |
|
4419
ab5d38241a7b
script: Parse argument as a string
Roy Marples <roy@marples.name>
parents:
4416
diff
changeset
|
712 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
713 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
714 case 'd': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
715 ifo->options |= DHCPCD_DEBUG; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
716 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
717 case 'e': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
718 ARG_REQUIRED; |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
719 add_environ(&ifo->environ, arg, 1); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
720 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
721 case 'h': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
722 if (!arg) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
723 ifo->options |= DHCPCD_HOSTNAME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
724 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
725 } |
|
5075
58e0b04c816d
options: Define parse_nstring and use it
Roy Marples <roy@marples.name>
parents:
5050
diff
changeset
|
726 s = parse_nstring(ifo->hostname, sizeof(ifo->hostname), arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
727 if (s == -1) { |
| 4010 | 728 logerr("%s: hostname", __func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
729 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
730 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
731 if (s != 0 && ifo->hostname[0] == '.') { |
| 4010 | 732 logerrx("hostname cannot begin with ."); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
733 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
734 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
735 if (ifo->hostname[0] == '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
736 ifo->options &= ~DHCPCD_HOSTNAME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
737 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
738 ifo->options |= DHCPCD_HOSTNAME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
739 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
740 case 'i': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
741 if (arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
742 s = parse_string((char *)ifo->vendorclassid + 1, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
743 VENDORCLASSID_MAX_LEN, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
744 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
745 s = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
746 if (s == -1) { |
| 4010 | 747 logerr("vendorclassid"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
748 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
749 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
750 *ifo->vendorclassid = (uint8_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
751 break; |
| 4010 | 752 case 'j': |
| 753 ARG_REQUIRED; | |
| 754 /* per interface logging is not supported | |
| 755 * don't want to overide the commandline */ | |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
756 if (!IN_CONFIG_BLOCK(ifo) && ctx->logfile == NULL) { |
| 4010 | 757 logclose(); |
| 758 ctx->logfile = strdup(arg); | |
| 759 logopen(ctx->logfile); | |
| 760 } | |
| 761 break; | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
762 case 'k': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
763 ifo->options |= DHCPCD_RELEASE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
764 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
765 case 'l': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
766 ARG_REQUIRED; |
|
5435
557a3f9f2be4
DHCP: allow leasetime -1 to represent infinity
Roy Marples <roy@marples.name>
parents:
5416
diff
changeset
|
767 if (strcmp(arg, "-1") == 0) { |
|
557a3f9f2be4
DHCP: allow leasetime -1 to represent infinity
Roy Marples <roy@marples.name>
parents:
5416
diff
changeset
|
768 ifo->leasetime = DHCP_INFINITE_LIFETIME; |
|
557a3f9f2be4
DHCP: allow leasetime -1 to represent infinity
Roy Marples <roy@marples.name>
parents:
5416
diff
changeset
|
769 break; |
|
557a3f9f2be4
DHCP: allow leasetime -1 to represent infinity
Roy Marples <roy@marples.name>
parents:
5416
diff
changeset
|
770 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
771 ifo->leasetime = (uint32_t)strtou(arg, NULL, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
772 0, 0, UINT32_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
773 if (e) { |
| 4010 | 774 logerrx("failed to convert leasetime %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
775 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
776 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
777 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
778 case 'm': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
779 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
780 ifo->metric = (int)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
781 if (e) { |
| 4010 | 782 logerrx("failed to convert metric %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
783 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
784 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
785 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
786 case 'o': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
787 ARG_REQUIRED; |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
788 if (ctx->options & DHCPCD_PRINT_PIDFILE) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
789 break; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
790 set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
791 &request, &require, &no, &reject); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
792 if (make_option_mask(d, dl, od, odl, request, arg, 1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
793 make_option_mask(d, dl, od, odl, no, arg, -1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
794 make_option_mask(d, dl, od, odl, reject, arg, -1) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
795 { |
| 5494 | 796 logerrx("unknown option: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
797 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
798 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
799 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
800 case O_REJECT: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
801 ARG_REQUIRED; |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
802 if (ctx->options & DHCPCD_PRINT_PIDFILE) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
803 break; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
804 set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
805 &request, &require, &no, &reject); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
806 if (make_option_mask(d, dl, od, odl, reject, arg, 1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
807 make_option_mask(d, dl, od, odl, request, arg, -1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
808 make_option_mask(d, dl, od, odl, require, arg, -1) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
809 { |
| 5494 | 810 logerrx("unknown option: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
811 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
812 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
813 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
814 case 'p': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
815 ifo->options |= DHCPCD_PERSISTENT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
816 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
817 case 'r': |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
818 if (parse_addr(&ifo->req_addr, NULL, arg) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
819 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
820 ifo->options |= DHCPCD_REQUEST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
821 ifo->req_mask.s_addr = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
822 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
823 case 's': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
824 if (arg && *arg != '\0') { |
|
4207
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
825 /* Strip out a broadcast address */ |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
826 p = strchr(arg, '/'); |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
827 if (p != NULL) { |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
828 p = strchr(p + 1, '/'); |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
829 if (p != NULL) |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
830 *p = '\0'; |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
831 } |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
832 i = parse_addr(&ifo->req_addr, &ifo->req_mask, arg); |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
833 if (p != NULL) { |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
834 /* Ensure the original string is preserved */ |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
835 *p++ = '/'; |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
836 if (i == 0) |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
837 i = parse_addr(&ifo->req_brd, NULL, p); |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
838 } |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
839 if (i != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
840 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
841 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
842 ifo->req_addr.s_addr = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
843 ifo->req_mask.s_addr = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
844 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
845 ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
846 ifo->options &= ~DHCPCD_STATIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
847 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
848 case O_INFORM6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
849 ifo->options |= DHCPCD_INFORM6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
850 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
851 case 't': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
852 ARG_REQUIRED; |
|
4923
4fcca755943e
eloop: Allow for for timeouts greater than time_t and time wrapping
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
853 ifo->timeout = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
854 if (e) { |
| 4010 | 855 logerrx("failed to convert timeout %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
856 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
857 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
858 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
859 case 'u': |
|
5075
58e0b04c816d
options: Define parse_nstring and use it
Roy Marples <roy@marples.name>
parents:
5050
diff
changeset
|
860 dl = sizeof(ifo->userclass) - ifo->userclass[0] - 1; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
861 s = parse_string((char *)ifo->userclass + |
|
5075
58e0b04c816d
options: Define parse_nstring and use it
Roy Marples <roy@marples.name>
parents:
5050
diff
changeset
|
862 ifo->userclass[0] + 2, dl, arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
863 if (s == -1) { |
| 4010 | 864 logerr("userclass"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
865 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
866 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
867 if (s != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
868 ifo->userclass[ifo->userclass[0] + 1] = (uint8_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
869 ifo->userclass[0] = (uint8_t)(ifo->userclass[0] + s +1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
870 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
871 break; |
|
5076
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
872 #ifndef SMALL |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
873 case O_MSUSERCLASS: |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
874 /* Some Microsoft DHCP servers expect userclass to be an |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
875 * opaque blob. This is not RFC 3004 compliant. */ |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
876 s = parse_string((char *)ifo->userclass + 1, |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
877 sizeof(ifo->userclass) - 1, arg); |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
878 if (s == -1) { |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
879 logerr("msuserclass"); |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
880 return -1; |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
881 } |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
882 ifo->userclass[0] = (uint8_t)s; |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
883 break; |
|
1d53edf5bdaa
DHCP: Add support for the Microsoft User Class option
Roy Marples <roy@marples.name>
parents:
5075
diff
changeset
|
884 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
885 case 'v': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
886 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
887 p = strchr(arg, ','); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
888 if (!p || !p[1]) { |
| 4010 | 889 logerrx("invalid vendor format: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
890 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
891 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
892 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
893 /* If vendor starts with , then it is not encapsulated */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
894 if (p == arg) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
895 arg++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
896 s = parse_string((char *)ifo->vendor + 1, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
897 VENDOR_MAX_LEN, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
898 if (s == -1) { |
| 4010 | 899 logerr("vendor"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
900 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
901 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
902 ifo->vendor[0] = (uint8_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
903 ifo->options |= DHCPCD_VENDORRAW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
904 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
905 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
906 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
907 /* Encapsulated vendor options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
908 if (ifo->options & DHCPCD_VENDORRAW) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
909 ifo->options &= ~DHCPCD_VENDORRAW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
910 ifo->vendor[0] = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
911 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
912 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
913 /* Strip and preserve the comma */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
914 *p = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
915 i = (int)strtoi(arg, NULL, 0, 1, 254, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
916 *p = ','; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
917 if (e) { |
| 4010 | 918 logerrx("vendor option should be between" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
919 " 1 and 254 inclusive"); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
920 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
921 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
922 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
923 arg = p + 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
924 s = VENDOR_MAX_LEN - ifo->vendor[0] - 2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
925 if (inet_aton(arg, &addr) == 1) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
926 if (s < 6) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
927 s = -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
928 errno = ENOBUFS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
929 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
930 memcpy(ifo->vendor + ifo->vendor[0] + 3, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
931 &addr.s_addr, sizeof(addr.s_addr)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
932 s = sizeof(addr.s_addr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
933 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
934 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
935 s = parse_string((char *)ifo->vendor + |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
936 ifo->vendor[0] + 3, (size_t)s, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
937 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
938 if (s == -1) { |
| 4010 | 939 logerr("vendor"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
940 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
941 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
942 if (s != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
943 ifo->vendor[ifo->vendor[0] + 1] = (uint8_t)i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
944 ifo->vendor[ifo->vendor[0] + 2] = (uint8_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
945 ifo->vendor[0] = (uint8_t)(ifo->vendor[0] + s + 2); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
946 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
947 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
948 case 'w': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
949 ifo->options |= DHCPCD_WAITIP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
950 if (arg != NULL && arg[0] != '\0') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
951 if (arg[0] == '4' || arg[1] == '4') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
952 ifo->options |= DHCPCD_WAITIP4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
953 if (arg[0] == '6' || arg[1] == '6') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
954 ifo->options |= DHCPCD_WAITIP6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
955 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
956 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
957 case 'y': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
958 ARG_REQUIRED; |
|
4923
4fcca755943e
eloop: Allow for for timeouts greater than time_t and time wrapping
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
959 ifo->reboot = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
960 if (e) { |
| 4010 | 961 logerr("failed to convert reboot %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
962 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
963 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
964 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
965 case 'z': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
966 ARG_REQUIRED; |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
967 if (!IN_CONFIG_BLOCK(ifo)) |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
968 ctx->ifav = splitv(&ctx->ifac, ctx->ifav, arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
969 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
970 case 'A': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
971 ifo->options &= ~DHCPCD_ARP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
972 /* IPv4LL requires ARP */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
973 ifo->options &= ~DHCPCD_IPV4LL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
974 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
975 case 'B': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
976 ifo->options &= ~DHCPCD_DAEMONISE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
977 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
978 case 'C': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
979 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
980 /* Commas to spaces for shell */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
981 while ((p = strchr(arg, ','))) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
982 *p = ' '; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
983 dl = strlen("skip_hooks=") + strlen(arg) + 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
984 p = malloc(sizeof(char) * dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
985 if (p == NULL) { |
| 4010 | 986 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
987 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
988 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
989 snprintf(p, dl, "skip_hooks=%s", arg); |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
990 add_environ(&ifo->environ, p, 0); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
991 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
992 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
993 case 'D': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
994 ifo->options |= DHCPCD_CLIENTID | DHCPCD_DUID; |
|
5456
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
995 if (ifname != NULL) /* duid type only a global option */ |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
996 break; |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
997 if (arg == NULL) |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
998 ctx->duid_type = DUID_DEFAULT; |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
999 else if (strcmp(arg, "ll") == 0) |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1000 ctx->duid_type = DUID_LL; |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1001 else if (strcmp(arg, "llt") == 0) |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1002 ctx->duid_type = DUID_LLT; |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1003 else if (strcmp(arg, "uuid") == 0) |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1004 ctx->duid_type = DUID_UUID; |
|
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1005 else { |
|
5551
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1006 dl = hwaddr_aton(NULL, arg); |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1007 if (dl != 0) { |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1008 no = realloc(ctx->duid, dl); |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1009 if (no == NULL) |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1010 logerrx(__func__); |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1011 else { |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1012 ctx->duid = no; |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1013 ctx->duid_len = hwaddr_aton(no, arg); |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1014 } |
|
0c4608a6cc2a
options: Allow duid to take a value
Roy Marples <roy@marples.name>
parents:
5550
diff
changeset
|
1015 } |
|
5456
9203603adc76
duid: Allow optional argument to specify ll or llt alongside uuid
Roy Marples <roy@marples.name>
parents:
5435
diff
changeset
|
1016 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1017 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1018 case 'E': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1019 ifo->options |= DHCPCD_LASTLEASE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1020 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1021 case 'F': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1022 if (!arg) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1023 ifo->fqdn = FQDN_BOTH; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1024 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1025 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1026 if (strcmp(arg, "none") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1027 ifo->fqdn = FQDN_NONE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1028 else if (strcmp(arg, "ptr") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1029 ifo->fqdn = FQDN_PTR; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1030 else if (strcmp(arg, "both") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1031 ifo->fqdn = FQDN_BOTH; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1032 else if (strcmp(arg, "disable") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1033 ifo->fqdn = FQDN_DISABLE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1034 else { |
| 5494 | 1035 logerrx("invalid FQDN value: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1036 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1037 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1038 break; |
| 4067 | 1039 case 'G': |
| 1040 ifo->options &= ~DHCPCD_GATEWAY; | |
| 1041 break; | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1042 case 'H': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1043 ifo->options |= DHCPCD_XID_HWADDR; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1044 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1045 case 'I': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1046 /* Strings have a type of 0 */; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1047 ifo->clientid[1] = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1048 if (arg) |
|
4429
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
1049 s = parse_hwaddr((char *)ifo->clientid + 1, |
|
85da28e7b6e7
options: improve string parsing some more
Roy Marples <roy@marples.name>
parents:
4428
diff
changeset
|
1050 CLIENTID_MAX_LEN, arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1051 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1052 s = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1053 if (s == -1) { |
| 4010 | 1054 logerr("clientid"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1055 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1056 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1057 ifo->options |= DHCPCD_CLIENTID; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1058 ifo->clientid[0] = (uint8_t)s; |
|
5412
10414d410d49
options: Let clientid override a prior duid
Roy Marples <roy@marples.name>
parents:
5411
diff
changeset
|
1059 ifo->options &= ~DHCPCD_DUID; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1060 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1061 case 'J': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1062 ifo->options |= DHCPCD_BROADCAST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1063 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1064 case 'K': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1065 ifo->options &= ~DHCPCD_LINK; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1066 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1067 case 'L': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1068 ifo->options &= ~DHCPCD_IPV4LL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1069 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1070 case 'M': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1071 ifo->options |= DHCPCD_MASTER; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1072 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1073 case 'O': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1074 ARG_REQUIRED; |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1075 if (ctx->options & DHCPCD_PRINT_PIDFILE) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1076 break; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
1077 set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1078 &request, &require, &no, &reject); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1079 if (make_option_mask(d, dl, od, odl, request, arg, -1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1080 make_option_mask(d, dl, od, odl, require, arg, -1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1081 make_option_mask(d, dl, od, odl, no, arg, 1) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1082 { |
| 5494 | 1083 logerrx("unknown option: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1084 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1085 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1086 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1087 case 'Q': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1088 ARG_REQUIRED; |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1089 if (ctx->options & DHCPCD_PRINT_PIDFILE) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1090 break; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
1091 set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1092 &request, &require, &no, &reject); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1093 if (make_option_mask(d, dl, od, odl, require, arg, 1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1094 make_option_mask(d, dl, od, odl, request, arg, 1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1095 make_option_mask(d, dl, od, odl, no, arg, -1) != 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1096 make_option_mask(d, dl, od, odl, reject, arg, -1) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1097 { |
| 5494 | 1098 logerrx("unknown option: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1099 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1100 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1101 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1102 case 'S': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1103 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1104 p = strchr(arg, '='); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1105 if (p == NULL) { |
| 4010 | 1106 logerrx("static assignment required"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1107 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1108 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1109 p++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1110 if (strncmp(arg, "ip_address=", strlen("ip_address=")) == 0) { |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1111 if (parse_addr(&ifo->req_addr, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1112 ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1113 p) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1114 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1115 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1116 ifo->options |= DHCPCD_STATIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1117 ifo->options &= ~DHCPCD_INFORM; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1118 } else if (strncmp(arg, "subnet_mask=", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1119 strlen("subnet_mask=")) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1120 { |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1121 if (parse_addr(&ifo->req_mask, NULL, p) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1122 return -1; |
|
4207
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
1123 } else if (strncmp(arg, "broadcast_address=", |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
1124 strlen("broadcast_address=")) == 0) |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
1125 { |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
1126 if (parse_addr(&ifo->req_brd, NULL, p) != 0) |
|
d9c3c7008d20
ipv4: allow configuration of static broadcast address
Roy Marples <roy@marples.name>
parents:
4197
diff
changeset
|
1127 return -1; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1128 } else if (strncmp(arg, "routes=", strlen("routes=")) == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1129 strncmp(arg, "static_routes=", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1130 strlen("static_routes=")) == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1131 strncmp(arg, "classless_static_routes=", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1132 strlen("classless_static_routes=")) == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1133 strncmp(arg, "ms_classless_static_routes=", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1134 strlen("ms_classless_static_routes=")) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1135 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1136 struct in_addr addr3; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1137 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1138 fp = np = strwhite(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1139 if (np == NULL) { |
| 4010 | 1140 logerrx("all routes need a gateway"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1141 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1142 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1143 *np++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1144 np = strskipwhite(np); |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1145 if (parse_addr(&addr, &addr2, p) == -1 || |
|
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1146 parse_addr(&addr3, NULL, np) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1147 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1148 *fp = ' '; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1149 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1150 } |
| 4442 | 1151 *fp = ' '; |
| 1152 if ((rt = rt_new0(ctx)) == NULL) | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1153 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1154 sa_in_init(&rt->rt_dest, &addr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1155 sa_in_init(&rt->rt_netmask, &addr2); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1156 sa_in_init(&rt->rt_gateway, &addr3); |
|
4522
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4511
diff
changeset
|
1157 if (rt_proto_add_ctx(&ifo->routes, rt, ctx)) |
| 4442 | 1158 add_environ(&ifo->config, arg, 0); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1159 } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) { |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1160 if (parse_addr(&addr, NULL, p) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1161 return -1; |
|
4248
2844dbb214b5
options: allow static routes to be configured on the command line
Roy Marples <roy@marples.name>
parents:
4207
diff
changeset
|
1162 if ((rt = rt_new0(ctx)) == NULL) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1163 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1164 addr2.s_addr = INADDR_ANY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1165 sa_in_init(&rt->rt_dest, &addr2); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1166 sa_in_init(&rt->rt_netmask, &addr2); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1167 sa_in_init(&rt->rt_gateway, &addr); |
|
4522
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4511
diff
changeset
|
1168 if (rt_proto_add_ctx(&ifo->routes, rt, ctx)) |
| 4442 | 1169 add_environ(&ifo->config, arg, 0); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1170 } else if (strncmp(arg, "interface_mtu=", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1171 strlen("interface_mtu=")) == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1172 strncmp(arg, "mtu=", strlen("mtu=")) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1173 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1174 ifo->mtu = (unsigned int)strtou(p, NULL, 0, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1175 MTU_MIN, MTU_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1176 if (e) { |
| 4010 | 1177 logerrx("invalid MTU %s", p); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1178 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1179 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1180 } else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1181 np = strchr(p, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1182 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1183 *np++ = '\0'; |
|
5050
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1184 if ((i = inet_pton(AF_INET6, p, &ifo->req_addr6)) == 1) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1185 if (np) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1186 ifo->req_prefix_len = (uint8_t)strtou(np, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1187 NULL, 0, 0, 128, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1188 if (e) { |
| 4010 | 1189 logerrx("%s: failed to " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1190 "convert prefix len", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1191 ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1192 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1193 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1194 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1195 ifo->req_prefix_len = 128; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1196 } |
|
5050
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1197 if (np) |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1198 *(--np) = '\0'; |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1199 if (i != 1) { |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1200 logerrx("invalid AF_INET6: %s", p); |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1201 memset(&ifo->req_addr6, 0, |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1202 sizeof(ifo->req_addr6)); |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1203 return -1; |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1204 } |
|
4426
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
1205 } else |
|
109f0860f9e5
options: add static routers and routes to environment
Roy Marples <roy@marples.name>
parents:
4424
diff
changeset
|
1206 add_environ(&ifo->config, arg, 1); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1207 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1208 case 'W': |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1209 if (parse_addr(&addr, &addr2, arg) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1210 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1211 if (strchr(arg, '/') == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1212 addr2.s_addr = INADDR_BROADCAST; |
| 4007 | 1213 naddr = reallocarray(ifo->whitelist, |
| 1214 ifo->whitelist_len + 2, sizeof(in_addr_t)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1215 if (naddr == NULL) { |
| 4010 | 1216 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1217 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1218 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1219 ifo->whitelist = naddr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1220 ifo->whitelist[ifo->whitelist_len++] = addr.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1221 ifo->whitelist[ifo->whitelist_len++] = addr2.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1222 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1223 case 'X': |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1224 if (parse_addr(&addr, &addr2, arg) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1225 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1226 if (strchr(arg, '/') == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1227 addr2.s_addr = INADDR_BROADCAST; |
| 4007 | 1228 naddr = reallocarray(ifo->blacklist, |
| 1229 ifo->blacklist_len + 2, sizeof(in_addr_t)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1230 if (naddr == NULL) { |
| 4010 | 1231 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1232 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1233 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1234 ifo->blacklist = naddr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1235 ifo->blacklist[ifo->blacklist_len++] = addr.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1236 ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1237 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1238 case 'Z': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1239 ARG_REQUIRED; |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
1240 if (!IN_CONFIG_BLOCK(ifo)) |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1241 ctx->ifdv = splitv(&ctx->ifdc, ctx->ifdv, arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1242 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1243 case '1': |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1244 ifo->options |= DHCPCD_ONESHOT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1245 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1246 case '4': |
|
5416
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1247 #ifdef INET |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1248 ifo->options &= ~DHCPCD_IPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1249 ifo->options |= DHCPCD_IPV4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1250 break; |
|
5416
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1251 #else |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1252 logerrx("INET has been compiled out"); |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1253 return -1; |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1254 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1255 case '6': |
|
5416
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1256 #ifdef INET6 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1257 ifo->options &= ~DHCPCD_IPV4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1258 ifo->options |= DHCPCD_IPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1259 break; |
|
5416
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1260 #else |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1261 logerrx("INET6 has been compiled out"); |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1262 return -1; |
|
1290c8e7ea84
dhcpcd: If using -4 or -6, check we have support for it
Roy Marples <roy@marples.name>
parents:
5412
diff
changeset
|
1263 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1264 case O_IPV4: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1265 ifo->options |= DHCPCD_IPV4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1266 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1267 case O_NOIPV4: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1268 ifo->options &= ~DHCPCD_IPV4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1269 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1270 case O_IPV6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1271 ifo->options |= DHCPCD_IPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1272 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1273 case O_NOIPV6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1274 ifo->options &= ~DHCPCD_IPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1275 break; |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1276 case O_ANONYMOUS: |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1277 ifo->options |= DHCPCD_ANONYMOUS; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1278 ifo->options &= ~DHCPCD_HOSTNAME; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1279 ifo->fqdn = FQDN_DISABLE; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1280 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1281 /* Block everything */ |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1282 memset(ifo->nomask, 0xff, sizeof(ifo->nomask)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1283 memset(ifo->nomask6, 0xff, sizeof(ifo->nomask6)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1284 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1285 /* Allow the bare minimum through */ |
|
5112
899adcd7f449
Fix build without INET or INET6
Roy Marples <roy@marples.name>
parents:
5090
diff
changeset
|
1286 #ifdef INET |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1287 del_option_mask(ifo->nomask, DHO_SUBNETMASK); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1288 del_option_mask(ifo->nomask, DHO_CSR); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1289 del_option_mask(ifo->nomask, DHO_ROUTER); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1290 del_option_mask(ifo->nomask, DHO_DNSSERVER); |
|
4967
e137c0aa1068
anonymous: Allow Domain Name option through.
Roy Marples <roy@marples.name>
parents:
4958
diff
changeset
|
1291 del_option_mask(ifo->nomask, DHO_DNSDOMAIN); |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1292 del_option_mask(ifo->nomask, DHO_BROADCAST); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1293 del_option_mask(ifo->nomask, DHO_STATICROUTE); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1294 del_option_mask(ifo->nomask, DHO_SERVERID); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1295 del_option_mask(ifo->nomask, DHO_RENEWALTIME); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1296 del_option_mask(ifo->nomask, DHO_REBINDTIME); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1297 del_option_mask(ifo->nomask, DHO_DNSSEARCH); |
|
5112
899adcd7f449
Fix build without INET or INET6
Roy Marples <roy@marples.name>
parents:
5090
diff
changeset
|
1298 #endif |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1299 |
|
5286
b820f26385b7
Fix compile with inet or inet6 disabled
Roy Marples <roy@marples.name>
parents:
5257
diff
changeset
|
1300 #ifdef DHCP6 |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1301 del_option_mask(ifo->nomask6, D6_OPTION_DNS_SERVERS); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1302 del_option_mask(ifo->nomask6, D6_OPTION_DOMAIN_LIST); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1303 del_option_mask(ifo->nomask6, D6_OPTION_SOL_MAX_RT); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1304 del_option_mask(ifo->nomask6, D6_OPTION_INF_MAX_RT); |
|
5112
899adcd7f449
Fix build without INET or INET6
Roy Marples <roy@marples.name>
parents:
5090
diff
changeset
|
1305 #endif |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1306 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
1307 break; |
|
5574
2a519da0f1a2
DHCP: Split hardware address randomisation out of anonymous option
Roy Marples <roy@marples.name>
parents:
5551
diff
changeset
|
1308 case O_RANDOMISE_HWADDR: |
|
2a519da0f1a2
DHCP: Split hardware address randomisation out of anonymous option
Roy Marples <roy@marples.name>
parents:
5551
diff
changeset
|
1309 ifo->randomise_hwaddr = true; |
|
2a519da0f1a2
DHCP: Split hardware address randomisation out of anonymous option
Roy Marples <roy@marples.name>
parents:
5551
diff
changeset
|
1310 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1311 #ifdef INET |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1312 case O_ARPING: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1313 while (arg != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1314 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1315 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1316 *fp++ = '\0'; |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
1317 if (parse_addr(&addr, NULL, arg) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1318 return -1; |
| 4007 | 1319 naddr = reallocarray(ifo->arping, |
| 1320 (size_t)ifo->arping_len + 1, sizeof(in_addr_t)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1321 if (naddr == NULL) { |
| 4010 | 1322 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1323 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1324 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1325 ifo->arping = naddr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1326 ifo->arping[ifo->arping_len++] = addr.s_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1327 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1328 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1329 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1330 case O_DESTINATION: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1331 ARG_REQUIRED; |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1332 if (ctx->options & DHCPCD_PRINT_PIDFILE) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
1333 break; |
|
4725
7ccfd011197b
options: Allow domain spaced options
Roy Marples <roy@marples.name>
parents:
4632
diff
changeset
|
1334 set_option_space(ctx, arg, &d, &dl, &od, &odl, ifo, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1335 &request, &require, &no, &reject); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1336 if (make_option_mask(d, dl, od, odl, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1337 ifo->dstmask, arg, 2) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1338 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1339 if (errno == EINVAL) |
| 5494 | 1340 logerrx("option does not take" |
| 1341 " an IPv4 address: %s", arg); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1342 else |
| 5494 | 1343 logerrx("unknown option: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1344 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1345 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1346 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1347 case O_FALLBACK: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1348 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1349 free(ifo->fallback); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1350 ifo->fallback = strdup(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1351 if (ifo->fallback == NULL) { |
| 4010 | 1352 logerrx(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1353 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1354 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1355 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1356 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1357 case O_IAID: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1358 ARG_REQUIRED; |
|
5550
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1359 if (ctx->options & DHCPCD_MASTER && !IN_CONFIG_BLOCK(ifo)) { |
| 4010 | 1360 logerrx("IAID must belong in an interface block"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1361 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1362 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1363 if (parse_iaid(ifo->iaid, arg, sizeof(ifo->iaid)) == -1) { |
| 4010 | 1364 logerrx("invalid IAID %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1365 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1366 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1367 ifo->options |= DHCPCD_IAID; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1368 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1369 case O_IPV6RS: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1370 ifo->options |= DHCPCD_IPV6RS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1371 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1372 case O_NOIPV6RS: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1373 ifo->options &= ~DHCPCD_IPV6RS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1374 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1375 case O_IPV6RA_FORK: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1376 ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1377 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1378 case O_IPV6RA_AUTOCONF: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1379 ifo->options |= DHCPCD_IPV6RA_AUTOCONF; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1380 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1381 case O_IPV6RA_NOAUTOCONF: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1382 ifo->options &= ~DHCPCD_IPV6RA_AUTOCONF; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1383 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1384 case O_NOALIAS: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1385 ifo->options |= DHCPCD_NOALIAS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1386 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1387 #ifdef DHCP6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1388 case O_IA_NA: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1389 i = D6_OPTION_IA_NA; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1390 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1391 case O_IA_TA: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1392 if (i == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1393 i = D6_OPTION_IA_TA; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1394 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1395 case O_IA_PD: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1396 if (i == 0) { |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1397 #ifdef SMALL |
|
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1398 logwarnx("%s: IA_PD not compiled in", ifname); |
|
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1399 return -1; |
|
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1400 #else |
|
5550
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1401 if (ctx->options & DHCPCD_MASTER && |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1402 !IN_CONFIG_BLOCK(ifo)) |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1403 { |
| 4494 | 1404 logerrx("IA PD must belong in an " |
| 4010 | 1405 "interface block"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1406 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1407 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1408 i = D6_OPTION_IA_PD; |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1409 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1410 } |
|
5550
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1411 if (ctx->options & DHCPCD_MASTER && |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1412 !IN_CONFIG_BLOCK(ifo) && arg) |
|
dba7608e00b3
options: allow --ia_na=1 and --ia_pd=2 on the command line
Roy Marples <roy@marples.name>
parents:
5546
diff
changeset
|
1413 { |
| 4010 | 1414 logerrx("IA with IAID must belong in an " |
| 1415 "interface block"); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1416 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1417 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1418 ifo->options |= DHCPCD_IA_FORCED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1419 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1420 if (fp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1421 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1422 fp = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1423 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1424 if (arg) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1425 p = strchr(arg, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1426 if (p) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1427 *p++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1428 if (parse_iaid(iaid, arg, sizeof(iaid)) == -1) { |
| 4010 | 1429 logerr("invalid IAID: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1430 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1431 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1432 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1433 ia = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1434 for (sl = 0; sl < ifo->ia_len; sl++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1435 if ((arg == NULL && !ifo->ia[sl].iaid_set) || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1436 (arg != NULL && ifo->ia[sl].iaid_set && |
|
4279
cdffb0137daa
dhcp6: IAID is now unique for IA type
Roy Marples <roy@marples.name>
parents:
4266
diff
changeset
|
1437 ifo->ia[sl].ia_type == (uint16_t)i && |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1438 ifo->ia[sl].iaid[0] == iaid[0] && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1439 ifo->ia[sl].iaid[1] == iaid[1] && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1440 ifo->ia[sl].iaid[2] == iaid[2] && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1441 ifo->ia[sl].iaid[3] == iaid[3])) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1442 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1443 ia = &ifo->ia[sl]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1444 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1445 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1446 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1447 if (ia == NULL) { |
| 4007 | 1448 ia = reallocarray(ifo->ia, |
| 1449 ifo->ia_len + 1, sizeof(*ifo->ia)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1450 if (ia == NULL) { |
| 4010 | 1451 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1452 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1453 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1454 ifo->ia = ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1455 ia = &ifo->ia[ifo->ia_len++]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1456 ia->ia_type = (uint16_t)i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1457 if (arg) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1458 ia->iaid[0] = iaid[0]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1459 ia->iaid[1] = iaid[1]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1460 ia->iaid[2] = iaid[2]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1461 ia->iaid[3] = iaid[3]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1462 ia->iaid_set = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1463 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1464 ia->iaid_set = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1465 if (!ia->iaid_set || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1466 p == NULL || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1467 ia->ia_type == D6_OPTION_IA_TA) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1468 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1469 memset(&ia->addr, 0, sizeof(ia->addr)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1470 ia->prefix_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1471 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1472 arg = p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1473 p = strchr(arg, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1474 if (p) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1475 *p++ = '\0'; |
|
5050
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1476 if (inet_pton(AF_INET6, arg, &ia->addr) != 1) { |
|
fb4b6e3ab45e
options: Improve AF_INET6 address parsing and logging
Roy Marples <roy@marples.name>
parents:
4991
diff
changeset
|
1477 logerrx("invalid AF_INET6: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1478 memset(&ia->addr, 0, sizeof(ia->addr)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1479 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1480 if (p && ia->ia_type == D6_OPTION_IA_PD) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1481 ia->prefix_len = (uint8_t)strtou(p, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1482 NULL, 0, 8, 120, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1483 if (e) { |
| 4010 | 1484 logerrx("%s: failed to convert" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1485 " prefix len", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1486 p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1487 ia->prefix_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1488 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1489 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1490 } |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1491 #ifndef SMALL |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1492 ia->sla_max = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1493 ia->sla_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1494 ia->sla = NULL; |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1495 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1496 } |
|
4358
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4349
diff
changeset
|
1497 |
|
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4349
diff
changeset
|
1498 #ifdef SMALL |
|
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4349
diff
changeset
|
1499 break; |
|
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4349
diff
changeset
|
1500 #else |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1501 if (ia->ia_type != D6_OPTION_IA_PD) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1502 break; |
|
4358
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4349
diff
changeset
|
1503 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1504 for (p = fp; p; p = fp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1505 fp = strwhite(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1506 if (fp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1507 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1508 fp = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1509 } |
| 4007 | 1510 sla = reallocarray(ia->sla, |
| 1511 ia->sla_len + 1, sizeof(*ia->sla)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1512 if (sla == NULL) { |
| 4010 | 1513 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1514 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1515 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1516 ia->sla = sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1517 sla = &ia->sla[ia->sla_len++]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1518 np = strchr(p, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1519 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1520 *np++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1521 if (strlcpy(sla->ifname, p, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1522 sizeof(sla->ifname)) >= sizeof(sla->ifname)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1523 { |
| 4010 | 1524 logerrx("%s: interface name too long", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1525 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1526 } |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5309
diff
changeset
|
1527 sla->sla_set = false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1528 sla->prefix_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1529 sla->suffix = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1530 p = np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1531 if (p) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1532 np = strchr(p, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1533 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1534 *np++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1535 if (*p != '\0') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1536 sla->sla = (uint32_t)strtou(p, NULL, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1537 0, 0, UINT32_MAX, &e); |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5309
diff
changeset
|
1538 sla->sla_set = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1539 if (e) { |
| 4010 | 1540 logerrx("%s: failed to convert " |
| 1541 "sla", | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1542 ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1543 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1544 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1545 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1546 p = np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1547 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1548 if (p) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1549 np = strchr(p, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1550 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1551 *np++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1552 if (*p != '\0') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1553 sla->prefix_len = (uint8_t)strtou(p, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1554 NULL, 0, 0, 120, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1555 if (e) { |
| 4010 | 1556 logerrx("%s: failed to " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1557 "convert prefix len", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1558 ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1559 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1560 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1561 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1562 p = np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1563 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1564 if (p) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1565 np = strchr(p, '/'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1566 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1567 *np = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1568 if (*p != '\0') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1569 sla->suffix = (uint64_t)strtou(p, NULL, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1570 0, 0, UINT64_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1571 if (e) { |
| 4010 | 1572 logerrx("%s: failed to " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1573 "convert suffix", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1574 ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1575 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1576 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1577 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1578 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1579 /* Sanity check */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1580 for (sl = 0; sl < ia->sla_len - 1; sl++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1581 slap = &ia->sla[sl]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1582 if (slap->sla_set != sla->sla_set) { |
| 4010 | 1583 logerrx("%s: cannot mix automatic " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1584 "and fixed SLA", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1585 sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1586 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1587 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1588 if (ia->prefix_len && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1589 (sla->prefix_len == ia->prefix_len || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1590 slap->prefix_len == ia->prefix_len)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1591 { |
| 4010 | 1592 logerrx("%s: cannot delegte the same" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1593 "prefix length more than once", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1594 sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1595 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1596 } |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5309
diff
changeset
|
1597 if (!sla->sla_set && |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1598 strcmp(slap->ifname, sla->ifname) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1599 { |
| 4010 | 1600 logwarnx("%s: cannot specify the " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1601 "same interface twice with " |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1602 "an automatic SLA", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1603 sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1604 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1605 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1606 if (slap->sla_set && sla->sla_set && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1607 slap->sla == sla->sla) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1608 { |
| 4010 | 1609 logerrx("%s: cannot" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1610 " assign the same SLA %u" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1611 " more than once", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1612 sla->ifname, sla->sla); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1613 goto err_sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1614 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1615 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1616 if (sla->sla_set && sla->sla > ia->sla_max) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1617 ia->sla_max = sla->sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1618 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1619 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1620 err_sla: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1621 ia->sla_len--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1622 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1623 #endif |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
1624 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1625 case O_HOSTNAME_SHORT: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1626 ifo->options |= DHCPCD_HOSTNAME | DHCPCD_HOSTNAME_SHORT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1627 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1628 case O_DEV: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1629 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1630 #ifdef PLUGIN_DEV |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1631 if (ctx->dev_load) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1632 free(ctx->dev_load); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1633 ctx->dev_load = strdup(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1634 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1635 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1636 case O_NODEV: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1637 ifo->options &= ~DHCPCD_DEV; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1638 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1639 case O_DEFINE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1640 dop = &ifo->dhcp_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1641 dop_len = &ifo->dhcp_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1642 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1643 case O_DEFINEND: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1644 if (dop == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1645 dop = &ifo->nd_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1646 dop_len = &ifo->nd_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1647 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1648 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1649 case O_DEFINE6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1650 if (dop == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1651 dop = &ifo->dhcp6_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1652 dop_len = &ifo->dhcp6_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1653 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1654 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1655 case O_VENDOPT: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1656 if (dop == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1657 dop = &ifo->vivso_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1658 dop_len = &ifo->vivso_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1659 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1660 *edop = *ldop = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1661 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1662 case O_EMBED: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1663 if (dop == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1664 if (*edop) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1665 dop = &(*edop)->embopts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1666 dop_len = &(*edop)->embopts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1667 } else if (ldop) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1668 dop = &(*ldop)->embopts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1669 dop_len = &(*ldop)->embopts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1670 } else { |
| 4010 | 1671 logerrx("embed must be after a define " |
| 1672 "or encap"); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1673 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1674 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1675 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1676 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1677 case O_ENCAP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1678 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1679 if (dop == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1680 if (*ldop == NULL) { |
| 4010 | 1681 logerrx("encap must be after a define"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1682 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1683 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1684 dop = &(*ldop)->encopts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1685 dop_len = &(*ldop)->encopts_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1686 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1687 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1688 /* Shared code for define, define6, embed and encap */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1689 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1690 /* code */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1691 if (opt == O_EMBED) /* Embedded options don't have codes */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1692 u = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1693 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1694 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1695 if (fp == NULL) { |
| 4010 | 1696 logerrx("invalid syntax: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1697 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1698 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1699 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1700 u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1701 if (e) { |
| 4010 | 1702 logerrx("invalid code: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1703 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1704 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1705 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1706 if (arg == NULL) { |
| 4010 | 1707 logerrx("invalid syntax"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1708 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1709 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1710 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1711 /* type */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1712 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1713 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1714 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1715 np = strchr(arg, ':'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1716 /* length */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1717 if (np) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1718 *np++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1719 bp = NULL; /* No bitflag */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1720 l = (long)strtou(np, NULL, 0, 0, LONG_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1721 if (e) { |
| 4010 | 1722 logerrx("failed to convert length"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1723 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1724 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1725 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1726 l = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1727 bp = strchr(arg, '='); /* bitflag assignment */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1728 if (bp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1729 *bp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1730 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1731 t = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1732 if (strcasecmp(arg, "request") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1733 t |= OT_REQUEST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1734 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1735 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1736 if (fp == NULL) { |
| 4010 | 1737 logerrx("incomplete request type"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1738 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1739 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1740 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1741 } else if (strcasecmp(arg, "norequest") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1742 t |= OT_NOREQ; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1743 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1744 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1745 if (fp == NULL) { |
| 4010 | 1746 logerrx("incomplete request type"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1747 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1748 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1749 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1750 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1751 if (strcasecmp(arg, "optional") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1752 t |= OT_OPTIONAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1753 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1754 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1755 if (fp == NULL) { |
| 4010 | 1756 logerrx("incomplete optional type"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1757 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1758 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1759 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1760 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1761 if (strcasecmp(arg, "index") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1762 t |= OT_INDEX; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1763 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1764 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1765 if (fp == NULL) { |
| 4010 | 1766 logerrx("incomplete index type"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1767 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1768 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1769 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1770 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1771 if (strcasecmp(arg, "array") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1772 t |= OT_ARRAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1773 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1774 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1775 if (fp == NULL) { |
| 4010 | 1776 logerrx("incomplete array type"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1777 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1778 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1779 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1780 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1781 if (strcasecmp(arg, "ipaddress") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1782 t |= OT_ADDRIPV4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1783 else if (strcasecmp(arg, "ip6address") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1784 t |= OT_ADDRIPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1785 else if (strcasecmp(arg, "string") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1786 t |= OT_STRING; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1787 else if (strcasecmp(arg, "byte") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1788 t |= OT_UINT8; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1789 else if (strcasecmp(arg, "bitflags") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1790 t |= OT_BITFLAG; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1791 else if (strcasecmp(arg, "uint8") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1792 t |= OT_UINT8; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1793 else if (strcasecmp(arg, "int8") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1794 t |= OT_INT8; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1795 else if (strcasecmp(arg, "uint16") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1796 t |= OT_UINT16; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1797 else if (strcasecmp(arg, "int16") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1798 t |= OT_INT16; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1799 else if (strcasecmp(arg, "uint32") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1800 t |= OT_UINT32; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1801 else if (strcasecmp(arg, "int32") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1802 t |= OT_INT32; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1803 else if (strcasecmp(arg, "flag") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1804 t |= OT_FLAG; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1805 else if (strcasecmp(arg, "raw") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1806 t |= OT_STRING | OT_RAW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1807 else if (strcasecmp(arg, "ascii") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1808 t |= OT_STRING | OT_ASCII; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1809 else if (strcasecmp(arg, "domain") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1810 t |= OT_STRING | OT_DOMAIN | OT_RFC1035; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1811 else if (strcasecmp(arg, "dname") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1812 t |= OT_STRING | OT_DOMAIN; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1813 else if (strcasecmp(arg, "binhex") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1814 t |= OT_STRING | OT_BINHEX; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1815 else if (strcasecmp(arg, "embed") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1816 t |= OT_EMBED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1817 else if (strcasecmp(arg, "encap") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1818 t |= OT_ENCAP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1819 else if (strcasecmp(arg, "rfc3361") ==0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1820 t |= OT_STRING | OT_RFC3361; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1821 else if (strcasecmp(arg, "rfc3442") ==0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1822 t |= OT_STRING | OT_RFC3442; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1823 else if (strcasecmp(arg, "option") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1824 t |= OT_OPTION; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1825 else { |
| 4010 | 1826 logerrx("unknown type: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1827 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1828 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1829 if (l && !(t & (OT_STRING | OT_BINHEX))) { |
| 5494 | 1830 logwarnx("ignoring length for type: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1831 l = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1832 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1833 if (t & OT_ARRAY && t & (OT_STRING | OT_BINHEX) && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1834 !(t & (OT_RFC1035 | OT_DOMAIN))) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1835 { |
| 4010 | 1836 logwarnx("ignoring array for strings"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1837 t &= ~OT_ARRAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1838 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1839 if (t & OT_BITFLAG) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1840 if (bp == NULL) |
| 4010 | 1841 logwarnx("missing bitflag assignment"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1842 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1843 /* variable */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1844 if (!fp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1845 if (!(t & OT_OPTION)) { |
| 4010 | 1846 logerrx("type %s requires a variable name", |
| 1847 arg); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1848 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1849 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1850 np = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1851 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1852 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1853 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1854 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1855 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1856 if (strcasecmp(arg, "reserved")) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1857 np = strdup(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1858 if (np == NULL) { |
| 4010 | 1859 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1860 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1861 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1862 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1863 np = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1864 t |= OT_RESERVED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1865 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1866 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1867 if (opt != O_EMBED) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1868 for (dl = 0, ndop = *dop; dl < *dop_len; dl++, ndop++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1869 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1870 /* type 0 seems freshly malloced struct |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1871 * for us to use */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1872 if (ndop->option == u || ndop->type == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1873 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1874 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1875 if (dl == *dop_len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1876 ndop = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1877 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1878 ndop = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1879 if (ndop == NULL) { |
| 4007 | 1880 ndop = reallocarray(*dop, *dop_len + 1, sizeof(**dop)); |
| 1881 if (ndop == NULL) { | |
| 4010 | 1882 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1883 free(np); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1884 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1885 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1886 *dop = ndop; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1887 ndop = &(*dop)[(*dop_len)++]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1888 ndop->embopts = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1889 ndop->embopts_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1890 ndop->encopts = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1891 ndop->encopts_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1892 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1893 free_dhcp_opt_embenc(ndop); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1894 ndop->option = (uint32_t)u; /* could have been 0 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1895 ndop->type = t; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1896 ndop->len = (size_t)l; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1897 ndop->var = np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1898 if (bp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1899 dl = strlen(bp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1900 memcpy(ndop->bitflags, bp, dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1901 memset(ndop->bitflags + dl, 0, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1902 sizeof(ndop->bitflags) - dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1903 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1904 memset(ndop->bitflags, 0, sizeof(ndop->bitflags)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1905 /* Save the define for embed and encap options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1906 switch (opt) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1907 case O_DEFINE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1908 case O_DEFINEND: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1909 case O_DEFINE6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1910 case O_VENDOPT: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1911 *ldop = ndop; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1912 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1913 case O_ENCAP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1914 *edop = ndop; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1915 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1916 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1917 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1918 case O_VENDCLASS: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1919 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1920 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1921 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1922 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1923 u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1924 if (e) { |
| 4010 | 1925 logerrx("invalid code: %s", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1926 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1927 } |
|
4260
8c6250af2ed4
DHCP6: Fix sending custom vendor class option.
Roy Marples <roy@marples.name>
parents:
4249
diff
changeset
|
1928 fp = strskipwhite(fp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1929 if (fp) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1930 s = parse_string(NULL, 0, fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1931 if (s == -1) { |
| 4010 | 1932 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1933 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1934 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1935 dl = (size_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1936 if (dl + (sizeof(uint16_t) * 2) > UINT16_MAX) { |
| 4010 | 1937 logerrx("vendor class is too big"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1938 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1939 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1940 np = malloc(dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1941 if (np == NULL) { |
| 4010 | 1942 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1943 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1944 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1945 parse_string(np, dl, fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1946 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1947 dl = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1948 np = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1949 } |
| 4007 | 1950 vivco = reallocarray(ifo->vivco, |
| 1951 ifo->vivco_len + 1, sizeof(*ifo->vivco)); | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1952 if (vivco == NULL) { |
| 4010 | 1953 logerr( __func__); |
| 4558 | 1954 free(np); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1955 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1956 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1957 ifo->vivco = vivco; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1958 ifo->vivco_en = (uint32_t)u; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1959 vivco = &ifo->vivco[ifo->vivco_len++]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1960 vivco->len = dl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1961 vivco->data = (uint8_t *)np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1962 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1963 case O_AUTHPROTOCOL: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1964 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1965 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1966 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1967 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1968 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1969 if (strcasecmp(arg, "token") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1970 ifo->auth.protocol = AUTH_PROTO_TOKEN; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1971 else if (strcasecmp(arg, "delayed") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1972 ifo->auth.protocol = AUTH_PROTO_DELAYED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1973 else if (strcasecmp(arg, "delayedrealm") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1974 ifo->auth.protocol = AUTH_PROTO_DELAYEDREALM; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1975 else { |
| 4010 | 1976 logerrx("%s: unsupported protocol", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1977 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1978 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1979 arg = strskipwhite(fp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1980 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1981 if (arg == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1982 ifo->auth.options |= DHCPCD_AUTH_SEND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1983 if (ifo->auth.protocol == AUTH_PROTO_TOKEN) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1984 ifo->auth.protocol = AUTH_ALG_NONE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1985 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1986 ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1987 ifo->auth.rdm = AUTH_RDM_MONOTONIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1988 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1989 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1990 if (fp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1991 *fp++ = '\0'; |
|
4266
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1992 if (ifo->auth.protocol == AUTH_PROTO_TOKEN) { |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1993 np = strchr(arg, '/'); |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1994 if (np) { |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1995 if (fp == NULL || np < fp) |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1996 *np++ = '\0'; |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1997 else |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1998 np = NULL; |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
1999 } |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2000 if (parse_uint32(&ifo->auth.token_snd_secretid, |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2001 arg) == -1) |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2002 logerrx("%s: not a number", arg); |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2003 else |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2004 ifo->auth.token_rcv_secretid = |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2005 ifo->auth.token_snd_secretid; |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2006 if (np && |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2007 parse_uint32(&ifo->auth.token_rcv_secretid, |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2008 np) == -1) |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2009 logerrx("%s: not a number", arg); |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2010 } else { |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2011 if (strcasecmp(arg, "hmacmd5") == 0 || |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2012 strcasecmp(arg, "hmac-md5") == 0) |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2013 ifo->auth.algorithm = AUTH_ALG_HMAC_MD5; |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2014 else { |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2015 logerrx("%s: unsupported algorithm", arg); |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2016 return 1; |
|
bd15cb1af330
auth: allow different tokens for send and receive
Roy Marples <roy@marples.name>
parents:
4260
diff
changeset
|
2017 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2018 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2019 arg = fp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2020 if (arg == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2021 ifo->auth.options |= DHCPCD_AUTH_SEND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2022 ifo->auth.rdm = AUTH_RDM_MONOTONIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2023 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2024 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2025 if (strcasecmp(arg, "monocounter") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2026 ifo->auth.rdm = AUTH_RDM_MONOTONIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2027 ifo->auth.options |= DHCPCD_AUTH_RDM_COUNTER; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2028 } else if (strcasecmp(arg, "monotonic") ==0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2029 strcasecmp(arg, "monotime") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2030 ifo->auth.rdm = AUTH_RDM_MONOTONIC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2031 else { |
| 4010 | 2032 logerrx("%s: unsupported RDM", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2033 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2034 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2035 ifo->auth.options |= DHCPCD_AUTH_SEND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2036 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2037 #else |
| 4010 | 2038 logerrx("no authentication support"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2039 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2040 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2041 case O_AUTHTOKEN: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2042 ARG_REQUIRED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2043 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2044 fp = strwhite(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2045 if (fp == NULL) { |
| 4010 | 2046 logerrx("authtoken requires a realm"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2047 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2048 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2049 *fp++ = '\0'; |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2050 token = calloc(1, sizeof(*token)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2051 if (token == NULL) { |
| 4010 | 2052 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2053 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2054 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2055 if (parse_uint32(&token->secretid, arg) == -1) { |
| 4010 | 2056 logerrx("%s: not a number", arg); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2057 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2058 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2059 arg = fp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2060 fp = strend(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2061 if (fp == NULL) { |
| 4010 | 2062 logerrx("authtoken requies an a key"); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2063 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2064 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2065 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2066 s = parse_string(NULL, 0, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2067 if (s == -1) { |
| 4010 | 2068 logerr("realm_len"); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2069 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2070 } |
|
5081
2104f358fb57
Remove empty brace from prior
Roy Marples <roy@marples.name>
parents:
5080
diff
changeset
|
2071 if (s != 0) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2072 token->realm_len = (size_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2073 token->realm = malloc(token->realm_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2074 if (token->realm == NULL) { |
| 4010 | 2075 logerr(__func__); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2076 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2077 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2078 parse_string((char *)token->realm, token->realm_len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2079 arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2080 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2081 arg = fp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2082 fp = strend(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2083 if (fp == NULL) { |
|
4325
f35fd6ef93c8
Remove supurfluous an.
Masanobu SAITOH <msaitoh@execsw.org>
parents:
4279
diff
changeset
|
2084 logerrx("authtoken requies an expiry date"); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2085 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2086 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2087 *fp++ = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2088 if (*arg == '"') { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2089 arg++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2090 np = strchr(arg, '"'); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2091 if (np) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2092 *np = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2093 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2094 if (strcmp(arg, "0") == 0 || strcasecmp(arg, "forever") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2095 token->expire =0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2096 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2097 struct tm tm; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2098 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2099 memset(&tm, 0, sizeof(tm)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2100 if (strptime(arg, "%Y-%m-%d %H:%M", &tm) == NULL) { |
| 4010 | 2101 logerrx("%s: invalid date time", arg); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2102 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2103 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2104 if ((token->expire = mktime(&tm)) == (time_t)-1) { |
| 4010 | 2105 logerr("%s: mktime", __func__); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2106 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2107 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2108 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2109 arg = fp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2110 s = parse_string(NULL, 0, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2111 if (s == -1 || s == 0) { |
| 4010 | 2112 if (s == -1) |
| 2113 logerr("token_len"); | |
| 2114 else | |
| 2115 logerrx("authtoken needs a key"); | |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2116 goto invalid_token; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2117 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2118 token->key_len = (size_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2119 token->key = malloc(token->key_len); |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2120 if (token->key == NULL) { |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2121 logerr(__func__); |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2122 goto invalid_token; |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2123 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2124 parse_string((char *)token->key, token->key_len, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2125 TAILQ_INSERT_TAIL(&ifo->auth.tokens, token, next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2126 break; |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2127 |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2128 invalid_token: |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2129 free(token->realm); |
|
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2130 free(token); |
| 5090 | 2131 #else |
| 2132 logerrx("no authentication support"); | |
| 2133 #endif | |
|
5080
5b024c9d95ec
options: optimise token storage by reducing free calls
Roy Marples <roy@marples.name>
parents:
5076
diff
changeset
|
2134 return -1; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2135 case O_AUTHNOTREQUIRED: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2136 ifo->auth.options &= ~DHCPCD_AUTH_REQUIRE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2137 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2138 case O_DHCP: |
|
4632
a52cb3bec112
DHCP: Allow DHCP over PtP interfaces.
Roy Marples <roy@marples.name>
parents:
4629
diff
changeset
|
2139 ifo->options |= DHCPCD_DHCP | DHCPCD_WANTDHCP | DHCPCD_IPV4; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2140 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2141 case O_NODHCP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2142 ifo->options &= ~DHCPCD_DHCP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2143 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2144 case O_DHCP6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2145 ifo->options |= DHCPCD_DHCP6 | DHCPCD_IPV6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2146 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2147 case O_NODHCP6: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2148 ifo->options &= ~DHCPCD_DHCP6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2149 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2150 case O_CONTROLGRP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2151 ARG_REQUIRED; |
|
5409
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2152 #ifdef PRIVSEP |
|
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2153 /* Control group is already set by this point. |
|
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2154 * We don't need to pledge getpw either with this. */ |
|
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2155 if (IN_PRIVSEP(ctx)) |
|
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2156 break; |
|
571dbb02e7c5
privsep: Don't read control_group in privsep
Roy Marples <roy@marples.name>
parents:
5392
diff
changeset
|
2157 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2158 #ifdef _REENTRANT |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2159 l = sysconf(_SC_GETGR_R_SIZE_MAX); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2160 if (l == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2161 dl = 1024; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2162 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2163 dl = (size_t)l; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2164 p = malloc(dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2165 if (p == NULL) { |
| 4010 | 2166 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2167 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2168 } |
|
5189
24331ceccbac
Fix buffer size in getgrnam_r
Quentin Carbonneaux <quentin@c9x.me>
parents:
5183
diff
changeset
|
2169 while ((i = getgrnam_r(arg, &grpbuf, p, dl, &grp)) == |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2170 ERANGE) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2171 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2172 size_t nl = dl * 2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2173 if (nl < dl) { |
| 4010 | 2174 logerrx("control_group: out of buffer"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2175 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2176 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2177 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2178 dl = nl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2179 np = realloc(p, dl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2180 if (np == NULL) { |
| 4010 | 2181 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2182 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2183 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2184 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2185 p = np; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2186 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2187 if (i != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2188 errno = i; |
| 4010 | 2189 logerr("getgrnam_r"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2190 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2191 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2192 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2193 if (grp == NULL) { |
|
5190
12b6ba947111
Do not report an error if control_group is already set
Quentin Carbonneaux <quentin@c9x.me>
parents:
5183
diff
changeset
|
2194 if (!ctx->control_group) |
|
12b6ba947111
Do not report an error if control_group is already set
Quentin Carbonneaux <quentin@c9x.me>
parents:
5183
diff
changeset
|
2195 logerrx("controlgroup: %s: not found", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2196 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2197 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2198 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2199 ctx->control_group = grp->gr_gid; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2200 free(p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2201 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2202 grp = getgrnam(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2203 if (grp == NULL) { |
|
5190
12b6ba947111
Do not report an error if control_group is already set
Quentin Carbonneaux <quentin@c9x.me>
parents:
5183
diff
changeset
|
2204 if (!ctx->control_group) |
|
12b6ba947111
Do not report an error if control_group is already set
Quentin Carbonneaux <quentin@c9x.me>
parents:
5183
diff
changeset
|
2205 logerrx("controlgroup: %s: not found", arg); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2206 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2207 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2208 ctx->control_group = grp->gr_gid; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2209 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2210 break; |
| 4067 | 2211 case O_GATEWAY: |
| 2212 ifo->options |= DHCPCD_GATEWAY; | |
| 2213 break; | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2214 case O_NOUP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2215 ifo->options &= ~DHCPCD_IF_UP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2216 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2217 case O_SLAAC: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2218 ARG_REQUIRED; |
|
5153
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2219 np = strwhite(arg); |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2220 if (np != NULL) { |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2221 *np++ = '\0'; |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2222 np = strskipwhite(np); |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2223 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2224 if (strcmp(arg, "private") == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2225 strcmp(arg, "stableprivate") == 0 || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2226 strcmp(arg, "stable") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2227 ifo->options |= DHCPCD_SLAACPRIVATE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2228 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2229 ifo->options &= ~DHCPCD_SLAACPRIVATE; |
|
5153
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2230 if (np != NULL && |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2231 (strcmp(np, "temp") == 0 || strcmp(np, "temporary") == 0)) |
|
8248b3a04908
inet6: Add 'temporary' directive to the slaac option
Roy Marples <roy@marples.name>
parents:
5112
diff
changeset
|
2232 ifo->options |= DHCPCD_SLAACTEMP; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2233 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2234 case O_BOOTP: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2235 ifo->options |= DHCPCD_BOOTP; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2236 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2237 case O_NODELAY: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2238 ifo->options &= ~DHCPCD_INITIAL_DELAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2239 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2240 case O_LASTLEASE_EXTEND: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2241 ifo->options |= DHCPCD_LASTLEASE | DHCPCD_LASTLEASE_EXTEND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2242 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2243 case O_INACTIVE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2244 ifo->options |= DHCPCD_INACTIVE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2245 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2246 case O_MUDURL: |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
2247 ARG_REQUIRED; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2248 s = parse_string((char *)ifo->mudurl + 1, MUDURL_MAX_LEN, arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2249 if (s == -1) { |
| 4010 | 2250 logerr("mudurl"); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2251 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2252 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2253 *ifo->mudurl = (uint8_t)s; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2254 break; |
|
4415
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2255 case O_LINK_RCVBUF: |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2256 #ifndef SMALL |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2257 ARG_REQUIRED; |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2258 ctx->link_rcvbuf = (int)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2259 if (e) { |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2260 logerrx("failed to convert link_rcvbuf %s", arg); |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2261 return -1; |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2262 } |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2263 #endif |
|
4eb8ce6f854c
options: add link_rcvbuf variable
Roy Marples <roy@marples.name>
parents:
4396
diff
changeset
|
2264 break; |
| 5535 | 2265 case O_CONFIGURE: |
| 2266 ifo->options |= DHCPCD_CONFIGURE; | |
| 2267 break; | |
| 2268 case O_NOCONFIGURE: | |
| 2269 ifo->options &= ~DHCPCD_CONFIGURE; | |
| 2270 break; | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2271 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2272 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2273 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2274 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2275 return 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2276 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2277 #ifdef ARG_REQUIRED |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2278 arg_required: |
| 4010 | 2279 logerrx("option %d requires an argument", opt); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2280 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2281 #undef ARG_REQUIRED |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2282 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2283 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2284 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2285 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2286 parse_config_line(struct dhcpcd_ctx *ctx, const char *ifname, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2287 struct if_options *ifo, const char *opt, char *line, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2288 struct dhcp_opt **ldop, struct dhcp_opt **edop) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2289 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2290 unsigned int i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2291 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2292 for (i = 0; i < sizeof(cf_options) / sizeof(cf_options[0]); i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2293 if (!cf_options[i].name || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2294 strcmp(cf_options[i].name, opt) != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2295 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2296 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2297 if (cf_options[i].has_arg == required_argument && !line) { |
| 4010 | 2298 logerrx("option requires an argument -- %s", opt); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2299 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2300 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2301 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2302 return parse_option(ctx, ifname, ifo, cf_options[i].val, line, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2303 ldop, edop); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2304 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2305 |
|
5532
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
2306 if (!(ctx->options & DHCPCD_PRINT_PIDFILE)) |
|
e6620d8e18bb
options: Don't log unknown option errors when printing the pidfile
Roy Marples <roy@marples.name>
parents:
5494
diff
changeset
|
2307 logerrx("unknown option: %s", opt); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2308 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2309 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2310 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2311 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2312 finish_config(struct if_options *ifo) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2313 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2314 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2315 /* Terminate the encapsulated options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2316 if (ifo->vendor[0] && !(ifo->options & DHCPCD_VENDORRAW)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2317 ifo->vendor[0]++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2318 ifo->vendor[ifo->vendor[0]] = DHO_END; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2319 /* We are called twice. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2320 * This should be fixed, but in the meantime, this |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2321 * guard should suffice */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2322 ifo->options |= DHCPCD_VENDORRAW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2323 } |
|
4836
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2324 |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2325 if (!(ifo->options & DHCPCD_ARP) || |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2326 ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)) |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2327 ifo->options &= ~DHCPCD_IPV4LL; |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2328 |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2329 if (!(ifo->options & DHCPCD_IPV4)) |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2330 ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4); |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2331 |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2332 if (!(ifo->options & DHCPCD_IPV6)) |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2333 ifo->options &= |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2334 ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2335 |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2336 if (!(ifo->options & DHCPCD_IPV6RS)) |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2337 ifo->options &= |
|
f36961a6e7d5
Move some option finialisation so it's available globally.
Roy Marples <roy@marples.name>
parents:
4725
diff
changeset
|
2338 ~(DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2339 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2340 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2341 struct if_options * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2342 default_config(struct dhcpcd_ctx *ctx) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2343 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2344 struct if_options *ifo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2345 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2346 /* Seed our default options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2347 if ((ifo = calloc(1, sizeof(*ifo))) == NULL) { |
| 4010 | 2348 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2349 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2350 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2351 ifo->options |= DHCPCD_IF_UP | DHCPCD_LINK | DHCPCD_INITIAL_DELAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2352 ifo->timeout = DEFAULT_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2353 ifo->reboot = DEFAULT_REBOOT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2354 ifo->metric = -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2355 ifo->auth.options |= DHCPCD_AUTH_REQUIRE; |
|
4629
06b0dbf7a171
route: Just compare order when adding routes from options.
Roy Marples <roy@marples.name>
parents:
4607
diff
changeset
|
2356 rb_tree_init(&ifo->routes, &rt_compare_list_ops); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2357 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2358 TAILQ_INIT(&ifo->auth.tokens); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2359 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2360 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2361 /* Inherit some global defaults */ |
|
5546
08426e8a98a7
DHCP6: Delegated activations work once more
Roy Marples <roy@marples.name>
parents:
5535
diff
changeset
|
2362 if (ctx->options & DHCPCD_CONFIGURE) |
|
08426e8a98a7
DHCP6: Delegated activations work once more
Roy Marples <roy@marples.name>
parents:
5535
diff
changeset
|
2363 ifo->options |= DHCPCD_CONFIGURE; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2364 if (ctx->options & DHCPCD_PERSISTENT) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2365 ifo->options |= DHCPCD_PERSISTENT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2366 if (ctx->options & DHCPCD_SLAACPRIVATE) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2367 ifo->options |= DHCPCD_SLAACPRIVATE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2368 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2369 return ifo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2370 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2371 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2372 struct if_options * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2373 read_config(struct dhcpcd_ctx *ctx, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2374 const char *ifname, const char *ssid, const char *profile) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2375 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2376 struct if_options *ifo; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2377 char buf[UDPLEN_MAX], *bp; /* 64k max config file size */ |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2378 char *line, *option, *p; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2379 ssize_t buflen; |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2380 size_t vlen; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2381 int skip, have_profile, new_block, had_block; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2382 #if !defined(INET) || !defined(INET6) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2383 size_t i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2384 struct dhcp_opt *opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2385 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2386 struct dhcp_opt *ldop, *edop; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2387 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2388 /* Seed our default options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2389 if ((ifo = default_config(ctx)) == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2390 return NULL; |
|
5411
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2391 if (default_options == 0) { |
|
5546
08426e8a98a7
DHCP6: Delegated activations work once more
Roy Marples <roy@marples.name>
parents:
5535
diff
changeset
|
2392 default_options |= DHCPCD_CONFIGURE | DHCPCD_DAEMONISE | |
|
08426e8a98a7
DHCP6: Delegated activations work once more
Roy Marples <roy@marples.name>
parents:
5535
diff
changeset
|
2393 DHCPCD_GATEWAY; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2394 #ifdef INET |
|
5411
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2395 skip = socket(PF_INET, SOCK_DGRAM, 0); |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2396 if (skip != -1) { |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2397 close(skip); |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2398 default_options |= DHCPCD_IPV4 | DHCPCD_ARP | |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2399 DHCPCD_DHCP | DHCPCD_IPV4LL; |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2400 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2401 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2402 #ifdef INET6 |
|
5411
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2403 skip = socket(PF_INET6, SOCK_DGRAM, 0); |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2404 if (skip != -1) { |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2405 close(skip); |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2406 default_options |= DHCPCD_IPV6 | DHCPCD_IPV6RS | |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2407 DHCPCD_IPV6RA_AUTOCONF | DHCPCD_IPV6RA_REQRDNSS | |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2408 DHCPCD_DHCP6; |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2409 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2410 #endif |
|
5411
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2411 #ifdef PLUGIN_DEV |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2412 default_options |= DHCPCD_DEV; |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2413 #endif |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2414 } |
|
c222e3e77e93
options: open an address socket to detect if inet6 is available
Roy Marples <roy@marples.name>
parents:
5409
diff
changeset
|
2415 ifo->options |= default_options; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2416 |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
2417 CLEAR_CONFIG_BLOCK(ifo); |
|
5390
3c3341010852
options: use DHCPCD_MASTER to guard global options
Roy Marples <roy@marples.name>
parents:
5376
diff
changeset
|
2418 |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2419 vlen = strlcpy((char *)ifo->vendorclassid + 1, ctx->vendor, |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2420 sizeof(ifo->vendorclassid) - 1); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2421 ifo->vendorclassid[0] = (uint8_t)(vlen > 255 ? 0 : vlen); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2422 |
|
4522
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4511
diff
changeset
|
2423 /* Reset route order */ |
|
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4511
diff
changeset
|
2424 ctx->rt_order = 0; |
|
e2582c7c7e1d
route: Use order from message / config
Roy Marples <roy@marples.name>
parents:
4511
diff
changeset
|
2425 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2426 /* Parse our embedded options file */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2427 if (ifname == NULL && !(ctx->options & DHCPCD_PRINT_PIDFILE)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2428 /* Space for initial estimates */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2429 #if defined(INET) && defined(INITDEFINES) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2430 ifo->dhcp_override = |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2431 calloc(INITDEFINES, sizeof(*ifo->dhcp_override)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2432 if (ifo->dhcp_override == NULL) |
| 4010 | 2433 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2434 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2435 ifo->dhcp_override_len = INITDEFINES; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2436 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2437 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2438 #if defined(INET6) && defined(INITDEFINENDS) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2439 ifo->nd_override = |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2440 calloc(INITDEFINENDS, sizeof(*ifo->nd_override)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2441 if (ifo->nd_override == NULL) |
| 4010 | 2442 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2443 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2444 ifo->nd_override_len = INITDEFINENDS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2445 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2446 #if defined(INET6) && defined(INITDEFINE6S) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2447 ifo->dhcp6_override = |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2448 calloc(INITDEFINE6S, sizeof(*ifo->dhcp6_override)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2449 if (ifo->dhcp6_override == NULL) |
| 4010 | 2450 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2451 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2452 ifo->dhcp6_override_len = INITDEFINE6S; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2453 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2454 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2455 /* Now load our embedded config */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2456 #ifdef EMBEDDED_CONFIG |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2457 buflen = dhcp_readfile(ctx, EMBEDDED_CONFIG, buf, sizeof(buf)); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2458 if (buflen == -1) { |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2459 logerr("%s: %s", __func__, EMBEDDED_CONFIG); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2460 return ifo; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2461 } |
|
5216
7cf6e8760b69
Fix an uninitialised memory access
Roy Marples <roy@marples.name>
parents:
5209
diff
changeset
|
2462 if (buf[buflen - 1] != '\0') { |
|
5309
700fa2afe696
Fix installing the embedded config as a file.
Roy Marples <roy@marples.name>
parents:
5286
diff
changeset
|
2463 if ((size_t)buflen < sizeof(buf) - 1) |
|
700fa2afe696
Fix installing the embedded config as a file.
Roy Marples <roy@marples.name>
parents:
5286
diff
changeset
|
2464 buflen++; |
|
5216
7cf6e8760b69
Fix an uninitialised memory access
Roy Marples <roy@marples.name>
parents:
5209
diff
changeset
|
2465 buf[buflen - 1] = '\0'; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2466 } |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2467 #else |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2468 buflen = (ssize_t)strlcpy(buf, dhcpcd_embedded_conf, |
|
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2469 sizeof(buf)); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2470 if ((size_t)buflen >= sizeof(buf)) { |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2471 logerrx("%s: embedded config too big", __func__); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2472 return ifo; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2473 } |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2474 /* Our embedded config is NULL terminated */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2475 #endif |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2476 bp = buf; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2477 while ((line = get_line(&bp, &buflen)) != NULL) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2478 option = strsep(&line, " \t"); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2479 if (line) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2480 line = strskipwhite(line); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2481 /* Trim trailing whitespace */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2482 if (line) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2483 p = line + strlen(line) - 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2484 while (p != line && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2485 (*p == ' ' || *p == '\t') && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2486 *(p - 1) != '\\') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2487 *p-- = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2488 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2489 parse_config_line(ctx, NULL, ifo, option, line, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2490 &ldop, &edop); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2491 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2492 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2493 #ifdef INET |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2494 ctx->dhcp_opts = ifo->dhcp_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2495 ctx->dhcp_opts_len = ifo->dhcp_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2496 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2497 for (i = 0, opt = ifo->dhcp_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2498 i < ifo->dhcp_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2499 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2500 free_dhcp_opt_embenc(opt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2501 free(ifo->dhcp_override); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2502 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2503 ifo->dhcp_override = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2504 ifo->dhcp_override_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2505 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2506 #ifdef INET6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2507 ctx->nd_opts = ifo->nd_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2508 ctx->nd_opts_len = ifo->nd_override_len; |
|
4349
f87c2ed9ff46
DHCP6: Remove #defines for functions when DHCP6 is disabled
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
2509 #ifdef DHCP6 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2510 ctx->dhcp6_opts = ifo->dhcp6_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2511 ctx->dhcp6_opts_len = ifo->dhcp6_override_len; |
|
4349
f87c2ed9ff46
DHCP6: Remove #defines for functions when DHCP6 is disabled
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
2512 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2513 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2514 for (i = 0, opt = ifo->nd_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2515 i < ifo->nd_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2516 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2517 free_dhcp_opt_embenc(opt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2518 free(ifo->nd_override); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2519 for (i = 0, opt = ifo->dhcp6_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2520 i < ifo->dhcp6_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2521 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2522 free_dhcp_opt_embenc(opt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2523 free(ifo->dhcp6_override); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2524 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2525 ifo->nd_override = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2526 ifo->nd_override_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2527 ifo->dhcp6_override = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2528 ifo->dhcp6_override_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2529 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2530 ctx->vivso = ifo->vivso_override; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2531 ctx->vivso_len = ifo->vivso_override_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2532 ifo->vivso_override = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2533 ifo->vivso_override_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2534 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2535 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2536 /* Parse our options file */ |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2537 buflen = dhcp_readfile(ctx, ctx->cffile, buf, sizeof(buf)); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2538 if (buflen == -1) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2539 /* dhcpcd can continue without it, but no DNS options |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2540 * would be requested ... */ |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2541 logerr("%s: %s", __func__, ctx->cffile); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2542 return ifo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2543 } |
|
5216
7cf6e8760b69
Fix an uninitialised memory access
Roy Marples <roy@marples.name>
parents:
5209
diff
changeset
|
2544 if (buf[buflen - 1] != '\0') { |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2545 if ((size_t)buflen < sizeof(buf) - 1) |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2546 buflen++; |
|
5216
7cf6e8760b69
Fix an uninitialised memory access
Roy Marples <roy@marples.name>
parents:
5209
diff
changeset
|
2547 buf[buflen - 1] = '\0'; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2548 } |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2549 dhcp_filemtime(ctx, ctx->cffile, &ifo->mtime); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2550 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2551 ldop = edop = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2552 skip = have_profile = new_block = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2553 had_block = ifname == NULL ? 1 : 0; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2554 bp = buf; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2555 while ((line = get_line(&bp, &buflen)) != NULL) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2556 option = strsep(&line, " \t"); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2557 if (line) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2558 line = strskipwhite(line); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2559 /* Trim trailing whitespace */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2560 if (line) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2561 p = line + strlen(line) - 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2562 while (p != line && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2563 (*p == ' ' || *p == '\t') && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2564 *(p - 1) != '\\') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2565 *p-- = '\0'; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2566 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2567 if (skip == 0 && new_block) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2568 had_block = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2569 new_block = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2570 ifo->options &= ~DHCPCD_WAITOPTS; |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
2571 SET_CONFIG_BLOCK(ifo); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2572 } |
|
5390
3c3341010852
options: use DHCPCD_MASTER to guard global options
Roy Marples <roy@marples.name>
parents:
5376
diff
changeset
|
2573 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2574 /* Start of an interface block, skip if not ours */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2575 if (strcmp(option, "interface") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2576 char **n; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2577 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2578 new_block = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2579 if (line == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2580 /* No interface given */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2581 skip = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2582 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2583 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2584 if (ifname && strcmp(line, ifname) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2585 skip = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2586 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2587 skip = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2588 if (ifname) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2589 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2590 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2591 n = reallocarray(ctx->ifcv, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2592 (size_t)ctx->ifcc + 1, sizeof(char *)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2593 if (n == NULL) { |
| 4010 | 2594 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2595 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2596 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2597 ctx->ifcv = n; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2598 ctx->ifcv[ctx->ifcc] = strdup(line); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2599 if (ctx->ifcv[ctx->ifcc] == NULL) { |
| 4010 | 2600 logerr(__func__); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2601 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2602 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2603 ctx->ifcc++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2604 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2605 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2606 /* Start of an ssid block, skip if not ours */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2607 if (strcmp(option, "ssid") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2608 new_block = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2609 if (ssid && line && strcmp(line, ssid) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2610 skip = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2611 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2612 skip = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2613 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2614 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2615 /* Start of a profile block, skip if not ours */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2616 if (strcmp(option, "profile") == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2617 new_block = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2618 if (profile && line && strcmp(line, profile) == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2619 skip = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2620 have_profile = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2621 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2622 skip = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2623 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2624 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2625 /* Skip arping if we have selected a profile but not parsing |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2626 * one. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2627 if (profile && !have_profile && strcmp(option, "arping") == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2628 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2629 if (skip) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2630 continue; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5199
diff
changeset
|
2631 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2632 parse_config_line(ctx, ifname, ifo, option, line, &ldop, &edop); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2633 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2634 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2635 if (profile && !have_profile) { |
|
4249
c30233f8cca3
routes: allow a head clear with a context
Roy Marples <roy@marples.name>
parents:
4248
diff
changeset
|
2636 free_options(ctx, ifo); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2637 errno = ENOENT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2638 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2639 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2640 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2641 if (!had_block) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2642 ifo->options &= ~DHCPCD_WAITOPTS; |
|
5392
b6d4660cc8da
options: rework prior to use macros
Roy Marples <roy@marples.name>
parents:
5390
diff
changeset
|
2643 CLEAR_CONFIG_BLOCK(ifo); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2644 finish_config(ifo); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2645 return ifo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2646 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2647 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2648 int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2649 add_options(struct dhcpcd_ctx *ctx, const char *ifname, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2650 struct if_options *ifo, int argc, char **argv) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2651 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2652 int oi, opt, r; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2653 unsigned long long wait_opts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2654 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2655 if (argc == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2656 return 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2657 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2658 optind = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2659 r = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2660 /* Don't apply the command line wait options to each interface, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2661 * only use the dhcpcd.conf entry for that. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2662 if (ifname != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2663 wait_opts = ifo->options & DHCPCD_WAITOPTS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2664 while ((opt = getopt_long(argc, argv, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2665 ctx->options & DHCPCD_PRINT_PIDFILE ? NOERR_IF_OPTS : IF_OPTS, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2666 cf_options, &oi)) != -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2667 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2668 r = parse_option(ctx, ifname, ifo, opt, optarg, NULL, NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2669 if (r != 1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2670 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2671 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2672 if (ifname != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2673 ifo->options &= ~DHCPCD_WAITOPTS; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2674 ifo->options |= wait_opts; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2675 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2676 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2677 finish_config(ifo); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2678 return r; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2679 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2680 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2681 void |
|
4249
c30233f8cca3
routes: allow a head clear with a context
Roy Marples <roy@marples.name>
parents:
4248
diff
changeset
|
2682 free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2683 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2684 size_t i; |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2685 #ifdef RT_FREE_ROUTE_TABLE |
|
4607
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2686 struct interface *ifp; |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2687 struct rt *rt; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2688 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2689 struct dhcp_opt *opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2690 struct vivco *vo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2691 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2692 struct token *token; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2693 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2694 |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2695 if (ifo == NULL) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2696 return; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2697 |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2698 if (ifo->environ) { |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2699 i = 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2700 while (ifo->environ[i]) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2701 free(ifo->environ[i++]); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2702 free(ifo->environ); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2703 } |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2704 if (ifo->config) { |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2705 i = 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2706 while (ifo->config[i]) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2707 free(ifo->config[i++]); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2708 free(ifo->config); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2709 } |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2710 |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2711 #ifdef RT_FREE_ROUTE_TABLE |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2712 /* Stupidly, we don't know the interface when creating the options. |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2713 * As such, make sure each route has one so they can goto the |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2714 * free list. */ |
|
4607
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2715 ifp = ctx->ifaces != NULL ? TAILQ_FIRST(ctx->ifaces) : NULL; |
|
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2716 if (ifp != NULL) { |
|
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2717 RB_TREE_FOREACH(rt, &ifo->routes) { |
|
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2718 if (rt->rt_ifp == NULL) |
|
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2719 rt->rt_ifp = ifp; |
|
8e54887526a6
routes: Fix a NULL dereference error for global static routes
Roy Marples <roy@marples.name>
parents:
4599
diff
changeset
|
2720 } |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2721 } |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2722 #endif |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2723 rt_headclear0(ctx, &ifo->routes, AF_UNSPEC); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2724 |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2725 free(ifo->arping); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2726 free(ifo->blacklist); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2727 free(ifo->fallback); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2728 |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2729 for (opt = ifo->dhcp_override; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2730 ifo->dhcp_override_len > 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2731 opt++, ifo->dhcp_override_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2732 free_dhcp_opt_embenc(opt); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2733 free(ifo->dhcp_override); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2734 for (opt = ifo->nd_override; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2735 ifo->nd_override_len > 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2736 opt++, ifo->nd_override_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2737 free_dhcp_opt_embenc(opt); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2738 free(ifo->nd_override); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2739 for (opt = ifo->dhcp6_override; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2740 ifo->dhcp6_override_len > 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2741 opt++, ifo->dhcp6_override_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2742 free_dhcp_opt_embenc(opt); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2743 free(ifo->dhcp6_override); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2744 for (vo = ifo->vivco; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2745 ifo->vivco_len > 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2746 vo++, ifo->vivco_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2747 free(vo->data); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2748 free(ifo->vivco); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2749 for (opt = ifo->vivso_override; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2750 ifo->vivso_override_len > 0; |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2751 opt++, ifo->vivso_override_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2752 free_dhcp_opt_embenc(opt); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2753 free(ifo->vivso_override); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2754 |
|
4072
475b9492af64
Warn about IA_PD support not being compiled in when requesting it
Roy Marples <roy@marples.name>
parents:
4068
diff
changeset
|
2755 #if defined(INET6) && !defined(SMALL) |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2756 for (; ifo->ia_len > 0; ifo->ia_len--) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2757 free(ifo->ia[ifo->ia_len - 1].sla); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2758 #endif |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2759 free(ifo->ia); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2760 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2761 #ifdef AUTH |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2762 while ((token = TAILQ_FIRST(&ifo->auth.tokens))) { |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2763 TAILQ_REMOVE(&ifo->auth.tokens, token, next); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2764 if (token->realm_len) |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2765 free(token->realm); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2766 free(token->key); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2767 free(token); |
|
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2768 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2769 #endif |
|
4599
1d09f6293928
Fix a memory NULL deference when freeing static routes at exit.
Roy Marples <roy@marples.name>
parents:
4559
diff
changeset
|
2770 free(ifo); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2771 } |
