diff options
author | 2018-12-27 17:02:03 +0000 | |
---|---|---|
committer | 2018-12-27 17:02:03 +0000 | |
commit | 991c0c97aab2a85aa12430766d315b3786c7d40f (patch) | |
tree | 45c6677887e39ef8a359b7c292fcd5ce144b73de | |
parent | Check for main ruleset explicitly (diff) | |
download | wireguard-openbsd-991c0c97aab2a85aa12430766d315b3786c7d40f.tar.xz wireguard-openbsd-991c0c97aab2a85aa12430766d315b3786c7d40f.zip |
Rename bfdesc to bpffd and packethandler() to bpffd_handler() to make
the code slightly more intuitive.
-rw-r--r-- | sbin/dhclient/bpf.c | 24 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 20 |
4 files changed, 27 insertions, 27 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index 01c9f48222b..2ca4cc158b7 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.71 2018/12/08 23:06:41 krw Exp $ */ +/* $OpenBSD: bpf.c,v 1.72 2018/12/27 17:02:03 krw Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -178,14 +178,14 @@ struct bpf_insn dhcp_bpf_wfilter[] = { int dhcp_bpf_wfilter_len = sizeof(dhcp_bpf_wfilter) / sizeof(struct bpf_insn); int -configure_bpf_sock(int bfdesc) +configure_bpf_sock(int bpffd) { struct bpf_version v; struct bpf_program p; int flag = 1, sz; /* Make sure the BPF version is in range. */ - if (ioctl(bfdesc, BIOCVERSION, &v) == -1) + if (ioctl(bpffd, BIOCVERSION, &v) == -1) fatal("BIOCVERSION"); if (v.bv_major != BPF_MAJOR_VERSION || @@ -198,14 +198,14 @@ configure_bpf_sock(int bfdesc) * comes in, rather than waiting for the input buffer to fill * with packets. */ - if (ioctl(bfdesc, BIOCIMMEDIATE, &flag) == -1) + if (ioctl(bpffd, BIOCIMMEDIATE, &flag) == -1) fatal("BIOCIMMEDIATE"); - if (ioctl(bfdesc, BIOCSFILDROP, &flag) == -1) + if (ioctl(bpffd, BIOCSFILDROP, &flag) == -1) fatal("BIOCSFILDROP"); /* Get the required BPF buffer length from the kernel. */ - if (ioctl(bfdesc, BIOCGBLEN, &sz) == -1) + if (ioctl(bpffd, BIOCGBLEN, &sz) == -1) fatal("BIOCGBLEN"); /* Set up the bpf filter program structure. */ @@ -219,7 +219,7 @@ configure_bpf_sock(int bfdesc) */ dhcp_bpf_filter[8].k = LOCAL_PORT; - if (ioctl(bfdesc, BIOCSETF, &p) == -1) + if (ioctl(bpffd, BIOCSETF, &p) == -1) fatal("BIOCSETF"); /* Set up the bpf write filter program structure. */ @@ -229,10 +229,10 @@ configure_bpf_sock(int bfdesc) if (dhcp_bpf_wfilter[7].k == 0x1fff) dhcp_bpf_wfilter[7].k = htons(IP_MF|IP_OFFMASK); - if (ioctl(bfdesc, BIOCSETWF, &p) == -1) + if (ioctl(bpffd, BIOCSETWF, &p) == -1) fatal("BIOCSETWF"); - if (ioctl(bfdesc, BIOCLOCK, NULL) == -1) + if (ioctl(bpffd, BIOCLOCK, NULL) == -1) fatal("BIOCLOCK"); return sz; @@ -303,7 +303,7 @@ send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to, total += iov[i].iov_len; if (to.s_addr == INADDR_BROADCAST) { - result = writev(ifi->bfdesc, iov, iovcnt); + result = writev(ifi->bpffd, iov, iovcnt); if (result == -1) log_warn("%s: writev(%s)", log_procname, desc); else if (result < total) { @@ -352,9 +352,9 @@ receive_packet(struct interface_info *ifi, struct sockaddr_in *from, do { /* If the buffer is empty, fill it. */ if (ifi->rbuf_offset >= ifi->rbuf_len) { - length = read(ifi->bfdesc, ifi->rbuf, ifi->rbuf_max); + length = read(ifi->bpffd, ifi->rbuf, ifi->rbuf_max); if (length == -1) { - log_warn("%s: read(bfdesc)", log_procname); + log_warn("%s: read(bpffd)", log_procname); return length; } else if (length == 0) return length; diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index b45d31cf885..ea5b2fc5e45 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.594 2018/12/27 16:15:10 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.595 2018/12/27 17:02:03 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -655,8 +655,8 @@ main(int argc, char *argv[]) /* Register the interface. */ ifi->ufdesc = get_udp_sock(ifi->rdomain); - ifi->bfdesc = get_bpf_sock(ifi->name); - ifi->rbuf_max = configure_bpf_sock(ifi->bfdesc); + ifi->bpffd = get_bpf_sock(ifi->name); + ifi->rbuf_max = configure_bpf_sock(ifi->bpffd); ifi->rbuf = malloc(ifi->rbuf_max); if (ifi->rbuf == NULL) fatal("bpf input buffer"); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index f6a17a0c6da..b86d2510903 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.258 2018/11/11 00:49:05 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.259 2018/12/27 17:02:03 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -118,7 +118,7 @@ struct interface_info { char name[IFNAMSIZ]; char ssid[32]; uint8_t ssid_len; - int bfdesc; /* bpf - reading & broadcast writing*/ + int bpffd; /* bpf - reading & broadcast writing*/ int ufdesc; /* udp - unicast writing */ unsigned char *rbuf; size_t rbuf_max; diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index ed83f460478..6d56a8c952d 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.153 2018/11/04 16:32:11 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.154 2018/12/27 17:02:03 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -72,7 +72,7 @@ #include "privsep.h" -void packethandler(struct interface_info *); +void bpffd_handler(struct interface_info *); void flush_unpriv_ibuf(void); void sendhup(void); @@ -90,9 +90,9 @@ dispatch(struct interface_info *ifi, int routefd) while (quit == 0 || quit == SIGHUP) { if (quit == SIGHUP) { /* Ignore any future packets, messages or timeouts. */ - if (ifi->bfdesc != -1) { - close(ifi->bfdesc); - ifi->bfdesc = -1; + if (ifi->bpffd != -1) { + close(ifi->bpffd); + ifi->bpffd = -1; } if (routefd != -1) { close(routefd); @@ -130,7 +130,7 @@ dispatch(struct interface_info *ifi, int routefd) * fds[1] == routing socket for incoming RTM messages * fds[2] == imsg socket to privileged process */ - fds[0].fd = ifi->bfdesc; + fds[0].fd = ifi->bpffd; fds[1].fd = routefd; fds[2].fd = unpriv_ibuf->fd; fds[0].events = fds[1].events = fds[2].events = POLLIN; @@ -142,14 +142,14 @@ dispatch(struct interface_info *ifi, int routefd) if (nfds == -1) { if (errno == EINTR) continue; - log_warn("%s: poll(bfdesc, routefd, unpriv_ibuf)", + log_warn("%s: poll(bpffd, routefd, unpriv_ibuf)", log_procname); quit = INTERNALSIG; continue; } if ((fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) != 0) { - log_debug("%s: bfdesc: ERR|HUP|NVAL", log_procname); + log_debug("%s: bpffd: ERR|HUP|NVAL", log_procname); quit = INTERNALSIG; continue; } @@ -169,7 +169,7 @@ dispatch(struct interface_info *ifi, int routefd) if ((fds[0].revents & POLLIN) != 0) { do { - packethandler(ifi); + bpffd_handler(ifi); } while (quit == 0 && ifi->rbuf_offset < ifi->rbuf_len); } if ((fds[1].revents & POLLIN) != 0) @@ -185,7 +185,7 @@ dispatch(struct interface_info *ifi, int routefd) } void -packethandler(struct interface_info *ifi) +bpffd_handler(struct interface_info *ifi) { struct sockaddr_in from; struct ether_addr hfrom; |