Deleted Added
full compact
sbpf.c (153881) sbpf.c (161357)
1/* $FreeBSD: head/contrib/ipfilter/ipsend/sbpf.c 153881 2005-12-30 11:52:26Z guido $ */
1/* $FreeBSD: head/contrib/ipfilter/ipsend/sbpf.c 161357 2006-08-16 12:23:02Z guido $ */
2/*
3 * (C)opyright 1995-1998 Darren Reed. (from tcplog)
4 *
5 * See the IPFILTER.LICENCE file for details on licencing.
6 *
7 */
8#include <sys/param.h>
9#include <sys/types.h>

--- 22 unchanged lines hidden (view full) ---

32#include <netinet/udp_var.h>
33#include <netinet/tcp.h>
34
35#include <stdio.h>
36#include <netdb.h>
37#include <string.h>
38#include <unistd.h>
39#include <stdlib.h>
2/*
3 * (C)opyright 1995-1998 Darren Reed. (from tcplog)
4 *
5 * See the IPFILTER.LICENCE file for details on licencing.
6 *
7 */
8#include <sys/param.h>
9#include <sys/types.h>

--- 22 unchanged lines hidden (view full) ---

32#include <netinet/udp_var.h>
33#include <netinet/tcp.h>
34
35#include <stdio.h>
36#include <netdb.h>
37#include <string.h>
38#include <unistd.h>
39#include <stdlib.h>
40#ifdef __NetBSD__
41# include <paths.h>
42#endif
40#include <ctype.h>
41#include <signal.h>
42#include <errno.h>
43
44#include "ipsend.h"
45
46#if !defined(lint)
47static const char sccsid[] = "@(#)sbpf.c 1.3 8/25/95 (C)1995 Darren Reed";
43#include <ctype.h>
44#include <signal.h>
45#include <errno.h>
46
47#include "ipsend.h"
48
49#if !defined(lint)
50static const char sccsid[] = "@(#)sbpf.c 1.3 8/25/95 (C)1995 Darren Reed";
48static const char rcsid[] = "@(#)$Id: sbpf.c,v 2.5 2002/02/24 07:30:03 darrenr Exp $";
51static const char rcsid[] = "@(#)$Id: sbpf.c,v 2.5.4.1 2006/03/21 16:32:58 darrenr Exp $";
49#endif
50
51/*
52 * the code herein is dervied from libpcap.
53 */
54static u_char *buf = NULL;
55static int bufsize = 0, timeout = 1;
56
57
58int initdevice(device, tout)
59char *device;
60int tout;
61{
62 struct bpf_version bv;
63 struct timeval to;
64 struct ifreq ifr;
52#endif
53
54/*
55 * the code herein is dervied from libpcap.
56 */
57static u_char *buf = NULL;
58static int bufsize = 0, timeout = 1;
59
60
61int initdevice(device, tout)
62char *device;
63int tout;
64{
65 struct bpf_version bv;
66 struct timeval to;
67 struct ifreq ifr;
68#ifdef _PATH_BPF
69 char *bpfname = _PATH_BPF;
70 int fd;
71
72 if ((fd = open(bpfname, O_RDWR)) < 0)
73 {
74 fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
75 return -1;
76 }
77#else
65 char bpfname[16];
66 int fd = 0, i;
67
68 for (i = 0; i < 16; i++)
69 {
70 (void) sprintf(bpfname, "/dev/bpf%d", i);
71 if ((fd = open(bpfname, O_RDWR)) >= 0)
72 break;
73 }
74 if (i == 16)
75 {
76 fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
77 return -1;
78 }
78 char bpfname[16];
79 int fd = 0, i;
80
81 for (i = 0; i < 16; i++)
82 {
83 (void) sprintf(bpfname, "/dev/bpf%d", i);
84 if ((fd = open(bpfname, O_RDWR)) >= 0)
85 break;
86 }
87 if (i == 16)
88 {
89 fprintf(stderr, "no bpf devices available as /dev/bpfxx\n");
90 return -1;
91 }
92#endif
79
80 if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0)
81 {
82 perror("BIOCVERSION");
83 return -1;
84 }
85 if (bv.bv_major != BPF_MAJOR_VERSION ||
86 bv.bv_minor < BPF_MINOR_VERSION)

--- 56 unchanged lines hidden ---
93
94 if (ioctl(fd, BIOCVERSION, (caddr_t)&bv) < 0)
95 {
96 perror("BIOCVERSION");
97 return -1;
98 }
99 if (bv.bv_major != BPF_MAJOR_VERSION ||
100 bv.bv_minor < BPF_MINOR_VERSION)

--- 56 unchanged lines hidden ---