merge local changes between dhcp-4.4.2 and dhcp-4.4.2-P1diff -r1.3 -r1.4 src/external/mpl/dhcp/dist/client/dhclient.c
(christos)
--- src/external/mpl/dhcp/dist/client/dhclient.c 2020/08/03 21:10:56 1.3
+++ src/external/mpl/dhcp/dist/client/dhclient.c 2021/05/26 22:52:31 1.4
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | /* $NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $ */ | 1 | /* $NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $ */ | |
2 | 2 | |||
3 | /* dhclient.c | 3 | /* dhclient.c | |
4 | 4 | |||
5 | DHCP Client. */ | 5 | DHCP Client. */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 2004-2020 by Internet Systems Consortium, Inc. ("ISC") | 8 | * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC") | |
9 | * Copyright (c) 1995-2003 by Internet Software Consortium | 9 | * Copyright (c) 1995-2003 by Internet Software Consortium | |
10 | * | 10 | * | |
11 | * This Source Code Form is subject to the terms of the Mozilla Public | 11 | * This Source Code Form is subject to the terms of the Mozilla Public | |
12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
14 | * | 14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | 15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | |
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | 17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * Internet Systems Consortium, Inc. | 23 | * Internet Systems Consortium, Inc. | |
24 | * 950 Charter Street | 24 | * 950 Charter Street | |
25 | * Redwood City, CA 94063 | 25 | * Redwood City, CA 94063 | |
26 | * <info@isc.org> | 26 | * <info@isc.org> | |
27 | * https://www.isc.org/ | 27 | * https://www.isc.org/ | |
28 | * | 28 | * | |
29 | * This code is based on the original client state machine that was | 29 | * This code is based on the original client state machine that was | |
30 | * written by Elliot Poger. The code has been extensively hacked on | 30 | * written by Elliot Poger. The code has been extensively hacked on | |
31 | * by Ted Lemon since then, so any mistakes you find are probably his | 31 | * by Ted Lemon since then, so any mistakes you find are probably his | |
32 | * fault and not Elliot's. | 32 | * fault and not Elliot's. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | __RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $"); | 36 | __RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $"); | |
37 | 37 | |||
38 | #include "dhcpd.h" | 38 | #include "dhcpd.h" | |
39 | #include <isc/util.h> | 39 | #include <isc/util.h> | |
40 | #include <isc/file.h> | 40 | #include <isc/file.h> | |
41 | #include <dns/result.h> | 41 | #include <dns/result.h> | |
42 | #include <syslog.h> | 42 | #include <syslog.h> | |
43 | #include <signal.h> | 43 | #include <signal.h> | |
44 | #include <errno.h> | 44 | #include <errno.h> | |
45 | #include <sys/time.h> | 45 | #include <sys/time.h> | |
46 | #include <sys/wait.h> | 46 | #include <sys/wait.h> | |
47 | #include <limits.h> | 47 | #include <limits.h> | |
48 | 48 | |||
49 | TIME default_lease_time = 43200; /* 12 hours... */ | 49 | TIME default_lease_time = 43200; /* 12 hours... */ | |
@@ -74,27 +74,27 @@ struct sockaddr_in sockaddr_broadcast; | @@ -74,27 +74,27 @@ struct sockaddr_in sockaddr_broadcast; | |||
74 | struct in_addr giaddr; | 74 | struct in_addr giaddr; | |
75 | struct data_string default_duid; | 75 | struct data_string default_duid; | |
76 | int duid_type = 0; | 76 | int duid_type = 0; | |
77 | int duid_v4 = 0; | 77 | int duid_v4 = 0; | |
78 | int std_dhcid = 0; | 78 | int std_dhcid = 0; | |
79 | 79 | |||
80 | int decline_wait_time = 10; /* Default to 10 secs per, RFC 2131, 3.1.5 */ | 80 | int decline_wait_time = 10; /* Default to 10 secs per, RFC 2131, 3.1.5 */ | |
81 | 81 | |||
82 | /* ASSERT_STATE() does nothing now; it used to be | 82 | /* ASSERT_STATE() does nothing now; it used to be | |
83 | assert (state_is == state_shouldbe). */ | 83 | assert (state_is == state_shouldbe). */ | |
84 | #define ASSERT_STATE(state_is, state_shouldbe) {} | 84 | #define ASSERT_STATE(state_is, state_shouldbe) {} | |
85 | 85 | |||
86 | #ifndef UNIT_TEST | 86 | #ifndef UNIT_TEST | |
87 | static const char copyright[] = "Copyright 2004-2020 Internet Systems Consortium."; | 87 | static const char copyright[] = "Copyright 2004-2021 Internet Systems Consortium."; | |
88 | static const char arr [] = "All rights reserved."; | 88 | static const char arr [] = "All rights reserved."; | |
89 | static const char message [] = "Internet Systems Consortium DHCP Client"; | 89 | static const char message [] = "Internet Systems Consortium DHCP Client"; | |
90 | static const char url [] = "For info, please visit https://www.isc.org/software/dhcp/"; | 90 | static const char url [] = "For info, please visit https://www.isc.org/software/dhcp/"; | |
91 | #endif /* UNIT_TEST */ | 91 | #endif /* UNIT_TEST */ | |
92 | 92 | |||
93 | u_int16_t local_port = 0; | 93 | u_int16_t local_port = 0; | |
94 | u_int16_t remote_port = 0; | 94 | u_int16_t remote_port = 0; | |
95 | #if defined(DHCPv6) && defined(DHCP4o6) | 95 | #if defined(DHCPv6) && defined(DHCP4o6) | |
96 | int dhcp4o6_state = -1; /* -1 = stopped, 0 = polling, 1 = started */ | 96 | int dhcp4o6_state = -1; /* -1 = stopped, 0 = polling, 1 = started */ | |
97 | #endif | 97 | #endif | |
98 | int no_daemon = 0; | 98 | int no_daemon = 0; | |
99 | int dfd[2] = { -1, -1 }; | 99 | int dfd[2] = { -1, -1 }; | |
100 | struct string_list *client_env = NULL; | 100 | struct string_list *client_env = NULL; | |
@@ -231,27 +231,27 @@ add_interfaces(char **ifaces, int niface | @@ -231,27 +231,27 @@ add_interfaces(char **ifaces, int niface | |||
231 | * If the user has provided an incorrect command line print out | 231 | * If the user has provided an incorrect command line print out | |
232 | * the description of the command line. The arguments provide | 232 | * the description of the command line. The arguments provide | |
233 | * a way for the caller to request more specific information about | 233 | * a way for the caller to request more specific information about | |
234 | * the error be printed as well. Mostly this will be that some | 234 | * the error be printed as well. Mostly this will be that some | |
235 | * comamnd doesn't include its argument. | 235 | * comamnd doesn't include its argument. | |
236 | * | 236 | * | |
237 | * \param sfmt - The basic string and format for the specific error | 237 | * \param sfmt - The basic string and format for the specific error | |
238 | * \param sarg - Generally the offending argument from the comamnd line. | 238 | * \param sarg - Generally the offending argument from the comamnd line. | |
239 | * | 239 | * | |
240 | * \return Nothing | 240 | * \return Nothing | |
241 | */ | 241 | */ | |
242 | 242 | |||
243 | #include <sys/cdefs.h> | 243 | #include <sys/cdefs.h> | |
244 | __RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $"); | 244 | __RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $"); | |
245 | 245 | |||
246 | #if defined(DHCPv6) && defined(DHCP4o6) | 246 | #if defined(DHCPv6) && defined(DHCP4o6) | |
247 | static void dhcp4o6_poll(void *dummy); | 247 | static void dhcp4o6_poll(void *dummy); | |
248 | static void dhcp4o6_resume(void); | 248 | static void dhcp4o6_resume(void); | |
249 | static void recv_dhcpv4_response(struct data_string *raw); | 249 | static void recv_dhcpv4_response(struct data_string *raw); | |
250 | static int send_dhcpv4_query(struct client_state *client, int broadcast); | 250 | static int send_dhcpv4_query(struct client_state *client, int broadcast); | |
251 | 251 | |||
252 | static void dhcp4o6_stop(void); | 252 | static void dhcp4o6_stop(void); | |
253 | static void forw_dhcpv4_response(struct packet *packet); | 253 | static void forw_dhcpv4_response(struct packet *packet); | |
254 | static void forw_dhcpv4_query(struct data_string *raw); | 254 | static void forw_dhcpv4_query(struct data_string *raw); | |
255 | #endif | 255 | #endif | |
256 | 256 | |||
257 | #ifndef UNIT_TEST | 257 | #ifndef UNIT_TEST | |
@@ -1220,27 +1220,27 @@ int find_subnet (struct subnet **sp, | @@ -1220,27 +1220,27 @@ int find_subnet (struct subnet **sp, | |||
1220 | * been sent to us by DHCP servers. | 1220 | * been sent to us by DHCP servers. | |
1221 | * acked_leases: leases corresponding to DHCPACK messages that have been | 1221 | * acked_leases: leases corresponding to DHCPACK messages that have been | |
1222 | * sent to us by DHCP servers. | 1222 | * sent to us by DHCP servers. | |
1223 | * sendpacket: DHCP packet we're trying to send. | 1223 | * sendpacket: DHCP packet we're trying to send. | |
1224 | * destination: IP address to send sendpacket to | 1224 | * destination: IP address to send sendpacket to | |
1225 | * In addition, there are several relevant per-lease variables. | 1225 | * In addition, there are several relevant per-lease variables. | |
1226 | * T1_expiry, T2_expiry, lease_expiry: lease milestones | 1226 | * T1_expiry, T2_expiry, lease_expiry: lease milestones | |
1227 | * In the active lease, these control the process of renewing the lease; | 1227 | * In the active lease, these control the process of renewing the lease; | |
1228 | * In leases on the acked_leases list, this simply determines when we | 1228 | * In leases on the acked_leases list, this simply determines when we | |
1229 | * can no longer legitimately use the lease. | 1229 | * can no longer legitimately use the lease. | |
1230 | */ | 1230 | */ | |
1231 | 1231 | |||
1232 | #include <sys/cdefs.h> | 1232 | #include <sys/cdefs.h> | |
1233 | __RCSID("$NetBSD: dhclient.c,v 1.3 2020/08/03 21:10:56 christos Exp $"); | 1233 | __RCSID("$NetBSD: dhclient.c,v 1.4 2021/05/26 22:52:31 christos Exp $"); | |
1234 | 1234 | |||
1235 | void state_reboot (cpp) | 1235 | void state_reboot (cpp) | |
1236 | void *cpp; | 1236 | void *cpp; | |
1237 | { | 1237 | { | |
1238 | struct client_state *client = cpp; | 1238 | struct client_state *client = cpp; | |
1239 | 1239 | |||
1240 | #if defined(DHCPv6) && defined(DHCP4o6) | 1240 | #if defined(DHCPv6) && defined(DHCP4o6) | |
1241 | if (dhcpv4_over_dhcpv6 && (dhcp4o6_state <= 0)) { | 1241 | if (dhcpv4_over_dhcpv6 && (dhcp4o6_state <= 0)) { | |
1242 | if (dhcp4o6_state < 0) | 1242 | if (dhcp4o6_state < 0) | |
1243 | dhcp4o6_poll(NULL); | 1243 | dhcp4o6_poll(NULL); | |
1244 | client->pending = P_REBOOT; | 1244 | client->pending = P_REBOOT; | |
1245 | return; | 1245 | return; | |
1246 | } | 1246 | } |
--- src/external/mpl/dhcp/dist/common/parse.c 2020/08/03 21:10:56 1.3
+++ src/external/mpl/dhcp/dist/common/parse.c 2021/05/26 22:52:31 1.4
@@ -1,45 +1,45 @@ | @@ -1,45 +1,45 @@ | |||
1 | /* $NetBSD: parse.c,v 1.3 2020/08/03 21:10:56 christos Exp $ */ | 1 | /* $NetBSD: parse.c,v 1.4 2021/05/26 22:52:31 christos Exp $ */ | |
2 | 2 | |||
3 | /* parse.c | 3 | /* parse.c | |
4 | 4 | |||
5 | Common parser code for dhcpd and dhclient. */ | 5 | Common parser code for dhcpd and dhclient. */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC") | 8 | * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC") | |
9 | * Copyright (c) 1995-2003 by Internet Software Consortium | 9 | * Copyright (c) 1995-2003 by Internet Software Consortium | |
10 | * | 10 | * | |
11 | * This Source Code Form is subject to the terms of the Mozilla Public | 11 | * This Source Code Form is subject to the terms of the Mozilla Public | |
12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
14 | * | 14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | 15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | |
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | 17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | * | 22 | * | |
23 | * Internet Systems Consortium, Inc. | 23 | * Internet Systems Consortium, Inc. | |
24 | * 950 Charter Street | 24 | * 950 Charter Street | |
25 | * Redwood City, CA 94063 | 25 | * Redwood City, CA 94063 | |
26 | * <info@isc.org> | 26 | * <info@isc.org> | |
27 | * https://www.isc.org/ | 27 | * https://www.isc.org/ | |
28 | * | 28 | * | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __RCSID("$NetBSD: parse.c,v 1.3 2020/08/03 21:10:56 christos Exp $"); | 32 | __RCSID("$NetBSD: parse.c,v 1.4 2021/05/26 22:52:31 christos Exp $"); | |
33 | 33 | |||
34 | #include "dhcpd.h" | 34 | #include "dhcpd.h" | |
35 | #include <isc/util.h> | 35 | #include <isc/util.h> | |
36 | #include <syslog.h> | 36 | #include <syslog.h> | |
37 | 37 | |||
38 | struct collection default_collection = { NULL, "default", NULL }; | 38 | struct collection default_collection = { NULL, "default", NULL }; | |
39 | struct collection *collections = &default_collection; | 39 | struct collection *collections = &default_collection; | |
40 | 40 | |||
41 | /* Enumerations can be specified in option formats, and are used for | 41 | /* Enumerations can be specified in option formats, and are used for | |
42 | parsing, so we define the routines that manage them here. */ | 42 | parsing, so we define the routines that manage them here. */ | |
43 | 43 | |||
44 | struct enumeration *enumerations; | 44 | struct enumeration *enumerations; | |
45 | 45 | |||
@@ -5551,33 +5551,34 @@ int parse_X (cfile, buf, max) | @@ -5551,33 +5551,34 @@ int parse_X (cfile, buf, max) | |||
5551 | unsigned len; | 5551 | unsigned len; | |
5552 | 5552 | |||
5553 | token = peek_token (&val, (unsigned *)0, cfile); | 5553 | token = peek_token (&val, (unsigned *)0, cfile); | |
5554 | if (token == NUMBER_OR_NAME || token == NUMBER) { | 5554 | if (token == NUMBER_OR_NAME || token == NUMBER) { | |
5555 | len = 0; | 5555 | len = 0; | |
5556 | do { | 5556 | do { | |
5557 | token = next_token (&val, (unsigned *)0, cfile); | 5557 | token = next_token (&val, (unsigned *)0, cfile); | |
5558 | if (token != NUMBER && token != NUMBER_OR_NAME) { | 5558 | if (token != NUMBER && token != NUMBER_OR_NAME) { | |
5559 | parse_warn (cfile, | 5559 | parse_warn (cfile, | |
5560 | "expecting hexadecimal constant."); | 5560 | "expecting hexadecimal constant."); | |
5561 | skip_to_semi (cfile); | 5561 | skip_to_semi (cfile); | |
5562 | return 0; | 5562 | return 0; | |
5563 | } | 5563 | } | |
5564 | convert_num (cfile, &buf [len], val, 16, 8); | 5564 | if (len >= max) { | |
5565 | if (len++ > max) { | |||
5566 | parse_warn (cfile, | 5565 | parse_warn (cfile, | |
5567 | "hexadecimal constant too long."); | 5566 | "hexadecimal constant too long."); | |
5568 | skip_to_semi (cfile); | 5567 | skip_to_semi (cfile); | |
5569 | return 0; | 5568 | return 0; | |
5570 | } | 5569 | } | |
5570 | convert_num (cfile, &buf [len], val, 16, 8); | |||
5571 | len++; | |||
5571 | token = peek_token (&val, (unsigned *)0, cfile); | 5572 | token = peek_token (&val, (unsigned *)0, cfile); | |
5572 | if (token == COLON) | 5573 | if (token == COLON) | |
5573 | token = next_token (&val, | 5574 | token = next_token (&val, | |
5574 | (unsigned *)0, cfile); | 5575 | (unsigned *)0, cfile); | |
5575 | } while (token == COLON); | 5576 | } while (token == COLON); | |
5576 | val = (char *)buf; | 5577 | val = (char *)buf; | |
5577 | } else if (token == STRING) { | 5578 | } else if (token == STRING) { | |
5578 | skip_token(&val, &len, cfile); | 5579 | skip_token(&val, &len, cfile); | |
5579 | if (len + 1 > max) { | 5580 | if (len + 1 > max) { | |
5580 | parse_warn (cfile, "string constant too long."); | 5581 | parse_warn (cfile, "string constant too long."); | |
5581 | skip_to_semi (cfile); | 5582 | skip_to_semi (cfile); | |
5582 | return 0; | 5583 | return 0; | |
5583 | } | 5584 | } |
--- src/external/mpl/dhcp/dist/common/tests/option_unittest.c 2018/04/07 22:37:29 1.2
+++ src/external/mpl/dhcp/dist/common/tests/option_unittest.c 2021/05/26 22:52:31 1.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: option_unittest.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ | 1 | /* $NetBSD: option_unittest.c,v 1.3 2021/05/26 22:52:31 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") | 4 | * Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") | |
5 | * | 5 | * | |
6 | * This Source Code Form is subject to the terms of the Mozilla Public | 6 | * This Source Code Form is subject to the terms of the Mozilla Public | |
7 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
9 | * | 9 | * | |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH | |
11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | |
12 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, | 12 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, | |
13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | |
15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
16 | * PERFORMANCE OF THIS SOFTWARE. | 16 | * PERFORMANCE OF THIS SOFTWARE. | |
17 | */ | 17 | */ | |
@@ -121,24 +121,108 @@ ATF_TC_BODY(pretty_print_option, tc) | @@ -121,24 +121,108 @@ ATF_TC_BODY(pretty_print_option, tc) | |||
121 | } | 121 | } | |
122 | 122 | |||
123 | 123 | |||
124 | /* Now we'll try a data value that's too large */ | 124 | /* Now we'll try a data value that's too large */ | |
125 | output_buf = pretty_print_option (option, bad_data, sizeof(bad_data), | 125 | output_buf = pretty_print_option (option, bad_data, sizeof(bad_data), | |
126 | emit_commas, emit_quotes); | 126 | emit_commas, emit_quotes); | |
127 | 127 | |||
128 | /* Make sure we safely get an error */ | 128 | /* Make sure we safely get an error */ | |
129 | if (!output_buf || strcmp(output_buf, "<error>")) { | 129 | if (!output_buf || strcmp(output_buf, "<error>")) { | |
130 | atf_tc_fail("pretty_print_option did not return \"<error>\""); | 130 | atf_tc_fail("pretty_print_option did not return \"<error>\""); | |
131 | } | 131 | } | |
132 | } | 132 | } | |
133 | 133 | |||
134 | ATF_TC(parse_X); | |||
135 | ||||
136 | ATF_TC_HEAD(parse_X, tc) | |||
137 | { | |||
138 | atf_tc_set_md_var(tc, "descr", | |||
139 | "Verify parse_X survices option too big."); | |||
140 | } | |||
141 | ||||
142 | /* Initializes a parse struct from an input buffer of data. */ | |||
143 | static void init_parse(struct parse *cfile, char* name, char *input) { | |||
144 | memset(cfile, 0, sizeof(struct parse)); | |||
145 | cfile->tlname = name; | |||
146 | cfile->lpos = cfile->line = 1; | |||
147 | cfile->cur_line = cfile->line1; | |||
148 | cfile->prev_line = cfile->line2; | |||
149 | cfile->token_line = cfile->cur_line; | |||
150 | cfile->cur_line[0] = cfile->prev_line[0] = 0; | |||
151 | cfile->file = -1; | |||
152 | cfile->eol_token = 0; | |||
153 | ||||
154 | cfile->inbuf = input; | |||
155 | cfile->buflen = strlen(input); | |||
156 | cfile->bufsiz = 0; | |||
157 | } | |||
158 | ||||
159 | /* | |||
160 | * This test verifies that parse_X does not overwrite the output | |||
161 | * buffer when given input data that exceeds the output buffer | |||
162 | * capacity. | |||
163 | */ | |||
164 | ATF_TC_BODY(parse_X, tc) | |||
165 | { | |||
166 | struct parse cfile; | |||
167 | u_int8_t output[10]; | |||
168 | unsigned len; | |||
169 | ||||
170 | /* Input hex literal */ | |||
171 | char *input = "01:02:03:04:05:06:07:08"; | |||
172 | unsigned expected_len = 8; | |||
173 | ||||
174 | /* Normal output plus two filler bytes */ | |||
175 | u_int8_t expected_plus_two[] = { | |||
176 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xff, 0xff | |||
177 | }; | |||
178 | ||||
179 | /* Safe output when option is too long */ | |||
180 | unsigned short_buf_len = 4; | |||
181 | u_int8_t expected_too_long[] = { | |||
182 | 0x01, 0x02, 0x03, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff | |||
183 | }; | |||
184 | ||||
185 | /* First we'll run one that works normally */ | |||
186 | memset(output, 0xff, sizeof(output)); | |||
187 | init_parse(&cfile, "hex_fits", input); | |||
188 | ||||
189 | len = parse_X(&cfile, output, expected_len); | |||
190 | ||||
191 | // Len should match the expected len. | |||
192 | if (len != expected_len) { | |||
193 | atf_tc_fail("parse_X failed, output len: %d", len); | |||
194 | } | |||
195 | ||||
196 | // We should not have written anything past the end of the buffer. | |||
197 | if (memcmp(output, expected_plus_two, sizeof(output))) { | |||
198 | atf_tc_fail("parse_X failed, output does not match expected"); | |||
199 | } | |||
200 | ||||
201 | // Now we'll try it with a buffer that's too small. | |||
202 | init_parse(&cfile, "hex_too_long", input); | |||
203 | memset(output, 0xff, sizeof(output)); | |||
204 | ||||
205 | len = parse_X(&cfile, output, short_buf_len); | |||
206 | ||||
207 | // On errors, len should be zero. | |||
208 | if (len != 0) { | |||
209 | atf_tc_fail("parse_X failed, we should have had an error"); | |||
210 | } | |||
211 | ||||
212 | // We should not have written anything past the end of the buffer. | |||
213 | if (memcmp(output, expected_too_long, sizeof(output))) { | |||
214 | atf_tc_fail("parse_X overwrote buffer!"); | |||
215 | } | |||
216 | } | |||
134 | 217 | |||
135 | /* This macro defines main() method that will call specified | 218 | /* This macro defines main() method that will call specified | |
136 | test cases. tp and simple_test_case names can be whatever you want | 219 | test cases. tp and simple_test_case names can be whatever you want | |
137 | as long as it is a valid variable identifier. */ | 220 | as long as it is a valid variable identifier. */ | |
138 | ATF_TP_ADD_TCS(tp) | 221 | ATF_TP_ADD_TCS(tp) | |
139 | { | 222 | { | |
140 | ATF_TP_ADD_TC(tp, option_refcnt); | 223 | ATF_TP_ADD_TC(tp, option_refcnt); | |
141 | ATF_TP_ADD_TC(tp, pretty_print_option); | 224 | ATF_TP_ADD_TC(tp, pretty_print_option); | |
225 | ATF_TP_ADD_TC(tp, parse_X); | |||
142 | 226 | |||
143 | return (atf_no_error()); | 227 | return (atf_no_error()); | |
144 | } | 228 | } |
--- src/external/mpl/dhcp/dist/relay/dhcrelay.c 2021/05/21 21:07:37 1.4
+++ src/external/mpl/dhcp/dist/relay/dhcrelay.c 2021/05/26 22:52:32 1.5
@@ -1,45 +1,45 @@ | @@ -1,45 +1,45 @@ | |||
1 | /* $NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $ */ | 1 | /* $NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $ */ | |
2 | 2 | |||
3 | /* dhcrelay.c | 3 | /* dhcrelay.c | |
4 | 4 | |||
5 | DHCP/BOOTP Relay Agent. */ | 5 | DHCP/BOOTP Relay Agent. */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright(c) 2004-2020 by Internet Systems Consortium, Inc.("ISC") | 8 | * Copyright(c) 2004-2021 by Internet Systems Consortium, Inc.("ISC") | |
9 | * Copyright(c) 1997-2003 by Internet Software Consortium | 9 | * Copyright(c) 1997-2003 by Internet Software Consortium | |
10 | * | 10 | * | |
11 | * This Source Code Form is subject to the terms of the Mozilla Public | 11 | * This Source Code Form is subject to the terms of the Mozilla Public | |
12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
14 | * | 14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | 15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | |
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | 17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | * | 22 | * | |
23 | * Internet Systems Consortium, Inc. | 23 | * Internet Systems Consortium, Inc. | |
24 | * 950 Charter Street | 24 | * 950 Charter Street | |
25 | * Redwood City, CA 94063 | 25 | * Redwood City, CA 94063 | |
26 | * <info@isc.org> | 26 | * <info@isc.org> | |
27 | * https://www.isc.org/ | 27 | * https://www.isc.org/ | |
28 | * | 28 | * | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __RCSID("$NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $"); | 32 | __RCSID("$NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $"); | |
33 | 33 | |||
34 | #include "dhcpd.h" | 34 | #include "dhcpd.h" | |
35 | #include <syslog.h> | 35 | #include <syslog.h> | |
36 | #include <signal.h> | 36 | #include <signal.h> | |
37 | #include <sys/time.h> | 37 | #include <sys/time.h> | |
38 | #include <isc/file.h> | 38 | #include <isc/file.h> | |
39 | 39 | |||
40 | TIME default_lease_time = 43200; /* 12 hours... */ | 40 | TIME default_lease_time = 43200; /* 12 hours... */ | |
41 | TIME max_lease_time = 86400; /* 24 hours... */ | 41 | TIME max_lease_time = 86400; /* 24 hours... */ | |
42 | struct tree_cache *global_options[256]; | 42 | struct tree_cache *global_options[256]; | |
43 | 43 | |||
44 | struct option *requested_opts[2]; | 44 | struct option *requested_opts[2]; | |
45 | 45 | |||
@@ -159,27 +159,27 @@ extern int add_relay_agent_options(struc | @@ -159,27 +159,27 @@ extern int add_relay_agent_options(struc | |||
159 | struct dhcp_packet *, unsigned, | 159 | struct dhcp_packet *, unsigned, | |
160 | struct in_addr); | 160 | struct in_addr); | |
161 | extern int find_interface_by_agent_option(struct dhcp_packet *, | 161 | extern int find_interface_by_agent_option(struct dhcp_packet *, | |
162 | struct interface_info **, u_int8_t *, int); | 162 | struct interface_info **, u_int8_t *, int); | |
163 | 163 | |||
164 | extern int strip_relay_agent_options(struct interface_info *, | 164 | extern int strip_relay_agent_options(struct interface_info *, | |
165 | struct interface_info **, | 165 | struct interface_info **, | |
166 | struct dhcp_packet *, unsigned); | 166 | struct dhcp_packet *, unsigned); | |
167 | 167 | |||
168 | #ifndef UNIT_TEST | 168 | #ifndef UNIT_TEST | |
169 | static void request_v4_interface(const char* name, int flags); | 169 | static void request_v4_interface(const char* name, int flags); | |
170 | 170 | |||
171 | static const char copyright[] = | 171 | static const char copyright[] = | |
172 | "Copyright 2004-2020 Internet Systems Consortium."; | 172 | "Copyright 2004-2021 Internet Systems Consortium."; | |
173 | static const char arr[] = "All rights reserved."; | 173 | static const char arr[] = "All rights reserved."; | |
174 | static const char message[] = | 174 | static const char message[] = | |
175 | "Internet Systems Consortium DHCP Relay Agent"; | 175 | "Internet Systems Consortium DHCP Relay Agent"; | |
176 | static const char url[] = | 176 | static const char url[] = | |
177 | "For info, please visit https://www.isc.org/software/dhcp/"; | 177 | "For info, please visit https://www.isc.org/software/dhcp/"; | |
178 | 178 | |||
179 | char *progname; | 179 | char *progname; | |
180 | 180 | |||
181 | #ifdef DHCPv6 | 181 | #ifdef DHCPv6 | |
182 | #ifdef RELAY_PORT | 182 | #ifdef RELAY_PORT | |
183 | #define DHCRELAY_USAGE \ | 183 | #define DHCRELAY_USAGE \ | |
184 | "Usage: %s [-4] [-d] [-q] [-a] [-D]\n" \ | 184 | "Usage: %s [-4] [-d] [-q] [-a] [-D]\n" \ | |
185 | " [-A <length>] [-c <hops>]\n" \ | 185 | " [-A <length>] [-c <hops>]\n" \ | |
@@ -254,27 +254,27 @@ char *progname; | @@ -254,27 +254,27 @@ char *progname; | |||
254 | * If the user has provided an incorrect command line print out | 254 | * If the user has provided an incorrect command line print out | |
255 | * the description of the command line. The arguments provide | 255 | * the description of the command line. The arguments provide | |
256 | * a way for the caller to request more specific information about | 256 | * a way for the caller to request more specific information about | |
257 | * the error be printed as well. Mostly this will be that some | 257 | * the error be printed as well. Mostly this will be that some | |
258 | * comamnd doesn't include its argument. | 258 | * comamnd doesn't include its argument. | |
259 | * | 259 | * | |
260 | * \param sfmt - The basic string and format for the specific error | 260 | * \param sfmt - The basic string and format for the specific error | |
261 | * \param sarg - Generally the offending argument from the comamnd line. | 261 | * \param sarg - Generally the offending argument from the comamnd line. | |
262 | * | 262 | * | |
263 | * \return Nothing | 263 | * \return Nothing | |
264 | */ | 264 | */ | |
265 | 265 | |||
266 | #include <sys/cdefs.h> | 266 | #include <sys/cdefs.h> | |
267 | __RCSID("$NetBSD: dhcrelay.c,v 1.4 2021/05/21 21:07:37 christos Exp $"); | 267 | __RCSID("$NetBSD: dhcrelay.c,v 1.5 2021/05/26 22:52:32 christos Exp $"); | |
268 | static const char use_noarg[] = "No argument for command: %s"; | 268 | static const char use_noarg[] = "No argument for command: %s"; | |
269 | #ifdef RELAY_PORT | 269 | #ifdef RELAY_PORT | |
270 | static const char use_port_defined[] = "Port already set, %s inappropriate"; | 270 | static const char use_port_defined[] = "Port already set, %s inappropriate"; | |
271 | #if !defined (USE_BPF_RECEIVE) && !defined (USE_LPF_RECEIVE) | 271 | #if !defined (USE_BPF_RECEIVE) && !defined (USE_LPF_RECEIVE) | |
272 | static const char bpf_sock_support[] = "Only LPF and BPF are supported: %s"; | 272 | static const char bpf_sock_support[] = "Only LPF and BPF are supported: %s"; | |
273 | #endif | 273 | #endif | |
274 | #endif | 274 | #endif | |
275 | #ifdef DHCPv6 | 275 | #ifdef DHCPv6 | |
276 | static const char use_badproto[] = "Protocol already set, %s inappropriate"; | 276 | static const char use_badproto[] = "Protocol already set, %s inappropriate"; | |
277 | static const char use_v4command[] = "Command not used for DHCPv6: %s"; | 277 | static const char use_v4command[] = "Command not used for DHCPv6: %s"; | |
278 | static const char use_v6command[] = "Command not used for DHCPv4: %s"; | 278 | static const char use_v6command[] = "Command not used for DHCPv4: %s"; | |
279 | #endif | 279 | #endif | |
280 | 280 | |||
@@ -1455,28 +1455,29 @@ add_relay_agent_options(struct interface | @@ -1455,28 +1455,29 @@ add_relay_agent_options(struct interface | |||
1455 | 1455 | |||
1456 | /* Recalculate total packet length. */ | 1456 | /* Recalculate total packet length. */ | |
1457 | length = sp -((u_int8_t *)packet); | 1457 | length = sp -((u_int8_t *)packet); | |
1458 | 1458 | |||
1459 | /* Make sure the packet isn't short(this is unlikely, but WTH) */ | 1459 | /* Make sure the packet isn't short(this is unlikely, but WTH) */ | |
1460 | if (length < BOOTP_MIN_LEN) { | 1460 | if (length < BOOTP_MIN_LEN) { | |
1461 | memset(sp, DHO_PAD, BOOTP_MIN_LEN - length); | 1461 | memset(sp, DHO_PAD, BOOTP_MIN_LEN - length); | |
1462 | return (BOOTP_MIN_LEN); | 1462 | return (BOOTP_MIN_LEN); | |
1463 | } | 1463 | } | |
1464 | 1464 | |||
1465 | return (length); | 1465 | return (length); | |
1466 | } | 1466 | } | |
1467 | 1467 | |||
1468 | #ifdef DHCPv6 | |||
1469 | #ifndef UNIT_TEST | 1468 | #ifndef UNIT_TEST | |
1469 | ||||
1470 | #ifdef DHCPv6 | |||
1470 | /* | 1471 | /* | |
1471 | * Parse a downstream argument: [address%]interface[#index]. | 1472 | * Parse a downstream argument: [address%]interface[#index]. | |
1472 | */ | 1473 | */ | |
1473 | static struct stream_list * | 1474 | static struct stream_list * | |
1474 | parse_downstream(char *arg) { | 1475 | parse_downstream(char *arg) { | |
1475 | struct stream_list *dp, *up; | 1476 | struct stream_list *dp, *up; | |
1476 | struct interface_info *ifp = NULL; | 1477 | struct interface_info *ifp = NULL; | |
1477 | char *ifname, *addr, *iid; | 1478 | char *ifname, *addr, *iid; | |
1478 | isc_result_t status; | 1479 | isc_result_t status; | |
1479 | 1480 | |||
1480 | if (!supports_multiple_interfaces(ifp) && | 1481 | if (!supports_multiple_interfaces(ifp) && | |
1481 | (downstreams != NULL)) | 1482 | (downstreams != NULL)) | |
1482 | log_fatal("No support for multiple interfaces."); | 1483 | log_fatal("No support for multiple interfaces."); | |
@@ -2041,59 +2042,56 @@ process_down6(struct packet *packet) { | @@ -2041,59 +2042,56 @@ process_down6(struct packet *packet) { | |||
2041 | goto cleanup; | 2042 | goto cleanup; | |
2042 | } | 2043 | } | |
2043 | 2044 | |||
2044 | /* Send the message to the downstream. */ | 2045 | /* Send the message to the downstream. */ | |
2045 | send_packet6(dp->ifp, (unsigned char *) relay_msg.data, | 2046 | send_packet6(dp->ifp, (unsigned char *) relay_msg.data, | |
2046 | (size_t) relay_msg.len, &to); | 2047 | (size_t) relay_msg.len, &to); | |
2047 | 2048 | |||
2048 | cleanup: | 2049 | cleanup: | |
2049 | if (relay_msg.data != NULL) | 2050 | if (relay_msg.data != NULL) | |
2050 | data_string_forget(&relay_msg, MDL); | 2051 | data_string_forget(&relay_msg, MDL); | |
2051 | if (if_id.data != NULL) | 2052 | if (if_id.data != NULL) | |
2052 | data_string_forget(&if_id, MDL); | 2053 | data_string_forget(&if_id, MDL); | |
2053 | } | 2054 | } | |
2054 | #endif /* UNIT_TEST */ | |||
2055 | 2055 | |||
2056 | /* | 2056 | /* | |
2057 | * Called by the dispatch packet handler with a decoded packet. | 2057 | * Called by the dispatch packet handler with a decoded packet. | |
2058 | */ | 2058 | */ | |
2059 | void | 2059 | void | |
2060 | dhcpv6(struct packet *packet) { | 2060 | dhcpv6(struct packet *packet) { | |
2061 | #ifndef UNIT_TEST | |||
2062 | struct stream_list *dp; | 2061 | struct stream_list *dp; | |
2063 | 2062 | |||
2064 | /* Try all relay-replies downwards. */ | 2063 | /* Try all relay-replies downwards. */ | |
2065 | if (packet->dhcpv6_msg_type == DHCPV6_RELAY_REPL) { | 2064 | if (packet->dhcpv6_msg_type == DHCPV6_RELAY_REPL) { | |
2066 | process_down6(packet); | 2065 | process_down6(packet); | |
2067 | return; | 2066 | return; | |
2068 | } | 2067 | } | |
2069 | /* Others are candidates to go up if they come from down. */ | 2068 | /* Others are candidates to go up if they come from down. */ | |
2070 | for (dp = downstreams; dp; dp = dp->next) { | 2069 | for (dp = downstreams; dp; dp = dp->next) { | |
2071 | if (packet->interface != dp->ifp) | 2070 | if (packet->interface != dp->ifp) | |
2072 | continue; | 2071 | continue; | |
2073 | process_up6(packet, dp); | 2072 | process_up6(packet, dp); | |
2074 | return; | 2073 | return; | |
2075 | } | 2074 | } | |
2076 | /* Relay-forward could work from an unknown interface. */ | 2075 | /* Relay-forward could work from an unknown interface. */ | |
2077 | if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) { | 2076 | if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) { | |
2078 | process_up6(packet, NULL); | 2077 | process_up6(packet, NULL); | |
2079 | return; | 2078 | return; | |
2080 | } | 2079 | } | |
2081 | 2080 | |||
2082 | log_info("Can't process packet from interface '%s'.", | 2081 | log_info("Can't process packet from interface '%s'.", | |
2083 | packet->interface->name); | 2082 | packet->interface->name); | |
2084 | #endif /* UNIT_TEST */ | |||
2085 | } | 2083 | } | |
2086 | #endif /* DHCPv6 */ | 2084 | #endif | |
2087 | 2085 | |||
2088 | /* Stub routines needed for linking with DHCP libraries. */ | 2086 | /* Stub routines needed for linking with DHCP libraries. */ | |
2089 | void | 2087 | void | |
2090 | bootp(struct packet *packet) { | 2088 | bootp(struct packet *packet) { | |
2091 | return; | 2089 | return; | |
2092 | } | 2090 | } | |
2093 | 2091 | |||
2094 | void | 2092 | void | |
2095 | dhcp(struct packet *packet) { | 2093 | dhcp(struct packet *packet) { | |
2096 | return; | 2094 | return; | |
2097 | } | 2095 | } | |
2098 | 2096 | |||
2099 | #if defined(DHCPv6) && defined(DHCP4o6) | 2097 | #if defined(DHCPv6) && defined(DHCP4o6) | |
@@ -2171,13 +2169,14 @@ void request_v4_interface(const char* na | @@ -2171,13 +2169,14 @@ void request_v4_interface(const char* na | |||
2171 | if (status != ISC_R_SUCCESS) { | 2169 | if (status != ISC_R_SUCCESS) { | |
2172 | log_fatal("%s: interface_allocate: %s", name, | 2170 | log_fatal("%s: interface_allocate: %s", name, | |
2173 | isc_result_totext(status)); | 2171 | isc_result_totext(status)); | |
2174 | } | 2172 | } | |
2175 | 2173 | |||
2176 | log_debug("Requesting: %s as upstream: %c downstream: %c", name, | 2174 | log_debug("Requesting: %s as upstream: %c downstream: %c", name, | |
2177 | (flags & INTERFACE_UPSTREAM ? 'Y' : 'N'), | 2175 | (flags & INTERFACE_UPSTREAM ? 'Y' : 'N'), | |
2178 | (flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N')); | 2176 | (flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N')); | |
2179 | 2177 | |||
2180 | memcpy(tmp->name, name, len); | 2178 | memcpy(tmp->name, name, len); | |
2181 | interface_snorf(tmp, (INTERFACE_REQUESTED | flags)); | 2179 | interface_snorf(tmp, (INTERFACE_REQUESTED | flags)); | |
2182 | interface_dereference(&tmp, MDL); | 2180 | interface_dereference(&tmp, MDL); | |
2183 | } | 2181 | } | |
2182 | #endif /* UNIT_TEST */ |
--- src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c 2020/08/03 21:10:57 1.2
+++ src/external/mpl/dhcp/dist/relay/tests/relay_unittests.c 2021/05/26 22:52:32 1.3
@@ -1,40 +1,40 @@ | @@ -1,40 +1,40 @@ | |||
1 | /* $NetBSD: relay_unittests.c,v 1.2 2020/08/03 21:10:57 christos Exp $ */ | 1 | /* $NetBSD: relay_unittests.c,v 1.3 2021/05/26 22:52:32 christos Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2019-2020 by Internet Systems Consortium, Inc. ("ISC") | 4 | * Copyright (c) 2019-2020 by Internet Systems Consortium, Inc. ("ISC") | |
5 | * | 5 | * | |
6 | * This Source Code Form is subject to the terms of the Mozilla Public | 6 | * This Source Code Form is subject to the terms of the Mozilla Public | |
7 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
9 | * | 9 | * | |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
16 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 | * | 17 | * | |
18 | * Internet Systems Consortium, Inc. | 18 | * Internet Systems Consortium, Inc. | |
19 | * 950 Charter Street | 19 | * 950 Charter Street | |
20 | * Redwood City, CA 94063 | 20 | * Redwood City, CA 94063 | |
21 | * <info@isc.org> | 21 | * <info@isc.org> | |
22 | * https://www.isc.org/ | 22 | * https://www.isc.org/ | |
23 | * | 23 | * | |
24 | */ | 24 | */ | |
25 | 25 | |||
26 | #include <sys/cdefs.h> | 26 | #include <sys/cdefs.h> | |
27 | __RCSID("$NetBSD: relay_unittests.c,v 1.2 2020/08/03 21:10:57 christos Exp $"); | 27 | __RCSID("$NetBSD: relay_unittests.c,v 1.3 2021/05/26 22:52:32 christos Exp $"); | |
28 | 28 | |||
29 | #include "config.h" | 29 | #include "config.h" | |
30 | #include <atf-c.h> | 30 | #include <atf-c.h> | |
31 | #include <omapip/omapip_p.h> | 31 | #include <omapip/omapip_p.h> | |
32 | #include "dhcpd.h" | 32 | #include "dhcpd.h" | |
33 | 33 | |||
34 | /* @brief Externs for dhcrelay.c functions under test */ | 34 | /* @brief Externs for dhcrelay.c functions under test */ | |
35 | extern int add_agent_options; | 35 | extern int add_agent_options; | |
36 | extern int add_relay_agent_options(struct interface_info *, | 36 | extern int add_relay_agent_options(struct interface_info *, | |
37 | struct dhcp_packet *, unsigned, | 37 | struct dhcp_packet *, unsigned, | |
38 | struct in_addr); | 38 | struct in_addr); | |
39 | 39 | |||
40 | extern int find_interface_by_agent_option(struct dhcp_packet *, | 40 | extern int find_interface_by_agent_option(struct dhcp_packet *, | |
@@ -401,13 +401,39 @@ ATF_TC_BODY(add_relay_agent_options_test | @@ -401,13 +401,39 @@ ATF_TC_BODY(add_relay_agent_options_test | |||
401 | if (check_with_pad(packet.options, output_data, sizeof(output_data), | 401 | if (check_with_pad(packet.options, output_data, sizeof(output_data), | |
402 | pad) != 0) { | 402 | pad) != 0) { | |
403 | atf_tc_fail("input_data2: expected output does not match"); | 403 | atf_tc_fail("input_data2: expected output does not match"); | |
404 | } | 404 | } | |
405 | } | 405 | } | |
406 | } | 406 | } | |
407 | 407 | |||
408 | ATF_TP_ADD_TCS(tp) { | 408 | ATF_TP_ADD_TCS(tp) { | |
409 | ATF_TP_ADD_TC(tp, strip_relay_agent_options_test); | 409 | ATF_TP_ADD_TC(tp, strip_relay_agent_options_test); | |
410 | ATF_TP_ADD_TC(tp, add_relay_agent_options_test); | 410 | ATF_TP_ADD_TC(tp, add_relay_agent_options_test); | |
411 | 411 | |||
412 | return (atf_no_error()); | 412 | return (atf_no_error()); | |
413 | } | 413 | } | |
414 | ||||
415 | /* Below are dummy function definitions to satisfy "required" symbols */ | |||
416 | isc_result_t find_class (struct class **c, const char *s, | |||
417 | const char *file, int line) { | |||
418 | return 0; | |||
419 | } | |||
420 | ||||
421 | int check_collection (struct packet *packet, struct lease *lease, | |||
422 | struct collection *collection) { | |||
423 | return 0; | |||
424 | } | |||
425 | ||||
426 | void classify (struct packet *packet, struct class *class){} | |||
427 | void bootp(struct packet *packet){} | |||
428 | void dhcp(struct packet *packet){} | |||
429 | void dhcpv6(struct packet *packet){} | |||
430 | ||||
431 | int parse_allow_deny (struct option_cache **oc, struct parse *cfile, | |||
432 | int flag) { | |||
433 | return 0; | |||
434 | } | |||
435 | ||||
436 | isc_result_t dhcp_set_control_state (control_object_state_t oldstate, | |||
437 | control_object_state_t newstate) { | |||
438 | return (ISC_R_SUCCESS); | |||
439 | } |
--- src/external/mpl/dhcp/dist/server/dhcpd.c 2020/08/03 21:10:57 1.3
+++ src/external/mpl/dhcp/dist/server/dhcpd.c 2021/05/26 22:52:32 1.4
@@ -1,48 +1,48 @@ | @@ -1,48 +1,48 @@ | |||
1 | /* $NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $ */ | 1 | /* $NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $ */ | |
2 | 2 | |||
3 | /* dhcpd.c | 3 | /* dhcpd.c | |
4 | 4 | |||
5 | DHCP Server Daemon. */ | 5 | DHCP Server Daemon. */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 2004-2020 by Internet Systems Consortium, Inc. ("ISC") | 8 | * Copyright (c) 2004-2021 by Internet Systems Consortium, Inc. ("ISC") | |
9 | * Copyright (c) 1996-2003 by Internet Software Consortium | 9 | * Copyright (c) 1996-2003 by Internet Software Consortium | |
10 | * | 10 | * | |
11 | * This Source Code Form is subject to the terms of the Mozilla Public | 11 | * This Source Code Form is subject to the terms of the Mozilla Public | |
12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | 12 | * License, v. 2.0. If a copy of the MPL was not distributed with this | |
13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 13 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
14 | * | 14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | 15 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES | |
16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 16 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | 17 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR | |
18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 18 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 19 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 20 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 21 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | * | 22 | * | |
23 | * Internet Systems Consortium, Inc. | 23 | * Internet Systems Consortium, Inc. | |
24 | * 950 Charter Street | 24 | * 950 Charter Street | |
25 | * Redwood City, CA 94063 | 25 | * Redwood City, CA 94063 | |
26 | * <info@isc.org> | 26 | * <info@isc.org> | |
27 | * https://www.isc.org/ | 27 | * https://www.isc.org/ | |
28 | * | 28 | * | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __RCSID("$NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $"); | 32 | __RCSID("$NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $"); | |
33 | 33 | |||
34 | static const char copyright[] = | 34 | static const char copyright[] = | |
35 | "Copyright 2004-2020 Internet Systems Consortium."; | 35 | "Copyright 2004-2021 Internet Systems Consortium."; | |
36 | static const char arr [] = "All rights reserved."; | 36 | static const char arr [] = "All rights reserved."; | |
37 | static const char message [] = "Internet Systems Consortium DHCP Server"; | 37 | static const char message [] = "Internet Systems Consortium DHCP Server"; | |
38 | static const char url [] = | 38 | static const char url [] = | |
39 | "For info, please visit https://www.isc.org/software/dhcp/"; | 39 | "For info, please visit https://www.isc.org/software/dhcp/"; | |
40 | 40 | |||
41 | #include "dhcpd.h" | 41 | #include "dhcpd.h" | |
42 | #include <omapip/omapip_p.h> | 42 | #include <omapip/omapip_p.h> | |
43 | #include <syslog.h> | 43 | #include <syslog.h> | |
44 | #include <signal.h> | 44 | #include <signal.h> | |
45 | #include <errno.h> | 45 | #include <errno.h> | |
46 | #include <limits.h> | 46 | #include <limits.h> | |
47 | #include <sys/types.h> | 47 | #include <sys/types.h> | |
48 | #include <sys/time.h> | 48 | #include <sys/time.h> | |
@@ -216,27 +216,27 @@ static void omapi_listener_start (void * | @@ -216,27 +216,27 @@ static void omapi_listener_start (void * | |||
216 | * If the user has provided an incorrect command line print out | 216 | * If the user has provided an incorrect command line print out | |
217 | * the description of the command line. The arguments provide | 217 | * the description of the command line. The arguments provide | |
218 | * a way for the caller to request more specific information about | 218 | * a way for the caller to request more specific information about | |
219 | * the error be printed as well. Mostly this will be that some | 219 | * the error be printed as well. Mostly this will be that some | |
220 | * comamnd doesn't include its argument. | 220 | * comamnd doesn't include its argument. | |
221 | * | 221 | * | |
222 | * \param sfmt - The basic string and format for the specific error | 222 | * \param sfmt - The basic string and format for the specific error | |
223 | * \param sarg - Generally the offending argument from the comamnd line. | 223 | * \param sarg - Generally the offending argument from the comamnd line. | |
224 | * | 224 | * | |
225 | * \return Nothing | 225 | * \return Nothing | |
226 | */ | 226 | */ | |
227 | 227 | |||
228 | #include <sys/cdefs.h> | 228 | #include <sys/cdefs.h> | |
229 | __RCSID("$NetBSD: dhcpd.c,v 1.3 2020/08/03 21:10:57 christos Exp $"); | 229 | __RCSID("$NetBSD: dhcpd.c,v 1.4 2021/05/26 22:52:32 christos Exp $"); | |
230 | static char use_noarg[] = "No argument for command: %s "; | 230 | static char use_noarg[] = "No argument for command: %s "; | |
231 | 231 | |||
232 | static void | 232 | static void | |
233 | usage(const char *sfmt, const char *sarg) { | 233 | usage(const char *sfmt, const char *sarg) { | |
234 | log_info("%s %s", message, PACKAGE_VERSION); | 234 | log_info("%s %s", message, PACKAGE_VERSION); | |
235 | log_info(copyright); | 235 | log_info(copyright); | |
236 | log_info(arr); | 236 | log_info(arr); | |
237 | log_info(url); | 237 | log_info(url); | |
238 | 238 | |||
239 | /* If desired print out the specific error message */ | 239 | /* If desired print out the specific error message */ | |
240 | #ifdef PRINT_SPECIFIC_CL_ERRORS | 240 | #ifdef PRINT_SPECIFIC_CL_ERRORS | |
241 | if (sfmt != NULL) | 241 | if (sfmt != NULL) | |
242 | log_error(sfmt, sarg); | 242 | log_error(sfmt, sarg); |