summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Chaprana <n.chaprana@samsung.com>2020-02-25 19:51:13 +0530
committerNishant Chaprana <n.chaprana@samsung.com>2020-03-02 15:23:27 +0530
commit3ded0d7ad87ce74e2a7944dde83222736e2bb39f (patch)
tree74f8d3b6a2c6b93a25189d87c2bc2eb620ccb0d6
parent172fdf5748d335e247c5e763fbda06dce77c6470 (diff)
downloadtoybox-3ded0d7ad87ce74e2a7944dde83222736e2bb39f.tar.gz
toybox-3ded0d7ad87ce74e2a7944dde83222736e2bb39f.tar.bz2
toybox-3ded0d7ad87ce74e2a7944dde83222736e2bb39f.zip
Implement -B option as mentioned in dhcp --help
Change-Id: Id636629a50ee7d21ed908189c270394eb850e960 Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
-rw-r--r--toys/pending/dhcp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/toys/pending/dhcp.c b/toys/pending/dhcp.c
index 9dad00a..3c70765 100644
--- a/toys/pending/dhcp.c
+++ b/toys/pending/dhcp.c
@@ -82,7 +82,8 @@ GLOBALS(
#define STATE_RENEW_REQUESTED 5
#define STATE_RELEASED 6
-#define BOOTP_BROADCAST 0x8000
+#define BOOTP_BROADCAST_ON 0x8000
+#define BOOTP_BROADCAST_OFF 0x0000
#define DHCP_MAGIC 0x63825363
#define DHCP_REQUEST 1
@@ -1006,7 +1007,10 @@ static int dhcpc_sendmsg(int msgtype)
// Handle the message specific settings
switch (msgtype) {
case DHCPDISCOVER: // Broadcast DISCOVER message to all servers
- state->pdhcp.flags = htons(BOOTP_BROADCAST); // Broadcast bit.
+ if (flag_chk(FLAG_B))
+ state->pdhcp.flags = htons(BOOTP_BROADCAST_ON); // Broadcast bit set.
+ else
+ state->pdhcp.flags = htons(BOOTP_BROADCAST_OFF); // Broadcast bit unset.
if (flag_chk(FLAG_r)) {
inet_aton(TT.req_ip, &rqsd);
pend = dhcpc_addreqipaddr(&rqsd, pend);
@@ -1020,7 +1024,10 @@ static int dhcpc_sendmsg(int msgtype)
if (flag_chk(FLAG_x)) pend = set_xopt(pend);
break;
case DHCPREQUEST: // Send REQUEST message to the server that sent the *first* OFFER
- state->pdhcp.flags = htons(BOOTP_BROADCAST); // Broadcast bit.
+ if (flag_chk(FLAG_B))
+ state->pdhcp.flags = htons(BOOTP_BROADCAST_ON); // Broadcast bit set.
+ else
+ state->pdhcp.flags = htons(BOOTP_BROADCAST_OFF); // Broadcast bit unset.
if (state->status == STATE_RENEWING) memcpy(&state->pdhcp.ciaddr, &state->ipaddr.s_addr, 4);
pend = dhcpc_addmaxsize(pend, htons(sizeof(dhcp_raw_t)));
rqsd.s_addr = htonl(server);