NLOCK(); + return (ENOSPC); + } + + uaddr = bi->bi_ubuf; + cnt = 0; + LIST_FOREACH(bp, &bpf_iflist, bif_next) { + u_int len; + int error; + + len = strlen(bp->bif_name) + 1; + if ((error = copyout(bp->bif_name, uaddr, len)) != 0) { + BPF_UNLOCK(); + return (error); + } + if (++cnt == bi->bi_count) + break; + uaddr += len; + } + BPF_UNLOCK(); + bi->bi_count = cnt; + + return (0); +} + /* * Set d's packet filter program to fp. If this file already has a filter, * free it and replace it. Returns EINVAL for bogus requests. diff --git a/sys/net/bpf.h b/sys/net/bpf.h index cda03c06d51d..f6bcb0e34ed4 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -118,6 +118,15 @@ struct bpf_zbuf { size_t bz_buflen; /* Size of zero-copy buffers. */ }; +/* + * Struct used by BIOCGETIFLIST. + */ +struct bpf_iflist { + u_int bi_size; + u_int bi_count; + void *bi_ubuf; +}; + #define BIOCGBLEN _IOR('B', 102, u_int) #define BIOCSBLEN _IOWR('B', 102, u_int) #define BIOCSETF _IOW('B', 103, struct bpf_program) @@ -151,6 +160,7 @@ struct bpf_zbuf { #define BIOCGTSTAMP _IOR('B', 131, u_int) #define BIOCSTSTAMP _IOW('B', 132, u_int) #define BIOCSETVLANPCP _IOW('B', 133, u_int) +#define BIOCGETIFLIST _IOWR('B', 134, struct bpf_iflist) /* Obsolete */ #define BIOCGSEESENT BIOCGDIRECTION diff --git a/sys/sys/param.h b/sys/sys/param.h index 003c28c082cb..fa09878507c6 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -74,7 +74,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1600005 +#define __FreeBSD_version 1600006 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,