summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-02 15:07:46 +0200
committerDenys Vlasenko2021-06-02 15:07:46 +0200
commit698cdef538f51bb85b68d591b1e42eb6b04d891c (patch)
tree0946d0c3a0f0749f30d4f16a6c50e519e03f5de9 /networking
parent265fcddd08f22c99a2a419a1537c18f4d6d43e9f (diff)
downloadbusybox-698cdef538f51bb85b68d591b1e42eb6b04d891c.zip
busybox-698cdef538f51bb85b68d591b1e42eb6b04d891c.tar.gz
udhcpc: remove deprecated -H/-h HOSTNAME options (9 years), deprecate -V VENDOR
function old new delta udhcpc_main 2563 2582 +19 dhcp_option_strings 294 301 +7 dhcp_optflags 80 82 +2 .rodata 103250 103248 -2 udhcpc_longopts 252 241 -11 add_client_options 209 175 -34 alloc_dhcp_option 59 - -59 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 3/3 up/down: 28/-106) Total: -78 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/common.c3
-rw-r--r--networking/udhcp/d6_dhcpc.c3
-rw-r--r--networking/udhcp/dhcpc.c78
-rw-r--r--networking/udhcp/dhcpc.h2
4 files changed, 36 insertions, 50 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 684d76b..7929950 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -49,6 +49,7 @@ const struct dhcp_optflag dhcp_optflags[] = {
{ OPTION_U32 , 0x33 }, /* DHCP_LEASE_TIME */
{ OPTION_IP , 0x36 }, /* DHCP_SERVER_ID */
{ OPTION_STRING , 0x38 }, /* DHCP_ERR_MESSAGE */
+ { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */
//TODO: must be combined with 'sname' and 'file' handling:
{ OPTION_STRING_HOST , 0x42 }, /* DHCP_TFTP_SERVER_NAME */
{ OPTION_STRING , 0x43 }, /* DHCP_BOOT_FILE */
@@ -83,7 +84,6 @@ const struct dhcp_optflag dhcp_optflags[] = {
{ OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */
{ OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */
//looks like these opts will work just fine even without these defs:
-// { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */
// /* not really a string: */
// { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */
{ 0, 0 } /* zeroed terminating entry */
@@ -120,6 +120,7 @@ const char dhcp_option_strings[] ALIGN1 =
"lease" "\0" /* DHCP_LEASE_TIME */
"serverid" "\0" /* DHCP_SERVER_ID */
"message" "\0" /* DHCP_ERR_MESSAGE */
+ "vendor" "\0" /* DHCP_VENDOR */
"tftp" "\0" /* DHCP_TFTP_SERVER_NAME*/
"bootfile" "\0" /* DHCP_BOOT_FILE */
// "userclass" "\0" /* DHCP_USER_CLASS */
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index c4bedb2..3fd1fa7 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)
/* not set, set the default client ID */
client_data.clientid[1] = 3; /* DUID-LL */
client_data.clientid[3] = 1; /* ethernet */
- clientid_mac_ptr = udhcp_insert_new_option(&client_data.options, D6_OPT_CLIENTID,
+ clientid_mac_ptr = udhcp_insert_new_option(
+ &client_data.options, D6_OPT_CLIENTID,
client_data.clientid, 2+2 + 6, /*dhcp6:*/ 1);
clientid_mac_ptr += 2+2 + 2+2; /* skip option code, len, DUID-LL, ethernet */
}
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index a06eeaa..16228f0 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -55,8 +55,7 @@ struct tpacket_auxdata {
#if ENABLE_LONG_OPTS
static const char udhcpc_longopts[] ALIGN1 =
"clientid-none\0" No_argument "C"
- "vendorclass\0" Required_argument "V"
- "hostname\0" Required_argument "H"
+ "vendorclass\0" Required_argument "V" //deprecated
"fqdn\0" Required_argument "F"
"interface\0" Required_argument "i"
"now\0" No_argument "n"
@@ -84,27 +83,25 @@ static const char udhcpc_longopts[] ALIGN1 =
enum {
OPT_C = 1 << 0,
OPT_V = 1 << 1,
- OPT_H = 1 << 2,
- OPT_h = 1 << 3,
- OPT_F = 1 << 4,
- OPT_i = 1 << 5,
- OPT_n = 1 << 6,
- OPT_p = 1 << 7,
- OPT_q = 1 << 8,
- OPT_R = 1 << 9,
- OPT_r = 1 << 10,
- OPT_s = 1 << 11,
- OPT_T = 1 << 12,
- OPT_t = 1 << 13,
- OPT_S = 1 << 14,
- OPT_A = 1 << 15,
- OPT_O = 1 << 16,
- OPT_o = 1 << 17,
- OPT_x = 1 << 18,
- OPT_f = 1 << 19,
- OPT_B = 1 << 20,
+ OPT_F = 1 << 2,
+ OPT_i = 1 << 3,
+ OPT_n = 1 << 4,
+ OPT_p = 1 << 5,
+ OPT_q = 1 << 6,
+ OPT_R = 1 << 7,
+ OPT_r = 1 << 8,
+ OPT_s = 1 << 9,
+ OPT_T = 1 << 10,
+ OPT_t = 1 << 11,
+ OPT_S = 1 << 12,
+ OPT_A = 1 << 13,
+ OPT_O = 1 << 14,
+ OPT_o = 1 << 15,
+ OPT_x = 1 << 16,
+ OPT_f = 1 << 17,
+ OPT_B = 1 << 18,
/* The rest has variable bit positions, need to be clever */
- OPTBIT_B = 20,
+ OPTBIT_B = 18,
USE_FOR_MMU( OPTBIT_b,)
IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
IF_FEATURE_UDHCP_PORT( OPTBIT_P,)
@@ -638,10 +635,6 @@ static void add_client_options(struct dhcp_packet *packet)
packet->options[end + OPT_DATA + len] = DHCP_END;
}
- if (client_data.vendorclass)
- udhcp_add_binary_option(packet, client_data.vendorclass);
- if (client_data.hostname)
- udhcp_add_binary_option(packet, client_data.hostname);
if (client_data.fqdn)
udhcp_add_binary_option(packet, client_data.fqdn);
@@ -722,7 +715,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested)
udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested);
/* Add options: maxsize,
- * optionally: hostname, fqdn, vendorclass, client-id,
+ * optionally: fqdn, client-id,
* "param req" option according to -O, options specified with -x
*/
add_client_options(&packet);
@@ -766,7 +759,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste
udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server);
/* Add options: maxsize,
- * optionally: hostname, fqdn, vendorclass, client-id,
+ * optionally: fqdn, client-id,
* "param req" option according to -O, and options specified with -x
*/
add_client_options(&packet);
@@ -811,7 +804,7 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
packet.ciaddr = ciaddr;
/* Add options: maxsize,
- * optionally: hostname, fqdn, vendorclass, client-id,
+ * optionally: fqdn, client-id,
* "param req" option according to -O, and options specified with -x
*/
add_client_options(&packet);
@@ -1236,7 +1229,7 @@ int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int udhcpc_main(int argc UNUSED_PARAM, char **argv)
{
uint8_t *message;
- const char *str_V, *str_h, *str_F, *str_r;
+ const char *str_V, *str_F, *str_r;
IF_FEATURE_UDHCPC_ARPING(const char *str_a = "2000";)
IF_FEATURE_UDHCP_PORT(char *str_P;)
uint8_t *clientid_mac_ptr;
@@ -1272,14 +1265,14 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* Parse command line */
opt = getopt32long(argv, "^"
/* O,x: list; -T,-t,-A take numeric param */
- "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
+ "CV:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
USE_FOR_MMU("b")
IF_FEATURE_UDHCPC_ARPING("a::")
IF_FEATURE_UDHCP_PORT("P:")
"v"
"\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */
, udhcpc_longopts
- , &str_V, &str_h, &str_h, &str_F
+ , &str_V, &str_F
, &client_data.interface, &client_data.pidfile /* i,p */
, &str_r /* r */
, &client_data.script /* s */
@@ -1290,11 +1283,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
IF_FEATURE_UDHCP_PORT(, &str_P)
IF_UDHCP_VERBOSE(, &dhcp_verbose)
);
- if (opt & (OPT_h|OPT_H)) {
- //msg added 2011-11
- bb_simple_error_msg("option -h NAME is deprecated, use -x hostname:NAME");
- client_data.hostname = alloc_dhcp_option(DHCP_HOST_NAME, str_h, 0);
- }
if (opt & OPT_F) {
/* FQDN option format: [0x51][len][flags][0][0]<fqdn> */
client_data.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3);
@@ -1344,6 +1332,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
);
free(optstr);
}
+ if (str_V[0] != '\0') {
+ //msg added 2021-06
+ bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR");
+ udhcp_insert_new_option(
+ &client_data.options, DHCP_VENDOR,
+ str_V, strlen(str_V), /*dhcp6:*/ 0);
+ }
if (udhcp_read_interface(client_data.interface,
&client_data.ifindex,
@@ -1362,15 +1357,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
client_data_client_mac - 1, 1 + 6, /*dhcp6:*/ 0);
clientid_mac_ptr += 3; /* skip option code, len, ethernet */
}
- if (str_V[0] != '\0') {
- // can drop -V, str_V, client_data.vendorclass,
- // but need to add "vendor" to the list of recognized
- // string opts for this to work;
- // and need to tweak add_client_options() too...
- // ...so the question is, should we?
- //bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR");
- client_data.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0);
- }
#if !BB_MMU
/* on NOMMU reexec (i.e., background) early */
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h
index a4cc188..5c71096 100644
--- a/networking/udhcp/dhcpc.h
+++ b/networking/udhcp/dhcpc.h
@@ -18,8 +18,6 @@ struct client_data_t {
char *pidfile; /* Optionally store the process ID */
const char *script; /* User script to run at dhcp events */
struct option_set *options; /* list of DHCP options to send to server */
- uint8_t *vendorclass; /* Optional vendor class-id to use */
- uint8_t *hostname; /* Optional hostname to use */
uint8_t *fqdn; /* Optional fully qualified domain name to use */
llist_t *envp; /* list of DHCP options used for env vars */