summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2004-12-17 15:56:59 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2004-12-17 15:56:59 +0000
commit1b640e4ba9c00e3621f171f7e86f5cb974caade9 (patch)
tree1476fc79aa8c3ab2f8906c876d45ea448bb282c7 /sys
parent3d749c75763899b95734dc202ea8589d2ddf477c (diff)
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')
-rw-r--r--sys/net/bpf.c130
-rw-r--r--sys/net/bpf.h56
-rw-r--r--sys/net/bpfdesc.h6
3 files changed, 70 insertions, 122 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;
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 77759f3d422..da4dc8a06ae 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.h,v 1.28 2004/06/22 04:04:19 canacar Exp $ */
+/* $OpenBSD: bpf.h,v 1.29 2004/12/17 15:56:58 reyk Exp $ */
/* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */
/*
@@ -152,28 +152,28 @@ struct bpf_hdr {
/*
* Data-link level type codes.
*/
-#define DLT_NULL 0 /* no link-layer encapsulation */
-#define DLT_EN10MB 1 /* Ethernet (10Mb) */
-#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
-#define DLT_AX25 3 /* Amateur Radio AX.25 */
-#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
-#define DLT_CHAOS 5 /* Chaos */
-#define DLT_IEEE802 6 /* IEEE 802 Networks */
-#define DLT_ARCNET 7 /* ARCNET */
-#define DLT_SLIP 8 /* Serial Line IP */
-#define DLT_PPP 9 /* Point-to-point Protocol */
-#define DLT_FDDI 10 /* FDDI */
-#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
-#define DLT_LOOP 12 /* loopback type (af header) */
-#define DLT_ENC 13 /* IPSEC enc type (af header, spi, flags) */
-#define DLT_RAW 14 /* raw IP */
-#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
-#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
-#define DLT_OLD_PFLOG 17 /* Packet filter logging, old (XXX remove?) */
-#define DLT_PFSYNC 18 /* Packet filter state syncing */
-#define DLT_PPP_ETHER 51 /* PPP over Ethernet; session only, w/o ether header */
-#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
-#define DLT_PFLOG 117 /* Packet filter logging, by pcap people */
+#define DLT_NULL 0 /* no link-layer encapsulation */
+#define DLT_EN10MB 1 /* Ethernet (10Mb) */
+#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
+#define DLT_AX25 3 /* Amateur Radio AX.25 */
+#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
+#define DLT_CHAOS 5 /* Chaos */
+#define DLT_IEEE802 6 /* IEEE 802 Networks */
+#define DLT_ARCNET 7 /* ARCNET */
+#define DLT_SLIP 8 /* Serial Line IP */
+#define DLT_PPP 9 /* Point-to-point Protocol */
+#define DLT_FDDI 10 /* FDDI */
+#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
+#define DLT_LOOP 12 /* loopback type (af header) */
+#define DLT_ENC 13 /* IPSEC enc type (af header, spi, flags) */
+#define DLT_RAW 14 /* raw IP */
+#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
+#define DLT_OLD_PFLOG 17 /* Packet filter logging, old (XXX remove?) */
+#define DLT_PFSYNC 18 /* Packet filter state syncing */
+#define DLT_PPP_ETHER 51 /* PPP over Ethernet; session only w/o ether header */
+#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */
+#define DLT_PFLOG 117 /* Packet filter logging, by pcap people */
/*
* The instruction encodings.
@@ -195,7 +195,7 @@ struct bpf_hdr {
#define BPF_H 0x08
#define BPF_B 0x10
#define BPF_MODE(code) ((code) & 0xe0)
-#define BPF_IMM 0x00
+#define BPF_IMM 0x00
#define BPF_ABS 0x20
#define BPF_IND 0x40
#define BPF_MEM 0x60
@@ -235,10 +235,10 @@ struct bpf_hdr {
* The instruction data structure.
*/
struct bpf_insn {
- u_int16_t code;
- u_char jt;
- u_char jf;
- u_int32_t k;
+ u_int16_t code;
+ u_char jt;
+ u_char jf;
+ u_int32_t k;
};
/*
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index 715cca0ee03..b9b3c2e5a1d 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpfdesc.h,v 1.14 2004/06/22 04:04:19 canacar Exp $ */
+/* $OpenBSD: bpfdesc.h,v 1.15 2004/12/17 15:56:58 reyk Exp $ */
/* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
/*
@@ -59,8 +59,8 @@ struct bpf_d {
caddr_t bd_sbuf; /* store slot */
caddr_t bd_hbuf; /* hold slot */
caddr_t bd_fbuf; /* free slot */
- int bd_slen; /* current length of store buffer */
- int bd_hlen; /* current length of hold buffer */
+ int bd_slen; /* current length of store buffer */
+ int bd_hlen; /* current length of hold buffer */
int bd_bufsize; /* absolute length of buffers */