From: Roy Marples Date: Thu, 3 Jul 2008 00:12:57 +0000 (+0000) Subject: Work around PCC not supporting the __packed__ attribute on structures. dhcpcd now... X-Git-Tag: v4.0.2~248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d49ff6f18d7e5b8dffb71bb1a608568933f2aec;p=thirdparty%2Fdhcpcd.git Work around PCC not supporting the __packed__ attribute on structures. dhcpcd now works fully with PCC on NetBSD-4.99.67. --- 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);