diff options
-rw-r--r-- | networking/udhcp/common.c | 3 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 3 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 78 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 2 |
4 files changed, 36 insertions, 50 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 684d76b2b..7929950f5 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
@@ -49,6 +49,7 @@ const struct dhcp_optflag dhcp_optflags[] = { | |||
49 | { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */ | 49 | { OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */ |
50 | { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */ | 50 | { OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */ |
51 | { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */ | 51 | { OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */ |
52 | { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */ | ||
52 | //TODO: must be combined with 'sname' and 'file' handling: | 53 | //TODO: must be combined with 'sname' and 'file' handling: |
53 | { OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */ | 54 | { OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */ |
54 | { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */ | 55 | { OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */ |
@@ -83,7 +84,6 @@ const struct dhcp_optflag dhcp_optflags[] = { | |||
83 | { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */ | 84 | { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */ |
84 | { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ | 85 | { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ |
85 | //looks like these opts will work just fine even without these defs: | 86 | //looks like these opts will work just fine even without these defs: |
86 | // { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */ | ||
87 | // /* not really a string: */ | 87 | // /* not really a string: */ |
88 | // { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */ | 88 | // { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */ |
89 | { 0, 0 } /* zeroed terminating entry */ | 89 | { 0, 0 } /* zeroed terminating entry */ |
@@ -120,6 +120,7 @@ const char dhcp_option_strings[] ALIGN1 = | |||
120 | "lease" "\0" /* DHCP_LEASE_TIME */ | 120 | "lease" "\0" /* DHCP_LEASE_TIME */ |
121 | "serverid" "\0" /* DHCP_SERVER_ID */ | 121 | "serverid" "\0" /* DHCP_SERVER_ID */ |
122 | "message" "\0" /* DHCP_ERR_MESSAGE */ | 122 | "message" "\0" /* DHCP_ERR_MESSAGE */ |
123 | "vendor" "\0" /* DHCP_VENDOR */ | ||
123 | "tftp" "\0" /* DHCP_TFTP_SERVER_NAME*/ | 124 | "tftp" "\0" /* DHCP_TFTP_SERVER_NAME*/ |
124 | "bootfile" "\0" /* DHCP_BOOT_FILE */ | 125 | "bootfile" "\0" /* DHCP_BOOT_FILE */ |
125 | // "userclass" "\0" /* DHCP_USER_CLASS */ | 126 | // "userclass" "\0" /* DHCP_USER_CLASS */ |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index c4bedb259..3fd1fa7ce 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -1296,7 +1296,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1296 | /* not set, set the default client ID */ | 1296 | /* not set, set the default client ID */ |
1297 | client_data.clientid[1] = 3; /* DUID-LL */ | 1297 | client_data.clientid[1] = 3; /* DUID-LL */ |
1298 | client_data.clientid[3] = 1; /* ethernet */ | 1298 | client_data.clientid[3] = 1; /* ethernet */ |
1299 | clientid_mac_ptr = udhcp_insert_new_option(&client_data.options, D6_OPT_CLIENTID, | 1299 | clientid_mac_ptr = udhcp_insert_new_option( |
1300 | &client_data.options, D6_OPT_CLIENTID, | ||
1300 | client_data.clientid, 2+2 + 6, /*dhcp6:*/ 1); | 1301 | client_data.clientid, 2+2 + 6, /*dhcp6:*/ 1); |
1301 | clientid_mac_ptr += 2+2 + 2+2; /* skip option code, len, DUID-LL, ethernet */ | 1302 | clientid_mac_ptr += 2+2 + 2+2; /* skip option code, len, DUID-LL, ethernet */ |
1302 | } | 1303 | } |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index a06eeaa16..16228f048 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -55,8 +55,7 @@ struct tpacket_auxdata { | |||
55 | #if ENABLE_LONG_OPTS | 55 | #if ENABLE_LONG_OPTS |
56 | static const char udhcpc_longopts[] ALIGN1 = | 56 | static const char udhcpc_longopts[] ALIGN1 = |
57 | "clientid-none\0" No_argument "C" | 57 | "clientid-none\0" No_argument "C" |
58 | "vendorclass\0" Required_argument "V" | 58 | "vendorclass\0" Required_argument "V" //deprecated |
59 | "hostname\0" Required_argument "H" | ||
60 | "fqdn\0" Required_argument "F" | 59 | "fqdn\0" Required_argument "F" |
61 | "interface\0" Required_argument "i" | 60 | "interface\0" Required_argument "i" |
62 | "now\0" No_argument "n" | 61 | "now\0" No_argument "n" |
@@ -84,27 +83,25 @@ static const char udhcpc_longopts[] ALIGN1 = | |||
84 | enum { | 83 | enum { |
85 | OPT_C = 1 << 0, | 84 | OPT_C = 1 << 0, |
86 | OPT_V = 1 << 1, | 85 | OPT_V = 1 << 1, |
87 | OPT_H = 1 << 2, | 86 | OPT_F = 1 << 2, |
88 | OPT_h = 1 << 3, | 87 | OPT_i = 1 << 3, |
89 | OPT_F = 1 << 4, | 88 | OPT_n = 1 << 4, |
90 | OPT_i = 1 << 5, | 89 | OPT_p = 1 << 5, |
91 | OPT_n = 1 << 6, | 90 | OPT_q = 1 << 6, |
92 | OPT_p = 1 << 7, | 91 | OPT_R = 1 << 7, |
93 | OPT_q = 1 << 8, | 92 | OPT_r = 1 << 8, |
94 | OPT_R = 1 << 9, | 93 | OPT_s = 1 << 9, |
95 | OPT_r = 1 << 10, | 94 | OPT_T = 1 << 10, |
96 | OPT_s = 1 << 11, | 95 | OPT_t = 1 << 11, |
97 | OPT_T = 1 << 12, | 96 | OPT_S = 1 << 12, |
98 | OPT_t = 1 << 13, | 97 | OPT_A = 1 << 13, |
99 | OPT_S = 1 << 14, | 98 | OPT_O = 1 << 14, |
100 | OPT_A = 1 << 15, | 99 | OPT_o = 1 << 15, |
101 | OPT_O = 1 << 16, | 100 | OPT_x = 1 << 16, |
102 | OPT_o = 1 << 17, | 101 | OPT_f = 1 << 17, |
103 | OPT_x = 1 << 18, | 102 | OPT_B = 1 << 18, |
104 | OPT_f = 1 << 19, | ||
105 | OPT_B = 1 << 20, | ||
106 | /* The rest has variable bit positions, need to be clever */ | 103 | /* The rest has variable bit positions, need to be clever */ |
107 | OPTBIT_B = 20, | 104 | OPTBIT_B = 18, |
108 | USE_FOR_MMU( OPTBIT_b,) | 105 | USE_FOR_MMU( OPTBIT_b,) |
109 | IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,) | 106 | IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,) |
110 | IF_FEATURE_UDHCP_PORT( OPTBIT_P,) | 107 | IF_FEATURE_UDHCP_PORT( OPTBIT_P,) |
@@ -638,10 +635,6 @@ static void add_client_options(struct dhcp_packet *packet) | |||
638 | packet->options[end + OPT_DATA + len] = DHCP_END; | 635 | packet->options[end + OPT_DATA + len] = DHCP_END; |
639 | } | 636 | } |
640 | 637 | ||
641 | if (client_data.vendorclass) | ||
642 | udhcp_add_binary_option(packet, client_data.vendorclass); | ||
643 | if (client_data.hostname) | ||
644 | udhcp_add_binary_option(packet, client_data.hostname); | ||
645 | if (client_data.fqdn) | 638 | if (client_data.fqdn) |
646 | udhcp_add_binary_option(packet, client_data.fqdn); | 639 | udhcp_add_binary_option(packet, client_data.fqdn); |
647 | 640 | ||
@@ -722,7 +715,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested) | |||
722 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); | 715 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); |
723 | 716 | ||
724 | /* Add options: maxsize, | 717 | /* Add options: maxsize, |
725 | * optionally: hostname, fqdn, vendorclass, client-id, | 718 | * optionally: fqdn, client-id, |
726 | * "param req" option according to -O, options specified with -x | 719 | * "param req" option according to -O, options specified with -x |
727 | */ | 720 | */ |
728 | add_client_options(&packet); | 721 | add_client_options(&packet); |
@@ -766,7 +759,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
766 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); | 759 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); |
767 | 760 | ||
768 | /* Add options: maxsize, | 761 | /* Add options: maxsize, |
769 | * optionally: hostname, fqdn, vendorclass, client-id, | 762 | * optionally: fqdn, client-id, |
770 | * "param req" option according to -O, and options specified with -x | 763 | * "param req" option according to -O, and options specified with -x |
771 | */ | 764 | */ |
772 | add_client_options(&packet); | 765 | add_client_options(&packet); |
@@ -811,7 +804,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | |||
811 | packet.ciaddr = ciaddr; | 804 | packet.ciaddr = ciaddr; |
812 | 805 | ||
813 | /* Add options: maxsize, | 806 | /* Add options: maxsize, |
814 | * optionally: hostname, fqdn, vendorclass, client-id, | 807 | * optionally: fqdn, client-id, |
815 | * "param req" option according to -O, and options specified with -x | 808 | * "param req" option according to -O, and options specified with -x |
816 | */ | 809 | */ |
817 | add_client_options(&packet); | 810 | add_client_options(&packet); |
@@ -1236,7 +1229,7 @@ int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
1236 | int udhcpc_main(int argc UNUSED_PARAM, char **argv) | 1229 | int udhcpc_main(int argc UNUSED_PARAM, char **argv) |
1237 | { | 1230 | { |
1238 | uint8_t *message; | 1231 | uint8_t *message; |
1239 | const char *str_V, *str_h, *str_F, *str_r; | 1232 | const char *str_V, *str_F, *str_r; |
1240 | IF_FEATURE_UDHCPC_ARPING(const char *str_a = "2000";) | 1233 | IF_FEATURE_UDHCPC_ARPING(const char *str_a = "2000";) |
1241 | IF_FEATURE_UDHCP_PORT(char *str_P;) | 1234 | IF_FEATURE_UDHCP_PORT(char *str_P;) |
1242 | uint8_t *clientid_mac_ptr; | 1235 | uint8_t *clientid_mac_ptr; |
@@ -1272,14 +1265,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1272 | /* Parse command line */ | 1265 | /* Parse command line */ |
1273 | opt = getopt32long(argv, "^" | 1266 | opt = getopt32long(argv, "^" |
1274 | /* O,x: list; -T,-t,-A take numeric param */ | 1267 | /* O,x: list; -T,-t,-A take numeric param */ |
1275 | "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB" | 1268 | "CV:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB" |
1276 | USE_FOR_MMU("b") | 1269 | USE_FOR_MMU("b") |
1277 | IF_FEATURE_UDHCPC_ARPING("a::") | 1270 | IF_FEATURE_UDHCPC_ARPING("a::") |
1278 | IF_FEATURE_UDHCP_PORT("P:") | 1271 | IF_FEATURE_UDHCP_PORT("P:") |
1279 | "v" | 1272 | "v" |
1280 | "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ | 1273 | "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ |
1281 | , udhcpc_longopts | 1274 | , udhcpc_longopts |
1282 | , &str_V, &str_h, &str_h, &str_F | 1275 | , &str_V, &str_F |
1283 | , &client_data.interface, &client_data.pidfile /* i,p */ | 1276 | , &client_data.interface, &client_data.pidfile /* i,p */ |
1284 | , &str_r /* r */ | 1277 | , &str_r /* r */ |
1285 | , &client_data.script /* s */ | 1278 | , &client_data.script /* s */ |
@@ -1290,11 +1283,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1290 | IF_FEATURE_UDHCP_PORT(, &str_P) | 1283 | IF_FEATURE_UDHCP_PORT(, &str_P) |
1291 | IF_UDHCP_VERBOSE(, &dhcp_verbose) | 1284 | IF_UDHCP_VERBOSE(, &dhcp_verbose) |
1292 | ); | 1285 | ); |
1293 | if (opt & (OPT_h|OPT_H)) { | ||
1294 | //msg added 2011-11 | ||
1295 | bb_simple_error_msg("option -h NAME is deprecated, use -x hostname:NAME"); | ||
1296 | client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0); | ||
1297 | } | ||
1298 | if (opt & OPT_F) { | 1286 | if (opt & OPT_F) { |
1299 | /* FQDN option format: [0x51][len][flags][0][0]<fqdn> */ | 1287 | /* FQDN option format: [0x51][len][flags][0][0]<fqdn> */ |
1300 | client_data.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3); | 1288 | client_data.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3); |
@@ -1344,6 +1332,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1344 | ); | 1332 | ); |
1345 | free(optstr); | 1333 | free(optstr); |
1346 | } | 1334 | } |
1335 | if (str_V[0] != '\0') { | ||
1336 | //msg added 2021-06 | ||
1337 | bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR"); | ||
1338 | udhcp_insert_new_option( | ||
1339 | &client_data.options, DHCP_VENDOR, | ||
1340 | str_V, strlen(str_V), /*dhcp6:*/ 0); | ||
1341 | } | ||
1347 | 1342 | ||
1348 | if (udhcp_read_interface(client_data.interface, | 1343 | if (udhcp_read_interface(client_data.interface, |
1349 | &client_data.ifindex, | 1344 | &client_data.ifindex, |
@@ -1362,15 +1357,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1362 | client_data_client_mac - 1, 1 + 6, /*dhcp6:*/ 0); | 1357 | client_data_client_mac - 1, 1 + 6, /*dhcp6:*/ 0); |
1363 | clientid_mac_ptr += 3; /* skip option code, len, ethernet */ | 1358 | clientid_mac_ptr += 3; /* skip option code, len, ethernet */ |
1364 | } | 1359 | } |
1365 | if (str_V[0] != '\0') { | ||
1366 | // can drop -V, str_V, client_data.vendorclass, | ||
1367 | // but need to add "vendor" to the list of recognized | ||
1368 | // string opts for this to work; | ||
1369 | // and need to tweak add_client_options() too... | ||
1370 | // ...so the question is, should we? | ||
1371 | //bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR"); | ||
1372 | client_data.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0); | ||
1373 | } | ||
1374 | 1360 | ||
1375 | #if !BB_MMU | 1361 | #if !BB_MMU |
1376 | /* on NOMMU reexec (i.e., background) early */ | 1362 | /* on NOMMU reexec (i.e., background) early */ |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index a4cc188b6..5c710963f 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -18,8 +18,6 @@ struct client_data_t { | |||
18 | char *pidfile; /* Optionally store the process ID */ | 18 | char *pidfile; /* Optionally store the process ID */ |
19 | const char *script; /* User script to run at dhcp events */ | 19 | const char *script; /* User script to run at dhcp events */ |
20 | struct option_set *options; /* list of DHCP options to send to server */ | 20 | struct option_set *options; /* list of DHCP options to send to server */ |
21 | uint8_t *vendorclass; /* Optional vendor class-id to use */ | ||
22 | uint8_t *hostname; /* Optional hostname to use */ | ||
23 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ | 21 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ |
24 | llist_t *envp; /* list of DHCP options used for env vars */ | 22 | llist_t *envp; /* list of DHCP options used for env vars */ |
25 | 23 | ||