diff options
author | brooks <brooks@FreeBSD.org> | 2008-04-15 22:48:56 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2008-04-15 22:48:56 +0000 |
commit | c390aa9572bcd15d4db164f0326ecd949bfad016 (patch) | |
tree | 6b534a62bc9057ce071491294e82cd483e53e49a /sbin | |
parent | f66a2c343355525253d7367e0997db45ea860ae1 (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sbin/dhclient/bpf.c | 15 |
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); |