summaryrefslogtreecommitdiffstats
path: root/bpf.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-07-03 00:12:57 +0000
committerRoy Marples <roy@marples.name>2008-07-03 00:12:57 +0000
commit1d49ff6f18d7e5b8dffb71bb1a608568933f2aec (patch)
treeeb22002b32269c9cd62c2df5d08dd5700170ea58 /bpf.c
parent7264b4772f41fb07bb258f00e434f67660e8afb0 (diff)
downloaddhcpcd-1d49ff6f18d7e5b8dffb71bb1a608568933f2aec.tar.xz
Work around PCC not supporting the __packed__ attribute on structures. dhcpcd now works fully with PCC on NetBSD-4.99.67.
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/bpf.c b/bpf.c
index 097555aa..18dfca51 100644
--- a/bpf.c
+++ b/bpf.c
@@ -151,6 +151,11 @@ send_raw_packet(const struct interface *iface, int protocol,
iov[1].iov_base = UNCONST(data);
iov[1].iov_len = len;
+#ifdef __PCC__
+ /* Work around PCC not respecting the packed ether_header */
+ iov[0].iov_len = 14;
+#endif
+
return writev(iface->fd, iov, 2);
}
@@ -193,6 +198,11 @@ get_raw_packet(struct interface *iface, int protocol,
goto next; /* Packet beyond buffer, drop. */
payload = iface->buffer + packet.bh_hdrlen + sizeof(hw);
bytes = packet.bh_caplen - sizeof(hw);
+#ifdef __PCC__
+ /* Work around PCC not respecting the packed ether_header */
+ payload -= sizeof(hw) - 14;
+ bytes += sizeof(hw) - 14;
+#endif
if (bytes > len)
bytes = len;
memcpy(data, payload, bytes);