Syncdiff -r1.20 -r1.21 src/external/bsd/dhcpcd/dist/defs.h
(roy)
--- src/external/bsd/dhcpcd/dist/Attic/defs.h 2015/08/21 10:39:00 1.20
+++ src/external/bsd/dhcpcd/dist/Attic/defs.h 2015/09/04 12:25:01 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: defs.h,v 1.20 2015/08/21 10:39:00 roy Exp $ */ | 1 | /* $NetBSD: defs.h,v 1.21 2015/09/04 12:25:01 roy Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * dhcpcd - DHCP client daemon | 4 | * dhcpcd - DHCP client daemon | |
5 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 5 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef CONFIG_H | 29 | #ifndef CONFIG_H | |
30 | #define CONFIG_H | 30 | #define CONFIG_H | |
31 | 31 | |||
32 | #define PACKAGE "dhcpcd" | 32 | #define PACKAGE "dhcpcd" | |
33 | #define VERSION "6.9.2" | 33 | #define VERSION "6.9.3" | |
34 | 34 | |||
35 | #ifndef CONFIG | 35 | #ifndef CONFIG | |
36 | # define CONFIG SYSCONFDIR "/" PACKAGE ".conf" | 36 | # define CONFIG SYSCONFDIR "/" PACKAGE ".conf" | |
37 | #endif | 37 | #endif | |
38 | #ifndef SCRIPT | 38 | #ifndef SCRIPT | |
39 | # define SCRIPT LIBEXECDIR "/" PACKAGE "-run-hooks" | 39 | # define SCRIPT LIBEXECDIR "/" PACKAGE "-run-hooks" | |
40 | #endif | 40 | #endif | |
41 | #ifndef DEVDIR | 41 | #ifndef DEVDIR | |
42 | # define DEVDIR LIBDIR "/" PACKAGE "/dev" | 42 | # define DEVDIR LIBDIR "/" PACKAGE "/dev" | |
43 | #endif | 43 | #endif | |
44 | #ifndef DUID | 44 | #ifndef DUID | |
45 | # define DUID SYSCONFDIR "/" PACKAGE ".duid" | 45 | # define DUID SYSCONFDIR "/" PACKAGE ".duid" | |
46 | #endif | 46 | #endif |
--- src/external/bsd/dhcpcd/dist/Attic/dhcp.c 2015/08/22 05:45:57 1.34
+++ src/external/bsd/dhcpcd/dist/Attic/dhcp.c 2015/09/04 12:25:01 1.35
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | #include <sys/cdefs.h> | 1 | #include <sys/cdefs.h> | |
2 | __RCSID("$NetBSD: dhcp.c,v 1.34 2015/08/22 05:45:57 christos Exp $"); | 2 | __RCSID("$NetBSD: dhcp.c,v 1.35 2015/09/04 12:25:01 roy Exp $"); | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * dhcpcd - DHCP client daemon | 5 | * dhcpcd - DHCP client daemon | |
6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
7 | * All rights reserved | 7 | * All rights reserved | |
8 | 8 | |||
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -703,28 +703,31 @@ get_option_routes(struct interface *ifp, | @@ -703,28 +703,31 @@ get_option_routes(struct interface *ifp, | |||
703 | memcpy(&route->gate.s_addr, p, 4); | 703 | memcpy(&route->gate.s_addr, p, 4); | |
704 | p += 4; | 704 | p += 4; | |
705 | TAILQ_INSERT_TAIL(routes, route, next); | 705 | TAILQ_INSERT_TAIL(routes, route, next); | |
706 | } | 706 | } | |
707 | } | 707 | } | |
708 | 708 | |||
709 | return routes; | 709 | return routes; | |
710 | } | 710 | } | |
711 | 711 | |||
712 | uint16_t | 712 | uint16_t | |
713 | dhcp_get_mtu(const struct interface *ifp) | 713 | dhcp_get_mtu(const struct interface *ifp) | |
714 | { | 714 | { | |
715 | const struct dhcp_message *dhcp; | 715 | const struct dhcp_message *dhcp; | |
716 | uint16_t mtu = 0; // XXX: gcc | 716 | uint16_t mtu; | |
717 | 717 | |||
718 | if (ifp->options->mtu) | |||
719 | return (uint16_t)ifp->options->mtu; | |||
720 | mtu = 0; /* bogus gcc warning */ | |||
718 | if ((dhcp = D_CSTATE(ifp)->new) == NULL || | 721 | if ((dhcp = D_CSTATE(ifp)->new) == NULL || | |
719 | has_option_mask(ifp->options->nomask, DHO_MTU) || | 722 | has_option_mask(ifp->options->nomask, DHO_MTU) || | |
720 | get_option_uint16(ifp->ctx, &mtu, dhcp, DHO_MTU) == -1) | 723 | get_option_uint16(ifp->ctx, &mtu, dhcp, DHO_MTU) == -1) | |
721 | return 0; | 724 | return 0; | |
722 | return mtu; | 725 | return mtu; | |
723 | } | 726 | } | |
724 | 727 | |||
725 | /* Grab our routers from the DHCP message and apply any MTU value | 728 | /* Grab our routers from the DHCP message and apply any MTU value | |
726 | * the message contains */ | 729 | * the message contains */ | |
727 | struct rt_head * | 730 | struct rt_head * | |
728 | dhcp_get_routes(struct interface *ifp) | 731 | dhcp_get_routes(struct interface *ifp) | |
729 | { | 732 | { | |
730 | struct rt_head *routes; | 733 | struct rt_head *routes; | |
@@ -2012,27 +2015,28 @@ dhcp_arp_conflicted(struct arp_state *as | @@ -2012,27 +2015,28 @@ dhcp_arp_conflicted(struct arp_state *as | |||
2012 | (amsg->sip.s_addr == 0 && | 2015 | (amsg->sip.s_addr == 0 && | |
2013 | amsg->tip.s_addr == state->offer->yiaddr)))) | 2016 | amsg->tip.s_addr == state->offer->yiaddr)))) | |
2014 | { | 2017 | { | |
2015 | #ifdef IN_IFF_DUPLICATED | 2018 | #ifdef IN_IFF_DUPLICATED | |
2016 | struct ipv4_addr *ia; | 2019 | struct ipv4_addr *ia; | |
2017 | #endif | 2020 | #endif | |
2018 | 2021 | |||
2019 | if (amsg) | 2022 | if (amsg) | |
2020 | astate->failed.s_addr = state->offer->yiaddr; | 2023 | astate->failed.s_addr = state->offer->yiaddr; | |
2021 | else | 2024 | else | |
2022 | astate->failed = astate->addr; | 2025 | astate->failed = astate->addr; | |
2023 | arp_report_conflicted(astate, amsg); | 2026 | arp_report_conflicted(astate, amsg); | |
2024 | unlink(state->leasefile); | 2027 | unlink(state->leasefile); | |
2025 | if (!state->lease.frominfo) | 2028 | if (!(ifp->options->options & DHCPCD_STATIC) && | |
2029 | !state->lease.frominfo) | |||
2026 | dhcp_decline(ifp); | 2030 | dhcp_decline(ifp); | |
2027 | #ifdef IN_IFF_DUPLICATED | 2031 | #ifdef IN_IFF_DUPLICATED | |
2028 | ia = ipv4_iffindaddr(ifp, &astate->addr, NULL); | 2032 | ia = ipv4_iffindaddr(ifp, &astate->addr, NULL); | |
2029 | if (ia) | 2033 | if (ia) | |
2030 | ipv4_deladdr(ifp, &ia->addr, &ia->net, 1); | 2034 | ipv4_deladdr(ifp, &ia->addr, &ia->net, 1); | |
2031 | #endif | 2035 | #endif | |
2032 | arp_free(astate); | 2036 | arp_free(astate); | |
2033 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | 2037 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | |
2034 | eloop_timeout_add_sec(ifp->ctx->eloop, | 2038 | eloop_timeout_add_sec(ifp->ctx->eloop, | |
2035 | DHCP_RAND_MAX, dhcp_discover, ifp); | 2039 | DHCP_RAND_MAX, dhcp_discover, ifp); | |
2036 | } | 2040 | } | |
2037 | } | 2041 | } | |
2038 | 2042 | |||
@@ -2176,54 +2180,107 @@ dhcp_message_new(const struct in_addr *a | @@ -2176,54 +2180,107 @@ dhcp_message_new(const struct in_addr *a | |||
2176 | dhcp->cookie = htonl(MAGIC_COOKIE); | 2180 | dhcp->cookie = htonl(MAGIC_COOKIE); | |
2177 | p = dhcp->options; | 2181 | p = dhcp->options; | |
2178 | if (mask && mask->s_addr != INADDR_ANY) { | 2182 | if (mask && mask->s_addr != INADDR_ANY) { | |
2179 | *p++ = DHO_SUBNETMASK; | 2183 | *p++ = DHO_SUBNETMASK; | |
2180 | *p++ = sizeof(mask->s_addr); | 2184 | *p++ = sizeof(mask->s_addr); | |
2181 | memcpy(p, &mask->s_addr, sizeof(mask->s_addr)); | 2185 | memcpy(p, &mask->s_addr, sizeof(mask->s_addr)); | |
2182 | p+= sizeof(mask->s_addr); | 2186 | p+= sizeof(mask->s_addr); | |
2183 | } | 2187 | } | |
2184 | *p++ = DHO_END; | 2188 | *p++ = DHO_END; | |
2185 | return dhcp; | 2189 | return dhcp; | |
2186 | } | 2190 | } | |
2187 | 2191 | |||
2188 | static void | 2192 | static void | |
2193 | dhcp_arp_bind(struct interface *ifp) | |||
2194 | { | |||
2195 | const struct dhcp_state *state; | |||
2196 | struct in_addr addr; | |||
2197 | struct ipv4_addr *ia; | |||
2198 | struct arp_state *astate; | |||
2199 | ||||
2200 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | |||
2201 | ||||
2202 | state = D_CSTATE(ifp); | |||
2203 | addr.s_addr = state->offer->yiaddr; | |||
2204 | /* If the interface already has the address configured | |||
2205 | * then we can't ARP for duplicate detection. */ | |||
2206 | ia = ipv4_findaddr(ifp->ctx, &addr); | |||
2207 | ||||
2208 | #ifdef IN_IFF_TENTATIVE | |||
2209 | if (ia == NULL || ia->addr_flags & IN_IFF_NOTUSEABLE) { | |||
2210 | if ((astate = arp_new(ifp, &addr)) != NULL) { | |||
2211 | astate->probed_cb = dhcp_arp_probed; | |||
2212 | astate->conflicted_cb = dhcp_arp_conflicted; | |||
2213 | astate->announced_cb = dhcp_arp_announced; | |||
2214 | } | |||
2215 | if (ia == NULL) { | |||
2216 | struct dhcp_lease l; | |||
2217 | ||||
2218 | get_lease(ifp->ctx, &l, state->offer); | |||
2219 | /* Add the address now, let the kernel handle DAD. */ | |||
2220 | ipv4_addaddr(ifp, &l.addr, &l.net, &l.brd); | |||
2221 | } else | |||
2222 | logger(ifp->ctx, LOG_INFO, "%s: waiting for DAD on %s", | |||
2223 | ifp->name, inet_ntoa(addr)); | |||
2224 | return; | |||
2225 | } | |||
2226 | #else | |||
2227 | if (ifp->options->options & DHCPCD_ARP && ia == NULL) { | |||
2228 | struct dhcp_lease l; | |||
2229 | ||||
2230 | get_lease(ifp->ctx, &l, state->offer); | |||
2231 | logger(ifp->ctx, LOG_INFO, "%s: probing static address %s/%d", | |||
2232 | ifp->name, inet_ntoa(l.addr), inet_ntocidr(l.net)); | |||
2233 | if ((astate = arp_new(ifp, &addr)) != NULL) { | |||
2234 | astate->probed_cb = dhcp_arp_probed; | |||
2235 | astate->conflicted_cb = dhcp_arp_conflicted; | |||
2236 | astate->announced_cb = dhcp_arp_announced; | |||
2237 | /* We need to handle DAD. */ | |||
2238 | arp_probe(astate); | |||
2239 | } | |||
2240 | return; | |||
2241 | } | |||
2242 | #endif | |||
2243 | ||||
2244 | dhcp_bind(ifp); | |||
2245 | } | |||
2246 | ||||
2247 | static void | |||
2189 | dhcp_static(struct interface *ifp) | 2248 | dhcp_static(struct interface *ifp) | |
2190 | { | 2249 | { | |
2191 | struct if_options *ifo; | 2250 | struct if_options *ifo; | |
2192 | struct dhcp_state *state; | 2251 | struct dhcp_state *state; | |
2193 | struct ipv4_addr *ia; | 2252 | struct ipv4_addr *ia; | |
2194 | 2253 | |||
2195 | state = D_STATE(ifp); | 2254 | state = D_STATE(ifp); | |
2196 | ifo = ifp->options; | 2255 | ifo = ifp->options; | |
2197 | 2256 | |||
2198 | ia = NULL; | 2257 | ia = NULL; | |
2199 | if (ifo->req_addr.s_addr == INADDR_ANY && | 2258 | if (ifo->req_addr.s_addr == INADDR_ANY && | |
2200 | (ia = ipv4_iffindaddr(ifp, NULL, NULL)) == NULL) | 2259 | (ia = ipv4_iffindaddr(ifp, NULL, NULL)) == NULL) | |
2201 | { | 2260 | { | |
2202 | logger(ifp->ctx, LOG_INFO, | 2261 | logger(ifp->ctx, LOG_INFO, | |
2203 | "%s: waiting for 3rd party to " | 2262 | "%s: waiting for 3rd party to " | |
2204 | "configure IP address", | 2263 | "configure IP address", | |
2205 | ifp->name); | 2264 | ifp->name); | |
2206 | state->reason = "3RDPARTY"; | 2265 | state->reason = "3RDPARTY"; | |
2207 | script_runreason(ifp, state->reason); | 2266 | script_runreason(ifp, state->reason); | |
2208 | return; | 2267 | return; | |
2209 | } | 2268 | } | |
2210 | 2269 | |||
2211 | state->offer = dhcp_message_new(ia ? &ia->addr : &ifo->req_addr, | 2270 | state->offer = dhcp_message_new(ia ? &ia->addr : &ifo->req_addr, | |
2212 | ia ? &ia->net : &ifo->req_mask); | 2271 | ia ? &ia->net : &ifo->req_mask); | |
2213 | if (state->offer) { | 2272 | if (state->offer) | |
2214 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | 2273 | dhcp_arp_bind(ifp); | |
2215 | dhcp_bind(ifp); | |||
2216 | } | |||
2217 | } | 2274 | } | |
2218 | 2275 | |||
2219 | void | 2276 | void | |
2220 | dhcp_inform(struct interface *ifp) | 2277 | dhcp_inform(struct interface *ifp) | |
2221 | { | 2278 | { | |
2222 | struct dhcp_state *state; | 2279 | struct dhcp_state *state; | |
2223 | struct if_options *ifo; | 2280 | struct if_options *ifo; | |
2224 | struct ipv4_addr *ap; | 2281 | struct ipv4_addr *ap; | |
2225 | 2282 | |||
2226 | state = D_STATE(ifp); | 2283 | state = D_STATE(ifp); | |
2227 | ifo = ifp->options; | 2284 | ifo = ifp->options; | |
2228 | if (ifp->ctx->options & DHCPCD_TEST) { | 2285 | if (ifp->ctx->options & DHCPCD_TEST) { | |
2229 | state->addr.s_addr = ifo->req_addr.s_addr; | 2286 | state->addr.s_addr = ifo->req_addr.s_addr; | |
@@ -2493,28 +2550,29 @@ static void | @@ -2493,28 +2550,29 @@ static void | |||
2493 | dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp, | 2550 | dhcp_handledhcp(struct interface *ifp, struct dhcp_message **dhcpp, | |
2494 | const struct in_addr *from) | 2551 | const struct in_addr *from) | |
2495 | { | 2552 | { | |
2496 | struct dhcp_state *state = D_STATE(ifp); | 2553 | struct dhcp_state *state = D_STATE(ifp); | |
2497 | struct if_options *ifo = ifp->options; | 2554 | struct if_options *ifo = ifp->options; | |
2498 | struct dhcp_message *dhcp = *dhcpp; | 2555 | struct dhcp_message *dhcp = *dhcpp; | |
2499 | struct dhcp_lease *lease = &state->lease; | 2556 | struct dhcp_lease *lease = &state->lease; | |
2500 | uint8_t type, tmp; | 2557 | uint8_t type, tmp; | |
2501 | const uint8_t *auth; | 2558 | const uint8_t *auth; | |
2502 | struct in_addr addr; | 2559 | struct in_addr addr; | |
2503 | unsigned int i; | 2560 | unsigned int i; | |
2504 | size_t auth_len; | 2561 | size_t auth_len; | |
2505 | char *msg; | 2562 | char *msg; | |
2563 | #ifdef IN_IFF_DUPLICATED | |||
2506 | struct ipv4_addr *ia; | 2564 | struct ipv4_addr *ia; | |
2507 | struct arp_state *astate; | 2565 | #endif | |
2508 | 2566 | |||
2509 | /* We may have found a BOOTP server */ | 2567 | /* We may have found a BOOTP server */ | |
2510 | if (get_option_uint8(ifp->ctx, &type, dhcp, DHO_MESSAGETYPE) == -1) | 2568 | if (get_option_uint8(ifp->ctx, &type, dhcp, DHO_MESSAGETYPE) == -1) | |
2511 | type = 0; | 2569 | type = 0; | |
2512 | else if (ifo->options & DHCPCD_BOOTP) { | 2570 | else if (ifo->options & DHCPCD_BOOTP) { | |
2513 | logger(ifp->ctx, LOG_DEBUG, | 2571 | logger(ifp->ctx, LOG_DEBUG, | |
2514 | "%s: ignoring DHCP reply (excpecting BOOTP)", | 2572 | "%s: ignoring DHCP reply (excpecting BOOTP)", | |
2515 | ifp->name); | 2573 | ifp->name); | |
2516 | return; | 2574 | return; | |
2517 | } | 2575 | } | |
2518 | 2576 | |||
2519 | /* Authenticate the message */ | 2577 | /* Authenticate the message */ | |
2520 | auth = get_option(ifp->ctx, dhcp, DHO_AUTHENTICATION, &auth_len); | 2578 | auth = get_option(ifp->ctx, dhcp, DHO_AUTHENTICATION, &auth_len); | |
@@ -2787,63 +2845,27 @@ dhcp_handledhcp(struct interface *ifp, s | @@ -2787,63 +2845,27 @@ dhcp_handledhcp(struct interface *ifp, s | |||
2787 | state->nakoff = 0; | 2845 | state->nakoff = 0; | |
2788 | 2846 | |||
2789 | /* BOOTP could have already assigned this above, so check we still | 2847 | /* BOOTP could have already assigned this above, so check we still | |
2790 | * have a pointer. */ | 2848 | * have a pointer. */ | |
2791 | if (*dhcpp) { | 2849 | if (*dhcpp) { | |
2792 | free(state->offer); | 2850 | free(state->offer); | |
2793 | state->offer = dhcp; | 2851 | state->offer = dhcp; | |
2794 | *dhcpp = NULL; | 2852 | *dhcpp = NULL; | |
2795 | } | 2853 | } | |
2796 | 2854 | |||
2797 | lease->frominfo = 0; | 2855 | lease->frominfo = 0; | |
2798 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | 2856 | eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); | |
2799 | 2857 | |||
2800 | addr.s_addr = state->offer->yiaddr; | 2858 | dhcp_arp_bind(ifp); | |
2801 | /* If the interface already has the address configured | |||
2802 | * then we can't ARP for duplicate detection. */ | |||
2803 | ia = ipv4_findaddr(ifp->ctx, &addr); | |||
2804 | ||||
2805 | #ifdef IN_IFF_TENTATIVE | |||
2806 | if (ia == NULL || ia->addr_flags & IN_IFF_NOTUSEABLE) { | |||
2807 | if ((astate = arp_new(ifp, &addr)) != NULL) { | |||
2808 | astate->probed_cb = dhcp_arp_probed; | |||
2809 | astate->conflicted_cb = dhcp_arp_conflicted; | |||
2810 | astate->announced_cb = dhcp_arp_announced; | |||
2811 | } | |||
2812 | if (ia == NULL) { | |||
2813 | struct dhcp_lease l; | |||
2814 | ||||
2815 | get_lease(ifp->ctx, &l, state->offer); | |||
2816 | /* Add the address now, let the kernel handle DAD. */ | |||
2817 | ipv4_addaddr(ifp, &l.addr, &l.net, &l.brd); | |||
2818 | } | |||
2819 | return; | |||
2820 | } | |||
2821 | #else | |||
2822 | if (ifo->options & DHCPCD_ARP) { | |||
2823 | if (ia == NULL) { | |||
2824 | if ((astate = arp_new(ifp, &addr)) != NULL) { | |||
2825 | astate->probed_cb = dhcp_arp_probed; | |||
2826 | astate->conflicted_cb = dhcp_arp_conflicted; | |||
2827 | astate->announced_cb = dhcp_arp_announced; | |||
2828 | /* We need to handle DAD. */ | |||
2829 | arp_probe(astate); | |||
2830 | } | |||
2831 | return; | |||
2832 | } | |||
2833 | } | |||
2834 | #endif | |||
2835 | ||||
2836 | dhcp_bind(ifp); | |||
2837 | } | 2859 | } | |
2838 | 2860 | |||
2839 | static size_t | 2861 | static size_t | |
2840 | get_udp_data(const uint8_t **data, const uint8_t *udp) | 2862 | get_udp_data(const uint8_t **data, const uint8_t *udp) | |
2841 | { | 2863 | { | |
2842 | struct udp_dhcp_packet p; | 2864 | struct udp_dhcp_packet p; | |
2843 | 2865 | |||
2844 | memcpy(&p, udp, sizeof(p)); | 2866 | memcpy(&p, udp, sizeof(p)); | |
2845 | *data = udp + offsetof(struct udp_dhcp_packet, dhcp); | 2867 | *data = udp + offsetof(struct udp_dhcp_packet, dhcp); | |
2846 | return ntohs(p.ip.ip_len) - sizeof(p.ip) - sizeof(p.udp); | 2868 | return ntohs(p.ip.ip_len) - sizeof(p.ip) - sizeof(p.udp); | |
2847 | } | 2869 | } | |
2848 | 2870 | |||
2849 | static int | 2871 | static int |
--- src/external/bsd/dhcpcd/dist/Attic/dhcpcd.c 2015/08/21 10:39:00 1.27
+++ src/external/bsd/dhcpcd/dist/Attic/dhcpcd.c 2015/09/04 12:25:01 1.28
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | #include <sys/cdefs.h> | 1 | #include <sys/cdefs.h> | |
2 | __RCSID("$NetBSD: dhcpcd.c,v 1.27 2015/08/21 10:39:00 roy Exp $"); | 2 | __RCSID("$NetBSD: dhcpcd.c,v 1.28 2015/09/04 12:25:01 roy Exp $"); | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * dhcpcd - DHCP client daemon | 5 | * dhcpcd - DHCP client daemon | |
6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
7 | * All rights reserved | 7 | * All rights reserved | |
8 | 8 | |||
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -426,27 +426,27 @@ configure_interface1(struct interface *i | @@ -426,27 +426,27 @@ configure_interface1(struct interface *i | |||
426 | 426 | |||
427 | /* Do any platform specific configuration */ | 427 | /* Do any platform specific configuration */ | |
428 | if_conf(ifp); | 428 | if_conf(ifp); | |
429 | 429 | |||
430 | /* If we want to release a lease, we can't really persist the | 430 | /* If we want to release a lease, we can't really persist the | |
431 | * address either. */ | 431 | * address either. */ | |
432 | if (ifo->options & DHCPCD_RELEASE) | 432 | if (ifo->options & DHCPCD_RELEASE) | |
433 | ifo->options &= ~DHCPCD_PERSISTENT; | 433 | ifo->options &= ~DHCPCD_PERSISTENT; | |
434 | 434 | |||
435 | if (ifp->flags & IFF_POINTOPOINT && !(ifo->options & DHCPCD_INFORM)) | 435 | if (ifp->flags & IFF_POINTOPOINT && !(ifo->options & DHCPCD_INFORM)) | |
436 | ifo->options |= DHCPCD_STATIC; | 436 | ifo->options |= DHCPCD_STATIC; | |
437 | if (ifp->flags & IFF_NOARP || | 437 | if (ifp->flags & IFF_NOARP || | |
438 | ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)) | 438 | ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)) | |
439 | ifo->options &= ~(DHCPCD_ARP | DHCPCD_IPV4LL); | 439 | ifo->options &= ~DHCPCD_IPV4LL; | |
440 | if (ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK) || | 440 | if (ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK) || | |
441 | !(ifp->flags & IFF_MULTICAST)) | 441 | !(ifp->flags & IFF_MULTICAST)) | |
442 | ifo->options &= ~DHCPCD_IPV6RS; | 442 | ifo->options &= ~DHCPCD_IPV6RS; | |
443 | 443 | |||
444 | if (ifo->metric != -1) | 444 | if (ifo->metric != -1) | |
445 | ifp->metric = (unsigned int)ifo->metric; | 445 | ifp->metric = (unsigned int)ifo->metric; | |
446 | 446 | |||
447 | if (!(ifo->options & DHCPCD_IPV4)) | 447 | if (!(ifo->options & DHCPCD_IPV4)) | |
448 | ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4); | 448 | ifo->options &= ~(DHCPCD_DHCP | DHCPCD_IPV4LL | DHCPCD_WAITIP4); | |
449 | 449 | |||
450 | if (!(ifo->options & DHCPCD_IPV6)) | 450 | if (!(ifo->options & DHCPCD_IPV6)) | |
451 | ifo->options &= | 451 | ifo->options &= | |
452 | ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); | 452 | ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); |
--- src/external/bsd/dhcpcd/dist/Attic/if-options.c 2015/08/21 10:39:00 1.26
+++ src/external/bsd/dhcpcd/dist/Attic/if-options.c 2015/09/04 12:25:01 1.27
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | #include <sys/cdefs.h> | 1 | #include <sys/cdefs.h> | |
2 | __RCSID("$NetBSD: if-options.c,v 1.26 2015/08/21 10:39:00 roy Exp $"); | 2 | __RCSID("$NetBSD: if-options.c,v 1.27 2015/09/04 12:25:01 roy Exp $"); | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * dhcpcd - DHCP client daemon | 5 | * dhcpcd - DHCP client daemon | |
6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
7 | * All rights reserved | 7 | * All rights reserved | |
8 | 8 | |||
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -803,27 +803,27 @@ parse_option(struct dhcpcd_ctx *ctx, con | @@ -803,27 +803,27 @@ parse_option(struct dhcpcd_ctx *ctx, con | |||
803 | { | 803 | { | |
804 | ifo->options |= DHCPCD_INFORM; | 804 | ifo->options |= DHCPCD_INFORM; | |
805 | break; | 805 | break; | |
806 | } | 806 | } | |
807 | if (arg && *arg != '\0') { | 807 | if (arg && *arg != '\0') { | |
808 | if (parse_addr(ctx, | 808 | if (parse_addr(ctx, | |
809 | &ifo->req_addr, &ifo->req_mask, arg) != 0) | 809 | &ifo->req_addr, &ifo->req_mask, arg) != 0) | |
810 | return -1; | 810 | return -1; | |
811 | } else { | 811 | } else { | |
812 | ifo->req_addr.s_addr = 0; | 812 | ifo->req_addr.s_addr = 0; | |
813 | ifo->req_mask.s_addr = 0; | 813 | ifo->req_mask.s_addr = 0; | |
814 | } | 814 | } | |
815 | ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT; | 815 | ifo->options |= DHCPCD_INFORM | DHCPCD_PERSISTENT; | |
816 | ifo->options &= ~(DHCPCD_ARP | DHCPCD_STATIC); | 816 | ifo->options &= ~DHCPCD_STATIC; | |
817 | break; | 817 | break; | |
818 | case 't': | 818 | case 't': | |
819 | ifo->timeout = (time_t)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); | 819 | ifo->timeout = (time_t)strtoi(arg, NULL, 0, 0, INT32_MAX, &e); | |
820 | if (e) { | 820 | if (e) { | |
821 | logger(ctx, LOG_ERR, "failed to convert timeout"); | 821 | logger(ctx, LOG_ERR, "failed to convert timeout"); | |
822 | return -1; | 822 | return -1; | |
823 | } | 823 | } | |
824 | break; | 824 | break; | |
825 | case 'u': | 825 | case 'u': | |
826 | s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1; | 826 | s = USERCLASS_MAX_LEN - ifo->userclass[0] - 1; | |
827 | s = parse_string((char *)ifo->userclass + | 827 | s = parse_string((char *)ifo->userclass + | |
828 | ifo->userclass[0] + 2, (size_t)s, arg); | 828 | ifo->userclass[0] + 2, (size_t)s, arg); | |
829 | if (s == -1) { | 829 | if (s == -1) { | |
@@ -1091,26 +1091,36 @@ parse_option(struct dhcpcd_ctx *ctx, con | @@ -1091,26 +1091,36 @@ parse_option(struct dhcpcd_ctx *ctx, con | |||
1091 | } | 1091 | } | |
1092 | rt = calloc(1, sizeof(*rt)); | 1092 | rt = calloc(1, sizeof(*rt)); | |
1093 | if (rt == NULL) { | 1093 | if (rt == NULL) { | |
1094 | logger(ctx, LOG_ERR, "%s: %m", __func__); | 1094 | logger(ctx, LOG_ERR, "%s: %m", __func__); | |
1095 | return -1; | 1095 | return -1; | |
1096 | } | 1096 | } | |
1097 | rt->dest.s_addr = INADDR_ANY; | 1097 | rt->dest.s_addr = INADDR_ANY; | |
1098 | rt->net.s_addr = INADDR_ANY; | 1098 | rt->net.s_addr = INADDR_ANY; | |
1099 | if (parse_addr(ctx, &rt->gate, NULL, p) == -1) { | 1099 | if (parse_addr(ctx, &rt->gate, NULL, p) == -1) { | |
1100 | free(rt); | 1100 | free(rt); | |
1101 | return -1; | 1101 | return -1; | |
1102 | } | 1102 | } | |
1103 | TAILQ_INSERT_TAIL(ifo->routes, rt, next); | 1103 | TAILQ_INSERT_TAIL(ifo->routes, rt, next); | |
1104 | } else if (strncmp(arg, "interface_mtu=", | |||
1105 | strlen("interface_mtu=")) == 0 || | |||
1106 | strncmp(arg, "mtu=", strlen("mtu=")) == 0) | |||
1107 | { | |||
1108 | ifo->mtu = (unsigned int)strtou(p, NULL, 0, | |||
1109 | MTU_MIN, MTU_MAX, &e); | |||
1110 | if (e) { | |||
1111 | logger(ctx, LOG_ERR, "invalid MTU %s", p); | |||
1112 | return -1; | |||
1113 | } | |||
1104 | } else { | 1114 | } else { | |
1105 | dl = 0; | 1115 | dl = 0; | |
1106 | if (ifo->config != NULL) { | 1116 | if (ifo->config != NULL) { | |
1107 | while (ifo->config[dl] != NULL) { | 1117 | while (ifo->config[dl] != NULL) { | |
1108 | if (strncmp(ifo->config[dl], arg, | 1118 | if (strncmp(ifo->config[dl], arg, | |
1109 | (size_t)(p - arg)) == 0) | 1119 | (size_t)(p - arg)) == 0) | |
1110 | { | 1120 | { | |
1111 | p = strdup(arg); | 1121 | p = strdup(arg); | |
1112 | if (p == NULL) { | 1122 | if (p == NULL) { | |
1113 | logger(ctx, LOG_ERR, | 1123 | logger(ctx, LOG_ERR, | |
1114 | "%s: %m", __func__); | 1124 | "%s: %m", __func__); | |
1115 | return -1; | 1125 | return -1; | |
1116 | } | 1126 | } |
--- src/external/bsd/dhcpcd/dist/Attic/if-options.h 2015/08/21 10:39:00 1.13
+++ src/external/bsd/dhcpcd/dist/Attic/if-options.h 2015/09/04 12:25:01 1.14
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if-options.h,v 1.13 2015/08/21 10:39:00 roy Exp $ */ | 1 | /* $NetBSD: if-options.h,v 1.14 2015/09/04 12:25:01 roy Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * dhcpcd - DHCP client daemon | 4 | * dhcpcd - DHCP client daemon | |
5 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 5 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
6 | * All rights reserved | 6 | * All rights reserved | |
7 | 7 | |||
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -164,26 +164,27 @@ struct if_options { | @@ -164,26 +164,27 @@ struct if_options { | |||
164 | uint8_t rejectmasknd[(UINT16_MAX + 1) / NBBY]; | 164 | uint8_t rejectmasknd[(UINT16_MAX + 1) / NBBY]; | |
165 | uint8_t requestmask6[(UINT16_MAX + 1) / NBBY]; | 165 | uint8_t requestmask6[(UINT16_MAX + 1) / NBBY]; | |
166 | uint8_t requiremask6[(UINT16_MAX + 1) / NBBY]; | 166 | uint8_t requiremask6[(UINT16_MAX + 1) / NBBY]; | |
167 | uint8_t nomask6[(UINT16_MAX + 1) / NBBY]; | 167 | uint8_t nomask6[(UINT16_MAX + 1) / NBBY]; | |
168 | uint8_t rejectmask6[(UINT16_MAX + 1) / NBBY]; | 168 | uint8_t rejectmask6[(UINT16_MAX + 1) / NBBY]; | |
169 | uint32_t leasetime; | 169 | uint32_t leasetime; | |
170 | time_t timeout; | 170 | time_t timeout; | |
171 | time_t reboot; | 171 | time_t reboot; | |
172 | unsigned long long options; | 172 | unsigned long long options; | |
173 | 173 | |||
174 | struct in_addr req_addr; | 174 | struct in_addr req_addr; | |
175 | struct in_addr req_mask; | 175 | struct in_addr req_mask; | |
176 | struct rt_head *routes; | 176 | struct rt_head *routes; | |
177 | unsigned int mtu; | |||
177 | char **config; | 178 | char **config; | |
178 | 179 | |||
179 | char **environ; | 180 | char **environ; | |
180 | char *script; | 181 | char *script; | |
181 | 182 | |||
182 | char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */ | 183 | char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */ | |
183 | uint8_t fqdn; | 184 | uint8_t fqdn; | |
184 | uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2]; | 185 | uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2]; | |
185 | uint8_t clientid[CLIENTID_MAX_LEN + 2]; | 186 | uint8_t clientid[CLIENTID_MAX_LEN + 2]; | |
186 | uint8_t userclass[USERCLASS_MAX_LEN + 2]; | 187 | uint8_t userclass[USERCLASS_MAX_LEN + 2]; | |
187 | uint8_t vendor[VENDOR_MAX_LEN + 2]; | 188 | uint8_t vendor[VENDOR_MAX_LEN + 2]; | |
188 | 189 | |||
189 | size_t blacklist_len; | 190 | size_t blacklist_len; |
--- src/external/bsd/dhcpcd/dist/Attic/if.c 2015/08/21 10:39:00 1.15
+++ src/external/bsd/dhcpcd/dist/Attic/if.c 2015/09/04 12:25:01 1.16
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | #include <sys/cdefs.h> | 1 | #include <sys/cdefs.h> | |
2 | __RCSID("$NetBSD: if.c,v 1.15 2015/08/21 10:39:00 roy Exp $"); | 2 | __RCSID("$NetBSD: if.c,v 1.16 2015/09/04 12:25:01 roy Exp $"); | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * dhcpcd - DHCP client daemon | 5 | * dhcpcd - DHCP client daemon | |
6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
7 | * All rights reserved | 7 | * All rights reserved | |
8 | 8 | |||
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -669,24 +669,24 @@ xsocket(int domain, int type, int protoc | @@ -669,24 +669,24 @@ xsocket(int domain, int type, int protoc | |||
669 | #ifdef SOCK_CLOEXEC | 669 | #ifdef SOCK_CLOEXEC | |
670 | if (flags & O_CLOEXEC) | 670 | if (flags & O_CLOEXEC) | |
671 | type |= SOCK_CLOEXEC; | 671 | type |= SOCK_CLOEXEC; | |
672 | if (flags & O_NONBLOCK) | 672 | if (flags & O_NONBLOCK) | |
673 | type |= SOCK_NONBLOCK; | 673 | type |= SOCK_NONBLOCK; | |
674 | 674 | |||
675 | return socket(domain, type, protocol); | 675 | return socket(domain, type, protocol); | |
676 | #else | 676 | #else | |
677 | int s, xflags; | 677 | int s, xflags; | |
678 | 678 | |||
679 | if ((s = socket(domain, type, protocol)) == -1) | 679 | if ((s = socket(domain, type, protocol)) == -1) | |
680 | return -1; | 680 | return -1; | |
681 | if ((flags & O_CLOEXEC) && (xflags = fcntl(s, F_GETFD, 0)) == -1 || | 681 | if ((flags & O_CLOEXEC) && (xflags = fcntl(s, F_GETFD, 0)) == -1 || | |
682 | fcntl(s, F_SETFD, xlags | FD_CLOEXEC) == -1) | 682 | fcntl(s, F_SETFD, xflags | FD_CLOEXEC) == -1) | |
683 | goto out; | 683 | goto out; | |
684 | if ((flags & O_NONBLOCK) && (xflags = fcntl(s, F_GETFL, 0)) == -1 || | 684 | if ((flags & O_NONBLOCK) && (xflags = fcntl(s, F_GETFL, 0)) == -1 || | |
685 | fcntl(s, F_SETFL, xflags | O_NONBLOCK) == -1) | 685 | fcntl(s, F_SETFL, xflags | O_NONBLOCK) == -1) | |
686 | goto out; | 686 | goto out; | |
687 | return s; | 687 | return s; | |
688 | out: | 688 | out: | |
689 | close(s); | 689 | close(s); | |
690 | return -1; | 690 | return -1; | |
691 | #endif | 691 | #endif | |
692 | } | 692 | } |
--- src/external/bsd/dhcpcd/dist/Attic/script.c 2015/08/21 10:39:00 1.22
+++ src/external/bsd/dhcpcd/dist/Attic/script.c 2015/09/04 12:25:01 1.23
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | #include <sys/cdefs.h> | 1 | #include <sys/cdefs.h> | |
2 | __RCSID("$NetBSD: script.c,v 1.22 2015/08/21 10:39:00 roy Exp $"); | 2 | __RCSID("$NetBSD: script.c,v 1.23 2015/09/04 12:25:01 roy Exp $"); | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * dhcpcd - DHCP client daemon | 5 | * dhcpcd - DHCP client daemon | |
6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | 6 | * Copyright (c) 2006-2015 Roy Marples <roy@marples.name> | |
7 | * All rights reserved | 7 | * All rights reserved | |
8 | 8 | |||
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -124,55 +124,56 @@ exec_script(const struct dhcpcd_ctx *ctx | @@ -124,55 +124,56 @@ exec_script(const struct dhcpcd_ctx *ctx | |||
124 | return -1; | 124 | return -1; | |
125 | } | 125 | } | |
126 | return pid; | 126 | return pid; | |
127 | } | 127 | } | |
128 | 128 | |||
129 | #ifdef INET | 129 | #ifdef INET | |
130 | static char * | 130 | static char * | |
131 | make_var(struct dhcpcd_ctx *ctx, const char *prefix, const char *var) | 131 | make_var(struct dhcpcd_ctx *ctx, const char *prefix, const char *var) | |
132 | { | 132 | { | |
133 | size_t len; | 133 | size_t len; | |
134 | char *v; | 134 | char *v; | |
135 | 135 | |||
136 | len = strlen(prefix) + strlen(var) + 2; | 136 | len = strlen(prefix) + strlen(var) + 2; | |
137 | v = malloc(len); | 137 | if ((v = malloc(len)) == NULL) { | |
138 | if (v == NULL) { | |||
139 | logger(ctx, LOG_ERR, "%s: %m", __func__); | 138 | logger(ctx, LOG_ERR, "%s: %m", __func__); | |
140 | return NULL; | 139 | return NULL; | |
141 | } | 140 | } | |
142 | snprintf(v, len, "%s_%s", prefix, var); | 141 | snprintf(v, len, "%s_%s", prefix, var); | |
143 | return v; | 142 | return v; | |
144 | } | 143 | } | |
145 | 144 | |||
146 | 145 | |||
147 | static int | 146 | static int | |
148 | append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len, | 147 | append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len, | |
149 | const char *prefix, const char *const *config) | 148 | const char *prefix, const char *const *config) | |
150 | { | 149 | { | |
151 | size_t i, j, e1; | 150 | size_t i, j, e1; | |
152 | char **ne, *eq, **nep, *p; | 151 | char **ne, *eq, **nep, *p; | |
153 | int ret; | 152 | int ret; | |
154 | 153 | |||
155 | if (config == NULL) | 154 | if (config == NULL) | |
156 | return 0; | 155 | return 0; | |
157 | 156 | |||
158 | ne = *env; | 157 | ne = *env; | |
159 | ret = 0; | 158 | ret = 0; | |
160 | for (i = 0; config[i] != NULL; i++) { | 159 | for (i = 0; config[i] != NULL; i++) { | |
161 | eq = strchr(config[i], '='); | 160 | eq = strchr(config[i], '='); | |
162 | e1 = (size_t)(eq - config[i] + 1); | 161 | e1 = (size_t)(eq - config[i] + 1); | |
163 | for (j = 0; j < *len; j++) { | 162 | for (j = 0; j < *len; j++) { | |
164 | if (strncmp(ne[j] + strlen(prefix) + 1, | 163 | if (strncmp(ne[j], prefix, strlen(prefix)) == 0 && | |
165 | config[i], e1) == 0) | 164 | ne[j][strlen(prefix)] == '_' && | |
165 | strncmp(ne[j] + strlen(prefix) + 1, | |||
166 | config[i], e1) == 0) | |||
166 | { | 167 | { | |
167 | p = make_var(ctx, prefix, config[i]); | 168 | p = make_var(ctx, prefix, config[i]); | |
168 | if (p == NULL) { | 169 | if (p == NULL) { | |
169 | ret = -1; | 170 | ret = -1; | |
170 | break; | 171 | break; | |
171 | } | 172 | } | |
172 | free(ne[j]); | 173 | free(ne[j]); | |
173 | ne[j] = p; | 174 | ne[j] = p; | |
174 | break; | 175 | break; | |
175 | } | 176 | } | |
176 | } | 177 | } | |
177 | if (j == *len) { | 178 | if (j == *len) { | |
178 | j++; | 179 | j++; |