summaryrefslogtreecommitdiffstats
path: root/bpf.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-07-03 17:07:24 +0000
committerRoy Marples <roy@marples.name>2008-07-03 17:07:24 +0000
commit217e8e835e6f407fb992d70705cb1d99efe075c6 (patch)
tree20abbe7df4e60032423ae72184942a616116b406 /bpf.c
parent22a95a986d1e820642cf0ee3ef4f47e3b7053d81 (diff)
downloaddhcpcd-217e8e835e6f407fb992d70705cb1d99efe075c6.tar.xz
Cleaner fix for working with PCC.
Diffstat (limited to 'bpf.c')
-rw-r--r--bpf.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/bpf.c b/bpf.c
index 18dfca51..f015344b 100644
--- a/bpf.c
+++ b/bpf.c
@@ -143,19 +143,13 @@ send_raw_packet(const struct interface *iface, int protocol,
struct iovec iov[2];
struct ether_header hw;
- memset(&hw, 0, sizeof(hw));
+ memset(&hw, 0, ETHER_HDR_LEN);
memset(&hw.ether_dhost, 0xff, ETHER_ADDR_LEN);
hw.ether_type = htons(protocol);
iov[0].iov_base = &hw;
- iov[0].iov_len = sizeof(hw);
+ iov[0].iov_len = ETHER_HDR_LEN;
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);
}
@@ -167,7 +161,6 @@ get_raw_packet(struct interface *iface, int protocol,
{
int fd = -1;
struct bpf_hdr packet;
- struct ether_header hw;
ssize_t bytes;
const unsigned char *payload;
@@ -196,13 +189,8 @@ get_raw_packet(struct interface *iface, int protocol,
if (iface->buffer_pos + packet.bh_caplen + packet.bh_hdrlen >
iface->buffer_len)
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
+ payload = iface->buffer + packet.bh_hdrlen + ETHER_HDR_LEN;
+ bytes = packet.bh_caplen - ETHER_HDR_LEN;
if (bytes > len)
bytes = len;
memcpy(data, payload, bytes);