Skip to contentSkip to conversation

slirp dhcp broadcast flag support

PATCH New Josh Elsasser 1 participant 1 message Oct 23, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 slirp dhcp broadcast flag support

This patch adds support for the dhcp broadcast flag to slirp's dhcp server. If a DHCP DISCOVER/REQUEST packet is recieved with the broadcast flag set then the response will be sent to 255.255.255.255.

-jre

Index: slirp/bootp.c
===================================================================
RCS file: /sources/qemu/qemu/slirp/bootp.c,v
retrieving revision 1.8

bootp.c +6 -0
diff -u -r1.8 bootp.c
@@ -184,6 +184,12 @@
     rbp->bp_yiaddr = daddr.sin_addr; /* Client IP address */
     rbp->bp_siaddr = saddr.sin_addr; /* Server IP address */
 
+    if (ntohs(bp->bp_flags) & RFC1531_BROADCAST_FLAG) {
+        rbp->bp_flags = htons(RFC1531_BROADCAST_FLAG);
+        daddr.sin_addr.s_addr = 0xffffffff;
+        /* XXX should use link-level address to ff:ff:ff:ff:ff:ff too */
+    }
+
     q = rbp->bp_vend;
     memcpy(q, rfc1533_cookie, 4);
     q += 4;

Index: slirp/bootp.h
===================================================================
RCS file: /sources/qemu/qemu/slirp/bootp.h,v
retrieving revision 1.2

bootp.h +3 -1
diff -u -r1.2 bootp.h
@@ -6,6 +6,8 @@
 #define BOOTP_REQUEST	1
 #define BOOTP_REPLY	2
 
+#define RFC1531_BROADCAST_FLAG  0x8000
+
 #define RFC1533_COOKIE		99, 130, 83, 99
 #define RFC1533_PAD		0
 #define RFC1533_NETMASK		1
@@ -99,7 +101,7 @@
     uint8_t bp_hops;
     uint32_t bp_xid;
     uint16_t bp_secs;
-    uint16_t unused;
+    uint16_t bp_flags;
     struct in_addr bp_ciaddr;
     struct in_addr bp_yiaddr;
     struct in_addr bp_siaddr;