[Toybox] [PATCH] dhcp: Add a new option to unset broadcast bit

Rob Landley rob at landley.net
Wed Oct 1 14:43:05 PDT 2025


On 9/3/25 10:56, Zikai Chen wrote:
> Hi,
> 
> I'm using the dhcp client in Android, and I need the functionality that the
> dhcp client can trigger unicast dhcp offer/ack from the server, so I added
> a new option to the dhcp client.

I'm trying to put together a release so I'm reviewing the commits since 
last time, and... how does this work?

@@ -996,7 +999,7 @@ 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.
+    state->pdhcp.flags = htons(broadcast_bit);
      if (toys.optflags & FLAG_r) {
        inet_aton(TT.req_ip, &rqsd);
        pend = dhcpc_addreqipaddr(&rqsd, pend);

If your discover doesn't have the broadcast bit set, how does it know 
where the dhcp server lives?

Presumably the server is sending a packet back via ethernet address 
(does toybox's dhcpd know how to do that?) but how did the request get 
to the dhcp server in the first place if it wasn't broadcast?

Did you test this? Does it work for you? (Nothing on 
https://android.googlesource.com/platform/external/toybox/ has been 
updated in the past 6 months.)

Rob


More information about the Toybox mailing list