summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2008-04-15 22:48:56 +0000
committerbrooks <brooks@FreeBSD.org>2008-04-15 22:48:56 +0000
commitc390aa9572bcd15d4db164f0326ecd949bfad016 (patch)
tree6b534a62bc9057ce071491294e82cd483e53e49a /sbin/dhclient
parentf66a2c343355525253d7367e0997db45ea860ae1 (diff)
downloadFreeBSD-src-c390aa9572bcd15d4db164f0326ecd949bfad016.zip
FreeBSD-src-c390aa9572bcd15d4db164f0326ecd949bfad016.tar.gz
When sending packets directly to the DHCP server, use a socket and send
directly rather than bogusly sending it out as a link layer broadcast (which fails to be received on some networks). PR: bin/96018 MFC after: 2 weeks
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/bpf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 43122fb..8a669e1 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -245,6 +245,21 @@ send_packet(struct interface_info *interface, struct dhcp_packet *raw,
unsigned char buf[256];
struct iovec iov[2];
int result, bufp = 0;
+ int sock;
+
+ if (to->sin_addr.s_addr != INADDR_BROADCAST) {
+ note("SENDING DIRECT");
+ /* We know who the server is, send the packet via
+ normal socket interface */
+
+ if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) >= 0) {
+ result = sendto (sock, (char *)raw, len, 0,
+ (struct sockaddr *)to, sizeof *to);
+ close(sock);
+ if (result > 0)
+ return result;
+ }
+ }
/* Assemble the headers... */
assemble_hw_header(interface, buf, &bufp, hto);
OpenPOWER on IntegriCloud