summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2004-12-17 15:56:58 +0000
committerreyk <reyk@openbsd.org>2004-12-17 15:56:58 +0000
commit726ab300e3a413e43105a54d3ba1ad519af07782 (patch)
tree11efd01126effdc1df60659bd6b2767e5fd17c2b /sys/net/bpf.c
parentFix printf in loadfirmware error path. (diff)
downloadwireguard-openbsd-726ab300e3a413e43105a54d3ba1ad519af07782.tar.xz
wireguard-openbsd-726ab300e3a413e43105a54d3ba1ad519af07782.zip
knf cleanup, convert old k&r-style functions to ansi-style for a
consistent style in sys/net/bpf.c. ok henning@, "looks fine" canacar@
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c130
1 files changed, 39 insertions, 91 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 79e147d34bd..25440ec33ec 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.54 2004/10/09 19:55:28 brad Exp $ */
+/* $OpenBSD: bpf.c,v 1.55 2004/12/17 15:56:58 reyk Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -101,12 +101,8 @@ struct bpf_d *bpfilter_create(int);
void bpfilter_destroy(struct bpf_d *);
int
-bpf_movein(uio, linktype, mp, sockp, filter)
- struct uio *uio;
- int linktype;
- struct mbuf **mp;
- struct sockaddr *sockp;
- struct bpf_insn *filter;
+bpf_movein(struct uio *uio, int linktype, struct mbuf **mp,
+ struct sockaddr *sockp, struct bpf_insn *filter)
{
struct mbuf *m;
int error;
@@ -224,9 +220,7 @@ bpf_movein(uio, linktype, mp, sockp, filter)
* Must be called at splimp.
*/
void
-bpf_attachd(d, bp)
- struct bpf_d *d;
- struct bpf_if *bp;
+bpf_attachd(struct bpf_d *d, struct bpf_if *bp)
{
/*
* Point d at bp, and add d to the interface's list of listeners.
@@ -244,8 +238,7 @@ bpf_attachd(d, bp)
* Detach a file from its interface.
*/
void
-bpf_detachd(d)
- struct bpf_d *d;
+bpf_detachd(struct bpf_d *d)
{
struct bpf_d **p;
struct bpf_if *bp;
@@ -306,8 +299,7 @@ bpf_detachd(d)
*/
/* ARGSUSED */
void
-bpfilterattach(n)
- int n;
+bpfilterattach(int n)
{
LIST_INIT(&bpf_d_list);
}
@@ -318,11 +310,7 @@ bpfilterattach(n)
*/
/* ARGSUSED */
int
-bpfopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+bpfopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct bpf_d *d;
@@ -351,11 +339,7 @@ bpfopen(dev, flag, mode, p)
*/
/* ARGSUSED */
int
-bpfclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+bpfclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct bpf_d *d;
int s;
@@ -386,10 +370,7 @@ bpfclose(dev, flag, mode, p)
* bpfread - read next chunk of packets from buffers
*/
int
-bpfread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
+bpfread(dev_t dev, struct uio *uio, int ioflag)
{
struct bpf_d *d;
int error;
@@ -409,7 +390,7 @@ bpfread(dev, uio, ioflag)
s = splimp();
D_GET(d);
-
+
/*
* bd_rdStart is tagged when we start the read, iff there's a timeout.
* we can then figure out when we're done reading.
@@ -444,7 +425,8 @@ bpfread(dev, uio, ioflag)
ROTATE_BUFFERS(d);
break;
}
- if ((d->bd_rtout != -1) || (d->bd_rdStart + d->bd_rtout) < ticks) {
+ if ((d->bd_rtout != -1) ||
+ (d->bd_rdStart + d->bd_rtout) < ticks) {
error = tsleep((caddr_t)d, PRINET|PCATCH, "bpf",
d->bd_rtout);
} else {
@@ -510,8 +492,7 @@ bpfread(dev, uio, ioflag)
* If there are processes sleeping on this descriptor, wake them up.
*/
static __inline void
-bpf_wakeup(d)
- struct bpf_d *d;
+bpf_wakeup(struct bpf_d *d)
{
wakeup((caddr_t)d);
if (d->bd_async && d->bd_sig)
@@ -525,10 +506,7 @@ bpf_wakeup(d)
}
int
-bpfwrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
+bpfwrite(dev_t dev, struct uio *uio, int ioflag)
{
struct bpf_d *d;
struct ifnet *ifp;
@@ -576,8 +554,7 @@ bpfwrite(dev, uio, ioflag)
* receive and drop counts. Should be called at splimp.
*/
void
-bpf_reset_d(d)
- struct bpf_d *d;
+bpf_reset_d(struct bpf_d *d)
{
if (d->bd_hbuf) {
/* Free the hold buffer. */
@@ -609,12 +586,7 @@ bpf_reset_d(d)
*/
/* ARGSUSED */
int
-bpfioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+bpfioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
{
struct bpf_d *d;
int s, error = 0;
@@ -865,7 +837,7 @@ bpfioctl(dev, cmd, addr, flag, p)
case BIOCSRSIG: /* Set receive signal */
{
- u_int sig;
+ u_int sig;
sig = *(u_int *)addr;
@@ -887,10 +859,7 @@ bpfioctl(dev, cmd, addr, flag, p)
* free it and replace it. Returns EINVAL for bogus requests.
*/
int
-bpf_setf(d, fp, wf)
- struct bpf_d *d;
- struct bpf_program *fp;
- int wf;
+bpf_setf(struct bpf_d *d, struct bpf_program *fp, int wf)
{
struct bpf_insn *fcode, *old;
u_int flen, size;
@@ -941,9 +910,7 @@ bpf_setf(d, fp, wf)
* Return an errno or 0.
*/
int
-bpf_setif(d, ifr)
- struct bpf_d *d;
- struct ifreq *ifr;
+bpf_setif(struct bpf_d *d, struct ifreq *ifr)
{
struct bpf_if *bp, *candidate = NULL;
int s, error;
@@ -957,6 +924,7 @@ bpf_setif(d, ifr)
if (ifp == 0 ||
strcmp(ifp->if_xname, ifr->ifr_name) != 0)
continue;
+
/*
* We found the requested interface.
*/
@@ -997,9 +965,7 @@ bpf_setif(d, ifr)
* Copy the interface name to the ifreq.
*/
void
-bpf_ifname(ifp, ifr)
- struct ifnet *ifp;
- struct ifreq *ifr;
+bpf_ifname(struct ifnet *ifp, struct ifreq *ifr)
{
bcopy(ifp->if_xname, ifr->ifr_name, IFNAMSIZ);
}
@@ -1008,10 +974,7 @@ bpf_ifname(ifp, ifr)
* Support for poll() system call
*/
int
-bpfpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+bpfpoll(dev_t dev, int events, struct proc *p)
{
struct bpf_d *d;
int s, revents;
@@ -1042,7 +1005,7 @@ struct filterops bpfread_filtops =
{ 1, NULL, filt_bpfrdetach, filt_bpfread };
int
-bpfkqfilter(dev_t dev,struct knote *kn)
+bpfkqfilter(dev_t dev, struct knote *kn)
{
struct bpf_d *d;
struct klist *klist;
@@ -1100,10 +1063,7 @@ filt_bpfread(struct knote *kn, long hint)
* buffer.
*/
int
-bpf_tap(arg, pkt, pktlen)
- caddr_t arg;
- u_char *pkt;
- u_int pktlen;
+bpf_tap(caddr_t arg, u_char *pkt, u_int pktlen)
{
struct bpf_if *bp;
struct bpf_d *d;
@@ -1134,10 +1094,7 @@ bpf_tap(arg, pkt, pktlen)
* from m_copydata in sys/uipc_mbuf.c.
*/
void
-bpf_mcopy(src_arg, dst_arg, len)
- const void *src_arg;
- void *dst_arg;
- size_t len;
+bpf_mcopy(const void *src_arg, void *dst_arg, size_t len)
{
const struct mbuf *m;
u_int count;
@@ -1160,9 +1117,7 @@ bpf_mcopy(src_arg, dst_arg, len)
* Incoming linkage from device drivers, when packet is in an mbuf chain.
*/
int
-bpf_mtap(arg, m)
- caddr_t arg;
- struct mbuf *m;
+bpf_mtap(caddr_t arg, struct mbuf *m)
{
struct bpf_if *bp = (struct bpf_if *)arg;
struct bpf_d *d;
@@ -1180,11 +1135,13 @@ bpf_mtap(arg, m)
for (d = bp->bif_dlist; d != 0; d = d->bd_next) {
++d->bd_rcount;
slen = bpf_filter(d->bd_rfilter, (u_char *)m, pktlen, 0);
- if (slen != 0) {
- bpf_catchpacket(d, (u_char *)m, pktlen, slen, bpf_mcopy);
- if (d->bd_fildrop)
- drop++;
- }
+
+ if (slen == 0)
+ continue;
+
+ bpf_catchpacket(d, (u_char *)m, pktlen, slen, bpf_mcopy);
+ if (d->bd_fildrop)
+ drop++;
}
return (drop);
@@ -1199,11 +1156,8 @@ bpf_mtap(arg, m)
* pkt is really an mbuf.
*/
void
-bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn)
- struct bpf_d *d;
- u_char *pkt;
- size_t pktlen, snaplen;
- void (*cpfn)(const void *, void *, size_t);
+bpf_catchpacket(struct bpf_d *d, u_char *pkt, size_t pktlen, size_t snaplen,
+ void (*cpfn)(const void *, void *, size_t))
{
struct bpf_hdr *hp;
int totlen, curlen;
@@ -1285,8 +1239,7 @@ bpf_catchpacket(d, pkt, pktlen, snaplen, cpfn)
* Initialize all nonzero fields of a descriptor.
*/
int
-bpf_allocbufs(d)
- struct bpf_d *d;
+bpf_allocbufs(struct bpf_d *d)
{
d->bd_fbuf = (caddr_t)malloc(d->bd_bufsize, M_DEVBUF, M_NOWAIT);
if (d->bd_fbuf == NULL)
@@ -1306,8 +1259,7 @@ bpf_allocbufs(d)
* when the reference count drops to zero.
*/
void
-bpf_freed(d)
- struct bpf_d *d;
+bpf_freed(struct bpf_d *d)
{
if (--d->bd_ref > 0)
return;
@@ -1333,10 +1285,7 @@ bpf_freed(d)
* size of the link header (variable length headers not yet supported).
*/
void
-bpfattach(driverp, ifp, dlt, hdrlen)
- caddr_t *driverp;
- struct ifnet *ifp;
- u_int dlt, hdrlen;
+bpfattach(caddr_t *driverp, struct ifnet *ifp, u_int dlt, u_int hdrlen)
{
struct bpf_if *bp;
bp = (struct bpf_if *)malloc(sizeof(*bp), M_DEVBUF, M_DONTWAIT);
@@ -1365,8 +1314,7 @@ bpfattach(driverp, ifp, dlt, hdrlen)
/* Detach an interface from its attached bpf device. */
void
-bpfdetach(ifp)
- struct ifnet *ifp;
+bpfdetach(struct ifnet *ifp)
{
struct bpf_if *bp, *nbp, **pbp = &bpf_iflist;
struct bpf_d *bd;