Mercurial > hg > dhcpcd
annotate src/dhcp6.c @ 5535:a0d828e25482 draft
Add --noconfigure option
With this set dhcpcd will not configure anything on the host.
The expectation is that a 3rd party script will instead.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 04 Nov 2020 14:18:48 +0000 |
| parents | 6a2da5651841 |
| children | ef762d54fb7a |
| rev | line source |
|---|---|
|
4548
c7df03794de3
Add SPDX identifiers to all dhcpcd source files.
Yegor Yefremov <yegorslists@googlemail.com>
parents:
4543
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/utsname.h> |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
30 #include <sys/types.h> |
|
3932
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 <netinet/in.h> |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
33 #include <netinet/ip6.h> |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
34 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
35 #include <assert.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 <ctype.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 <errno.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 <fcntl.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 <inttypes.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 <stdbool.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 <stddef.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 <fcntl.h> |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
46 #include <syslog.h> |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
47 |
|
5038
1e35e845790a
eloop: define eloop queue numbers in common.h
Roy Marples <roy@marples.name>
parents:
4966
diff
changeset
|
48 #define ELOOP_QUEUE ELOOP_DHCP6 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
49 #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
|
50 #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
|
51 #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
|
52 #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
|
53 #include "duid.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 "eloop.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 "if.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
56 #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
|
57 #include "ipv6nd.h" |
| 4010 | 58 #include "logerr.h" |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
59 #include "privsep.h" |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
60 #include "script.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
61 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
62 #ifdef HAVE_SYS_BITOPS_H |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
63 #include <sys/bitops.h> |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
64 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
65 #include "compat/bitops.h" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
66 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
67 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
68 /* DHCPCD Project has been assigned an IANA PEN of 40712 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
69 #define DHCPCD_IANA_PEN 40712 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
70 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
71 /* Unsure if I want this */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
72 //#define VENDOR_SPLIT |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
73 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
74 /* Support older systems with different defines */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
75 #if !defined(IPV6_RECVPKTINFO) && defined(IPV6_PKTINFO) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
76 #define IPV6_RECVPKTINFO IPV6_PKTINFO |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
77 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
78 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
79 #ifdef DHCP6 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
80 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
81 /* Assert the correct structure size for on wire */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
82 struct dhcp6_message { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
83 uint8_t type; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
84 uint8_t xid[3]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
85 /* followed by options */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
86 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
87 __CTASSERT(sizeof(struct dhcp6_message) == 4); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
88 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
89 struct dhcp6_option { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
90 uint16_t code; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
91 uint16_t len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
92 /* followed by data */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
93 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
94 __CTASSERT(sizeof(struct dhcp6_option) == 4); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
95 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
96 struct dhcp6_ia_na { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
97 uint8_t iaid[4]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
98 uint32_t t1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
99 uint32_t t2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
100 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
101 __CTASSERT(sizeof(struct dhcp6_ia_na) == 12); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
102 |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
103 struct dhcp6_ia_ta { |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
104 uint8_t iaid[4]; |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
105 }; |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
106 __CTASSERT(sizeof(struct dhcp6_ia_ta) == 4); |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
107 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
108 struct dhcp6_ia_addr { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
109 struct in6_addr addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
110 uint32_t pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
111 uint32_t vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
112 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
113 __CTASSERT(sizeof(struct dhcp6_ia_addr) == 16 + 8); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
114 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
115 /* XXX FIXME: This is the only packed structure and it does not align. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
116 * Maybe manually decode it? */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
117 struct dhcp6_pd_addr { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
118 uint32_t pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
119 uint32_t vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
120 uint8_t prefix_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
121 struct in6_addr prefix; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
122 } __packed; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
123 __CTASSERT(sizeof(struct dhcp6_pd_addr) == 8 + 1 + 16); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
124 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
125 struct dhcp6_op { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
126 uint16_t type; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
127 const char *name; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
128 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
129 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
130 static const struct dhcp6_op dhcp6_ops[] = { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
131 { DHCP6_SOLICIT, "SOLICIT6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
132 { DHCP6_ADVERTISE, "ADVERTISE6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
133 { DHCP6_REQUEST, "REQUEST6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
134 { DHCP6_REPLY, "REPLY6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
135 { DHCP6_RENEW, "RENEW6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
136 { DHCP6_REBIND, "REBIND6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
137 { DHCP6_CONFIRM, "CONFIRM6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
138 { DHCP6_INFORMATION_REQ, "INFORM6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
139 { DHCP6_RELEASE, "RELEASE6" }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
140 { DHCP6_RECONFIGURE, "RECONFIGURE6" }, |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
141 { DHCP6_DECLINE, "DECLINE6" }, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
142 { 0, NULL } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
143 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
144 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
145 struct dhcp_compat { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
146 uint8_t dhcp_opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
147 uint16_t dhcp6_opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
148 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
149 |
| 5484 | 150 static const struct dhcp_compat dhcp_compats[] = { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
151 { DHO_DNSSERVER, D6_OPTION_DNS_SERVERS }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
152 { DHO_HOSTNAME, D6_OPTION_FQDN }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
153 { DHO_DNSDOMAIN, D6_OPTION_FQDN }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
154 { DHO_NISSERVER, D6_OPTION_NIS_SERVERS }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
155 { DHO_NTPSERVER, D6_OPTION_SNTP_SERVERS }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
156 { DHO_RAPIDCOMMIT, D6_OPTION_RAPID_COMMIT }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
157 { DHO_FQDN, D6_OPTION_FQDN }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
158 { DHO_VIVCO, D6_OPTION_VENDOR_CLASS }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
159 { DHO_VIVSO, D6_OPTION_VENDOR_OPTS }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
160 { DHO_DNSSEARCH, D6_OPTION_DOMAIN_LIST }, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
161 { 0, 0 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
162 }; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
163 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
164 static const char * const dhcp6_statuses[] = { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
165 "Success", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
166 "Unspecified Failure", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
167 "No Addresses Available", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
168 "No Binding", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
169 "Not On Link", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
170 "Use Multicast", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
171 "No Prefix Available" |
|
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 |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
174 static void dhcp6_bind(struct interface *, const char *, const char *); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
175 static void dhcp6_failinform(void *); |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
176 static void dhcp6_recvaddr(void *); |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
177 static void dhcp6_startdecline(struct interface *); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
178 |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
179 #ifdef SMALL |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
180 #define dhcp6_hasprefixdelegation(a) (0) |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
181 #else |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
182 static int dhcp6_hasprefixdelegation(struct interface *); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
183 #endif |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
184 |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
185 #define DECLINE_IA(ia) \ |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
186 ((ia)->addr_flags & IN6_IFF_DUPLICATED && \ |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
187 (ia)->ia_type != 0 && (ia)->ia_type != D6_OPTION_IA_PD && \ |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
188 !((ia)->flags & IPV6_AF_STALE) && \ |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
189 (ia)->prefix_vltime != 0) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
190 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
191 void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
192 dhcp6_printoptions(const 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
|
193 const struct dhcp_opt *opts, size_t opts_len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
194 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
195 size_t i, j; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
196 const struct dhcp_opt *opt, *opt2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
197 int cols; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
198 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
199 for (i = 0, opt = 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
|
200 i < ctx->dhcp6_opts_len; i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
201 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
202 for (j = 0, opt2 = opts; j < opts_len; j++, opt2++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
203 if (opt2->option == opt->option) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
204 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
205 if (j == opts_len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
206 cols = printf("%05d %s", opt->option, opt->var); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
207 dhcp_print_option_encoding(opt, cols); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
208 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
209 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
210 for (i = 0, opt = opts; i < opts_len; i++, opt++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
211 cols = printf("%05d %s", opt->option, opt->var); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
212 dhcp_print_option_encoding(opt, cols); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
213 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
214 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
215 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
216 static size_t |
|
4258
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
217 dhcp6_makeuser(void *data, const struct interface *ifp) |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
218 { |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
219 const struct if_options *ifo = ifp->options; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
220 struct dhcp6_option o; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
221 uint8_t *p; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
222 const uint8_t *up, *ue; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
223 uint16_t ulen, unlen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
224 size_t olen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
225 |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
226 /* Convert the DHCPv4 user class option to DHCPv6 */ |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
227 up = ifo->userclass; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
228 ulen = *up++; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
229 if (ulen == 0) |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
230 return 0; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
231 |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
232 p = data; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
233 olen = 0; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
234 if (p != NULL) |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
235 p += sizeof(o); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
236 |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
237 ue = up + ulen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
238 for (; up < ue; up += ulen) { |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
239 ulen = *up++; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
240 olen += sizeof(ulen) + ulen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
241 if (data == NULL) |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
242 continue; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
243 unlen = htons(ulen); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
244 memcpy(p, &unlen, sizeof(unlen)); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
245 p += sizeof(unlen); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
246 memcpy(p, up, ulen); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
247 p += ulen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
248 } |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
249 if (data != NULL) { |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
250 o.code = htons(D6_OPTION_USER_CLASS); |
|
4259
bf08893bc7fd
Cast away a conversion warning.
Roy Marples <roy@marples.name>
parents:
4258
diff
changeset
|
251 o.len = htons((uint16_t)olen); |
|
4258
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
252 memcpy(data, &o, sizeof(o)); |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
253 } |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
254 |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
255 return sizeof(o) + olen; |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
256 } |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
257 |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
258 static size_t |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
259 dhcp6_makevendor(void *data, const struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
260 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
261 const struct if_options *ifo; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
262 size_t len, vlen, i; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
263 uint8_t *p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
264 const 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
|
265 struct dhcp6_option o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
266 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
267 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
268 len = sizeof(uint32_t); /* IANA PEN */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
269 if (ifo->vivco_en) { |
|
5273
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
270 vlen = 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
271 for (i = 0, vivco = ifo->vivco; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
272 i < 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
|
273 i++, vivco++) |
|
5273
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
274 vlen += sizeof(uint16_t) + vivco->len; |
|
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
275 len += vlen; |
|
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
276 } else if (ifo->vendorclassid[0] != '\0') { |
|
5275
b7d18124ad21
DHCP6: Revert part of prior - only allow vendorclassid to disable
Roy Marples <roy@marples.name>
parents:
5273
diff
changeset
|
277 /* dhcpcd owns DHCPCD_IANA_PEN. |
|
b7d18124ad21
DHCP6: Revert part of prior - only allow vendorclassid to disable
Roy Marples <roy@marples.name>
parents:
5273
diff
changeset
|
278 * If you need your own string, get your own IANA PEN. */ |
|
b7d18124ad21
DHCP6: Revert part of prior - only allow vendorclassid to disable
Roy Marples <roy@marples.name>
parents:
5273
diff
changeset
|
279 vlen = strlen(ifp->ctx->vendor); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
280 len += sizeof(uint16_t) + vlen; |
|
5273
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
281 } else |
|
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
282 return 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
283 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
284 if (len > UINT16_MAX) { |
| 4010 | 285 logerrx("%s: DHCPv6 Vendor Class too big", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
286 return 0; |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
289 if (data != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
290 uint32_t pen; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
291 uint16_t hvlen; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
292 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
293 p = data; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
294 o.code = htons(D6_OPTION_VENDOR_CLASS); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
295 o.len = htons((uint16_t)len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
296 memcpy(p, &o, sizeof(o)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
297 p += sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
298 pen = htonl(ifo->vivco_en ? ifo->vivco_en : DHCPCD_IANA_PEN); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
299 memcpy(p, &pen, sizeof(pen)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
300 p += sizeof(pen); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
301 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
302 if (ifo->vivco_en) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
303 for (i = 0, vivco = ifo->vivco; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
304 i < 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
|
305 i++, vivco++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
306 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
307 hvlen = htons((uint16_t)vivco->len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
308 memcpy(p, &hvlen, sizeof(hvlen)); |
|
4260
8c6250af2ed4
DHCP6: Fix sending custom vendor class option.
Roy Marples <roy@marples.name>
parents:
4259
diff
changeset
|
309 p += sizeof(hvlen); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
310 memcpy(p, vivco->data, vivco->len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
311 p += vivco->len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
312 } |
|
5273
3a33b39120eb
DHCP6: Use interface vendorclassid rather than context
Roy Marples <roy@marples.name>
parents:
5236
diff
changeset
|
313 } else if (ifo->vendorclassid[0] != '\0') { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
314 hvlen = htons((uint16_t)vlen); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
315 memcpy(p, &hvlen, sizeof(hvlen)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
316 p += sizeof(hvlen); |
|
5275
b7d18124ad21
DHCP6: Revert part of prior - only allow vendorclassid to disable
Roy Marples <roy@marples.name>
parents:
5273
diff
changeset
|
317 memcpy(p, ifp->ctx->vendor, vlen); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
318 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
319 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
320 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
321 return sizeof(o) + len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
322 } |
|
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 static void * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
325 dhcp6_findoption(void *data, size_t data_len, uint16_t code, uint16_t *len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
326 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
327 uint8_t *d; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
328 struct dhcp6_option o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
329 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
330 code = htons(code); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
331 for (d = data; data_len != 0; d += o.len, data_len -= o.len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
332 if (data_len < sizeof(o)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
333 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
334 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
335 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
336 memcpy(&o, d, sizeof(o)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
337 d += sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
338 data_len -= sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
339 o.len = htons(o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
340 if (data_len < o.len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
341 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
342 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
343 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
344 if (o.code == code) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
345 if (len != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
346 *len = o.len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
347 return d; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
348 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
349 } |
|
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 errno = ENOENT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
352 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
353 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
354 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
355 static void * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
356 dhcp6_findmoption(void *data, size_t data_len, uint16_t code, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
357 uint16_t *len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
358 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
359 uint8_t *d; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
360 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
361 if (data_len < sizeof(struct dhcp6_message)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
362 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
363 return false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
364 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
365 d = data; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
366 d += sizeof(struct dhcp6_message); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
367 data_len -= sizeof(struct dhcp6_message); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
368 return dhcp6_findoption(d, data_len, code, len); |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
371 static const uint8_t * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
372 dhcp6_getoption(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
|
373 size_t *os, unsigned int *code, 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
|
374 const uint8_t *od, size_t ol, struct dhcp_opt **oopt) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
375 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
376 struct dhcp6_option o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
377 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
|
378 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
|
379 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
380 if (od != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
381 *os = sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
382 if (ol < *os) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
383 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
384 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
385 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
386 memcpy(&o, od, sizeof(o)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
387 *len = ntohs(o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
388 if (*len > ol - *os) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
389 errno = ERANGE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
390 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
391 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
392 *code = ntohs(o.code); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
393 } |
|
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 *oopt = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
396 for (i = 0, opt = 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
|
397 i < ctx->dhcp6_opts_len; i++, opt++) |
|
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 if (opt->option == *code) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
400 *oopt = opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
401 break; |
|
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 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
404 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
405 if (od != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
406 return od + sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
407 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
408 } |
|
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 static bool |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
411 dhcp6_updateelapsed(struct interface *ifp, struct dhcp6_message *m, 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
|
412 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
413 uint8_t *opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
414 uint16_t opt_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
415 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
416 struct timespec tv; |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
417 unsigned long long hsec; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
418 uint16_t sec; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
419 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
420 opt = dhcp6_findmoption(m, len, D6_OPTION_ELAPSED, &opt_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
421 if (opt == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
422 return false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
423 if (opt_len != sizeof(sec)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
424 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
425 return false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
426 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
427 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
428 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
429 clock_gettime(CLOCK_MONOTONIC, &tv); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
430 if (state->RTC == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
431 /* An RTC of zero means we're the first message |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
432 * out of the door, so the elapsed time is zero. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
433 state->started = tv; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
434 hsec = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
435 } else { |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
436 unsigned long long secs; |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
437 unsigned int nsecs; |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
438 |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
439 secs = eloop_timespec_diff(&tv, &state->started, &nsecs); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
440 /* Elapsed time is measured in centiseconds. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
441 * We need to be sure it will not potentially overflow. */ |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
442 if (secs >= (UINT16_MAX / CSEC_PER_SEC) + 1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
443 hsec = UINT16_MAX; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
444 else { |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
445 hsec = (secs * CSEC_PER_SEC) + |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
446 (nsecs / NSEC_PER_CSEC); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
447 if (hsec > UINT16_MAX) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
448 hsec = UINT16_MAX; |
|
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 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
451 sec = htons((uint16_t)hsec); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
452 memcpy(opt, &sec, sizeof(sec)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
453 return true; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
454 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
455 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
456 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
457 dhcp6_newxid(const struct interface *ifp, struct dhcp6_message *m) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
458 { |
|
4177
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
459 const struct interface *ifp1; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
460 const struct dhcp6_state *state1; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
461 uint32_t xid; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
462 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
463 if (ifp->options->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
|
464 ifp->hwlen >= sizeof(xid)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
465 /* The lower bits are probably more unique on the network */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
466 memcpy(&xid, (ifp->hwaddr + ifp->hwlen) - sizeof(xid), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
467 sizeof(xid)); |
|
4177
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
468 else { |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
469 again: |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
470 xid = arc4random(); |
|
4177
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
471 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
472 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
473 m->xid[0] = (xid >> 16) & 0xff; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
474 m->xid[1] = (xid >> 8) & 0xff; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
475 m->xid[2] = xid & 0xff; |
|
4177
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
476 |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
477 /* Ensure it's unique */ |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
478 TAILQ_FOREACH(ifp1, ifp->ctx->ifaces, next) { |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
479 if (ifp == ifp1) |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
480 continue; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
481 if ((state1 = D6_CSTATE(ifp1)) == NULL) |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
482 continue; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
483 if (state1->send != NULL && |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
484 state1->send->xid[0] == m->xid[0] && |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
485 state1->send->xid[1] == m->xid[1] && |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
486 state1->send->xid[2] == m->xid[2]) |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
487 break; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
488 } |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
489 |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
490 if (ifp1 != NULL) { |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
491 if (ifp->options->options & DHCPCD_XID_HWADDR && |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
492 ifp->hwlen >= sizeof(xid)) |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
493 { |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
494 logerrx("%s: duplicate xid on %s", |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
495 ifp->name, ifp1->name); |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
496 return; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
497 } |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
498 goto again; |
|
bce060648873
Ensure that xid is unique across all interfaces.
Roy Marples <roy@marples.name>
parents:
4175
diff
changeset
|
499 } |
|
3932
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
502 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
503 static const struct if_sla * |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
504 dhcp6_findselfsla(struct interface *ifp) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
505 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
506 size_t i, j; |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
507 struct if_ia *ia; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
508 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
509 for (i = 0; i < ifp->options->ia_len; i++) { |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
510 ia = &ifp->options->ia[i]; |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
511 if (ia->ia_type != D6_OPTION_IA_PD) |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
512 continue; |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
513 for (j = 0; j < ia->sla_len; j++) { |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
514 if (strcmp(ia->sla[j].ifname, ifp->name) == 0) |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
515 return &ia->sla[j]; |
|
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 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
518 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
519 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
520 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
521 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
522 dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
523 const struct ipv6_addr *prefix, const struct if_sla *sla, 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
|
524 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
525 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
526 struct if_sla asla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
527 char sabuf[INET6_ADDRSTRLEN]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
528 const char *sa; |
|
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 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
531 if (state == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
532 ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
533 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
534 if (state == NULL) { |
| 4010 | 535 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
|
536 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
537 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
538 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
539 TAILQ_INIT(&state->addrs); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
540 state->state = DH6S_DELEGATED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
541 state->reason = "DELEGATED6"; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
542 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
543 |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
544 if (sla == NULL || !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
|
545 /* No SLA set, so make an assumption of |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
546 * desired SLA and prefix length. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
547 asla.sla = ifp->index; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
548 asla.prefix_len = 0; |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
549 asla.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
|
550 sla = &asla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
551 } else if (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
|
552 /* An SLA was given, but prefix length was not. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
553 * We need to work out a suitable prefix length for |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
554 * potentially more than one interface. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
555 asla.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
|
556 asla.prefix_len = 0; |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
557 asla.sla_set = 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
|
558 sla = &asla; |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
561 if (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
|
562 uint32_t sla_max; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
563 int bits; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
564 |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
565 sla_max = ia->sla_max; |
|
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
566 if (sla_max == 0 && (sla == NULL || !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
|
567 const struct interface *ifi; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
568 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
569 TAILQ_FOREACH(ifi, ifp->ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
570 if (ifi->index > sla_max) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
571 sla_max = ifi->index; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
572 } |
|
5359
e6b89e1a4077
DHCP6: Use sla setting when calculating delegated prefix length
Roy Marples <roy@marples.name>
parents:
5357
diff
changeset
|
573 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
574 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
575 bits = fls32(sla_max); |
|
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 (prefix->prefix_len + bits > (int)UINT8_MAX) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
578 asla.prefix_len = UINT8_MAX; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
579 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
580 asla.prefix_len = (uint8_t)(prefix->prefix_len + bits); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
581 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
582 /* Make a 64 prefix by default, as this makes SLAAC |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
583 * possible. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
584 * Otherwise round up to the nearest 4 bits. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
585 if (asla.prefix_len <= 64) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
586 asla.prefix_len = 64; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
587 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
588 asla.prefix_len = |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
589 (uint8_t)ROUNDUP4(asla.prefix_len); |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
592 #define BIT(n) (1UL << (n)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
593 #define BIT_MASK(len) (BIT(len) - 1) |
|
4560
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
594 if (ia->sla_max == 0) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
595 /* Work out the real sla_max from our bits used */ |
|
4560
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
596 bits = asla.prefix_len - prefix->prefix_len; |
|
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
597 /* Make static analysis happy. |
|
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
598 * Bits cannot be bigger than 32 thanks to fls32. */ |
|
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
599 assert(bits <= 32); |
|
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
600 ia->sla_max = (uint32_t)BIT_MASK(bits); |
|
9745c72fc2eb
DHCP6: Assert auto sla is only 32-bits
Roy Marples <roy@marples.name>
parents:
4549
diff
changeset
|
601 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
602 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
603 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
604 if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
605 sla->sla, addr, sla->prefix_len) == -1) |
|
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 sa = inet_ntop(AF_INET6, &prefix->prefix, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
608 sabuf, sizeof(sabuf)); |
| 4010 | 609 logerr("%s: invalid prefix %s/%d + %d/%d", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
610 ifp->name, sa, prefix->prefix_len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
611 sla->sla, sla->prefix_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
612 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
613 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
614 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
615 if (prefix->prefix_exclude_len && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
616 IN6_ARE_ADDR_EQUAL(addr, &prefix->prefix_exclude)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
617 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
618 sa = inet_ntop(AF_INET6, &prefix->prefix_exclude, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
619 sabuf, sizeof(sabuf)); |
| 4010 | 620 logerrx("%s: cannot delegate excluded prefix %s/%d", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
621 ifp->name, sa, prefix->prefix_exclude_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
622 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
623 } |
|
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 return sla->prefix_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
626 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
627 #endif |
|
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 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
630 dhcp6_makemessage(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
631 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
632 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
633 struct dhcp6_message *m; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
634 struct dhcp6_option o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
635 uint8_t *p, *si, *unicast, IA; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
636 size_t n, l, len, ml, hl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
637 uint8_t type; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
638 uint16_t si_len, uni_len, n_options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
639 uint8_t *o_lenp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
640 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
|
641 const struct dhcp_opt *opt, *opt2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
642 const struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
643 char hbuf[HOSTNAME_MAX_LEN + 1]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
644 const char *hostname; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
645 int fqdn; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
646 struct dhcp6_ia_na ia_na; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
647 uint16_t ia_na_len; |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
648 struct if_ia *ifia; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
649 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
650 uint16_t auth_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
651 #endif |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
652 uint8_t duid[DUID_LEN]; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
653 size_t duid_len = 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
654 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
655 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
656 if (state->send) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
657 free(state->send); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
658 state->send = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
659 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
660 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
661 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
662 fqdn = ifo->fqdn; |
|
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 if (fqdn == FQDN_DISABLE && 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
|
665 /* We're sending the DHCPv4 hostname option, so send FQDN as |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
666 * DHCPv6 has no FQDN option and DHCPv4 must not send |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
667 * hostname and FQDN according to RFC4702 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
668 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
|
669 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
670 if (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
|
671 hostname = dhcp_get_hostname(hbuf, sizeof(hbuf), ifo); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
672 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
673 hostname = NULL; /* appearse gcc */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
674 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
675 /* Work out option size first */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
676 n_options = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
677 len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
678 si = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
679 hl = 0; /* Appease gcc */ |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
680 if (state->state != DH6S_RELEASE && state->state != DH6S_DECLINE) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
681 for (l = 0, opt = ifp->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
|
682 l < ifp->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
|
683 l++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
684 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
685 for (n = 0, opt2 = 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
|
686 n < 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
|
687 n++, opt2++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
688 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
689 if (opt->option == opt2->option) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
690 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
691 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
692 if (n < ifo->dhcp6_override_len) |
|
4724
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
693 continue; |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
694 if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
695 continue; |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
696 n_options++; |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
697 len += sizeof(o.len); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
698 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
699 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
700 for (l = 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
|
701 l < 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
|
702 l++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
703 { |
|
4724
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
704 if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
705 continue; |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
706 n_options++; |
|
d64400c59a28
DHCP: Don't request an automatically requested option if not wanted
Roy Marples <roy@marples.name>
parents:
4695
diff
changeset
|
707 len += sizeof(o.len); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
708 } |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
709 if (dhcp6_findselfsla(ifp)) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
710 n_options++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
711 len += sizeof(o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
712 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
713 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
714 if (len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
715 len += sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
716 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
717 if (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
|
718 hl = encode_rfc1035(hostname, NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
719 len += sizeof(o) + 1 + hl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
720 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
721 |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
722 if (!has_option_mask(ifo->nomask6, D6_OPTION_MUDURL) && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
723 ifo->mudurl[0]) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
724 len += sizeof(o) + ifo->mudurl[0]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
725 |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
726 #ifdef AUTH |
|
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 ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) != |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
728 DHCPCD_AUTH_SENDREQUIRE && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
729 DHC_REQ(ifo->requestmask6, ifo->nomask6, |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
730 D6_OPTION_RECONF_ACCEPT)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
731 len += sizeof(o); /* Reconfigure Accept */ |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
732 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
733 } |
|
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 len += sizeof(*state->send); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
736 len += sizeof(o) + sizeof(uint16_t); /* elapsed */ |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
737 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
738 if (ifo->options & DHCPCD_ANONYMOUS) { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
739 duid_len = duid_make(duid, ifp, DUID_LL); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
740 len += sizeof(o) + duid_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
741 } else { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
742 len += sizeof(o) + ifp->ctx->duid_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
743 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
744 |
|
4258
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
745 if (!has_option_mask(ifo->nomask6, D6_OPTION_USER_CLASS)) |
|
f7795e713bf5
DHCPv6: Transpose DHCP userclass option into DHCPv6
Roy Marples <roy@marples.name>
parents:
4247
diff
changeset
|
746 len += dhcp6_makeuser(NULL, ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
747 if (!has_option_mask(ifo->nomask6, D6_OPTION_VENDOR_CLASS)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
748 len += dhcp6_makevendor(NULL, ifp); |
|
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 /* IA */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
751 m = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
752 ml = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
753 switch(state->state) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
754 case DH6S_REQUEST: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
755 m = state->recv; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
756 ml = state->recv_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
757 /* FALLTHROUGH */ |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
758 case DH6S_DECLINE: |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
759 /* FALLTHROUGH */ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
760 case DH6S_RELEASE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
761 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
762 case DH6S_RENEW: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
763 if (m == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
764 m = state->new; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
765 ml = state->new_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
766 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
767 si = dhcp6_findmoption(m, ml, D6_OPTION_SERVERID, &si_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
768 if (si == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
769 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
770 len += sizeof(o) + si_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
771 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
772 case DH6S_REBIND: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
773 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
774 case DH6S_CONFIRM: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
775 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
776 case DH6S_DISCOVER: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
777 if (m == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
778 m = state->new; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
779 ml = state->new_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
780 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
781 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
782 if (ap->flags & IPV6_AF_STALE) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
783 continue; |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
784 if (!(ap->flags & IPV6_AF_REQUEST) && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
785 (ap->prefix_vltime == 0 || |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
786 state->state == DH6S_DISCOVER)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
787 continue; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
788 if (DECLINE_IA(ap) && state->state != DH6S_DECLINE) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
789 continue; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
790 if (ap->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
|
791 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
792 len += sizeof(o) + sizeof(struct dhcp6_pd_addr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
793 if (ap->prefix_exclude_len) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
794 len += sizeof(o) + 1 + |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
795 (uint8_t)((ap->prefix_exclude_len - |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
796 ap->prefix_len - 1) / NBBY) + 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
797 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
798 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
799 len += sizeof(o) + sizeof(struct dhcp6_ia_addr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
800 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
801 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
802 case DH6S_INIT: |
|
4281
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
803 for (l = 0; l < ifo->ia_len; l++) { |
|
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
804 len += sizeof(o) + sizeof(uint32_t); /* IAID */ |
|
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
805 /* IA_TA does not have T1 or T2 timers */ |
|
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
806 if (ifo->ia[l].ia_type != D6_OPTION_IA_TA) |
|
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
807 len += sizeof(uint32_t) + sizeof(uint32_t); |
|
0173b37a051b
dhcp6: fix a memory issue with prior patch
Roy Marples <roy@marples.name>
parents:
4280
diff
changeset
|
808 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
809 IA = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
810 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
811 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
812 IA = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
813 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
814 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
815 if (state->state == DH6S_DISCOVER && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
816 !(ifp->ctx->options & DHCPCD_TEST) && |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
817 DHC_REQ(ifo->requestmask6, ifo->nomask6, D6_OPTION_RAPID_COMMIT)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
818 len += sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
819 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
820 if (m == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
821 m = state->new; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
822 ml = state->new_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
823 } |
|
4418
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
824 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
825 switch(state->state) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
826 case DH6S_INIT: /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
827 case DH6S_DISCOVER: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
828 type = DHCP6_SOLICIT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
829 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
830 case DH6S_REQUEST: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
831 type = DHCP6_REQUEST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
832 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
833 case DH6S_CONFIRM: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
834 type = DHCP6_CONFIRM; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
835 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
836 case DH6S_REBIND: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
837 type = DHCP6_REBIND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
838 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
839 case DH6S_RENEW: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
840 type = DHCP6_RENEW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
841 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
842 case DH6S_INFORM: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
843 type = DHCP6_INFORMATION_REQ; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
844 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
845 case DH6S_RELEASE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
846 type = DHCP6_RELEASE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
847 break; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
848 case DH6S_DECLINE: |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
849 type = DHCP6_DECLINE; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
850 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
851 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
852 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
853 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
854 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
855 |
|
4418
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
856 switch(state->state) { |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
857 case DH6S_REQUEST: /* FALLTHROUGH */ |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
858 case DH6S_RENEW: /* FALLTHROUGH */ |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
859 case DH6S_RELEASE: |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
860 if (has_option_mask(ifo->nomask6, D6_OPTION_UNICAST)) { |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
861 unicast = NULL; |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
862 break; |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
863 } |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
864 unicast = dhcp6_findmoption(m, ml, D6_OPTION_UNICAST, &uni_len); |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
865 break; |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
866 default: |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
867 unicast = NULL; |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
868 break; |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
869 } |
|
64579c25e8e3
DHCPv6: Allow nooptions dhcp6_unicast to work.
Roy Marples <roy@marples.name>
parents:
4374
diff
changeset
|
870 |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
871 /* In non master mode we listen and send from fixed addresses. |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
872 * We should try and match an address we have to unicast to, |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
873 * but for now this is the safest policy. */ |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
874 if (unicast != NULL && !(ifp->ctx->options & DHCPCD_MASTER)) { |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
875 logdebugx("%s: ignoring unicast option as not master", |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
876 ifp->name); |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
877 unicast = NULL; |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
878 } |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
879 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
880 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
881 auth_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
882 if (ifo->auth.options & DHCPCD_AUTH_SEND) { |
|
5299
b7e676ac73c1
privsep: Access the RDM monotic file via IPC
Roy Marples <roy@marples.name>
parents:
5294
diff
changeset
|
883 ssize_t alen = dhcp_auth_encode(ifp->ctx, &ifo->auth, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
884 state->auth.token, NULL, 0, 6, type, NULL, 0); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
885 if (alen != -1 && alen > UINT16_MAX) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
886 errno = ERANGE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
887 alen = -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
888 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
889 if (alen == -1) |
| 4010 | 890 logerr("%s: %s: dhcp_auth_encode", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
891 else if (alen != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
892 auth_len = (uint16_t)alen; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
893 len += sizeof(o) + auth_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
894 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
895 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
896 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
897 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
898 state->send = malloc(len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
899 if (state->send == NULL) |
|
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 state->send_len = len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
903 state->send->type = type; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
904 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
905 /* If we found a unicast option, copy it to our state for sending */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
906 if (unicast && uni_len == sizeof(state->unicast)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
907 memcpy(&state->unicast, unicast, sizeof(state->unicast)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
908 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
909 state->unicast = in6addr_any; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
910 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
911 dhcp6_newxid(ifp, state->send); |
|
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 #define COPYIN1(_code, _len) { \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
914 o.code = htons((_code)); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
915 o.len = htons((_len)); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
916 memcpy(p, &o, sizeof(o)); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
917 p += sizeof(o); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
918 } |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
919 #define COPYIN(_code, _data, _len) do { \ |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
920 COPYIN1((_code), (_len)); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
921 if ((_len) != 0) { \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
922 memcpy(p, (_data), (_len)); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
923 p += (_len); \ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
924 } \ |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
925 } while (0 /* CONSTCOND */) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
926 #define NEXTLEN (p + offsetof(struct dhcp6_option, len)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
927 |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
928 /* Options are listed in numerical order as per RFC 7844 Section 4.1 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
929 * XXX: They should be randomised. */ |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
930 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
931 p = (uint8_t *)state->send + sizeof(*state->send); |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
932 if (ifo->options & DHCPCD_ANONYMOUS) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
933 COPYIN(D6_OPTION_CLIENTID, duid, |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
934 (uint16_t)duid_len); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
935 else |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
936 COPYIN(D6_OPTION_CLIENTID, ifp->ctx->duid, |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
937 (uint16_t)ifp->ctx->duid_len); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
938 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
939 if (si != NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
940 COPYIN(D6_OPTION_SERVERID, si, si_len); |
|
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 for (l = 0; IA && l < ifo->ia_len; l++) { |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
943 ifia = &ifo->ia[l]; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
944 o_lenp = NEXTLEN; |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
945 /* TA structure is the same as the others, |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
946 * it just lacks the T1 and T2 timers. |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
947 * These happen to be at the end of the struct, |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
948 * so we just don't copy them in. */ |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
949 if (ifia->ia_type == D6_OPTION_IA_TA) |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
950 ia_na_len = sizeof(struct dhcp6_ia_ta); |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
951 else |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
952 ia_na_len = sizeof(ia_na); |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
953 memcpy(ia_na.iaid, ifia->iaid, sizeof(ia_na.iaid)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
954 ia_na.t1 = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
955 ia_na.t2 = 0; |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
956 COPYIN(ifia->ia_type, &ia_na, ia_na_len); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
957 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
958 if (ap->flags & IPV6_AF_STALE) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
959 continue; |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
960 if (!(ap->flags & IPV6_AF_REQUEST) && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
961 (ap->prefix_vltime == 0 || |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
962 state->state == DH6S_DISCOVER)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
963 continue; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
964 if (DECLINE_IA(ap) && state->state != DH6S_DECLINE) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
965 continue; |
|
4280
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
966 if (ap->ia_type != ifia->ia_type) |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
967 continue; |
|
16dd1b6b5e13
dhcp6: match IA type with request
Roy Marples <roy@marples.name>
parents:
4279
diff
changeset
|
968 if (memcmp(ap->iaid, ifia->iaid, sizeof(ap->iaid))) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
969 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
970 if (ap->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
|
971 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
972 struct dhcp6_pd_addr pdp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
973 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
974 pdp.pltime = htonl(ap->prefix_pltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
975 pdp.vltime = htonl(ap->prefix_vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
976 pdp.prefix_len = ap->prefix_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
977 /* pdp.prefix is not aligned, so copy it in. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
978 memcpy(&pdp.prefix, &ap->prefix, sizeof(pdp.prefix)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
979 COPYIN(D6_OPTION_IAPREFIX, &pdp, sizeof(pdp)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
980 ia_na_len = (uint16_t) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
981 (ia_na_len + sizeof(o) + sizeof(pdp)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
982 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
983 /* RFC6603 Section 4.2 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
984 if (ap->prefix_exclude_len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
985 uint8_t exb[16], *ep, u8; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
986 const uint8_t *pp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
987 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
988 n = (size_t)((ap->prefix_exclude_len - |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
989 ap->prefix_len - 1) / NBBY) + 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
990 ep = exb; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
991 *ep++ = (uint8_t)ap->prefix_exclude_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
992 pp = ap->prefix_exclude.s6_addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
993 pp += (size_t) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
994 ((ap->prefix_len - 1) / NBBY) + |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
995 (n - 1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
996 u8 = ap->prefix_len % NBBY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
997 if (u8) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
998 n--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
999 while (n-- > 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1000 *ep++ = *pp--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1001 if (u8) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1002 *ep = (uint8_t)(*pp << u8); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1003 n++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1004 COPYIN(D6_OPTION_PD_EXCLUDE, exb, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1005 (uint16_t)n); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1006 ia_na_len = (uint16_t) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1007 (ia_na_len + sizeof(o) + n); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1008 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1009 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1010 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1011 struct dhcp6_ia_addr ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1012 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1013 ia.addr = ap->addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1014 ia.pltime = htonl(ap->prefix_pltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1015 ia.vltime = htonl(ap->prefix_vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1016 COPYIN(D6_OPTION_IA_ADDR, &ia, sizeof(ia)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1017 ia_na_len = (uint16_t) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1018 (ia_na_len + sizeof(o) + sizeof(ia)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1019 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1020 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1021 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1022 /* Update the total option lenth. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1023 ia_na_len = htons(ia_na_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1024 memcpy(o_lenp, &ia_na_len, sizeof(ia_na_len)); |
|
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 |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1027 if (state->send->type != DHCP6_RELEASE && |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1028 state->send->type != DHCP6_DECLINE && |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1029 n_options) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1030 { |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1031 o_lenp = NEXTLEN; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1032 o.len = 0; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1033 COPYIN1(D6_OPTION_ORO, 0); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1034 for (l = 0, opt = ifp->ctx->dhcp6_opts; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1035 l < ifp->ctx->dhcp6_opts_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1036 l++, opt++) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1037 { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1038 #ifndef SMALL |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1039 for (n = 0, opt2 = ifo->dhcp6_override; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1040 n < ifo->dhcp6_override_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1041 n++, opt2++) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1042 { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1043 if (opt->option == opt2->option) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1044 break; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1045 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1046 if (n < ifo->dhcp6_override_len) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1047 continue; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1048 #endif |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1049 if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1050 continue; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1051 o.code = htons((uint16_t)opt->option); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1052 memcpy(p, &o.code, sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1053 p += sizeof(o.code); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1054 o.len = (uint16_t)(o.len + sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1055 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1056 #ifndef SMALL |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1057 for (l = 0, opt = ifo->dhcp6_override; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1058 l < ifo->dhcp6_override_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1059 l++, opt++) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1060 { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1061 if (!DHC_REQOPT(opt, ifo->requestmask6, ifo->nomask6)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1062 continue; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1063 o.code = htons((uint16_t)opt->option); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1064 memcpy(p, &o.code, sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1065 p += sizeof(o.code); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1066 o.len = (uint16_t)(o.len + sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1067 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1068 if (dhcp6_findselfsla(ifp)) { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1069 o.code = htons(D6_OPTION_PD_EXCLUDE); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1070 memcpy(p, &o.code, sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1071 p += sizeof(o.code); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1072 o.len = (uint16_t)(o.len + sizeof(o.code)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1073 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1074 #endif |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1075 o.len = htons(o.len); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1076 memcpy(o_lenp, &o.len, sizeof(o.len)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1077 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1078 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1079 si_len = 0; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1080 COPYIN(D6_OPTION_ELAPSED, &si_len, sizeof(si_len)); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1081 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1082 if (state->state == DH6S_DISCOVER && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1083 !(ifp->ctx->options & DHCPCD_TEST) && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1084 DHC_REQ(ifo->requestmask6, ifo->nomask6, D6_OPTION_RAPID_COMMIT)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1085 COPYIN1(D6_OPTION_RAPID_COMMIT, 0); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1086 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1087 if (!has_option_mask(ifo->nomask6, D6_OPTION_USER_CLASS)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1088 p += dhcp6_makeuser(p, ifp); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1089 if (!has_option_mask(ifo->nomask6, D6_OPTION_VENDOR_CLASS)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1090 p += dhcp6_makevendor(p, ifp); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1091 |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1092 if (state->send->type != DHCP6_RELEASE && |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1093 state->send->type != DHCP6_DECLINE) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1094 { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1095 if (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
|
1096 o_lenp = NEXTLEN; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1097 COPYIN1(D6_OPTION_FQDN, 0); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1098 if (hl == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1099 *p = D6_FQDN_NONE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1100 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1101 switch (fqdn) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1102 case FQDN_BOTH: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1103 *p = D6_FQDN_BOTH; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1104 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1105 case FQDN_PTR: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1106 *p = D6_FQDN_PTR; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1107 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1108 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1109 *p = D6_FQDN_NONE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1110 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1111 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1112 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1113 p++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1114 encode_rfc1035(hostname, p); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1115 p += hl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1116 o.len = htons((uint16_t)(hl + 1)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1117 memcpy(o_lenp, &o.len, sizeof(o.len)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1118 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1119 |
| 4966 | 1120 if (!has_option_mask(ifo->nomask6, D6_OPTION_MUDURL) && |
| 1121 ifo->mudurl[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 COPYIN(D6_OPTION_MUDURL, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1123 ifo->mudurl + 1, ifo->mudurl[0]); |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
1124 |
|
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
1125 #ifdef AUTH |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1126 if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) != |
|
4726
ac7d83882d52
DHCP: Don't send force renew none or reconf accept if not asked for
Roy Marples <roy@marples.name>
parents:
4724
diff
changeset
|
1127 DHCPCD_AUTH_SENDREQUIRE && |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1128 DHC_REQ(ifo->requestmask6, ifo->nomask6, |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
1129 D6_OPTION_RECONF_ACCEPT)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1130 COPYIN1(D6_OPTION_RECONF_ACCEPT, 0); |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
1131 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1132 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1133 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1134 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1135 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1136 /* This has to be the last option */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1137 if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1138 COPYIN1(D6_OPTION_AUTH, auth_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1139 /* data will be filled at send message time */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1140 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1141 #endif |
|
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 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1144 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1145 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1146 static const char * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1147 dhcp6_get_op(uint16_t type) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1148 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1149 const struct dhcp6_op *d; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1150 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1151 for (d = dhcp6_ops; d->name; d++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1152 if (d->type == type) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1153 return d->name; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1154 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1155 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1156 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1157 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1158 dhcp6_freedrop_addrs(struct interface *ifp, int drop, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1159 const struct interface *ifd) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1160 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1161 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1162 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1163 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1164 if (state) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1165 ipv6_freedrop_addrs(&state->addrs, drop, ifd); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1166 if (drop) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1167 rt_build(ifp->ctx, AF_INET6); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1168 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1169 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1170 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1171 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1172 static void dhcp6_delete_delegates(struct interface *ifp) |
|
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 struct interface *ifp0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1175 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1176 if (ifp->ctx->ifaces) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1177 TAILQ_FOREACH(ifp0, ifp->ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1178 if (ifp0 != ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1179 dhcp6_freedrop_addrs(ifp0, 1, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1180 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1181 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1182 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1183 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1184 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1185 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1186 static ssize_t |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1187 dhcp6_update_auth(struct interface *ifp, struct dhcp6_message *m, 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
|
1188 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1189 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1190 uint8_t *opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1191 uint16_t opt_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1192 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1193 opt = dhcp6_findmoption(m, len, D6_OPTION_AUTH, &opt_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1194 if (opt == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1195 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1196 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1197 state = D6_STATE(ifp); |
|
5299
b7e676ac73c1
privsep: Access the RDM monotic file via IPC
Roy Marples <roy@marples.name>
parents:
5294
diff
changeset
|
1198 return dhcp_auth_encode(ifp->ctx, &ifp->options->auth, |
|
b7e676ac73c1
privsep: Access the RDM monotic file via IPC
Roy Marples <roy@marples.name>
parents:
5294
diff
changeset
|
1199 state->auth.token, (uint8_t *)state->send, state->send_len, 6, |
|
b7e676ac73c1
privsep: Access the RDM monotic file via IPC
Roy Marples <roy@marples.name>
parents:
5294
diff
changeset
|
1200 state->send->type, opt, opt_len); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1201 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1202 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1203 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1204 static const struct in6_addr alldhcp = IN6ADDR_LINKLOCAL_ALLDHCP_INIT; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1205 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1206 dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1207 { |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1208 struct dhcp6_state *state = D6_STATE(ifp); |
|
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1209 struct dhcpcd_ctx *ctx = ifp->ctx; |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1210 unsigned int RT; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1211 bool broadcast = true; |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1212 struct sockaddr_in6 dst = { |
|
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1213 .sin6_family = AF_INET6, |
|
5236
40c8b6fa2033
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples <roy@marples.name>
parents:
5234
diff
changeset
|
1214 /* Setting the port on Linux gives EINVAL when sending. |
|
40c8b6fa2033
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples <roy@marples.name>
parents:
5234
diff
changeset
|
1215 * This looks like a kernel bug as the equivalent works |
|
40c8b6fa2033
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples <roy@marples.name>
parents:
5234
diff
changeset
|
1216 * fine with the DHCP counterpart. */ |
|
40c8b6fa2033
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples <roy@marples.name>
parents:
5234
diff
changeset
|
1217 #ifndef __linux__ |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1218 .sin6_port = htons(DHCP6_SERVER_PORT), |
|
5236
40c8b6fa2033
Linux: workaround a kernel bug when sending DHCPv6 over SOCK_RAW
Roy Marples <roy@marples.name>
parents:
5234
diff
changeset
|
1219 #endif |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1220 }; |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1221 struct udphdr udp = { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1222 .uh_sport = htons(DHCP6_CLIENT_PORT), |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1223 .uh_dport = htons(DHCP6_SERVER_PORT), |
| 5234 | 1224 .uh_ulen = htons((uint16_t)(sizeof(udp) + state->send_len)), |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1225 }; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1226 struct iovec iov[] = { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1227 { .iov_base = &udp, .iov_len = sizeof(udp), }, |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1228 { .iov_base = state->send, .iov_len = state->send_len, }, |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1229 }; |
| 5172 | 1230 union { |
| 1231 struct cmsghdr hdr; | |
| 1232 uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; | |
| 1233 } cmsgbuf = { .buf = { 0 } }; | |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1234 struct msghdr msg = { |
|
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1235 .msg_name = &dst, .msg_namelen = sizeof(dst), |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1236 .msg_iov = iov, .msg_iovlen = __arraycount(iov), |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1237 }; |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1238 char uaddr[INET6_ADDRSTRLEN]; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1239 |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
1240 if (!callback && !if_is_link_up(ifp)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1241 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1242 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1243 if (!IN6_IS_ADDR_UNSPECIFIED(&state->unicast)) { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1244 switch (state->send->type) { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1245 case DHCP6_SOLICIT: /* FALLTHROUGH */ |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1246 case DHCP6_CONFIRM: /* FALLTHROUGH */ |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1247 case DHCP6_REBIND: |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1248 /* Unicasting is denied for these types. */ |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1249 break; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1250 default: |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1251 broadcast = false; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1252 inet_ntop(AF_INET6, &state->unicast, uaddr, |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1253 sizeof(uaddr)); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1254 break; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1255 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1256 } |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1257 dst.sin6_addr = broadcast ? alldhcp : state->unicast; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1258 |
|
4963
c15d5bf525c1
DHCP6: Fix a bogus compile warning
Roy Marples <roy@marples.name>
parents:
4958
diff
changeset
|
1259 if (!callback) { |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1260 logdebugx("%s: %s %s with xid 0x%02x%02x%02x%s%s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1261 ifp->name, |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1262 broadcast ? "broadcasting" : "unicasting", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1263 dhcp6_get_op(state->send->type), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1264 state->send->xid[0], |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1265 state->send->xid[1], |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1266 state->send->xid[2], |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1267 !broadcast ? " " : "", |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1268 !broadcast ? uaddr : ""); |
|
4963
c15d5bf525c1
DHCP6: Fix a bogus compile warning
Roy Marples <roy@marples.name>
parents:
4958
diff
changeset
|
1269 RT = 0; |
|
c15d5bf525c1
DHCP6: Fix a bogus compile warning
Roy Marples <roy@marples.name>
parents:
4958
diff
changeset
|
1270 } else { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1271 if (state->IMD && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1272 !(ifp->options->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
|
1273 state->IMD = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1274 if (state->IMD) { |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1275 state->RT = state->IMD * MSEC_PER_SEC; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1276 /* Some buggy PPP servers close the link too early |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1277 * after sending an invalid status in their reply |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1278 * which means this host won't see it. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1279 * 1 second grace seems to be the sweet spot. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1280 if (ifp->flags & IFF_POINTOPOINT) |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1281 state->RT += MSEC_PER_SEC; |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1282 } else if (state->RTC == 0) |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1283 state->RT = state->IRT * MSEC_PER_SEC; |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1284 |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1285 if (state->MRT != 0) { |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1286 unsigned int mrt = state->MRT * MSEC_PER_SEC; |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1287 |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1288 if (state->RT > mrt) |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1289 state->RT = mrt; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1290 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1291 |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1292 /* Add -.1 to .1 * RT randomness as per RFC8415 section 15 */ |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1293 uint32_t lru = arc4random_uniform( |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1294 state->RTC == 0 ? DHCP6_RAND_MAX |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1295 : DHCP6_RAND_MAX - DHCP6_RAND_MIN); |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1296 int lr = (int)lru - (state->RTC == 0 ? 0 : DHCP6_RAND_MAX); |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1297 RT = state->RT |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1298 + (unsigned int)((float)state->RT |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1299 * ((float)lr / DHCP6_RAND_DIV)); |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1300 |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
1301 if (if_is_link_up(ifp)) |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1302 logdebugx("%s: %s %s (xid 0x%02x%02x%02x)%s%s," |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1303 " next in %0.1f seconds", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1304 ifp->name, |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1305 state->IMD != 0 ? "delaying" : |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1306 broadcast ? "broadcasting" : "unicasting", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1307 dhcp6_get_op(state->send->type), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1308 state->send->xid[0], |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1309 state->send->xid[1], |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1310 state->send->xid[2], |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1311 state->IMD == 0 && !broadcast ? " " : "", |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1312 state->IMD == 0 && !broadcast ? uaddr : "", |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1313 (float)RT / MSEC_PER_SEC); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1314 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1315 /* Wait the initial delay */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1316 if (state->IMD != 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1317 state->IMD = 0; |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1318 eloop_timeout_add_msec(ctx->eloop, RT, callback, ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1319 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1320 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1321 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1322 |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
1323 if (!if_is_link_up(ifp)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1324 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1325 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1326 /* Update the elapsed time */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1327 dhcp6_updateelapsed(ifp, state->send, state->send_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1328 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1329 if (ifp->options->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
|
1330 dhcp6_update_auth(ifp, state->send, state->send_len) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1331 { |
| 4010 | 1332 logerr("%s: %s: dhcp6_updateauth", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1333 if (errno != ESRCH) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1334 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1335 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1336 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1337 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1338 /* Set the outbound interface */ |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1339 if (broadcast) { |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1340 struct cmsghdr *cm; |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1341 struct in6_pktinfo pi = { .ipi6_ifindex = ifp->index }; |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1342 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1343 dst.sin6_scope_id = ifp->index; |
| 5172 | 1344 msg.msg_control = cmsgbuf.buf; |
| 1345 msg.msg_controllen = sizeof(cmsgbuf.buf); | |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
1346 cm = CMSG_FIRSTHDR(&msg); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1347 if (cm == NULL) /* unlikely */ |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1348 return -1; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1349 cm->cmsg_level = IPPROTO_IPV6; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1350 cm->cmsg_type = IPV6_PKTINFO; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1351 cm->cmsg_len = CMSG_LEN(sizeof(pi)); |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1352 memcpy(CMSG_DATA(cm), &pi, sizeof(pi)); |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
1353 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1354 |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1355 #ifdef PRIVSEP |
|
4869
5bad3606b951
privsep: prefer IN_PRIVSEP macros
Roy Marples <roy@marples.name>
parents:
4841
diff
changeset
|
1356 if (IN_PRIVSEP(ifp->ctx)) { |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1357 if (ps_inet_senddhcp6(ifp, &msg) == -1) |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1358 logerr(__func__); |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1359 goto sent; |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1360 } |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1361 #endif |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1362 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
1363 if (sendmsg(ctx->dhcp6_wfd, &msg, 0) == -1) { |
| 4010 | 1364 logerr("%s: %s: sendmsg", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1365 /* Allow DHCPv6 to continue .... the errors |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1366 * would be rate limited by the protocol. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1367 * Generally the error is ENOBUFS when struggling to |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1368 * associate with an access point. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1369 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1370 |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1371 #ifdef PRIVSEP |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1372 sent: |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
1373 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1374 state->RTC++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1375 if (callback) { |
|
4942
fc102732fa9c
DHCP6: Only set RT to state with callbacks.
Roy Marples <roy@marples.name>
parents:
4939
diff
changeset
|
1376 state->RT = RT * 2; |
|
fc102732fa9c
DHCP6: Only set RT to state with callbacks.
Roy Marples <roy@marples.name>
parents:
4939
diff
changeset
|
1377 if (state->RT < RT) /* Check overflow */ |
|
fc102732fa9c
DHCP6: Only set RT to state with callbacks.
Roy Marples <roy@marples.name>
parents:
4939
diff
changeset
|
1378 state->RT = RT; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1379 if (state->MRC == 0 || state->RTC < state->MRC) |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1380 eloop_timeout_add_msec(ctx->eloop, |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1381 RT, callback, ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1382 else if (state->MRC != 0 && state->MRCcallback) |
|
4925
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1383 eloop_timeout_add_msec(ctx->eloop, |
|
74b140568feb
DHCP6: Calulate ReTransmission using milliseconds
Roy Marples <roy@marples.name>
parents:
4924
diff
changeset
|
1384 RT, state->MRCcallback, ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1385 else |
| 4010 | 1386 logwarnx("%s: sent %d times with no reply", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1387 ifp->name, state->RTC); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1388 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1389 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1390 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1391 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1392 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1393 dhcp6_sendinform(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1394 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1395 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1396 dhcp6_sendmessage(arg, dhcp6_sendinform); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1397 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1398 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1399 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1400 dhcp6_senddiscover(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1401 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1402 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1403 dhcp6_sendmessage(arg, dhcp6_senddiscover); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1404 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1405 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1406 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1407 dhcp6_sendrequest(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1408 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1409 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1410 dhcp6_sendmessage(arg, dhcp6_sendrequest); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1411 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1412 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1413 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1414 dhcp6_sendrebind(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1415 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1416 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1417 dhcp6_sendmessage(arg, dhcp6_sendrebind); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1418 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1419 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1420 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1421 dhcp6_sendrenew(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1422 { |
|
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 dhcp6_sendmessage(arg, dhcp6_sendrenew); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1425 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1426 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1427 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1428 dhcp6_sendconfirm(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1429 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1430 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1431 dhcp6_sendmessage(arg, dhcp6_sendconfirm); |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1434 static void |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1435 dhcp6_senddecline(void *arg) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1436 { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1437 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1438 dhcp6_sendmessage(arg, dhcp6_senddecline); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1439 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1440 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1441 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
|
1442 dhcp6_sendrelease(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1443 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1444 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1445 dhcp6_sendmessage(arg, dhcp6_sendrelease); |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1448 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1449 dhcp6_startrenew(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1450 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1451 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1452 struct dhcp6_state *state; |
|
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 ifp = arg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1455 if ((state = D6_STATE(ifp)) == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1456 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1457 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1458 /* Only renew in the bound or renew states */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1459 if (state->state != DH6S_BOUND && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1460 state->state != DH6S_RENEW) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1461 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1462 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1463 /* Remove the timeout as the renew may have been forced. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1464 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_startrenew, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1465 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1466 state->state = DH6S_RENEW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1467 state->RTC = 0; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1468 state->IMD = REN_MAX_DELAY; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1469 state->IRT = REN_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1470 state->MRT = REN_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1471 state->MRC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1472 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1473 if (dhcp6_makemessage(ifp) == -1) |
| 4010 | 1474 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1475 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1476 dhcp6_sendrenew(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1477 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1478 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1479 void dhcp6_renew(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1480 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1481 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1482 dhcp6_startrenew(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1483 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1484 |
|
5288
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
1485 bool |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1486 dhcp6_dadcompleted(const struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1487 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1488 const struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1489 const struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1490 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1491 state = D6_CSTATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1492 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1493 if (ap->flags & IPV6_AF_ADDED && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1494 !(ap->flags & IPV6_AF_DADCOMPLETED)) |
|
5288
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
1495 return false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1496 } |
|
5288
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
1497 return true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1498 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1499 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1500 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1501 dhcp6_dadcallback(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1502 { |
| 4116 | 1503 struct ipv6_addr *ia = arg; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1504 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1505 struct dhcp6_state *state; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1506 struct ipv6_addr *ia2; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1507 bool completed, valid, oneduplicated; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1508 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1509 completed = (ia->flags & IPV6_AF_DADCOMPLETED); |
| 4116 | 1510 ia->flags |= IPV6_AF_DADCOMPLETED; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1511 if (ia->addr_flags & IN6_IFF_DUPLICATED) |
| 4116 | 1512 logwarnx("%s: DAD detected %s", ia->iface->name, ia->saddr); |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1513 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1514 #ifdef ND6_ADVERTISE |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1515 else |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1516 ipv6nd_advertise(ia); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1517 #endif |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1518 if (completed) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1519 return; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1520 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1521 ifp = ia->iface; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1522 state = D6_STATE(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1523 if (state->state != DH6S_BOUND && state->state != DH6S_DELEGATED) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1524 return; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1525 |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
1526 #ifdef SMALL |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1527 valid = true; |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
1528 #else |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1529 valid = (ia->delegating_prefix == NULL); |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
1530 #endif |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1531 completed = true; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1532 oneduplicated = false; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1533 TAILQ_FOREACH(ia2, &state->addrs, next) { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1534 if (ia2->flags & IPV6_AF_ADDED && |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1535 !(ia2->flags & IPV6_AF_DADCOMPLETED)) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1536 { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1537 completed = false; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1538 break; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1539 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1540 if (DECLINE_IA(ia)) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1541 oneduplicated = true; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1542 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1543 if (!completed) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1544 return; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1545 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1546 logdebugx("%s: DHCPv6 DAD completed", ifp->name); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1547 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1548 if (oneduplicated && state->state == DH6S_BOUND) { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1549 dhcp6_startdecline(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1550 return; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1551 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1552 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1553 script_runreason(ifp, |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
1554 #ifndef SMALL |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1555 ia->delegating_prefix ? "DELEGATED6" : |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
1556 #endif |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1557 state->reason); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1558 if (valid) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1559 dhcpcd_daemonise(ifp->ctx); |
|
3932
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 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1563 dhcp6_addrequestedaddrs(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1564 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1565 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1566 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
|
1567 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
|
1568 struct ipv6_addr *a; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1569 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1570 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1571 /* Add any requested prefixes / addresses */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1572 for (i = 0; i < ifp->options->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1573 ia = &ifp->options->ia[i]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1574 if (!((ia->ia_type == D6_OPTION_IA_PD && 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
|
1575 !IN6_IS_ADDR_UNSPECIFIED(&ia->addr))) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1576 continue; |
|
4090
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1577 a = ipv6_newaddr(ifp, &ia->addr, |
|
3932
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 * RFC 5942 Section 5 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1580 * We cannot assume any prefix length, nor tie the |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1581 * address to an existing one as it could expire |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1582 * before the address. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1583 * As such we just give it a 128 prefix. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1584 */ |
|
4090
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1585 ia->ia_type == D6_OPTION_IA_PD ? ia->prefix_len : 128, |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1586 IPV6_AF_REQUEST); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1587 if (a == NULL) |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1588 continue; |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1589 a->dadcallback = dhcp6_dadcallback; |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1590 memcpy(&a->iaid, &ia->iaid, sizeof(a->iaid)); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
1591 a->ia_type = ia->ia_type; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1592 TAILQ_INSERT_TAIL(&state->addrs, a, next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1593 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1594 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1595 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1596 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1597 dhcp6_startdiscover(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1598 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1599 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1600 struct dhcp6_state *state; |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1601 int llevel; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1602 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1603 ifp = arg; |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1604 state = D6_STATE(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1605 #ifndef SMALL |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1606 if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0) |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1607 dhcp6_delete_delegates(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1608 #endif |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1609 if (state->new == NULL && !state->failed) |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1610 llevel = LOG_INFO; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1611 else |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1612 llevel = LOG_DEBUG; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1613 logmessage(llevel, "%s: soliciting a DHCPv6 lease", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1614 state->state = DH6S_DISCOVER; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1615 state->RTC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1616 state->IMD = SOL_MAX_DELAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1617 state->IRT = SOL_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1618 state->MRT = state->sol_max_rt; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1619 state->MRC = SOL_MAX_RC; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1620 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1621 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1622 free(state->new); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1623 state->new = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1624 state->new_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1625 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1626 if (dhcp6_makemessage(ifp) == -1) |
| 4010 | 1627 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1628 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1629 dhcp6_senddiscover(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1630 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1631 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1632 static void |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1633 dhcp6_startinform(void *arg) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1634 { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1635 struct interface *ifp; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1636 struct dhcp6_state *state; |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1637 int llevel; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1638 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1639 ifp = arg; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1640 state = D6_STATE(ifp); |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1641 if (state->new == NULL && !state->failed) |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1642 llevel = LOG_INFO; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1643 else |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1644 llevel = LOG_DEBUG; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1645 logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1646 state->state = DH6S_INFORM; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1647 state->RTC = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1648 state->IMD = INF_MAX_DELAY; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1649 state->IRT = INF_TIMEOUT; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1650 state->MRT = state->inf_max_rt; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1651 state->MRC = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1652 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1653 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1654 if (dhcp6_makemessage(ifp) == -1) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1655 logerr("%s: %s", __func__, ifp->name); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1656 return; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1657 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1658 dhcp6_sendinform(ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1659 /* RFC3315 18.1.2 says that if CONFIRM failed then the prior addresses |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1660 * SHOULD be used. The wording here is poor, because the addresses are |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1661 * merely one facet of the lease as a whole. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1662 * This poor wording might explain the lack of similar text for INFORM |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1663 * in 18.1.5 because there are no addresses in the INFORM message. */ |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1664 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1665 INF_MAX_RD, dhcp6_failinform, ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1666 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1667 |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1668 static bool |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1669 dhcp6_startdiscoinform(struct interface *ifp) |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1670 { |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1671 unsigned long long opts = ifp->options->options; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1672 |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1673 if (opts & DHCPCD_IA_FORCED || ipv6nd_hasradhcp(ifp, true)) |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1674 dhcp6_startdiscover(ifp); |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1675 else if (opts & DHCPCD_INFORM6 || ipv6nd_hasradhcp(ifp, false)) |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1676 dhcp6_startinform(ifp); |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1677 else |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1678 return false; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1679 return true; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1680 } |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1681 |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1682 static void |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1683 dhcp6_leaseextend(struct interface *ifp) |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1684 { |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1685 struct dhcp6_state *state = D6_STATE(ifp); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1686 struct ipv6_addr *ia; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1687 |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1688 logwarnx("%s: extending DHCPv6 lease", ifp->name); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1689 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1690 ia->flags |= IPV6_AF_EXTENDED; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1691 /* Set infinite lifetimes. */ |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1692 ia->prefix_pltime = ND6_INFINITE_LIFETIME; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1693 ia->prefix_vltime = ND6_INFINITE_LIFETIME; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1694 } |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1695 } |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1696 |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1697 static void |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1698 dhcp6_fail(struct interface *ifp) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1699 { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1700 struct dhcp6_state *state = D6_STATE(ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1701 |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1702 state->failed = true; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1703 |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1704 /* RFC3315 18.1.2 says that prior addresses SHOULD be used on failure. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1705 * RFC2131 3.2.3 says that MAY chose to use the prior address. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1706 * Because dhcpcd was written first for RFC2131, we have the LASTLEASE |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1707 * option which defaults to off as that makes the most sense for |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1708 * mobile clients. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1709 * dhcpcd also has LASTLEASE_EXTEND to extend this lease past it's |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1710 * expiry, but this is strictly not RFC compliant in any way or form. */ |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1711 if (state->new != NULL && |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1712 ifp->options->options & DHCPCD_LASTLEASE_EXTEND) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1713 { |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1714 dhcp6_leaseextend(ifp); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1715 dhcp6_bind(ifp, NULL, NULL); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1716 } else { |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1717 dhcp6_freedrop_addrs(ifp, 1, NULL); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1718 #ifndef SMALL |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1719 dhcp6_delete_delegates(ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1720 #endif |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1721 free(state->old); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1722 state->old = state->new; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1723 state->old_len = state->new_len; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1724 state->new = NULL; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1725 state->new_len = 0; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1726 if (state->old != NULL) |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1727 script_runreason(ifp, "EXPIRE6"); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
1728 dhcp_unlink(ifp->ctx, state->leasefile); |
|
5357
2ddfb6841ebb
DHCP6: Add requested addresses after freeing all state addresses
Roy Marples <roy@marples.name>
parents:
5299
diff
changeset
|
1729 dhcp6_addrequestedaddrs(ifp); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1730 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1731 |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
1732 if (!dhcp6_startdiscoinform(ifp)) { |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1733 logwarnx("%s: no advertising IPv6 router wants DHCP",ifp->name); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1734 state->state = DH6S_INIT; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1735 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1736 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1737 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1738 |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1739 static int |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1740 dhcp6_failloglevel(struct interface *ifp) |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1741 { |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1742 const struct dhcp6_state *state = D6_CSTATE(ifp); |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1743 |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1744 return state->failed ? LOG_DEBUG : LOG_ERR; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1745 } |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1746 |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1747 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
|
1748 dhcp6_failconfirm(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1749 { |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1750 struct interface *ifp = arg; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1751 int llevel = dhcp6_failloglevel(ifp); |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1752 |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1753 logmessage(llevel, "%s: failed to confirm prior DHCPv6 address", |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1754 ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1755 dhcp6_fail(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1756 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1757 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1758 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1759 dhcp6_failrequest(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1760 { |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1761 struct interface *ifp = arg; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1762 int llevel = dhcp6_failloglevel(ifp); |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1763 |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1764 logmessage(llevel, "%s: failed to request DHCPv6 address", ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1765 dhcp6_fail(ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1766 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1767 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1768 static void |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1769 dhcp6_failinform(void *arg) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1770 { |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1771 struct interface *ifp = arg; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1772 int llevel = dhcp6_failloglevel(ifp); |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1773 |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1774 logmessage(llevel, "%s: failed to request DHCPv6 information", |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1775 ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1776 dhcp6_fail(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1777 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1778 |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1779 #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
|
1780 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1781 dhcp6_failrebind(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1782 { |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1783 struct interface *ifp = arg; |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1784 |
|
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
1785 logerrx("%s: failed to rebind prior DHCPv6 delegation", ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1786 dhcp6_fail(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1787 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1788 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1789 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1790 dhcp6_hasprefixdelegation(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1791 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1792 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
|
1793 uint16_t t; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1794 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1795 t = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1796 for (i = 0; i < ifp->options->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1797 if (t && t != ifp->options->ia[i].ia_type) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1798 if (t == 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
|
1799 ifp->options->ia[i].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
|
1800 return 2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1801 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1802 t = ifp->options->ia[i].ia_type; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1803 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1804 return t == D6_OPTION_IA_PD ? 1 : 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1805 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1806 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1807 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1808 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1809 dhcp6_startrebind(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1810 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1811 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1812 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1813 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1814 int pd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1815 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1816 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1817 ifp = arg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1818 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrenew, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1819 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1820 if (state->state == DH6S_RENEW) |
| 4010 | 1821 logwarnx("%s: failed to renew DHCPv6, rebinding", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1822 else |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
1823 loginfox("%s: rebinding prior DHCPv6 lease", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1824 state->state = DH6S_REBIND; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1825 state->RTC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1826 state->MRC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1827 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1828 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1829 /* RFC 3633 section 12.1 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1830 pd = dhcp6_hasprefixdelegation(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1831 if (pd) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1832 state->IMD = CNF_MAX_DELAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1833 state->IRT = CNF_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1834 state->MRT = CNF_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1835 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1836 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1837 { |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1838 state->IMD = REB_MAX_DELAY; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1839 state->IRT = REB_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1840 state->MRT = REB_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1841 } |
|
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 if (dhcp6_makemessage(ifp) == -1) |
| 4010 | 1844 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1845 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1846 dhcp6_sendrebind(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1847 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1848 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1849 /* RFC 3633 section 12.1 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1850 if (pd) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1851 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1852 CNF_MAX_RD, dhcp6_failrebind, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1853 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1854 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1855 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1856 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1857 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1858 dhcp6_startrequest(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1859 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1860 struct dhcp6_state *state; |
|
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 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_senddiscover, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1863 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1864 state->state = DH6S_REQUEST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1865 state->RTC = 0; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1866 state->IMD = 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1867 state->IRT = REQ_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1868 state->MRT = REQ_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1869 state->MRC = REQ_MAX_RC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1870 state->MRCcallback = dhcp6_failrequest; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1871 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1872 if (dhcp6_makemessage(ifp) == -1) { |
| 4010 | 1873 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1874 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1875 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1876 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1877 dhcp6_sendrequest(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1878 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1879 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1880 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1881 dhcp6_startconfirm(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1882 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1883 struct dhcp6_state *state; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1884 struct ipv6_addr *ia; |
|
3932
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 state = D6_STATE(ifp); |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1887 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1888 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1889 if (!DECLINE_IA(ia)) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1890 continue; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1891 logerrx("%s: prior DHCPv6 has a duplicated address", ifp->name); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1892 dhcp6_startdecline(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1893 return; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1894 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1895 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1896 state->state = DH6S_CONFIRM; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1897 state->RTC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1898 state->IMD = CNF_MAX_DELAY; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1899 state->IRT = CNF_TIMEOUT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1900 state->MRT = CNF_MAX_RT; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1901 state->MRC = CNF_MAX_RC; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1902 |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
1903 loginfox("%s: confirming prior DHCPv6 lease", ifp->name); |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1904 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1905 if (dhcp6_makemessage(ifp) == -1) { |
| 4010 | 1906 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1907 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1908 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1909 dhcp6_sendconfirm(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1910 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1911 CNF_MAX_RD, dhcp6_failconfirm, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1912 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1913 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1914 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1915 dhcp6_startexpire(void *arg) |
|
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 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1918 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1919 ifp = arg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1920 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrebind, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1921 |
| 4010 | 1922 logerrx("%s: DHCPv6 lease expired", ifp->name); |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
1923 dhcp6_fail(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1924 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1925 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1926 static void |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1927 dhcp6_faildecline(void *arg) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1928 { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1929 struct interface *ifp = arg; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1930 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1931 logerrx("%s: failed to decline duplicated DHCPv6 addresses", ifp->name); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1932 dhcp6_fail(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1933 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1934 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1935 static void |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1936 dhcp6_startdecline(struct interface *ifp) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1937 { |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1938 struct dhcp6_state *state; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1939 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1940 state = D6_STATE(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1941 loginfox("%s: declining failed DHCPv6 addresses", ifp->name); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1942 state->state = DH6S_DECLINE; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1943 state->RTC = 0; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1944 state->IMD = 0; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1945 state->IRT = DEC_TIMEOUT; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1946 state->MRT = 0; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1947 state->MRC = DEC_MAX_RC; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1948 state->MRCcallback = dhcp6_faildecline; |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1949 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1950 if (dhcp6_makemessage(ifp) == -1) |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1951 logerr("%s: %s", __func__, ifp->name); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1952 else |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1953 dhcp6_senddecline(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1954 } |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1955 |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
1956 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
|
1957 dhcp6_finishrelease(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1958 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1959 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1960 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1961 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1962 ifp = (struct interface *)arg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1963 if ((state = D6_STATE(ifp)) != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1964 state->state = DH6S_RELEASED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1965 dhcp6_drop(ifp, "RELEASE6"); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1966 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1967 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1968 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1969 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1970 dhcp6_startrelease(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1971 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1972 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1973 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1974 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1975 if (state->state != DH6S_BOUND) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1976 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1977 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1978 state->state = DH6S_RELEASE; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1979 state->RTC = 0; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1980 state->IMD = REL_MAX_DELAY; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1981 state->IRT = REL_TIMEOUT; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
1982 state->MRT = REL_MAX_RT; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1983 /* MRC of REL_MAX_RC is optional in RFC 3315 18.1.6 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1984 #if 0 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1985 state->MRC = REL_MAX_RC; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1986 state->MRCcallback = dhcp6_finishrelease; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1987 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1988 state->MRC = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1989 state->MRCcallback = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1990 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1991 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1992 if (dhcp6_makemessage(ifp) == -1) |
| 4010 | 1993 logerr("%s: %s", __func__, ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1994 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1995 dhcp6_sendrelease(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1996 dhcp6_finishrelease(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1997 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1998 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
1999 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2000 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2001 dhcp6_checkstatusok(const struct interface *ifp, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2002 struct dhcp6_message *m, uint8_t *p, 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
|
2003 { |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2004 struct dhcp6_state *state; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2005 uint8_t *opt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2006 uint16_t opt_len, code; |
|
4247
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2007 size_t mlen; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2008 void * (*f)(void *, size_t, uint16_t, uint16_t *), *farg; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2009 char buf[32], *sbuf; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2010 const char *status; |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2011 int loglevel; |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2012 |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2013 state = D6_STATE(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2014 f = p ? dhcp6_findoption : dhcp6_findmoption; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2015 if (p) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2016 farg = p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2017 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2018 farg = m; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2019 if ((opt = f(farg, len, D6_OPTION_STATUS_CODE, &opt_len)) == NULL) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2020 //logdebugx("%s: no status", ifp->name); |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2021 state->lerror = 0; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2022 errno = ESRCH; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2023 return 0; |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2026 if (opt_len < sizeof(code)) { |
| 4010 | 2027 logerrx("%s: status truncated", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2028 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2029 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2030 memcpy(&code, opt, sizeof(code)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2031 code = ntohs(code); |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2032 if (code == D6_STATUS_OK) { |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2033 state->lerror = 0; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2034 errno = 0; |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2035 return 0; |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2036 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2037 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2038 /* Anything after the code is a message. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2039 opt += sizeof(code); |
|
4247
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2040 mlen = opt_len - sizeof(code); |
|
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2041 if (mlen == 0) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2042 sbuf = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2043 if (code < sizeof(dhcp6_statuses) / sizeof(char *)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2044 status = dhcp6_statuses[code]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2045 else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2046 snprintf(buf, sizeof(buf), "Unknown Status (%d)", code); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2047 status = buf; |
|
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 } else { |
|
4247
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2050 if ((sbuf = malloc(mlen + 1)) == NULL) { |
| 4010 | 2051 logerr(__func__); |
|
4105
83dac3d51eae
Fix processing of INFORM6 replies without an OK status code.
Roy Marples <roy@marples.name>
parents:
4090
diff
changeset
|
2052 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
|
2053 } |
|
4247
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2054 memcpy(sbuf, opt, mlen); |
|
22a5ac71f5c8
dhcp6: fix a potential string termination error on status messages
Roy Marples <roy@marples.name>
parents:
4233
diff
changeset
|
2055 sbuf[mlen] = '\0'; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2056 status = sbuf; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2057 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2058 |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2059 if (state->lerror == code || state->state == DH6S_INIT) |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2060 loglevel = LOG_DEBUG; |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2061 else |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2062 loglevel = LOG_ERR; |
|
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2063 logmessage(loglevel, "%s: DHCPv6 REPLY: %s", ifp->name, status); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2064 free(sbuf); |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
2065 state->lerror = code; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2066 errno = 0; |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2067 return (int)code; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2068 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2069 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2070 const struct ipv6_addr * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2071 dhcp6_iffindaddr(const struct interface *ifp, const struct in6_addr *addr, |
|
4123
441ac8d90316
Promote IPv6 dhcpcd address flags to unsignned int to allow expansion.
Roy Marples <roy@marples.name>
parents:
4117
diff
changeset
|
2072 unsigned 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
|
2073 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2074 const struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2075 const struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2076 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2077 if ((state = D6_STATE(ifp)) != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2078 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2079 if (ipv6_findaddrmatch(ap, addr, flags)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2080 return ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2081 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2082 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2083 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2084 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2085 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2086 struct ipv6_addr * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2087 dhcp6_findaddr(struct dhcpcd_ctx *ctx, const struct in6_addr *addr, |
|
4123
441ac8d90316
Promote IPv6 dhcpcd address flags to unsignned int to allow expansion.
Roy Marples <roy@marples.name>
parents:
4117
diff
changeset
|
2088 unsigned 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
|
2089 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2090 struct interface *ifp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2091 struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2092 struct dhcp6_state *state; |
|
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 TAILQ_FOREACH(ifp, ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2095 if ((state = D6_STATE(ifp)) != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2096 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2097 if (ipv6_findaddrmatch(ap, addr, flags)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2098 return ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2099 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2100 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2101 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2102 return NULL; |
|
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 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2105 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2106 dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2107 uint8_t *d, size_t l, const struct timespec *acquired) |
|
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 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2110 uint8_t *o, *nd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2111 uint16_t ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2112 struct ipv6_addr *a; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2113 int i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2114 struct dhcp6_ia_addr ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2115 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2116 i = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2117 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2118 while ((o = dhcp6_findoption(d, l, D6_OPTION_IA_ADDR, &ol))) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2119 /* Set d and l first to ensure we find the next option. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2120 nd = o + ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2121 l -= (size_t)(nd - d); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2122 d = nd; |
|
4458
0e6212a4aa03
DHCPv6: Fix a potential buffer overflow reading NA/TA addresses
Roy Marples <roy@marples.name>
parents:
4423
diff
changeset
|
2123 if (ol < sizeof(ia)) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2124 errno = EINVAL; |
| 4010 | 2125 logerrx("%s: IA Address option truncated", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2126 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2127 } |
|
4458
0e6212a4aa03
DHCPv6: Fix a potential buffer overflow reading NA/TA addresses
Roy Marples <roy@marples.name>
parents:
4423
diff
changeset
|
2128 memcpy(&ia, o, sizeof(ia)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2129 ia.pltime = ntohl(ia.pltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2130 ia.vltime = ntohl(ia.vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2131 /* RFC 3315 22.6 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2132 if (ia.pltime > ia.vltime) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2133 errno = EINVAL; |
| 4010 | 2134 logerr("%s: IA Address pltime %"PRIu32 |
| 2135 " > vltime %"PRIu32, | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2136 ifp->name, ia.pltime, ia.vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2137 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2138 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2139 TAILQ_FOREACH(a, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2140 if (ipv6_findaddrmatch(a, &ia.addr, 0)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2141 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2142 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2143 if (a == NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2144 /* |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2145 * RFC 5942 Section 5 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2146 * We cannot assume any prefix length, nor tie the |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2147 * address to an existing one as it could expire |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2148 * before the address. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2149 * As such we just give it a 128 prefix. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2150 */ |
|
4090
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2151 a = ipv6_newaddr(ifp, &ia.addr, 128, IPV6_AF_ONLINK); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2152 a->dadcallback = dhcp6_dadcallback; |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2153 a->ia_type = ot; |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2154 memcpy(a->iaid, iaid, sizeof(a->iaid)); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2155 a->created = *acquired; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2156 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2157 TAILQ_INSERT_TAIL(&state->addrs, a, next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2158 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2159 if (!(a->flags & IPV6_AF_ONLINK)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2160 a->flags |= IPV6_AF_ONLINK | IPV6_AF_NEW; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2161 a->flags &= ~(IPV6_AF_STALE | IPV6_AF_EXTENDED); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2162 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2163 a->acquired = *acquired; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2164 a->prefix_pltime = ia.pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2165 if (a->prefix_vltime != ia.vltime) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2166 a->flags |= IPV6_AF_NEW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2167 a->prefix_vltime = ia.vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2168 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2169 if (a->prefix_pltime && a->prefix_pltime < state->lowpl) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2170 state->lowpl = a->prefix_pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2171 if (a->prefix_vltime && a->prefix_vltime > state->expire) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2172 state->expire = a->prefix_vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2173 i++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2174 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2175 return i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2176 } |
|
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 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2179 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2180 dhcp6_findpd(struct interface *ifp, const uint8_t *iaid, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2181 uint8_t *d, size_t l, const struct timespec *acquired) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2182 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2183 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2184 uint8_t *o, *nd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2185 struct ipv6_addr *a; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2186 int i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2187 uint8_t nb, *pw; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2188 uint16_t ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2189 struct dhcp6_pd_addr pdp; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2190 struct in6_addr pdp_prefix; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2191 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2192 i = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2193 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2194 while ((o = dhcp6_findoption(d, l, D6_OPTION_IAPREFIX, &ol))) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2195 /* Set d and l first to ensure we find the next option. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2196 nd = o + ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2197 l -= (size_t)(nd - d); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2198 d = nd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2199 if (ol < sizeof(pdp)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2200 errno = EINVAL; |
| 4010 | 2201 logerrx("%s: IA Prefix option truncated", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2202 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2203 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2204 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2205 memcpy(&pdp, o, sizeof(pdp)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2206 pdp.pltime = ntohl(pdp.pltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2207 pdp.vltime = ntohl(pdp.vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2208 /* RFC 3315 22.6 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2209 if (pdp.pltime > pdp.vltime) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2210 errno = EINVAL; |
| 4010 | 2211 logerrx("%s: IA Prefix pltime %"PRIu32 |
| 2212 " > vltime %"PRIu32, | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2213 ifp->name, pdp.pltime, pdp.vltime); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2214 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2215 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2216 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2217 o += sizeof(pdp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2218 ol = (uint16_t)(ol - sizeof(pdp)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2219 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2220 /* pdp.prefix is not aligned so copy it out. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2221 memcpy(&pdp_prefix, &pdp.prefix, sizeof(pdp_prefix)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2222 TAILQ_FOREACH(a, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2223 if (IN6_ARE_ADDR_EQUAL(&a->prefix, &pdp_prefix)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2224 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2225 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2226 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2227 if (a == NULL) { |
|
4090
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2228 a = ipv6_newaddr(ifp, &pdp_prefix, pdp.prefix_len, |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2229 IPV6_AF_DELEGATEDPFX); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2230 if (a == NULL) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2231 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2232 a->created = *acquired; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2233 a->dadcallback = dhcp6_dadcallback; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2234 a->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
|
2235 memcpy(a->iaid, iaid, sizeof(a->iaid)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2236 TAILQ_INSERT_TAIL(&state->addrs, a, next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2237 } else { |
|
4883
a6eeb584a437
DHCP6: Fix deprecating a delegated prefix
Roy Marples <roy@marples.name>
parents:
4877
diff
changeset
|
2238 if (!(a->flags & IPV6_AF_DELEGATEDPFX)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2239 a->flags |= IPV6_AF_NEW | IPV6_AF_DELEGATEDPFX; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2240 a->flags &= ~(IPV6_AF_STALE | |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2241 IPV6_AF_EXTENDED | |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2242 IPV6_AF_REQUEST); |
|
4193
a1772bc670f0
dhcp6: fix prefix delegations from spamming syslog
Roy Marples <roy@marples.name>
parents:
4192
diff
changeset
|
2243 if (a->prefix_vltime != pdp.vltime) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2244 a->flags |= IPV6_AF_NEW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2245 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2246 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2247 a->acquired = *acquired; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2248 a->prefix_pltime = pdp.pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2249 a->prefix_vltime = pdp.vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2250 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2251 if (a->prefix_pltime && a->prefix_pltime < state->lowpl) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2252 state->lowpl = a->prefix_pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2253 if (a->prefix_vltime && a->prefix_vltime > state->expire) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2254 state->expire = a->prefix_vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2255 i++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2256 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2257 a->prefix_exclude_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2258 memset(&a->prefix_exclude, 0, sizeof(a->prefix_exclude)); |
|
4499
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2259 o = dhcp6_findoption(o, ol, D6_OPTION_PD_EXCLUDE, &ol); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2260 if (o == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2261 continue; |
|
4499
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2262 |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2263 /* RFC 6603 4.2 says option length MUST be between 2 and 17. |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2264 * This allows 1 octet for prefix length and 16 for the |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2265 * subnet ID. */ |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2266 if (ol < 2 || ol > 17) { |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2267 logerrx("%s: invalid PD Exclude option", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2268 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2269 } |
|
4499
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2270 |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2271 /* RFC 6603 4.2 says prefix length MUST be between the |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2272 * length of the IAPREFIX prefix length + 1 and 128. */ |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2273 if (*o < a->prefix_len + 1 || *o > 128) { |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2274 logerrx("%s: invalid PD Exclude length", ifp->name); |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2275 continue; |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2276 } |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2277 |
|
4509
78cdda45f5d9
DHCPv6: Fix exclude prefix length check.
Roy Marples <roy@marples.name>
parents:
4499
diff
changeset
|
2278 ol--; |
|
4499
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2279 /* Check option length matches prefix length. */ |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2280 if (((*o - a->prefix_len - 1) / NBBY) + 1 != ol) { |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2281 logerrx("%s: PD Exclude length mismatch", ifp->name); |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2282 continue; |
|
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2283 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2284 a->prefix_exclude_len = *o++; |
|
4509
78cdda45f5d9
DHCPv6: Fix exclude prefix length check.
Roy Marples <roy@marples.name>
parents:
4499
diff
changeset
|
2285 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2286 memcpy(&a->prefix_exclude, &a->prefix, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2287 sizeof(a->prefix_exclude)); |
|
4499
94b77a3ab52f
DHCPv6: Fix a potential read overflow with D6_OPTION_PD_EXCLUDE
Roy Marples <roy@marples.name>
parents:
4464
diff
changeset
|
2288 nb = a->prefix_len % NBBY; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2289 if (nb) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2290 ol--; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2291 pw = a->prefix_exclude.s6_addr + |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2292 (a->prefix_exclude_len / NBBY) - 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2293 while (ol-- > 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2294 *pw-- = *o++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2295 if (nb) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2296 *pw = (uint8_t)(*pw | (*o >> nb)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2297 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2298 return i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2299 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2300 #endif |
|
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 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2303 dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, 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
|
2304 const char *sfrom, const struct timespec *acquired) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2305 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2306 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2307 const 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
|
2308 struct dhcp6_option o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2309 uint8_t *d, *p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2310 struct dhcp6_ia_na ia; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2311 int i, e, error; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2312 size_t j; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2313 uint16_t nl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2314 uint8_t iaid[4]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2315 char buf[sizeof(iaid) * 3]; |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2316 struct ipv6_addr *ap; |
|
4279
cdffb0137daa
dhcp6: IAID is now unique for IA type
Roy Marples <roy@marples.name>
parents:
4267
diff
changeset
|
2317 struct if_ia *ifia; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2318 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2319 if (l < sizeof(*m)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2320 /* Should be impossible with guards at packet in |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2321 * and reading leases */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2322 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2323 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2324 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2325 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2326 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2327 i = e = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2328 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2329 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
4179
a996934a143b
dhcp6: don't make delegated addresses stale
Roy Marples <roy@marples.name>
parents:
4178
diff
changeset
|
2330 if (!(ap->flags & IPV6_AF_DELEGATED)) |
|
a996934a143b
dhcp6: don't make delegated addresses stale
Roy Marples <roy@marples.name>
parents:
4178
diff
changeset
|
2331 ap->flags |= IPV6_AF_STALE; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2332 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2333 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2334 d = (uint8_t *)m + sizeof(*m); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2335 l -= sizeof(*m); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2336 while (l > sizeof(o)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2337 memcpy(&o, d, sizeof(o)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2338 o.len = ntohs(o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2339 if (o.len > l || sizeof(o) + o.len > l) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2340 errno = EINVAL; |
| 4010 | 2341 logerrx("%s: option overflow", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2342 break; |
|
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 p = d + sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2345 d = p + o.len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2346 l -= sizeof(o) + o.len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2347 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2348 o.code = ntohs(o.code); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2349 switch(o.code) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2350 case 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
|
2351 nl = 4; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2352 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2353 case 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
|
2354 case 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
|
2355 nl = 12; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2356 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2357 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2358 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2359 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2360 if (o.len < nl) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2361 errno = EINVAL; |
| 4010 | 2362 logerrx("%s: IA option truncated", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2363 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2364 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2365 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2366 memcpy(&ia, p, nl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2367 p += nl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2368 o.len = (uint16_t)(o.len - nl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2369 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2370 for (j = 0; j < ifo->ia_len; j++) { |
|
4279
cdffb0137daa
dhcp6: IAID is now unique for IA type
Roy Marples <roy@marples.name>
parents:
4267
diff
changeset
|
2371 ifia = &ifo->ia[j]; |
|
cdffb0137daa
dhcp6: IAID is now unique for IA type
Roy Marples <roy@marples.name>
parents:
4267
diff
changeset
|
2372 if (ifia->ia_type == o.code && |
|
cdffb0137daa
dhcp6: IAID is now unique for IA type
Roy Marples <roy@marples.name>
parents:
4267
diff
changeset
|
2373 memcmp(ifia->iaid, ia.iaid, sizeof(ia.iaid)) == 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2374 break; |
|
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 if (j == 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
|
2377 !(ifo->ia_len == 0 && ifp->ctx->options & DHCPCD_DUMPLEASE)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2378 { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2379 logdebugx("%s: ignoring unrequested IAID %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2380 ifp->name, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2381 hwaddr_ntoa(ia.iaid, sizeof(ia.iaid), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2382 buf, sizeof(buf))); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2383 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2384 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2385 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2386 if (o.code != 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
|
2387 ia.t1 = ntohl(ia.t1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2388 ia.t2 = ntohl(ia.t2); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2389 /* RFC 3315 22.4 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2390 if (ia.t2 > 0 && ia.t1 > ia.t2) { |
| 4010 | 2391 logwarnx("%s: IAID %s T1(%d) > T2(%d) from %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2392 ifp->name, |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
2393 hwaddr_ntoa(iaid, sizeof(iaid), buf, |
|
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
2394 sizeof(buf)), |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2395 ia.t1, ia.t2, sfrom); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2396 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2397 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2398 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2399 ia.t1 = ia.t2 = 0; /* appease gcc */ |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2400 if ((error = dhcp6_checkstatusok(ifp, NULL, p, o.len)) != 0) { |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2401 if (error == D6_STATUS_NOBINDING) |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2402 state->has_no_binding = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2403 e = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2404 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2405 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2406 if (o.code == 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
|
2407 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2408 if (dhcp6_findpd(ifp, ia.iaid, p, o.len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2409 acquired) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2410 { |
| 4010 | 2411 logwarnx("%s: %s: DHCPv6 REPLY missing Prefix", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2412 ifp->name, sfrom); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2413 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2414 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2415 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2416 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2417 if (dhcp6_findna(ifp, o.code, ia.iaid, p, o.len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2418 acquired) == 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2419 { |
| 4010 | 2420 logwarnx("%s: %s: DHCPv6 REPLY missing " |
| 2421 "IA Address", | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2422 ifp->name, sfrom); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2423 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2424 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2425 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2426 if (o.code != 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
|
2427 if (ia.t1 != 0 && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2428 (ia.t1 < state->renew || state->renew == 0)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2429 state->renew = ia.t1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2430 if (ia.t2 != 0 && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2431 (ia.t2 < state->rebind || state->rebind == 0)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2432 state->rebind = ia.t2; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2433 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2434 i++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2435 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2436 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2437 if (i == 0 && e) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2438 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2439 return i; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2440 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2441 |
|
4890
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2442 #ifndef SMALL |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2443 static void |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2444 dhcp6_deprecatedele(struct ipv6_addr *ia) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2445 { |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2446 struct ipv6_addr *da, *dan, *dda; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2447 struct timespec now; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2448 struct dhcp6_state *state; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2449 |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2450 timespecclear(&now); |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2451 TAILQ_FOREACH_SAFE(da, &ia->pd_pfxs, pd_next, dan) { |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2452 if (ia->prefix_vltime == 0) { |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2453 if (da->prefix_vltime != 0) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2454 da->prefix_vltime = 0; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2455 else |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2456 continue; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2457 } else if (da->prefix_pltime != 0) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2458 da->prefix_pltime = 0; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2459 else |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2460 continue; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2461 |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2462 if (ipv6_doaddr(da, &now) != -1) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2463 continue; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2464 |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2465 /* Delegation deleted, forget it. */ |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2466 TAILQ_REMOVE(&ia->pd_pfxs, da, pd_next); |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2467 |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2468 /* Delete it from the interface. */ |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2469 state = D6_STATE(da->iface); |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2470 TAILQ_FOREACH(dda, &state->addrs, next) { |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2471 if (IN6_ARE_ADDR_EQUAL(&dda->addr, &da->addr)) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2472 break; |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2473 } |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2474 if (dda != NULL) { |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2475 TAILQ_REMOVE(&state->addrs, dda, next); |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2476 ipv6_freeaddr(dda); |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2477 } |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2478 } |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2479 } |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2480 #endif |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2481 |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2482 static void |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2483 dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs) |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2484 { |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2485 struct ipv6_addr *ia, *ian; |
|
4896
b9b16e0b58d1
DHCP6: Remove now unused vars
Roy Marples <roy@marples.name>
parents:
4893
diff
changeset
|
2486 |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2487 TAILQ_FOREACH_SAFE(ia, addrs, next, ian) { |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2488 if (ia->flags & IPV6_AF_EXTENDED) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2489 ; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2490 else if (ia->flags & IPV6_AF_STALE) { |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2491 if (ia->prefix_vltime != 0) |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2492 logdebugx("%s: %s: became stale", |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2493 ia->iface->name, ia->saddr); |
|
5109
a7b7abb6211c
Note that setting pltime to zero for stale addresses isn't RFC compliant
Roy Marples <roy@marples.name>
parents:
5092
diff
changeset
|
2494 /* Technically this violates RFC 8415 18.2.10.1, |
|
a7b7abb6211c
Note that setting pltime to zero for stale addresses isn't RFC compliant
Roy Marples <roy@marples.name>
parents:
5092
diff
changeset
|
2495 * but we need a mechanism to tell the kernel to |
|
a7b7abb6211c
Note that setting pltime to zero for stale addresses isn't RFC compliant
Roy Marples <roy@marples.name>
parents:
5092
diff
changeset
|
2496 * try and prefer other addresses. */ |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2497 ia->prefix_pltime = 0; |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2498 } else if (ia->prefix_vltime == 0) |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2499 loginfox("%s: %s: no valid lifetime", |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2500 ia->iface->name, ia->saddr); |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2501 else |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2502 continue; |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2503 |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2504 #ifndef SMALL |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2505 /* If we delegated from this prefix, deprecate or remove |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2506 * the delegations. */ |
|
4890
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2507 if (ia->flags & IPV6_AF_DELEGATEDPFX) |
|
5cad682cbbae
DHCP6: Rework delegation deprecation
Roy Marples <roy@marples.name>
parents:
4883
diff
changeset
|
2508 dhcp6_deprecatedele(ia); |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2509 #endif |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2510 |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2511 if (ia->flags & IPV6_AF_REQUEST) { |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2512 ia->prefix_vltime = ia->prefix_pltime = 0; |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2513 eloop_q_timeout_delete(ia->iface->ctx->eloop, |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
2514 ELOOP_QUEUE_ALL, NULL, ia); |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2515 continue; |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2516 } |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2517 TAILQ_REMOVE(addrs, ia, next); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2518 if (ia->flags & IPV6_AF_EXTENDED) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2519 ipv6_deleteaddr(ia); |
|
4065
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2520 ipv6_freeaddr(ia); |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2521 } |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2522 } |
|
710e3f0e1b2f
Apply the real D108 patch, my bad.
Roy Marples <roy@marples.name>
parents:
4064
diff
changeset
|
2523 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2524 static int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2525 dhcp6_validatelease(struct interface *ifp, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2526 struct dhcp6_message *m, 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
|
2527 const char *sfrom, const struct timespec *acquired) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2528 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2529 struct dhcp6_state *state; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2530 int nia, ok_errno; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2531 struct timespec aq; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2532 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2533 if (len <= sizeof(*m)) { |
| 4010 | 2534 logerrx("%s: DHCPv6 lease truncated", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2535 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2536 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2537 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2538 state = D6_STATE(ifp); |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2539 errno = 0; |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2540 if (dhcp6_checkstatusok(ifp, m, NULL, len) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2541 return -1; |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2542 ok_errno = errno; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2543 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2544 state->renew = state->rebind = state->expire = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2545 state->lowpl = ND6_INFINITE_LIFETIME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2546 if (!acquired) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2547 clock_gettime(CLOCK_MONOTONIC, &aq); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2548 acquired = &aq; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2549 } |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2550 state->has_no_binding = false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2551 nia = dhcp6_findia(ifp, m, len, sfrom, acquired); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2552 if (nia == 0) { |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2553 if (state->state != DH6S_CONFIRM && ok_errno != 0) { |
| 4010 | 2554 logerrx("%s: no useable IA found in lease", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2555 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2556 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2557 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2558 /* We are confirming and have an OK, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2559 * so look for ia's in our old lease. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2560 * IA's must have existed here otherwise we would |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2561 * have rejected it earlier. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2562 assert(state->new != NULL && state->new_len != 0); |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
2563 state->has_no_binding = false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2564 nia = dhcp6_findia(ifp, state->new, state->new_len, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2565 sfrom, acquired); |
|
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 return nia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2568 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2569 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2570 static ssize_t |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2571 dhcp6_readlease(struct interface *ifp, int validate) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2572 { |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2573 union { |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2574 struct dhcp6_message dhcp6; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2575 uint8_t buf[UDPLEN_MAX]; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2576 } buf; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2577 struct dhcp6_state *state; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2578 ssize_t bytes; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2579 int fd; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2580 time_t mtime, now; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2581 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2582 uint8_t *o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2583 uint16_t ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2584 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2585 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2586 state = D6_STATE(ifp); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2587 if (state->leasefile[0] == '\0') { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2588 logdebugx("reading standard input"); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2589 bytes = read(fileno(stdin), buf.buf, sizeof(buf.buf)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2590 } else { |
| 5494 | 2591 logdebugx("%s: reading lease: %s", |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2592 ifp->name, state->leasefile); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2593 bytes = dhcp_readfile(ifp->ctx, state->leasefile, |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2594 buf.buf, sizeof(buf.buf)); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2595 } |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2596 if (bytes == -1) |
|
4677
fbb1a5946f9e
DHCP: Don't log an error if the lease file is empty
Roy Marples <roy@marples.name>
parents:
4601
diff
changeset
|
2597 goto ex; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2598 |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2599 if (ifp->ctx->options & DHCPCD_DUMPLEASE || state->leasefile[0] == '\0') |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2600 goto out; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2601 |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2602 if (bytes == 0) |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2603 goto ex; |
|
4677
fbb1a5946f9e
DHCP: Don't log an error if the lease file is empty
Roy Marples <roy@marples.name>
parents:
4601
diff
changeset
|
2604 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2605 /* If not validating IA's and if they have expired, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2606 * skip to the auth check. */ |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2607 if (!validate) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2608 goto auth; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2609 |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2610 if (dhcp_filemtime(ifp->ctx, state->leasefile, &mtime) == -1) |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2611 goto ex; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2612 clock_gettime(CLOCK_MONOTONIC, &state->acquired); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2613 if ((now = time(NULL)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2614 goto ex; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2615 state->acquired.tv_sec -= now - mtime; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2616 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2617 /* Check to see if the lease is still valid */ |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2618 fd = dhcp6_validatelease(ifp, &buf.dhcp6, (size_t)bytes, NULL, |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
2619 &state->acquired); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2620 if (fd == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2621 goto ex; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2622 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2623 if (state->expire != ND6_INFINITE_LIFETIME && |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2624 (time_t)state->expire < now - mtime && |
|
4695
62e0208e14b9
DHCP6: Solve a scan-build error
Roy Marples <roy@marples.name>
parents:
4693
diff
changeset
|
2625 !(ifp->options->options & DHCPCD_LASTLEASE_EXTEND)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2626 { |
|
4695
62e0208e14b9
DHCP6: Solve a scan-build error
Roy Marples <roy@marples.name>
parents:
4693
diff
changeset
|
2627 logdebugx("%s: discarding expired lease", ifp->name); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2628 bytes = 0; |
|
4695
62e0208e14b9
DHCP6: Solve a scan-build error
Roy Marples <roy@marples.name>
parents:
4693
diff
changeset
|
2629 goto ex; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2630 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2631 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2632 auth: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2633 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2634 /* Authenticate the message */ |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2635 o = dhcp6_findmoption(&buf.dhcp6, (size_t)bytes, D6_OPTION_AUTH, &ol); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2636 if (o) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2637 if (dhcp_auth_validate(&state->auth, &ifp->options->auth, |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2638 buf.buf, (size_t)bytes, 6, buf.dhcp6.type, o, ol) == NULL) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2639 { |
| 4010 | 2640 logerr("%s: authentication failed", ifp->name); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2641 bytes = 0; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2642 goto ex; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2643 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2644 if (state->auth.token) |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2645 logdebugx("%s: validated using 0x%08" PRIu32, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2646 ifp->name, state->auth.token->secretid); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2647 else |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
2648 loginfox("%s: accepted reconfigure key", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2649 } else if ((ifp->options->auth.options & DHCPCD_AUTH_SENDREQUIRE) == |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2650 DHCPCD_AUTH_SENDREQUIRE) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2651 { |
| 4010 | 2652 logerrx("%s: authentication now required", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2653 goto ex; |
|
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 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2656 |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2657 out: |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2658 free(state->new); |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2659 state->new = malloc((size_t)bytes); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2660 if (state->new == NULL) { |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2661 logerr(__func__); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2662 goto ex; |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2663 } |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2664 |
|
5208
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2665 memcpy(state->new, buf.buf, (size_t)bytes); |
|
6e53055c9989
Fix compile warnings with prior.
Roy Marples <roy@marples.name>
parents:
5207
diff
changeset
|
2666 state->new_len = (size_t)bytes; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2667 return bytes; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2668 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2669 ex: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2670 dhcp6_freedrop_addrs(ifp, 0, NULL); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2671 dhcp_unlink(ifp->ctx, state->leasefile); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2672 free(state->new); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2673 state->new = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2674 state->new_len = 0; |
|
5357
2ddfb6841ebb
DHCP6: Add requested addresses after freeing all state addresses
Roy Marples <roy@marples.name>
parents:
5299
diff
changeset
|
2675 dhcp6_addrequestedaddrs(ifp); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2676 return bytes == 0 ? 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
|
2677 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2678 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2679 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2680 dhcp6_startinit(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2681 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2682 struct dhcp6_state *state; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
2683 ssize_t r; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2684 uint8_t has_ta, has_non_ta; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2685 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
|
2686 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2687 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2688 state->state = DH6S_INIT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2689 state->expire = ND6_INFINITE_LIFETIME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2690 state->lowpl = ND6_INFINITE_LIFETIME; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2691 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2692 dhcp6_addrequestedaddrs(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2693 has_ta = has_non_ta = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2694 for (i = 0; i < ifp->options->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2695 switch (ifp->options->ia[i].ia_type) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2696 case 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
|
2697 has_ta = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2698 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2699 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2700 has_non_ta = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2701 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2702 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2703 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2704 if (!(ifp->ctx->options & DHCPCD_TEST) && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2705 !(has_ta && !has_non_ta) && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2706 ifp->options->reboot != 0) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2707 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2708 r = dhcp6_readlease(ifp, 1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2709 if (r == -1) { |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
2710 if (errno != ENOENT && errno != ESRCH) |
| 4010 | 2711 logerr("%s: %s", __func__, state->leasefile); |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
2712 } else if (r != 0 && |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
2713 !(ifp->options->options & DHCPCD_ANONYMOUS)) |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
2714 { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2715 /* RFC 3633 section 12.1 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2716 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2717 if (dhcp6_hasprefixdelegation(ifp)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2718 dhcp6_startrebind(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2719 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2720 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2721 dhcp6_startconfirm(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2722 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2723 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2724 } |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
2725 dhcp6_startdiscoinform(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2726 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2727 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2728 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2729 static struct ipv6_addr * |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2730 dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2731 const struct if_sla *sla, struct if_ia *if_ia) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2732 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2733 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2734 struct in6_addr addr, daddr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2735 struct ipv6_addr *ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2736 int pfxlen, dadcounter; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2737 uint64_t vl; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2738 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2739 /* RFC6603 Section 4.2 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2740 if (strcmp(ifp->name, prefix->iface->name) == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2741 if (prefix->prefix_exclude_len == 0) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2742 /* Don't spam the log automatically */ |
|
4055
75fedf83420a
sla could be NULL, so check that.
Roy Marples <roy@marples.name>
parents:
4024
diff
changeset
|
2743 if (sla != NULL) |
| 4010 | 2744 logwarnx("%s: DHCPv6 server does not support " |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2745 "OPTION_PD_EXCLUDE", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2746 ifp->name); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2747 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2748 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2749 pfxlen = prefix->prefix_exclude_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2750 memcpy(&addr, &prefix->prefix_exclude, sizeof(addr)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2751 } else if ((pfxlen = dhcp6_delegateaddr(&addr, ifp, prefix, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2752 sla, if_ia)) == -1) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2753 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2754 |
|
4055
75fedf83420a
sla could be NULL, so check that.
Roy Marples <roy@marples.name>
parents:
4024
diff
changeset
|
2755 if (sla != NULL && fls64(sla->suffix) > 128 - pfxlen) { |
| 4010 | 2756 logerrx("%s: suffix %" PRIu64 " + prefix_len %d > 128", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2757 ifp->name, sla->suffix, pfxlen); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2758 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2759 } |
|
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 /* Add our suffix */ |
|
4055
75fedf83420a
sla could be NULL, so check that.
Roy Marples <roy@marples.name>
parents:
4024
diff
changeset
|
2762 if (sla != NULL && sla->suffix != 0) { |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2763 daddr = addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2764 vl = be64dec(addr.s6_addr + 8); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2765 vl |= sla->suffix; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2766 be64enc(daddr.s6_addr + 8, vl); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2767 } else { |
|
5127
14b737f09947
RA: Rework temporary address management
Roy Marples <roy@marples.name>
parents:
5120
diff
changeset
|
2768 dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen, 0); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2769 if (dadcounter == -1) { |
| 4010 | 2770 logerrx("%s: error adding slaac to prefix_len %d", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2771 ifp->name, pfxlen); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2772 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2773 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2774 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2775 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2776 /* Find an existing address */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2777 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2778 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2779 if (IN6_ARE_ADDR_EQUAL(&ia->addr, &daddr)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2780 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2781 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2782 if (ia == NULL) { |
|
4090
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2783 ia = ipv6_newaddr(ifp, &daddr, (uint8_t)pfxlen, IPV6_AF_ONLINK); |
|
62f8388ea690
Make ipv6_newaddr() more flexable so it's the sole source of
Roy Marples <roy@marples.name>
parents:
4087
diff
changeset
|
2784 if (ia == NULL) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2785 return NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2786 ia->dadcallback = dhcp6_dadcallback; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2787 memcpy(&ia->iaid, &prefix->iaid, sizeof(ia->iaid)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2788 ia->created = prefix->acquired; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2789 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2790 TAILQ_INSERT_TAIL(&state->addrs, ia, next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2791 TAILQ_INSERT_TAIL(&prefix->pd_pfxs, ia, pd_next); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2792 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2793 ia->delegating_prefix = prefix; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2794 ia->prefix = addr; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2795 ia->prefix_len = (uint8_t)pfxlen; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2796 ia->acquired = prefix->acquired; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2797 ia->prefix_pltime = prefix->prefix_pltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2798 ia->prefix_vltime = prefix->prefix_vltime; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2799 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2800 /* If the prefix length hasn't changed, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2801 * don't install a reject route. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2802 if (prefix->prefix_len == pfxlen) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2803 prefix->flags |= IPV6_AF_NOREJECT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2804 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2805 prefix->flags &= ~IPV6_AF_NOREJECT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2806 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2807 return ia; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2808 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2809 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2810 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2811 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2812 dhcp6_script_try_run(struct interface *ifp, int delegated) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2813 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2814 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2815 struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2816 int completed; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2817 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2818 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2819 completed = 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2820 /* If all addresses have completed DAD run the script */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2821 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2822 if (!(ap->flags & IPV6_AF_ADDED)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2823 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2824 if (ap->flags & IPV6_AF_ONLINK) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2825 if (!(ap->flags & IPV6_AF_DADCOMPLETED) && |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
2826 ipv6_iffindaddr(ap->iface, &ap->addr, |
|
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
2827 IN6_IFF_TENTATIVE)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2828 ap->flags |= IPV6_AF_DADCOMPLETED; |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2829 if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0 |
|
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2830 #ifndef SMALL |
|
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2831 && ((delegated && ap->delegating_prefix) || |
|
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2832 (!delegated && !ap->delegating_prefix)) |
|
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2833 #endif |
|
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
2834 ) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2835 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2836 completed = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2837 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2838 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2839 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2840 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2841 if (completed) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2842 script_runreason(ifp, delegated ? "DELEGATED6" : state->reason); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2843 if (!delegated) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2844 dhcpcd_daemonise(ifp->ctx); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2845 } else |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2846 logdebugx("%s: waiting for DHCPv6 DAD to complete", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2847 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2848 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2849 #ifdef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2850 size_t |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2851 dhcp6_find_delegates(__unused struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2852 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2853 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2854 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2855 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2856 #else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2857 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2858 dhcp6_delegate_prefix(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2859 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2860 struct if_options *ifo; |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
2861 struct dhcp6_state *state; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2862 struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2863 size_t i, j, k; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2864 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
|
2865 struct if_sla *sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2866 struct interface *ifd; |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2867 bool carrier_warned; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2868 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2869 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2870 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2871 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2872 /* Clear the logged flag. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2873 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2874 ap->flags &= ~IPV6_AF_DELEGATEDLOG; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2875 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2876 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2877 TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2878 if (!ifd->active) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2879 continue; |
| 5535 | 2880 if (!(ifd->options->options & DHCPCD_CONFIGURE)) |
| 2881 continue; | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2882 k = 0; |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2883 carrier_warned = false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2884 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2885 if (!(ap->flags & IPV6_AF_DELEGATEDPFX)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2886 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2887 if (!(ap->flags & IPV6_AF_DELEGATEDLOG)) { |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2888 int loglevel; |
| 4010 | 2889 |
| 2890 if (ap->flags & IPV6_AF_NEW) | |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2891 loglevel = LOG_INFO; |
| 4010 | 2892 else |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2893 loglevel = LOG_DEBUG; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2894 /* We only want to log this the once as we loop |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2895 * through many interfaces first. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2896 ap->flags |= IPV6_AF_DELEGATEDLOG; |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
2897 logmessage(loglevel, "%s: delegated prefix %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2898 ifp->name, ap->saddr); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2899 ap->flags &= ~IPV6_AF_NEW; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2900 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2901 for (i = 0; i < ifo->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2902 ia = &ifo->ia[i]; |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
2903 if (ia->ia_type != D6_OPTION_IA_PD) |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
2904 continue; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2905 if (memcmp(ia->iaid, ap->iaid, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2906 sizeof(ia->iaid))) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2907 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2908 if (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
|
2909 /* no SLA configured, so lets |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2910 * automate it */ |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
2911 if (!if_is_link_up(ifd)) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2912 logdebugx( |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2913 "%s: has no carrier, cannot" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2914 " delegate addresses", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2915 ifd->name); |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2916 carrier_warned = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2917 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2918 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2919 if (dhcp6_ifdelegateaddr(ifd, ap, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2920 NULL, ia)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2921 k++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2922 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2923 for (j = 0; j < ia->sla_len; j++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2924 sla = &ia->sla[j]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2925 if (strcmp(ifd->name, sla->ifname)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2926 continue; |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
2927 if (!if_is_link_up(ifd)) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
2928 logdebugx( |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2929 "%s: has no carrier, cannot" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2930 " delegate addresses", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2931 ifd->name); |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2932 carrier_warned = true; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2933 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2934 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2935 if (dhcp6_ifdelegateaddr(ifd, ap, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2936 sla, ia)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2937 k++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2938 } |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2939 if (carrier_warned) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2940 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2941 } |
|
4073
a8ab7020191b
Remove abrt as it's unused and change carrier_warned to a bool.
Roy Marples <roy@marples.name>
parents:
4071
diff
changeset
|
2942 if (carrier_warned) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2943 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2944 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2945 if (k && !carrier_warned) { |
|
4175
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
2946 struct dhcp6_state *s = D6_STATE(ifd); |
|
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
2947 |
|
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
2948 ipv6_addaddrs(&s->addrs); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2949 dhcp6_script_try_run(ifd, 1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2950 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2951 } |
|
4074
20310dc3ece3
Prefix Delegation: build routes after all addresses delegated
Roy Marples <roy@marples.name>
parents:
4073
diff
changeset
|
2952 |
|
20310dc3ece3
Prefix Delegation: build routes after all addresses delegated
Roy Marples <roy@marples.name>
parents:
4073
diff
changeset
|
2953 /* Now all addresses have been added, rebuild the routing table. */ |
|
20310dc3ece3
Prefix Delegation: build routes after all addresses delegated
Roy Marples <roy@marples.name>
parents:
4073
diff
changeset
|
2954 rt_build(ifp->ctx, AF_INET6); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2955 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2956 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2957 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2958 dhcp6_find_delegates1(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2959 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2960 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2961 dhcp6_find_delegates(arg); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2962 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2963 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2964 size_t |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2965 dhcp6_find_delegates(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2966 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2967 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
|
2968 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2969 struct ipv6_addr *ap; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2970 size_t i, j, k; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2971 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
|
2972 struct if_sla *sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2973 struct interface *ifd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2974 |
| 5535 | 2975 if (ifp->options != NULL && |
| 2976 !(ifp->options->options & DHCPCD_CONFIGURE)) | |
| 2977 return 0; | |
| 2978 | |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2979 k = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2980 TAILQ_FOREACH(ifd, ifp->ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2981 ifo = ifd->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2982 state = D6_STATE(ifd); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2983 if (state == NULL || state->state != DH6S_BOUND) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2984 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2985 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2986 if (!(ap->flags & IPV6_AF_DELEGATEDPFX)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2987 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2988 for (i = 0; i < ifo->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2989 ia = &ifo->ia[i]; |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
2990 if (ia->ia_type != D6_OPTION_IA_PD) |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
2991 continue; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2992 if (memcmp(ia->iaid, ap->iaid, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2993 sizeof(ia->iaid))) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2994 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2995 for (j = 0; j < ia->sla_len; j++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2996 sla = &ia->sla[j]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2997 if (strcmp(ifp->name, sla->ifname)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2998 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
2999 if (ipv6_linklocal(ifp) == NULL) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3000 logdebugx( |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3001 "%s: delaying adding" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3002 " delegated addresses for" |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3003 " LL address", |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3004 ifp->name); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3005 ipv6_addlinklocalcallback(ifp, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3006 dhcp6_find_delegates1, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3007 return 1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3008 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3009 if (dhcp6_ifdelegateaddr(ifp, ap, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3010 sla, ia)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3011 k++; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3012 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3013 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3014 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3015 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3016 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3017 if (k) { |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
3018 loginfox("%s: adding delegated prefixes", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3019 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3020 state->state = DH6S_DELEGATED; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3021 ipv6_addaddrs(&state->addrs); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3022 rt_build(ifp->ctx, AF_INET6); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3023 dhcp6_script_try_run(ifp, 1); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3024 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3025 return k; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3026 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3027 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3028 |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3029 static void |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3030 dhcp6_bind(struct interface *ifp, const char *op, const char *sfrom) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3031 { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3032 struct dhcp6_state *state = D6_STATE(ifp); |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3033 bool timedout = (op == NULL), has_new = false, confirmed; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3034 struct ipv6_addr *ia; |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3035 int loglevel; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3036 struct timespec now; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3037 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3038 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3039 if (ia->flags & IPV6_AF_NEW) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3040 has_new = true; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3041 break; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3042 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3043 } |
|
5226
06575a46bbdd
DHCP: always log inform when not renewing
Roy Marples <roy@marples.name>
parents:
5208
diff
changeset
|
3044 loglevel = has_new || state->state != DH6S_RENEW ? LOG_INFO : LOG_DEBUG; |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3045 if (!timedout) { |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3046 logmessage(loglevel, "%s: %s received from %s", |
|
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3047 ifp->name, op, sfrom); |
| 5074 | 3048 #ifndef SMALL |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3049 /* If we delegated from an unconfirmed lease we MUST drop |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3050 * them now. Hopefully we have new delegations. */ |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3051 if (state->reason != NULL && |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3052 strcmp(state->reason, "TIMEOUT6") == 0) |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3053 dhcp6_delete_delegates(ifp); |
| 5074 | 3054 #endif |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3055 state->reason = NULL; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3056 } else |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3057 state->reason = "TIMEOUT6"; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3058 |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3059 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3060 clock_gettime(CLOCK_MONOTONIC, &now); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3061 |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3062 switch(state->state) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3063 case DH6S_INFORM: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3064 { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3065 struct dhcp6_option *o; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3066 uint16_t ol; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3067 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3068 if (state->reason == NULL) |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3069 state->reason = "INFORM6"; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3070 o = dhcp6_findmoption(state->new, state->new_len, |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3071 D6_OPTION_INFO_REFRESH_TIME, &ol); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3072 if (o == NULL || ol != sizeof(uint32_t)) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3073 state->renew = IRT_DEFAULT; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3074 else { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3075 memcpy(&state->renew, o, ol); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3076 state->renew = ntohl(state->renew); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3077 if (state->renew < IRT_MINIMUM) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3078 state->renew = IRT_MINIMUM; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3079 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3080 state->rebind = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3081 state->expire = ND6_INFINITE_LIFETIME; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3082 state->lowpl = ND6_INFINITE_LIFETIME; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3083 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3084 break; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3085 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3086 case DH6S_REQUEST: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3087 if (state->reason == NULL) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3088 state->reason = "BOUND6"; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3089 /* FALLTHROUGH */ |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3090 case DH6S_RENEW: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3091 if (state->reason == NULL) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3092 state->reason = "RENEW6"; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3093 /* FALLTHROUGH */ |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3094 case DH6S_REBIND: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3095 if (state->reason == NULL) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3096 state->reason = "REBIND6"; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3097 /* FALLTHROUGH */ |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3098 case DH6S_CONFIRM: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3099 if (state->reason == NULL) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3100 state->reason = "REBOOT6"; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3101 if (state->renew != 0) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3102 bool all_expired = true; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3103 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3104 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3105 if (ia->flags & IPV6_AF_STALE) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3106 continue; |
|
4877
d28785059be5
DHCP: Don't warn about expiry of deprecated addresses
Roy Marples <roy@marples.name>
parents:
4869
diff
changeset
|
3107 if (!(state->renew == ND6_INFINITE_LIFETIME |
|
d28785059be5
DHCP: Don't warn about expiry of deprecated addresses
Roy Marples <roy@marples.name>
parents:
4869
diff
changeset
|
3108 && ia->prefix_vltime == ND6_INFINITE_LIFETIME) |
|
d28785059be5
DHCP: Don't warn about expiry of deprecated addresses
Roy Marples <roy@marples.name>
parents:
4869
diff
changeset
|
3109 && ia->prefix_vltime != 0 |
|
4746
1ec4b413dcb3
DHCP6: Work better with infinite addresses
Roy Marples <roy@marples.name>
parents:
4726
diff
changeset
|
3110 && ia->prefix_vltime <= state->renew) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3111 logwarnx( |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3112 "%s: %s will expire before renewal", |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3113 ifp->name, ia->saddr); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3114 else |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3115 all_expired = false; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3116 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3117 if (all_expired) { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3118 /* All address's vltime happens at or before |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3119 * the configured T1 in the IA. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3120 * This is a badly configured server and we |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3121 * have to use our own notion of what |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3122 * T1 and T2 should be as a result. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3123 * |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3124 * Doing this violates RFC 3315 22.4: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3125 * In a message sent by a server to a client, |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3126 * the client MUST use the values in the T1 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3127 * and T2 fields for the T1 and T2 parameters, |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3128 * unless those values in those fields are 0. |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3129 */ |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3130 logwarnx("%s: ignoring T1 %"PRIu32 |
|
4464
d5a636216f97
DHCPv6: fix warning message wording
Roy Marples <roy@marples.name>
parents:
4458
diff
changeset
|
3131 " due to address expiry", |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3132 ifp->name, state->renew); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3133 state->renew = state->rebind = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3134 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3135 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3136 if (state->renew == 0 && state->lowpl != ND6_INFINITE_LIFETIME) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3137 state->renew = (uint32_t)(state->lowpl * 0.5); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3138 if (state->rebind == 0 && state->lowpl != ND6_INFINITE_LIFETIME) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3139 state->rebind = (uint32_t)(state->lowpl * 0.8); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3140 break; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3141 default: |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3142 state->reason = "UNKNOWN6"; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3143 break; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3144 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3145 |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3146 if (state->state != DH6S_CONFIRM && !timedout) { |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3147 state->acquired = now; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3148 free(state->old); |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3149 state->old = state->new; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3150 state->old_len = state->new_len; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3151 state->new = state->recv; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3152 state->new_len = state->recv_len; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3153 state->recv = NULL; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3154 state->recv_len = 0; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3155 confirmed = false; |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3156 } else { |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3157 /* Reduce timers based on when we got the lease. */ |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3158 uint32_t elapsed; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3159 |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3160 elapsed = (uint32_t)eloop_timespec_diff(&now, |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3161 &state->acquired, NULL); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3162 if (state->renew && state->renew != ND6_INFINITE_LIFETIME) { |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3163 if (state->renew > elapsed) |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3164 state->renew -= elapsed; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3165 else |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3166 state->renew = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3167 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3168 if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME) { |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3169 if (state->rebind > elapsed) |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3170 state->rebind -= elapsed; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3171 else |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3172 state->rebind = 0; |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3173 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3174 if (state->expire && state->expire != ND6_INFINITE_LIFETIME) { |
|
4924
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3175 if (state->expire > elapsed) |
|
7c1a365b1e2d
eloop: reduce timers rather than calculating expiry
Roy Marples <roy@marples.name>
parents:
4923
diff
changeset
|
3176 state->expire -= elapsed; |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3177 else |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3178 state->expire = 0; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3179 } |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3180 confirmed = true; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3181 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3182 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3183 if (ifp->ctx->options & DHCPCD_TEST) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3184 script_runreason(ifp, "TEST"); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3185 else { |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3186 if (state->state == DH6S_INFORM) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3187 state->state = DH6S_INFORMED; |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3188 else |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3189 state->state = DH6S_BOUND; |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
3190 state->failed = false; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3191 |
|
5398
505ddba6ec99
DHCP6: Restore lease timings
Roy Marples <roy@marples.name>
parents:
5359
diff
changeset
|
3192 if (state->renew && state->renew != ND6_INFINITE_LIFETIME) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3193 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
4923
4fcca755943e
eloop: Allow for for timeouts greater than time_t and time wrapping
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
3194 state->renew, |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3195 state->state == DH6S_INFORMED ? |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3196 dhcp6_startinform : dhcp6_startrenew, ifp); |
|
5398
505ddba6ec99
DHCP6: Restore lease timings
Roy Marples <roy@marples.name>
parents:
5359
diff
changeset
|
3197 if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME) |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3198 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
4923
4fcca755943e
eloop: Allow for for timeouts greater than time_t and time wrapping
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
3199 state->rebind, dhcp6_startrebind, ifp); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3200 if (state->expire != ND6_INFINITE_LIFETIME) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3201 eloop_timeout_add_sec(ifp->ctx->eloop, |
|
4923
4fcca755943e
eloop: Allow for for timeouts greater than time_t and time wrapping
Roy Marples <roy@marples.name>
parents:
4922
diff
changeset
|
3202 state->expire, dhcp6_startexpire, ifp); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3203 |
| 5535 | 3204 if (ifp->options->options & DHCPCD_CONFIGURE) { |
| 3205 ipv6_addaddrs(&state->addrs); | |
| 3206 if (!timedout) | |
| 3207 dhcp6_deprecateaddrs(&state->addrs); | |
| 3208 } | |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3209 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3210 if (state->state == DH6S_INFORMED) |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3211 logmessage(loglevel, "%s: refresh in %"PRIu32" seconds", |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3212 ifp->name, state->renew); |
|
4746
1ec4b413dcb3
DHCP6: Work better with infinite addresses
Roy Marples <roy@marples.name>
parents:
4726
diff
changeset
|
3213 else if (state->renew == ND6_INFINITE_LIFETIME) |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3214 logmessage(loglevel, "%s: leased for infinity", |
|
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3215 ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3216 else if (state->renew || state->rebind) |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3217 logmessage(loglevel, "%s: renew in %"PRIu32", " |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3218 "rebind in %"PRIu32", " |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3219 "expire in %"PRIu32" seconds", |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3220 ifp->name, |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3221 state->renew, state->rebind, state->expire); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3222 else if (state->expire == 0) |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3223 logmessage(loglevel, "%s: will expire", ifp->name); |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3224 else |
|
5064
7721231839f5
logerr: Use macros to call log functions
Sergey Nikiforov <Sergey.Nikiforov@kaspersky.com>
parents:
5046
diff
changeset
|
3225 logmessage(loglevel, "%s: expire in %"PRIu32" seconds", |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3226 ifp->name, state->expire); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3227 rt_build(ifp->ctx, AF_INET6); |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3228 if (!confirmed && !timedout) { |
| 5494 | 3229 logdebugx("%s: writing lease: %s", |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3230 ifp->name, state->leasefile); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3231 if (dhcp_writefile(ifp->ctx, state->leasefile, 0640, |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3232 state->new, state->new_len) == -1) |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3233 logerr("dhcp_writefile: %s",state->leasefile); |
|
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3234 } |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3235 #ifndef SMALL |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3236 dhcp6_delegate_prefix(ifp); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3237 #endif |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3238 dhcp6_script_try_run(ifp, 0); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3239 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3240 |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3241 if (ifp->ctx->options & DHCPCD_TEST || |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3242 (ifp->options->options & DHCPCD_INFORM && |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3243 !(ifp->ctx->options & DHCPCD_MASTER))) |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3244 { |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3245 eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS); |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3246 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3247 } |
|
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3248 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3249 static void |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3250 dhcp6_recvif(struct interface *ifp, const char *sfrom, |
|
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3251 struct dhcp6_message *r, size_t len) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3252 { |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3253 struct dhcpcd_ctx *ctx; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3254 size_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
|
3255 const char *op; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3256 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3257 uint8_t *o; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3258 uint16_t ol; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3259 const 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
|
3260 const struct if_options *ifo; |
|
4112
3efb356fc08e
dhcp6: implement lastlease and lastleaseextend
Roy Marples <roy@marples.name>
parents:
4107
diff
changeset
|
3261 bool valid_op; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3262 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3263 uint8_t *auth; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3264 uint16_t auth_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3265 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3266 |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3267 ctx = ifp->ctx; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3268 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3269 if (state == NULL || state->send == NULL) { |
|
4310
e28831be50f3
dhcp6: don't log an error here.
Roy Marples <roy@marples.name>
parents:
4303
diff
changeset
|
3270 logdebugx("%s: DHCPv6 reply received but not running", |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
3271 ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3272 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3273 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3274 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3275 /* We're already bound and this message is for another machine */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3276 /* XXX DELEGATED? */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3277 if (r->type != DHCP6_RECONFIGURE && |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
3278 (state->state == DH6S_BOUND || state->state == DH6S_INFORMED)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3279 { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3280 logdebugx("%s: DHCPv6 reply received but already bound", |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
3281 ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3282 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3283 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3284 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3285 if (dhcp6_findmoption(r, len, D6_OPTION_SERVERID, NULL) == NULL) { |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3286 logdebugx("%s: no DHCPv6 server ID from %s", ifp->name, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3287 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3288 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3289 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3290 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3291 for (i = 0, opt = 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
|
3292 i < 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
|
3293 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3294 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3295 if (has_option_mask(ifo->requiremask6, opt->option) && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3296 !dhcp6_findmoption(r, len, (uint16_t)opt->option, NULL)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3297 { |
| 4010 | 3298 logwarnx("%s: reject DHCPv6 (no option %s) from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3299 ifp->name, opt->var, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3300 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3301 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3302 if (has_option_mask(ifo->rejectmask6, opt->option) && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3303 dhcp6_findmoption(r, len, (uint16_t)opt->option, NULL)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3304 { |
| 4010 | 3305 logwarnx("%s: reject DHCPv6 (option %s) from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3306 ifp->name, opt->var, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3307 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3308 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3309 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3310 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3311 #ifdef AUTH |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3312 /* Authenticate the message */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3313 auth = dhcp6_findmoption(r, len, D6_OPTION_AUTH, &auth_len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3314 if (auth != NULL) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3315 if (dhcp_auth_validate(&state->auth, &ifo->auth, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3316 (uint8_t *)r, len, 6, r->type, auth, auth_len) == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3317 { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3318 logerr("%s: authentication failed from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3319 ifp->name, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3320 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3321 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3322 if (state->auth.token) |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3323 logdebugx("%s: validated using 0x%08" PRIu32, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3324 ifp->name, state->auth.token->secretid); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3325 else |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
3326 loginfox("%s: accepted reconfigure key", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3327 } else if (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
|
3328 if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) { |
|
5294
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3329 logerrx("%s: no authentication from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3330 ifp->name, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3331 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3332 } |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3333 logwarnx("%s: no authentication from %s", ifp->name, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3334 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3335 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3336 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3337 op = dhcp6_get_op(r->type); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3338 valid_op = op != NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3339 switch(r->type) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3340 case DHCP6_REPLY: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3341 switch(state->state) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3342 case DH6S_INFORM: |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3343 if (dhcp6_checkstatusok(ifp, r, NULL, len) != 0) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3344 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3345 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3346 case DH6S_CONFIRM: |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3347 if (dhcp6_validatelease(ifp, r, len, sfrom, NULL) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3348 { |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3349 dhcp6_startdiscoinform(ifp); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3350 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3351 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3352 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3353 case DH6S_DISCOVER: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3354 /* Only accept REPLY in DISCOVER for RAPID_COMMIT. |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3355 * Normally we get an ADVERTISE for a DISCOVER. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3356 if (!has_option_mask(ifo->requestmask6, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3357 D6_OPTION_RAPID_COMMIT) || |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3358 !dhcp6_findmoption(r, len, D6_OPTION_RAPID_COMMIT, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3359 NULL)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3360 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3361 valid_op = false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3362 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3363 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3364 /* Validate lease before setting state to REQUEST. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3365 /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3366 case DH6S_REQUEST: /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3367 case DH6S_RENEW: /* FALLTHROUGH */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3368 case DH6S_REBIND: |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3369 if (dhcp6_validatelease(ifp, r, len, sfrom, NULL) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3370 { |
|
4313
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3371 /* |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3372 * If we can't use the lease, fallback to |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3373 * DISCOVER and try and get a new one. |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3374 * |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3375 * This is needed become some servers |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3376 * renumber the prefix or address |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3377 * and deny the current one before it expires |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3378 * rather than sending it back with a zero |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3379 * lifetime along with the new prefix or |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3380 * address to use. |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3381 * This behavior is wrong, but moving to the |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3382 * DISCOVER phase works around it. |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3383 * |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3384 * The currently held lease is still valid |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3385 * until a new one is found. |
|
0b3ecef3de4a
dhcp6: always move to the DISCOVER phase if the offered lease is invalid
Roy Marples <roy@marples.name>
parents:
4312
diff
changeset
|
3386 */ |
|
4314
c9c480d74cfe
Fix prior - always return if lease is invalid.
Roy Marples <roy@marples.name>
parents:
4313
diff
changeset
|
3387 if (state->state != DH6S_DISCOVER) |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3388 dhcp6_startdiscoinform(ifp); |
|
4314
c9c480d74cfe
Fix prior - always return if lease is invalid.
Roy Marples <roy@marples.name>
parents:
4313
diff
changeset
|
3389 return; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3390 } |
|
4601
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3391 /* RFC8415 18.2.10.1 */ |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3392 if ((state->state == DH6S_RENEW || |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3393 state->state == DH6S_REBIND) && |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3394 state->has_no_binding) |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3395 { |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3396 dhcp6_startrequest(ifp); |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3397 return; |
|
db69ef4bc972
DHCP6: Change state to REQEST when any IA has NOBINDING status
Roy Marples <roy@marples.name>
parents:
4588
diff
changeset
|
3398 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3399 if (state->state == DH6S_DISCOVER) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3400 state->state = DH6S_REQUEST; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3401 break; |
|
5171
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3402 case DH6S_DECLINE: |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3403 /* This isnt really a failure, but an |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3404 * acknowledgement of one. */ |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3405 loginfox("%s: %s acknowledged DECLINE6", |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3406 ifp->name, sfrom); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3407 dhcp6_fail(ifp); |
|
5943646f9dd3
DHCP6: Implement DECLINE support for duplicated addresses
Roy Marples <roy@marples.name>
parents:
5160
diff
changeset
|
3408 return; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3409 default: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3410 valid_op = false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3411 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3412 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3413 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3414 case DHCP6_ADVERTISE: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3415 if (state->state != DH6S_DISCOVER) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3416 valid_op = false; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3417 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3418 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3419 /* RFC7083 */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3420 o = dhcp6_findmoption(r, len, D6_OPTION_SOL_MAX_RT, &ol); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3421 if (o && ol == sizeof(uint32_t)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3422 uint32_t max_rt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3423 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3424 memcpy(&max_rt, o, sizeof(max_rt)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3425 max_rt = ntohl(max_rt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3426 if (max_rt >= 60 && max_rt <= 86400) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3427 logdebugx("%s: SOL_MAX_RT %llu -> %u", |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
3428 ifp->name, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3429 (unsigned long long)state->sol_max_rt, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3430 max_rt); |
|
4939
b82b1e772a3d
This cast is no longer needed.
Roy Marples <roy@marples.name>
parents:
4925
diff
changeset
|
3431 state->sol_max_rt = max_rt; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3432 } else |
| 4010 | 3433 logerr("%s: invalid SOL_MAX_RT %u", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3434 ifp->name, max_rt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3435 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3436 o = dhcp6_findmoption(r, len, D6_OPTION_INF_MAX_RT, &ol); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3437 if (o && ol == sizeof(uint32_t)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3438 uint32_t max_rt; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3439 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3440 memcpy(&max_rt, o, sizeof(max_rt)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3441 max_rt = ntohl(max_rt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3442 if (max_rt >= 60 && max_rt <= 86400) { |
|
4023
66f9399ba5c6
Add logdebugx, similar to logerrx and logwarnx.
Roy Marples <roy@marples.name>
parents:
4010
diff
changeset
|
3443 logdebugx("%s: INF_MAX_RT %llu -> %u", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3444 ifp->name, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3445 (unsigned long long)state->inf_max_rt, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3446 max_rt); |
|
4939
b82b1e772a3d
This cast is no longer needed.
Roy Marples <roy@marples.name>
parents:
4925
diff
changeset
|
3447 state->inf_max_rt = max_rt; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3448 } else |
| 4010 | 3449 logerrx("%s: invalid INF_MAX_RT %u", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3450 ifp->name, max_rt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3451 } |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3452 if (dhcp6_validatelease(ifp, r, len, sfrom, NULL) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3453 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3454 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3455 case DHCP6_RECONFIGURE: |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
3456 #ifdef AUTH |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3457 if (auth == NULL) { |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
3458 #endif |
| 4010 | 3459 logerrx("%s: unauthenticated %s from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3460 ifp->name, op, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3461 if (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
|
3462 return; |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
3463 #ifdef AUTH |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3464 } |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3465 loginfox("%s: %s from %s", ifp->name, op, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3466 o = dhcp6_findmoption(r, len, D6_OPTION_RECONF_MSG, &ol); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3467 if (o == NULL) { |
| 4010 | 3468 logerrx("%s: missing Reconfigure Message option", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3469 ifp->name); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3470 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3471 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3472 if (ol != 1) { |
| 4010 | 3473 logerrx("%s: missing Reconfigure Message type", |
|
3960
42a6a3d1596e
Remove custom logger and output all diagnostics via syslog(3).
Roy Marples <roy@marples.name>
parents:
3932
diff
changeset
|
3474 ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3475 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3476 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3477 switch(*o) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3478 case DHCP6_RENEW: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3479 if (state->state != DH6S_BOUND) { |
| 4010 | 3480 logerrx("%s: not bound, ignoring %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3481 ifp->name, op); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3482 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3483 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3484 dhcp6_startrenew(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3485 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3486 case DHCP6_INFORMATION_REQ: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3487 if (state->state != DH6S_INFORMED) { |
| 4010 | 3488 logerrx("%s: not informed, ignoring %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3489 ifp->name, op); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3490 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3491 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3492 eloop_timeout_delete(ifp->ctx->eloop, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3493 dhcp6_sendinform, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3494 dhcp6_startinform(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3495 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3496 default: |
| 4010 | 3497 logerr("%s: unsupported %s type %d", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3498 ifp->name, op, *o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3499 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3500 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3501 return; |
|
4358
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4355
diff
changeset
|
3502 #else |
|
dd2971c0df6f
gcc: appease gcc-7's implicit fallthrough warning
Roy Marples <roy@marples.name>
parents:
4355
diff
changeset
|
3503 break; |
|
3989
b05654495fd8
If auth is disabled, then disable FORCERENEW and RECONFIGURE_ACCEPT
Roy Marples <roy@marples.name>
parents:
3960
diff
changeset
|
3504 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3505 default: |
| 4010 | 3506 logerrx("%s: invalid DHCP6 type %s (%d)", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3507 ifp->name, op, r->type); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3508 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3509 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3510 if (!valid_op) { |
| 4010 | 3511 logwarnx("%s: invalid state for DHCP6 type %s (%d)", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3512 ifp->name, op, r->type); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3513 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3514 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3515 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3516 if (state->recv_len < (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
|
3517 free(state->recv); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3518 state->recv = malloc(len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3519 if (state->recv == NULL) { |
| 4010 | 3520 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
|
3521 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3522 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3523 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3524 memcpy(state->recv, r, len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3525 state->recv_len = len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3526 |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3527 if (r->type == DHCP6_ADVERTISE) { |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3528 struct ipv6_addr *ia; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3529 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3530 if (state->state == DH6S_REQUEST) /* rapid commit */ |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3531 goto bind; |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3532 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3533 if (!(ia->flags & (IPV6_AF_STALE | IPV6_AF_REQUEST))) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3534 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3535 } |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3536 if (ia == NULL) |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3537 ia = TAILQ_FIRST(&state->addrs); |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3538 if (ia == NULL) |
|
4071
f5ff6efdcf39
It's possible to receive a DHCPv6 lease without an address.
Roy Marples <roy@marples.name>
parents:
4069
diff
changeset
|
3539 loginfox("%s: ADV (no address) from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3540 ifp->name, sfrom); |
|
4071
f5ff6efdcf39
It's possible to receive a DHCPv6 lease without an address.
Roy Marples <roy@marples.name>
parents:
4069
diff
changeset
|
3541 else |
|
f5ff6efdcf39
It's possible to receive a DHCPv6 lease without an address.
Roy Marples <roy@marples.name>
parents:
4069
diff
changeset
|
3542 loginfox("%s: ADV %s from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3543 ifp->name, ia->saddr, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3544 dhcp6_startrequest(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3545 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3546 } |
|
5042
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3547 |
|
dac9291f82f0
DHCP6: Clean up old lease when we fail to confirm/rebind, etc
Roy Marples <roy@marples.name>
parents:
5038
diff
changeset
|
3548 bind: |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3549 dhcp6_bind(ifp, op, sfrom); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3550 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3551 |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
3552 void |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3553 dhcp6_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg, struct ipv6_addr *ia) |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3554 { |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3555 struct sockaddr_in6 *from = msg->msg_name; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3556 size_t len = msg->msg_iov[0].iov_len; |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3557 char sfrom[INET6_ADDRSTRLEN]; |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3558 struct interface *ifp; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3559 struct dhcp6_message *r; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3560 const struct dhcp6_state *state; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3561 uint8_t *o; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3562 uint16_t ol; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3563 |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3564 inet_ntop(AF_INET6, &from->sin6_addr, sfrom, sizeof(sfrom)); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3565 if (len < sizeof(struct dhcp6_message)) { |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3566 logerrx("DHCPv6 packet too short from %s", sfrom); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3567 return; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3568 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3569 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3570 if (ia != NULL) |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3571 ifp = ia->iface; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3572 else { |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3573 ifp = if_findifpfromcmsg(ctx, msg, NULL); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3574 if (ifp == NULL) { |
|
4374
d67204739087
Fold all CMSG parsing into a common function.
Roy Marples <roy@marples.name>
parents:
4371
diff
changeset
|
3575 logerr(__func__); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3576 return; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3577 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3578 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3579 |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3580 r = (struct dhcp6_message *)msg->msg_iov[0].iov_base; |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3581 |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3582 uint8_t duid[DUID_LEN], *dp; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3583 size_t duid_len; |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3584 o = dhcp6_findmoption(r, len, D6_OPTION_CLIENTID, &ol); |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3585 if (ifp->options->options & DHCPCD_ANONYMOUS) { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3586 duid_len = duid_make(duid, ifp, DUID_LL); |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3587 dp = duid; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3588 } else { |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3589 duid_len = ctx->duid_len; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3590 dp = ctx->duid; |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3591 } |
|
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3592 if (o == NULL || ol != duid_len || memcmp(o, dp, ol) != 0) { |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3593 logdebugx("%s: incorrect client ID from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3594 ifp->name, sfrom); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3595 return; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3596 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3597 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3598 if (dhcp6_findmoption(r, len, D6_OPTION_SERVERID, NULL) == NULL) { |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3599 logdebugx("%s: no DHCPv6 server ID from %s", |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3600 ifp->name, sfrom); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3601 return; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3602 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3603 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3604 if (r->type == DHCP6_RECONFIGURE) { |
|
5294
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3605 if (!IN6_IS_ADDR_LINKLOCAL(&from->sin6_addr)) { |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3606 logerrx("%s: RECONFIGURE6 recv from %s, not LL", |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3607 ifp->name, sfrom); |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3608 return; |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3609 } |
|
5294
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3610 goto recvif; |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3611 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3612 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3613 state = D6_CSTATE(ifp); |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3614 if (state == NULL || |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3615 r->xid[0] != state->send->xid[0] || |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3616 r->xid[1] != state->send->xid[1] || |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3617 r->xid[2] != state->send->xid[2]) |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3618 { |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3619 struct interface *ifp1; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3620 const struct dhcp6_state *state1; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3621 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3622 /* Find an interface with a matching xid. */ |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3623 TAILQ_FOREACH(ifp1, ctx->ifaces, next) { |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3624 state1 = D6_CSTATE(ifp1); |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3625 if (state1 == NULL || state1->send == NULL) |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3626 continue; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3627 if (r->xid[0] == state1->send->xid[0] && |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3628 r->xid[1] == state1->send->xid[1] && |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3629 r->xid[2] == state1->send->xid[2]) |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3630 break; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3631 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3632 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3633 if (ifp1 == NULL) { |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3634 if (state != NULL) |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3635 logdebugx("%s: wrong xid 0x%02x%02x%02x" |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3636 " (expecting 0x%02x%02x%02x) from %s", |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3637 ifp->name, |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3638 r->xid[0], r->xid[1], r->xid[2], |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3639 state->send->xid[0], |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3640 state->send->xid[1], |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3641 state->send->xid[2], |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3642 sfrom); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3643 return; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3644 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3645 logdebugx("%s: redirecting DHCP6 message to %s", |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3646 ifp->name, ifp1->name); |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3647 ifp = ifp1; |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3648 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3649 |
|
4893
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3650 #if 0 |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3651 /* |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3652 * Handy code to inject raw DHCPv6 packets over responses |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3653 * from our server. |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3654 * This allows me to take a 3rd party wireshark trace and |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3655 * replay it in my code. |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3656 */ |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3657 static int replyn = 0; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3658 char fname[PATH_MAX], tbuf[UDPLEN_MAX]; |
|
4893
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3659 int fd; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3660 ssize_t tlen; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3661 uint8_t *si1, *si2; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3662 uint16_t si_len1, si_len2; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3663 |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3664 snprintf(fname, sizeof(fname), |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3665 "/tmp/dhcp6.reply%d.raw", replyn++); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3666 fd = open(fname, O_RDONLY, 0); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3667 if (fd == -1) { |
| 5494 | 3668 logerr("%s: open: %s", __func__, fname); |
|
4893
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3669 return; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3670 } |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3671 tlen = read(fd, tbuf, sizeof(tbuf)); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3672 if (tlen == -1) |
| 5494 | 3673 logerr("%s: read: %s", __func__, fname); |
|
4893
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3674 close(fd); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3675 |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3676 /* Copy across ServerID so we can work with our own server. */ |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3677 si1 = dhcp6_findmoption(r, len, D6_OPTION_SERVERID, &si_len1); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3678 si2 = dhcp6_findmoption(tbuf, (size_t)tlen, |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3679 D6_OPTION_SERVERID, &si_len2); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3680 if (si1 != NULL && si2 != NULL && si_len1 == si_len2) |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3681 memcpy(si2, si1, si_len2); |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3682 r = (struct dhcp6_message *)tbuf; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3683 len = (size_t)tlen; |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3684 #endif |
|
483c46e3c582
DHCP6: Add disabled code to allow packet replay
Roy Marples <roy@marples.name>
parents:
4890
diff
changeset
|
3685 |
|
5294
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
3686 recvif: |
|
4371
a7f3d85f54ce
Remove the send/recv structures from dhcpcd context and allocate
Roy Marples <roy@marples.name>
parents:
4358
diff
changeset
|
3687 dhcp6_recvif(ifp, sfrom, r, len); |
|
4178
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3688 } |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3689 |
|
ffc26bed14d2
dhcp6: redirect message to interface with matching xid
Roy Marples <roy@marples.name>
parents:
4177
diff
changeset
|
3690 static void |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3691 dhcp6_recv(struct dhcpcd_ctx *ctx, struct ipv6_addr *ia) |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3692 { |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3693 struct sockaddr_in6 from; |
|
5193
658eb5d94c0b
DHCP: Use correct buffer for receiving UDP
Roy Marples <roy@marples.name>
parents:
5172
diff
changeset
|
3694 union { |
|
658eb5d94c0b
DHCP: Use correct buffer for receiving UDP
Roy Marples <roy@marples.name>
parents:
5172
diff
changeset
|
3695 struct dhcp6_message dhcp6; |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
3696 uint8_t buf[UDPLEN_MAX]; /* Maximum UDP message size */ |
|
5193
658eb5d94c0b
DHCP: Use correct buffer for receiving UDP
Roy Marples <roy@marples.name>
parents:
5172
diff
changeset
|
3697 } iovbuf; |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3698 struct iovec iov = { |
|
5193
658eb5d94c0b
DHCP: Use correct buffer for receiving UDP
Roy Marples <roy@marples.name>
parents:
5172
diff
changeset
|
3699 .iov_base = iovbuf.buf, .iov_len = sizeof(iovbuf.buf), |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3700 }; |
| 5160 | 3701 union { |
| 3702 struct cmsghdr hdr; | |
| 3703 uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; | |
| 3704 } cmsgbuf = { .buf = { 0 } }; | |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3705 struct msghdr msg = { |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3706 .msg_name = &from, .msg_namelen = sizeof(from), |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3707 .msg_iov = &iov, .msg_iovlen = 1, |
| 5160 | 3708 .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf), |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3709 }; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3710 int s; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3711 ssize_t bytes; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3712 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3713 s = ia != NULL ? ia->dhcp6_fd : ctx->dhcp6_rfd; |
|
4787
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3714 bytes = recvmsg(s, &msg, 0); |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3715 if (bytes == -1) { |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3716 logerr(__func__); |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3717 return; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3718 } |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3719 |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3720 iov.iov_len = (size_t)bytes; |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3721 dhcp6_recvmsg(ctx, &msg, ia); |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3722 } |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3723 |
|
d3a3a2ab8ba9
Split *_recv() into *_recv() and *_recvmsg() functions
Roy Marples <roy@marples.name>
parents:
4754
diff
changeset
|
3724 static void |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3725 dhcp6_recvaddr(void *arg) |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3726 { |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3727 struct ipv6_addr *ia = arg; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3728 |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3729 dhcp6_recv(ia->iface->ctx, ia); |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3730 } |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3731 |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3732 static void |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3733 dhcp6_recvctx(void *arg) |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3734 { |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3735 struct dhcpcd_ctx *ctx = arg; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3736 |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3737 dhcp6_recv(ctx, NULL); |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3738 } |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3739 |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
3740 int |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3741 dhcp6_openraw(void) |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3742 { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3743 int fd, v; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3744 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3745 fd = socket(PF_INET6, SOCK_RAW | SOCK_CXNB, IPPROTO_UDP); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3746 if (fd == -1) |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3747 return -1; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3748 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3749 v = 1; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3750 if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &v, sizeof(v)) == -1) |
| 5281 | 3751 goto errexit; |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3752 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3753 v = offsetof(struct udphdr, uh_sum); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3754 if (setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &v, sizeof(v)) == -1) |
| 5281 | 3755 goto errexit; |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3756 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3757 return fd; |
| 5281 | 3758 |
| 3759 errexit: | |
| 3760 close(fd); | |
| 3761 return -1; | |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3762 } |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3763 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3764 int |
|
4830
4cc46a5fd589
DHCP6: Improve API for privsep
Roy Marples <roy@marples.name>
parents:
4793
diff
changeset
|
3765 dhcp6_openudp(unsigned int ifindex, struct in6_addr *ia) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3766 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3767 struct sockaddr_in6 sa; |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3768 int n, s; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3769 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3770 s = xsocket(PF_INET6, SOCK_DGRAM | SOCK_CXNB, IPPROTO_UDP); |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3771 if (s == -1) |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3772 goto errexit; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3773 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3774 memset(&sa, 0, sizeof(sa)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3775 sa.sin6_family = AF_INET6; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3776 sa.sin6_port = htons(DHCP6_CLIENT_PORT); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3777 #ifdef BSD |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3778 sa.sin6_len = sizeof(sa); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3779 #endif |
|
4175
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
3780 |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3781 if (ia != NULL) { |
|
4830
4cc46a5fd589
DHCP6: Improve API for privsep
Roy Marples <roy@marples.name>
parents:
4793
diff
changeset
|
3782 memcpy(&sa.sin6_addr, ia, sizeof(sa.sin6_addr)); |
|
5195
45226e01fbdd
inet6: Move BSD get/set scope function to ipv6 for general use
Roy Marples <roy@marples.name>
parents:
5193
diff
changeset
|
3783 ipv6_setscope(&sa, ifindex); |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3784 } |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3785 |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3786 if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) == -1) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3787 goto errexit; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3788 |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3789 n = 1; |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3790 if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &n, sizeof(n)) == -1) |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3791 goto errexit; |
|
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3792 |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3793 #ifdef SO_RERROR |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3794 n = 1; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3795 if (setsockopt(s, SOL_SOCKET, SO_RERROR, &n, sizeof(n)) == -1) |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3796 goto errexit; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3797 #endif |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3798 |
|
4129
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3799 return s; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3800 |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3801 errexit: |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3802 logerr(__func__); |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3803 if (s != -1) |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3804 close(s); |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3805 return -1; |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3806 } |
|
ab62c179db78
dhcp6: listen to each DHCP address for messages
Roy Marples <roy@marples.name>
parents:
4126
diff
changeset
|
3807 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3808 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3809 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3810 dhcp6_activateinterfaces(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3811 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3812 struct interface *ifd; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3813 size_t i, j; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3814 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
|
3815 struct if_sla *sla; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3816 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3817 for (i = 0; i < ifp->options->ia_len; i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3818 ia = &ifp->options->ia[i]; |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
3819 if (ia->ia_type != D6_OPTION_IA_PD) |
|
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
3820 continue; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3821 for (j = 0; j < ia->sla_len; j++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3822 sla = &ia->sla[j]; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3823 ifd = if_find(ifp->ctx->ifaces, sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3824 if (ifd == NULL) { |
| 4010 | 3825 logwarn("%s: cannot delegate to %s", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3826 ifp->name, sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3827 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3828 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3829 if (!ifd->active) { |
|
4024
0984f93d896e
To be consitent, do the same to loginfo as we just did for logdebug.
Roy Marples <roy@marples.name>
parents:
4023
diff
changeset
|
3830 loginfox("%s: activating for delegation", |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3831 sla->ifname); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3832 dhcpcd_activateinterface(ifd, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3833 DHCPCD_IPV6 | DHCPCD_DHCP6); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3834 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3835 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3836 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3837 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3838 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3839 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3840 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3841 dhcp6_start1(void *arg) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3842 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3843 struct interface *ifp = arg; |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3844 struct dhcpcd_ctx *ctx = ifp->ctx; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3845 struct if_options *ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3846 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3847 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
|
3848 const struct dhcp_compat *dhc; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3849 |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
3850 if ((ctx->options & (DHCPCD_MASTER|DHCPCD_PRIVSEP)) == DHCPCD_MASTER && |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3851 ctx->dhcp6_rfd == -1) |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
3852 { |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3853 ctx->dhcp6_rfd = dhcp6_openudp(0, NULL); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3854 if (ctx->dhcp6_rfd == -1) { |
|
4831
f60174650135
DHCP6: Fix prior to log an error
Roy Marples <roy@marples.name>
parents:
4830
diff
changeset
|
3855 logerr(__func__); |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3856 return; |
|
4831
f60174650135
DHCP6: Fix prior to log an error
Roy Marples <roy@marples.name>
parents:
4830
diff
changeset
|
3857 } |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3858 eloop_event_add(ctx->eloop, ctx->dhcp6_rfd, dhcp6_recvctx, ctx); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3859 } |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3860 |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3861 if (!IN_PRIVSEP(ctx) && ctx->dhcp6_wfd == -1) { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3862 ctx->dhcp6_wfd = dhcp6_openraw(); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3863 if (ctx->dhcp6_wfd == -1) { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3864 logerr(__func__); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3865 return; |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
3866 } |
|
4233
c2a1efc6b19a
dhcp6: deny unicast in non master mode
Roy Marples <roy@marples.name>
parents:
4232
diff
changeset
|
3867 } |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3868 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3869 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3870 /* If no DHCPv6 options are configured, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3871 match configured DHCPv4 options to DHCPv6 equivalents. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3872 for (i = 0; i < sizeof(ifo->requestmask6); i++) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3873 if (ifo->requestmask6[i] != '\0') |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3874 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3875 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3876 if (i == sizeof(ifo->requestmask6)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3877 for (dhc = dhcp_compats; dhc->dhcp_opt; dhc++) { |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3878 if (DHC_REQ(ifo->requestmask, ifo->nomask, dhc->dhcp_opt)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3879 add_option_mask(ifo->requestmask6, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3880 dhc->dhcp6_opt); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3881 } |
|
4958
a120f447fe74
Implement Anonymity Profiles for DHCP Clients, RFC 7844
Roy Marples <roy@marples.name>
parents:
4942
diff
changeset
|
3882 if (ifo->fqdn != FQDN_DISABLE || ifo->options & DHCPCD_HOSTNAME) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3883 add_option_mask(ifo->requestmask6, D6_OPTION_FQDN); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3884 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3885 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3886 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3887 /* Rapid commit won't work with Prefix Delegation Exclusion */ |
|
4282
18aa55c59279
dhcp6: Stop non delegated addresses being delegated
Roy Marples <roy@marples.name>
parents:
4281
diff
changeset
|
3888 if (dhcp6_findselfsla(ifp)) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3889 del_option_mask(ifo->requestmask6, D6_OPTION_RAPID_COMMIT); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3890 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3891 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3892 if (state->state == DH6S_INFORM) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3893 add_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3894 dhcp6_startinform(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3895 } else { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3896 del_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3897 dhcp6_startinit(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3898 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3899 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3900 #ifndef SMALL |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3901 dhcp6_activateinterfaces(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3902 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3903 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3904 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3905 int |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3906 dhcp6_start(struct interface *ifp, enum DH6S init_state) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3907 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3908 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3909 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3910 state = D6_STATE(ifp); |
|
4183
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3911 if (state != NULL) { |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3912 switch (init_state) { |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3913 case DH6S_INIT: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3914 goto gogogo; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3915 case DH6S_INFORM: |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3916 if (state->state == DH6S_INIT || |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3917 state->state == DH6S_INFORMED || |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3918 (state->state == DH6S_DISCOVER && |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3919 !(ifp->options->options & DHCPCD_IA_FORCED) && |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3920 !ipv6nd_hasradhcp(ifp, true))) |
|
4183
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3921 dhcp6_startinform(ifp); |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3922 break; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3923 case DH6S_REQUEST: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3924 if (ifp->options->options & DHCPCD_DHCP6 && |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3925 (state->state == DH6S_INIT || |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3926 state->state == DH6S_INFORM || |
|
4183
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3927 state->state == DH6S_INFORMED || |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3928 state->state == DH6S_DELEGATED)) |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3929 { |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3930 /* Change from stateless to stateful */ |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3931 init_state = DH6S_INIT; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3932 goto gogogo; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3933 } |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3934 break; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3935 case DH6S_CONFIRM: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3936 init_state = DH6S_INIT; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3937 goto gogogo; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3938 default: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3939 /* Not possible, but sushes some compiler warnings. */ |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3940 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3941 } |
|
4183
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3942 return 0; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3943 } else { |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3944 switch (init_state) { |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3945 case DH6S_CONFIRM: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3946 /* No DHCPv6 config, no existing state |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3947 * so nothing to do. */ |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3948 return 0; |
| 4543 | 3949 case DH6S_INFORM: |
| 3950 break; | |
|
4183
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3951 default: |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3952 init_state = DH6S_INIT; |
|
115cbfa711e2
DHCPv6: confirm lease on carrier up
Roy Marples <roy@marples.name>
parents:
4179
diff
changeset
|
3953 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3954 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3955 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3956 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3957 if (!(ifp->options->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
|
3958 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3959 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3960 ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3961 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3962 if (state == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3963 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3964 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3965 state->sol_max_rt = SOL_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3966 state->inf_max_rt = INF_MAX_RT; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3967 TAILQ_INIT(&state->addrs); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3968 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3969 gogogo: |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3970 state->state = init_state; |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3971 state->lerror = 0; |
|
5151
3c6da4e11150
DHCP6: don't log when things consitently fail
Roy Marples <roy@marples.name>
parents:
5127
diff
changeset
|
3972 state->failed = false; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3973 dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3974 AF_INET6, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3975 if (ipv6_linklocal(ifp) == NULL) { |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
3976 logdebugx("%s: delaying DHCPv6 for LL address", ifp->name); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3977 ipv6_addlinklocalcallback(ifp, dhcp6_start1, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3978 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3979 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3980 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3981 dhcp6_start1(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3982 return 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3983 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3984 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3985 void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3986 dhcp6_reboot(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3987 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3988 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3989 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
3990 state = D6_STATE(ifp); |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3991 if (state == NULL) |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3992 return; |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3993 |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3994 state->lerror = 0; |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3995 switch (state->state) { |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3996 case DH6S_BOUND: |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3997 dhcp6_startrebind(ifp); |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3998 break; |
|
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
3999 default: |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4000 dhcp6_startdiscoinform(ifp); |
|
4423
22c551e08f53
DHCP6: Don't spam syslog if we get the same error over and over
Roy Marples <roy@marples.name>
parents:
4418
diff
changeset
|
4001 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4002 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4003 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4004 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4005 static void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4006 dhcp6_freedrop(struct interface *ifp, int drop, const char *reason) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4007 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4008 struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4009 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
|
4010 unsigned long long options; |
|
4062
9ecf74393d25
DHCPv6: drop Prefix Delegations when dropping the lease.
Roy Marples <roy@marples.name>
parents:
4056
diff
changeset
|
4011 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4012 if (ifp->options) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4013 options = ifp->options->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4014 else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4015 options = ifp->ctx->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4016 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4017 if (ifp->ctx->eloop) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4018 eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4019 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4020 #ifndef SMALL |
|
4062
9ecf74393d25
DHCPv6: drop Prefix Delegations when dropping the lease.
Roy Marples <roy@marples.name>
parents:
4056
diff
changeset
|
4021 /* If we're dropping the lease, drop delegated addresses. |
|
9ecf74393d25
DHCPv6: drop Prefix Delegations when dropping the lease.
Roy Marples <roy@marples.name>
parents:
4056
diff
changeset
|
4022 * If, for whatever reason, we don't drop them in the future |
|
9ecf74393d25
DHCPv6: drop Prefix Delegations when dropping the lease.
Roy Marples <roy@marples.name>
parents:
4056
diff
changeset
|
4023 * then they should at least be marked as deprecated (pltime 0). */ |
|
9ecf74393d25
DHCPv6: drop Prefix Delegations when dropping the lease.
Roy Marples <roy@marples.name>
parents:
4056
diff
changeset
|
4024 if (drop && (options & DHCPCD_NODROP) != DHCPCD_NODROP) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4025 dhcp6_delete_delegates(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4026 #endif |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4027 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4028 state = D6_STATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4029 if (state) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4030 /* Failure to send the release may cause this function to |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4031 * re-enter */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4032 if (state->state == DH6S_RELEASE) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4033 dhcp6_finishrelease(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4034 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4035 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4036 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4037 if (drop && 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
|
4038 state->state != DH6S_DELEGATED) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4039 { |
|
5499
6a2da5651841
dhcpcd: Simplify the link handling even more
Roy Marples <roy@marples.name>
parents:
5497
diff
changeset
|
4040 if (if_is_link_up(ifp) && |
|
4107
ce438a54efa7
Treat INFORMED as a released state so it's dropped by the hooks
Roy Marples <roy@marples.name>
parents:
4105
diff
changeset
|
4041 state->state != DH6S_RELEASED && |
|
ce438a54efa7
Treat INFORMED as a released state so it's dropped by the hooks
Roy Marples <roy@marples.name>
parents:
4105
diff
changeset
|
4042 state->state != DH6S_INFORMED) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4043 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4044 dhcp6_startrelease(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4045 return; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4046 } |
|
5207
84b63f09c8a4
privsep: Handle all file IO in the Priviledged Actioneer
Roy Marples <roy@marples.name>
parents:
5195
diff
changeset
|
4047 dhcp_unlink(ifp->ctx, state->leasefile); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4048 } |
|
5294
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4049 #ifdef AUTH |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4050 else if (state->auth.reconf != NULL) { |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4051 /* |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4052 * Drop the lease as the token may only be present |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4053 * in the initial reply message and not subsequent |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4054 * renewals. |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4055 * If dhcpcd is restarted, the token is lost. |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4056 * XXX persist this in another file? |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4057 */ |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4058 dhcp_unlink(ifp->ctx, state->leasefile); |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4059 } |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4060 #endif |
|
942ddb46cd55
auth: Only accept RECONFIGURE messages from LL hosts
Roy Marples <roy@marples.name>
parents:
5288
diff
changeset
|
4061 |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4062 dhcp6_freedrop_addrs(ifp, drop, NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4063 free(state->old); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4064 state->old = state->new; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4065 state->old_len = state->new_len; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4066 state->new = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4067 state->new_len = 0; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4068 if (drop && state->old && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4069 (options & DHCPCD_NODROP) != DHCPCD_NODROP) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4070 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4071 if (reason == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4072 reason = "STOP6"; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4073 script_runreason(ifp, reason); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4074 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4075 free(state->old); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4076 free(state->send); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4077 free(state->recv); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4078 free(state); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4079 ifp->if_data[IF_DATA_DHCP6] = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4080 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4081 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4082 /* If we don't have any more DHCP6 enabled interfaces, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4083 * close the global socket and release resources */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4084 ctx = ifp->ctx; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4085 if (ctx->ifaces) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4086 TAILQ_FOREACH(ifp, ctx->ifaces, next) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4087 if (D6_STATE(ifp)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4088 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4089 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4090 } |
|
5231
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
4091 if (ifp == NULL && ctx->dhcp6_rfd != -1) { |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
4092 eloop_event_delete(ctx->eloop, ctx->dhcp6_rfd); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
4093 close(ctx->dhcp6_rfd); |
|
a2c342295221
privsep: Enable Capsicum for all processes.
Roy Marples <roy@marples.name>
parents:
5226
diff
changeset
|
4094 ctx->dhcp6_rfd = -1; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4095 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4096 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4097 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4098 void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4099 dhcp6_drop(struct interface *ifp, const char *reason) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4100 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4101 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4102 dhcp6_freedrop(ifp, 1, reason); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4103 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4104 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4105 void |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4106 dhcp6_free(struct interface *ifp) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4107 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4108 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4109 dhcp6_freedrop(ifp, 0, NULL); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4110 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4111 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4112 void |
|
4335
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4113 dhcp6_abort(struct interface *ifp) |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4114 { |
| 5074 | 4115 struct dhcp6_state *state; |
|
4588
6aced73a8438
Remove ND6 Advertisement from SMALL builds.
Roy Marples <roy@marples.name>
parents:
4560
diff
changeset
|
4116 #ifdef ND6_ADVERTISE |
|
4335
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4117 struct ipv6_addr *ia; |
|
4588
6aced73a8438
Remove ND6 Advertisement from SMALL builds.
Roy Marples <roy@marples.name>
parents:
4560
diff
changeset
|
4118 #endif |
|
4335
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4119 |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4120 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_start1, ifp); |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4121 state = D6_STATE(ifp); |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4122 if (state == NULL) |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4123 return; |
| 5074 | 4124 |
| 4125 #ifdef ND6_ADVERTISE | |
|
4335
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4126 TAILQ_FOREACH(ia, &state->addrs, next) { |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4127 ipv6nd_advertise(ia); |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4128 } |
|
4588
6aced73a8438
Remove ND6 Advertisement from SMALL builds.
Roy Marples <roy@marples.name>
parents:
4560
diff
changeset
|
4129 #endif |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4130 |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4131 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_startdiscover, ifp); |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4132 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_senddiscover, ifp); |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4133 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_startinform, ifp); |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4134 eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendinform, ifp); |
| 5074 | 4135 |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4136 switch (state->state) { |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4137 case DH6S_DISCOVER: /* FALLTHROUGH */ |
|
5046
91d05626f72d
Add an extra fallthrough to prior
Roy Marples <roy@marples.name>
parents:
5044
diff
changeset
|
4138 case DH6S_REQUEST: /* FALLTHROUGH */ |
|
5044
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4139 case DH6S_INFORM: |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4140 state->state = DH6S_INIT; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4141 break; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4142 default: |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4143 break; |
|
f51d310db3b7
inet6: Swap between DISCOVER and INFORM better
Roy Marples <roy@marples.name>
parents:
5042
diff
changeset
|
4144 } |
|
4335
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4145 } |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4146 |
|
d0519e1f2f5f
ip6: Implement IPv6 address sharing
Roy Marples <roy@marples.name>
parents:
4333
diff
changeset
|
4147 void |
|
4232
8b92c1844860
Log the pid of the process deleting an assigned address.
Roy Marples <roy@marples.name>
parents:
4231
diff
changeset
|
4148 dhcp6_handleifa(int cmd, struct ipv6_addr *ia, pid_t pid) |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4149 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4150 struct dhcp6_state *state; |
|
4189
0b088d803b61
dhcp6: don't listen on IPv6 addresses when not using DHCP6
Roy Marples <roy@marples.name>
parents:
4183
diff
changeset
|
4151 struct interface *ifp = ia->iface; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4152 |
|
4175
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
4153 /* If not running in master mode, listen to this address */ |
|
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
4154 if (cmd == RTM_NEWADDR && |
|
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
4155 !(ia->addr_flags & IN6_IFF_NOTUSEABLE) && |
|
4189
0b088d803b61
dhcp6: don't listen on IPv6 addresses when not using DHCP6
Roy Marples <roy@marples.name>
parents:
4183
diff
changeset
|
4156 ifp->active == IF_ACTIVE_USER && |
|
0b088d803b61
dhcp6: don't listen on IPv6 addresses when not using DHCP6
Roy Marples <roy@marples.name>
parents:
4183
diff
changeset
|
4157 !(ifp->ctx->options & DHCPCD_MASTER) && |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4158 ifp->options->options & DHCPCD_DHCP6) |
|
4830
4cc46a5fd589
DHCP6: Improve API for privsep
Roy Marples <roy@marples.name>
parents:
4793
diff
changeset
|
4159 { |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4160 #ifdef PRIVSEP |
|
4869
5bad3606b951
privsep: prefer IN_PRIVSEP macros
Roy Marples <roy@marples.name>
parents:
4841
diff
changeset
|
4161 if (IN_PRIVSEP_SE(ifp->ctx)) { |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4162 if (ps_inet_opendhcp6(ia) == -1) |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4163 logerr(__func__); |
|
4841
bace61b4b4ff
Solaris: Fix non PRIVSEP compile
Roy Marples <roy@marples.name>
parents:
4840
diff
changeset
|
4164 } else |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4165 #endif |
|
4841
bace61b4b4ff
Solaris: Fix non PRIVSEP compile
Roy Marples <roy@marples.name>
parents:
4840
diff
changeset
|
4166 { |
|
4840
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4167 if (ia->dhcp6_fd == -1) |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4168 ia->dhcp6_fd = dhcp6_openudp(ia->iface->index, |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4169 &ia->addr); |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4170 if (ia->dhcp6_fd != -1) |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4171 eloop_event_add(ia->iface->ctx->eloop, |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4172 ia->dhcp6_fd, dhcp6_recvaddr, ia); |
|
073fcd86db9b
privsep: Add support for priviledge separation
Roy Marples <roy@marples.name>
parents:
4831
diff
changeset
|
4173 } |
|
4830
4cc46a5fd589
DHCP6: Improve API for privsep
Roy Marples <roy@marples.name>
parents:
4793
diff
changeset
|
4174 } |
|
4cc46a5fd589
DHCP6: Improve API for privsep
Roy Marples <roy@marples.name>
parents:
4793
diff
changeset
|
4175 |
|
4175
2a14528ebe96
DHCPv6: listen on all IPv6 addresses for active interface
Roy Marples <roy@marples.name>
parents:
4145
diff
changeset
|
4176 |
|
4189
0b088d803b61
dhcp6: don't listen on IPv6 addresses when not using DHCP6
Roy Marples <roy@marples.name>
parents:
4183
diff
changeset
|
4177 if ((state = D6_STATE(ifp)) != NULL) |
|
4232
8b92c1844860
Log the pid of the process deleting an assigned address.
Roy Marples <roy@marples.name>
parents:
4231
diff
changeset
|
4178 ipv6_handleifa_addrs(cmd, &state->addrs, ia, pid); |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4179 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4180 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4181 ssize_t |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4182 dhcp6_env(FILE *fp, const char *prefix, const struct interface *ifp, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4183 const struct dhcp6_message *m, 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
|
4184 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4185 const 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
|
4186 struct dhcp_opt *opt, *vo; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4187 const uint8_t *p; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4188 struct dhcp6_option o; |
|
4538
8e383f84ebd0
Remove now unused variables.
Roy Marples <roy@marples.name>
parents:
4535
diff
changeset
|
4189 size_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
|
4190 char *pfx; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4191 uint32_t en; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4192 const struct dhcpcd_ctx *ctx; |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
4193 #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
|
4194 const struct dhcp6_state *state; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4195 const struct ipv6_addr *ap; |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
4196 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4197 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4198 if (m == NULL) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4199 goto delegated; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4200 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4201 if (len < sizeof(*m)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4202 /* Should be impossible with guards at packet in |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4203 * and reading leases */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4204 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4205 return -1; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4206 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4207 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4208 ifo = ifp->options; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4209 ctx = ifp->ctx; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4210 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4211 /* Zero our indexes */ |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4212 for (i = 0, opt = ctx->dhcp6_opts; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4213 i < ctx->dhcp6_opts_len; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4214 i++, opt++) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4215 dhcp_zero_index(opt); |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4216 for (i = 0, opt = ifp->options->dhcp6_override; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4217 i < ifp->options->dhcp6_override_len; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4218 i++, opt++) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4219 dhcp_zero_index(opt); |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4220 for (i = 0, opt = ctx->vivso; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4221 i < ctx->vivso_len; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4222 i++, opt++) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4223 dhcp_zero_index(opt); |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4224 if (asprintf(&pfx, "%s_dhcp6", prefix) == -1) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4225 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
|
4226 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4227 /* Unlike DHCP, DHCPv6 options *may* occur 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
|
4228 * There is also no provision for option concatenation unlike DHCP. */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4229 p = (const uint8_t *)m + sizeof(*m); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4230 len -= sizeof(*m); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4231 for (; len != 0; p += o.len, len -= o.len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4232 if (len < sizeof(o)) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4233 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4234 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4235 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4236 memcpy(&o, p, sizeof(o)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4237 p += sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4238 len -= sizeof(o); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4239 o.len = ntohs(o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4240 if (len < o.len) { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4241 errno = EINVAL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4242 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4243 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4244 o.code = ntohs(o.code); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4245 if (has_option_mask(ifo->nomask6, o.code)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4246 continue; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4247 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
|
4248 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
|
4249 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4250 if (opt->option == o.code) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4251 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4252 if (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
|
4253 o.code == D6_OPTION_VENDOR_OPTS && |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4254 o.len > sizeof(en)) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4255 { |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4256 memcpy(&en, p, sizeof(en)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4257 en = ntohl(en); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4258 vo = vivso_find(en, ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4259 } else |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4260 vo = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4261 if (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
|
4262 for (i = 0, opt = 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
|
4263 i < 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
|
4264 i++, opt++) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4265 if (opt->option == o.code) |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4266 break; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4267 if (i == 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
|
4268 opt = NULL; |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4269 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4270 if (opt) { |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4271 dhcp_envoption(ifp->ctx, |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4272 fp, pfx, ifp->name, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4273 opt, dhcp6_getoption, p, o.len); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4274 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4275 if (vo) { |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4276 dhcp_envoption(ifp->ctx, |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4277 fp, pfx, ifp->name, |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4278 vo, dhcp6_getoption, |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4279 p + sizeof(en), |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4280 o.len - sizeof(en)); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4281 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4282 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4283 free(pfx); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4284 |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4285 delegated: |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
4286 #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
|
4287 /* Needed for Delegated Prefixes */ |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4288 state = D6_CSTATE(ifp); |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4289 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4290 if (ap->delegating_prefix) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4291 break; |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4292 } |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4293 if (ap == NULL) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4294 return 1; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4295 if (fprintf(fp, "%s_delegated_dhcp6_prefix=", prefix) == -1) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4296 return -1; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4297 TAILQ_FOREACH(ap, &state->addrs, next) { |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4298 if (ap->delegating_prefix == NULL) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4299 continue; |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4300 if (ap != TAILQ_FIRST(&state->addrs)) { |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4301 if (fputc(' ', fp) == EOF) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4302 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
|
4303 } |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4304 if (fprintf(fp, "%s", ap->saddr) == -1) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4305 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
|
4306 } |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4307 if (fputc('\0', fp) == EOF) |
|
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4308 return -1; |
|
4069
026bd55d5f0f
Remove more prefix delegation code for small binaries.
Roy Marples <roy@marples.name>
parents:
4065
diff
changeset
|
4309 #endif |
|
3932
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4310 |
|
4535
f2ddefe6c69e
script: Write variables to a FILE
Roy Marples <roy@marples.name>
parents:
4532
diff
changeset
|
4311 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
|
4312 } |
|
e802a4235d75
Move the source files along with dev, crypt and comapt into src dir.
Roy Marples <roy@marples.name>
parents:
diff
changeset
|
4313 #endif |
|
5288
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4314 |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4315 #ifndef SMALL |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4316 int |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4317 dhcp6_dump(struct interface *ifp) |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4318 { |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4319 struct dhcp6_state *state; |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4320 |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4321 ifp->if_data[IF_DATA_DHCP6] = state = calloc(1, sizeof(*state)); |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4322 if (state == NULL) { |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4323 logerr(__func__); |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4324 return -1; |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4325 } |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4326 TAILQ_INIT(&state->addrs); |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4327 if (dhcp6_readlease(ifp, 0) == -1) { |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4328 logerr("dhcp6_readlease"); |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4329 return -1; |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4330 } |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4331 state->reason = "DUMP6"; |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4332 return script_runreason(ifp, state->reason); |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4333 } |
|
30958d539e6c
Restore dumping a lease from stdin
Roy Marples <roy@marples.name>
parents:
5281
diff
changeset
|
4334 #endif |
