Some network elements will silently drop DHCPv4 messages if they are
not sent as broadcast by the server. Therefore request broadcast
replies by unconditionally setting the broadcast flag for all
broadcast messages sent by the client.

With this change the broken vendor check can be omitted.
---

        Hi,

Let's see if this helps with the DHCP problems discussed on #connman.

Cheers,

        Patrik


 gdhcp/common.c | 32 ++------------------------------
 1 file changed, 2 insertions(+), 30 deletions(-)

diff --git a/gdhcp/common.c b/gdhcp/common.c
index a43530a..e111150 100644
--- a/gdhcp/common.c
+++ b/gdhcp/common.c
@@ -368,34 +368,6 @@ void dhcpv6_init_header(struct dhcpv6_packet *packet, 
uint8_t type)
        packet->transaction_id[2] = id & 0xff;
 }
 
-static bool check_vendor(uint8_t  *option_vendor, const char *vendor)
-{
-       uint8_t vendor_length = sizeof(vendor) - 1;
-
-       if (option_vendor[OPT_LEN - OPT_DATA] != vendor_length)
-               return false;
-
-       if (memcmp(option_vendor, vendor, vendor_length) != 0)
-               return false;
-
-       return true;
-}
-
-static void check_broken_vendor(struct dhcp_packet *packet)
-{
-       uint8_t *vendor;
-
-       if (packet->op != BOOTREQUEST)
-               return;
-
-       vendor = dhcp_get_option(packet, DHCP_VENDOR);
-       if (!vendor)
-               return;
-
-       if (check_vendor(vendor, "MSFT 98"))
-               packet->flags |= htons(BROADCAST_FLAG);
-}
-
 int dhcp_recv_l3_packet(struct dhcp_packet *packet, int fd)
 {
        int n;
@@ -409,8 +381,6 @@ int dhcp_recv_l3_packet(struct dhcp_packet *packet, int fd)
        if (packet->cookie != htonl(DHCP_MAGIC))
                return -EPROTO;
 
-       check_broken_vendor(packet);
-
        return n;
 }
 
@@ -559,6 +529,8 @@ int dhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
        if (fd < 0)
                return -errno;
 
+       dhcp_pkt->flags |= htons(BROADCAST_FLAG);
+
        memset(&dest, 0, sizeof(dest));
        memset(&packet, 0, sizeof(packet));
        packet.data = *dhcp_pkt;
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to