bpf_frame_header_len(const struct interface *ifp)
{
- switch(ifp->family) {
+ switch (ifp->family) {
case ARPHRD_ETHER:
return sizeof(struct ether_header);
default:
}
}
+static const uint8_t etherbroadcastaddr[] =
+ { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+static int
+bpf_frame_bcast(const struct interface *ifp, const char *frame)
+{
+
+ switch (ifp->family) {
+ case ARPHRD_ETHER:
+ return memcmp(frame +
+ offsetof(struct ether_header, ether_dhost),
+ etherbroadcastaddr, sizeof(etherbroadcastaddr));
+ default:
+ return -1;
+ }
+}
+
#ifndef __linux__
/* Linux is a special snowflake for opening, attaching and reading BPF.
* See if-linux.c for the Linux specific BPF functions. */
if (state->buffer_pos + packet.bh_caplen + packet.bh_hdrlen >
state->buffer_len)
goto next; /* Packet beyond buffer, drop. */
- payload = state->buffer + state->buffer_pos +
- packet.bh_hdrlen + fl;
+ payload = state->buffer + state->buffer_pos + packet.bh_hdrlen;
+ if (bpf_frame_bcast(ifp, payload) == 0)
+ *flags |= BPF_BCAST;
+ else
+ *flags &= ~BPF_BCAST;
+ payload += fl;
bytes = (ssize_t)packet.bh_caplen - fl;
if ((size_t)bytes > len)
bytes = (ssize_t)len;
#define BPF_READING (1U << 0)
#define BPF_EOF (1U << 1)
#define BPF_PARTIALCSUM (1U << 2)
+#define BPF_BCAST (1U << 3)
#include "dhcpcd.h"