author | rajkumar.sivaprakasam@oracle.com <rajkumar.sivaprakasam@oracle.com> |
Wed, 31 Jul 2013 00:20:46 -0700 | |
changeset 1413 | 5993f361061f |
parent 431 | e60e527b8179 |
permissions | -rw-r--r-- |
431
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
1 |
--- libpcap-1.1.1/pcap-bpf.c Thu Mar 11 17:56:54 2010 |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
2 |
+++ patched-libpcap-1.1.1/pcap-bpf.c Tue Jul 12 14:49:10 2011 |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
3 |
@@ -1392,7 +1392,15 @@ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
4 |
{ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
5 |
int status = 0; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
6 |
int fd; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
7 |
+#ifdef LIFNAMSIZ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
8 |
+ struct lifreq ifr; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
9 |
+ char *ifrname = ifr.lifr_name; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
10 |
+ const size_t ifnamsiz = sizeof(ifr.lifr_name); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
11 |
+#else |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
12 |
struct ifreq ifr; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
13 |
+ char *ifrname = ifr.ifr_name; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
14 |
+ const size_t ifnamsiz = sizeof(ifr.ifr_name); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
15 |
+#endif |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
16 |
struct bpf_version bv; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
17 |
#ifdef __APPLE__ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
18 |
int sockfd; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
19 |
@@ -1484,9 +1492,7 @@ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
20 |
*/ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
21 |
sockfd = socket(AF_INET, SOCK_DGRAM, 0); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
22 |
if (sockfd != -1) { |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
23 |
- strlcpy(ifr.ifr_name, |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
24 |
- p->opt.source, |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
25 |
- sizeof(ifr.ifr_name)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
26 |
+ strlcpy(ifrname, p->opt.source, ifnamsiz); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
27 |
if (ioctl(sockfd, SIOCGIFFLAGS, |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
28 |
(char *)&ifr) < 0) { |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
29 |
/* |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
30 |
@@ -1608,7 +1614,7 @@ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
31 |
pcap_strerror(errno)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
32 |
goto bad; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
33 |
} |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
34 |
- (void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
35 |
+ (void)strncpy(ifrname, p->opt.source, ifrnamsiz); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
36 |
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
37 |
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
38 |
p->opt.source, pcap_strerror(errno)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
39 |
@@ -1638,9 +1644,14 @@ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
40 |
/* |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
41 |
* Now bind to the device. |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
42 |
*/ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
43 |
- (void)strncpy(ifr.ifr_name, p->opt.source, |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
44 |
- sizeof(ifr.ifr_name)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
45 |
- if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
46 |
+ (void)strncpy(ifrname, p->opt.source, ifnamsiz); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
47 |
+#ifdef BIOCSETLIF |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
48 |
+ if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0) |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
49 |
+#else |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
50 |
+ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
51 |
+ if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
52 |
+#endif |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
53 |
+ { |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
54 |
status = check_setif_failure(p, errno); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
55 |
goto bad; |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
56 |
} |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
57 |
@@ -1667,9 +1678,12 @@ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
58 |
*/ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
59 |
(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
60 |
|
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
61 |
- (void)strncpy(ifr.ifr_name, p->opt.source, |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
62 |
- sizeof(ifr.ifr_name)); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
63 |
+ (void)strncpy(ifrname, p->opt.source, ifnamsiz); |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
64 |
+#ifdef BIOCSETLIF |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
65 |
+ if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0) |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
66 |
+#else |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
67 |
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0) |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
68 |
+#endif |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
69 |
break; /* that size worked; we're done */ |
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
70 |
|
e60e527b8179
7068506 Move libpcap from SFW to userland
Rishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
parents:
diff
changeset
|
71 |
if (errno != ENOBUFS) { |