Solaris 11 will support the ioctl BIOCSETLIF.
This operates on "struct lifname".
Whilst there are other *LIF ioctls, only this one
is important for libpcap.
For most consumers, the primary difference is the
length of the name allowed. The traditional ifname
structure only allowed for 16 character interface
names. The newer struct lifname allows for 32.
With the presence of interface renaming, amongst
other features, use of the struct lifname ioctls will
be required for proper functionality.
Darren
diff -u libpcap-clone/pcap-bpf.c libpcap/pcap-bpf.c
--- libpcap-clone/pcap-bpf.c Fri Jun 3 20:41:15 2011
+++ libpcap/pcap-bpf.c Fri Jun 3 19:47:06 2011
@@ -1459,7 +1459,15 @@
{
int status = 0;
int fd;
+#ifdef LIFNAMSIZ
+ struct lifreq ifr;
+ const char *ifrname = ifr.lifr_name;
+ const size_t ifnamsiz = sizeof(ifr.lifr_name);
+#else
struct ifreq ifr;
+ const char *ifrname = ifr.ifr_name;
+ const size_t ifnamsiz = sizeof(ifr.ifr_name);
+#endif
struct bpf_version bv;
#ifdef __APPLE__
int sockfd;
@@ -1551,9 +1559,8 @@
*/
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd != -1) {
- strlcpy(ifr.ifr_name,
- p->opt.source,
- sizeof(ifr.ifr_name));
+ strlcpy(ifrname,
+ p->opt.source, ifnamsiz);
if (ioctl(sockfd, SIOCGIFFLAGS,
(char *)&ifr) < 0) {
/*
@@ -1667,7 +1674,7 @@
pcap_strerror(errno));
goto bad;
}
- (void)strncpy(ifr.ifr_name, p->opt.source,
sizeof(ifr.ifr_name));
+ (void)strncpy(ifrname, p->opt.source, ifnamsiz);
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s:
%s",
p->opt.source, pcap_strerror(errno));
@@ -1697,9 +1704,13 @@
/*
* Now bind to the device.
*/
- (void)strncpy(ifr.ifr_name, p->opt.source,
- sizeof(ifr.ifr_name));
- if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
+ (void)strncpy(ifrname, p->opt.source, ifnamsiz);
+#ifdef BIOCSETLIF
+ if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0)
+#else
+ if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0)
+#endif
+ {
status = check_setif_failure(p, errno);
goto bad;
}
@@ -1726,9 +1737,12 @@
*/
(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
- (void)strncpy(ifr.ifr_name, p->opt.source,
- sizeof(ifr.ifr_name));
+ (void)strncpy(ifrname, p->opt.source, ifnamsiz);
+#ifdef BIOCSETLIF
+ if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0)
+#else
if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
+#endif
break; /* that size worked; we're done
*/
if (errno != ENOBUFS) {
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.