Date: Thu, 14 Aug 1997 09:55:58 -0400 From: John Woodruff <jjw@us.net> To: dhcpd-users@fugue.com, freebsd-hackers@FreeBSD.org Subject: isc-dhcpd, FreeBSD, USE_RAW_SEND Message-ID: <33F30E6E.2781E494@us.net>
next in thread | raw e-mail | index | archive | help
This is more of a "isc-dhcpd developer" question than most, or
perhaps a "FreeBSD developer" question...
I'm trying to get isc-dhcpd-5.16 to work on a FreeBSD 2.2.2
system with USE_RAW_SEND (for other reasons, I can't put BPF
into the kernel, so the "standard" build won't work; and the
there's only one broadcast ifc so I *think* it should work).
dhcpd has no problem hearing the request and formulating a
reply. The problem is that I can't seem to get the kernel
to send the reply - it rejects whatever I send.
First, the code in raw.c that setup "auto struct sockaddr_in name"
seemed really bogus since "name" was never used, so I whacked it.
This resulted in EDESTADDRREQ from the final writev().
Then, I hacked in some code to use sendto(). Omitting details:
buf = grow_raw_buf(sizeof(struct ip) /*new*/
+ sizeof(struct udphdr)
+ len);
assemble_udp_ip_header (interface, buf, &bufp, from.s_addr,
to -> sin_addr.s_addr, to -> sin_port,
(unsigned char *)raw, len);
memcpy((buf+bufp), raw, len);
bufp += len;
return sendto(interface->wfdesc,
buf, bufp, 0,
(struct sockaddr*)to, sizeof(*to) );
Looking at buf just before the sendto() shows what looks like a
perfectly good IP+UDP+DHCP packet, but now I get EINVAL from
the final sendto(). The IP fields that "man 4 ip" says must be
set correctly seem to indeed be.
(gdb) run
Starting program: /home/jjw/dhcp-5.15/./dhcpd -d -f
Internet Software Consortium DHCPD $Name: BETA_5_16 $ [...]
Listening on Socket/ep0/207.244.202.0
Sending on Raw/ep0/207.244.202.0
BOOTREQUEST from 0:c0:4f:de:7a:8 via ep0
BOOTREPLY on 207.244.202.8 to 0:c0:4f:de:7a:8 via ep0
Breakpoint 1, send_packet (interface=0x2a080, packet=0xefbfd478,
raw=0xefbfade8, len=300, from={s_addr = 46855375}, to=0xefbfa9d8,
hto=0xefbfa9c0) at raw.c:144
144 return sendto(interface->wfdesc,
(gdb) x/20xw buf
0x48011045 0x00000000 0x9f0f1110 0x02caf4cf
0xffffffff 0x44004300 0x00003401 0x00060102
0x002b7ba3 0x00006400 0x00000000 0x08caf4cf
0x02caf4cf 0x00000000 0xde4fc000 0x0000087a
0x00000000 0x00000000 0x00000000 0x0000000
(gdb) c
sendpkt: Invalid argument
Just in case the sendto wanted an etheraddr, I tried changing
the sizeof(*to) to 6. Still EINVAL. Yes, this is running root.
Can someone tell me what I'm doing wrong here?
--
John Woodruff, Sr. Network Engineer, US Net - jjw@us.net - 301-572-5926
Washington/Baltimore/Richmond ISP - $6.95/month for full PPP!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33F30E6E.2781E494>
