diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-06-29 20:45:03 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-06-29 20:45:03 -0700 |
commit | d6998249084df8dc1131b8dd3cbce0d65a075b4f (patch) | |
tree | a8e5e12973f2fa5c6797b578441f165dde7f5005 | |
parent | 8924ffeafc0cef74a399e9c8eb285b46c5a04e0f (diff) |
Rename opt.source to opt.device.
For local captures, it's jut the device. If we add remote capture
support, we'll be handed a URL, and will split the URL into multiple
components, and will store the various components in the opt structure,
with the path of the URL being opt.device.
-rw-r--r-- | pcap-bpf.c | 64 | ||||
-rw-r--r-- | pcap-bt-linux.c | 4 | ||||
-rw-r--r-- | pcap-can-linux.c | 2 | ||||
-rw-r--r-- | pcap-canusb-linux.c | 2 | ||||
-rw-r--r-- | pcap-dag.c | 2 | ||||
-rw-r--r-- | pcap-dbus.c | 4 | ||||
-rw-r--r-- | pcap-dlpi.c | 2 | ||||
-rw-r--r-- | pcap-dos.c | 8 | ||||
-rw-r--r-- | pcap-int.h | 2 | ||||
-rw-r--r-- | pcap-libdlpi.c | 10 | ||||
-rw-r--r-- | pcap-linux.c | 30 | ||||
-rw-r--r-- | pcap-netfilter-linux.c | 6 | ||||
-rw-r--r-- | pcap-nit.c | 2 | ||||
-rw-r--r-- | pcap-pf.c | 6 | ||||
-rw-r--r-- | pcap-sita.c | 2 | ||||
-rw-r--r-- | pcap-snf.c | 2 | ||||
-rw-r--r-- | pcap-snit.c | 2 | ||||
-rw-r--r-- | pcap-snoop.c | 42 | ||||
-rw-r--r-- | pcap-tc.c | 2 | ||||
-rw-r--r-- | pcap-usb-linux.c | 4 | ||||
-rw-r--r-- | pcap-win32.c | 4 | ||||
-rw-r--r-- | pcap.c | 48 |
22 files changed, 125 insertions, 125 deletions
@@ -746,7 +746,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p) * 10.4 (Darwin 8.x). s/en/wlt/, and check * whether the device exists. */ - if (strncmp(p->opt.source, "en", 2) != 0) { + if (strncmp(p->opt.device, "en", 2) != 0) { /* * Not an enN device; no monitor mode. */ @@ -759,7 +759,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p) return (PCAP_ERROR); } strlcpy(ifr.ifr_name, "wlt", sizeof(ifr.ifr_name)); - strlcat(ifr.ifr_name, p->opt.source + 2, sizeof(ifr.ifr_name)); + strlcat(ifr.ifr_name, p->opt.device + 2, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { /* * No such device? @@ -786,7 +786,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p) /* * Now bind to the device. */ - (void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); + (void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name)); if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { switch (errno) { @@ -811,7 +811,7 @@ pcap_can_set_rfmon_bpf(pcap_t *p) default: pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", - p->opt.source, pcap_strerror(errno)); + p->opt.device, pcap_strerror(errno)); close(fd); return (PCAP_ERROR); } @@ -1464,7 +1464,7 @@ check_setif_failure(pcap_t *p, int error) * No such device exists. */ #ifdef __APPLE__ - if (p->opt.rfmon && strncmp(p->opt.source, "wlt", 3) == 0) { + if (p->opt.rfmon && strncmp(p->opt.device, "wlt", 3) == 0) { /* * Monitor mode was requested, and we're trying * to open a "wltN" device. Assume that this @@ -1476,7 +1476,7 @@ check_setif_failure(pcap_t *p, int error) if (fd != -1) { strlcpy(ifr.ifr_name, "en", sizeof(ifr.ifr_name)); - strlcat(ifr.ifr_name, p->opt.source + 3, + strlcat(ifr.ifr_name, p->opt.device + 3, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { /* @@ -1537,7 +1537,7 @@ check_setif_failure(pcap_t *p, int error) * return PCAP_ERROR. */ pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", - p->opt.source, pcap_strerror(errno)); + p->opt.device, pcap_strerror(errno)); return (PCAP_ERROR); } } @@ -1639,7 +1639,7 @@ pcap_activate_bpf(pcap_t *p) * traffic on datalinks in non-global zones. Non-global zones * do not have access to datalinks outside of their own namespace. */ - if ((zonesep = strchr(p->opt.source, '/')) != NULL) { + if ((zonesep = strchr(p->opt.device, '/')) != NULL) { char path_zname[ZONENAME_MAX]; int znamelen; char *lnamep; @@ -1650,8 +1650,8 @@ pcap_activate_bpf(pcap_t *p) status = PCAP_ERROR; goto bad; } - znamelen = zonesep - p->opt.source; - (void) strlcpy(path_zname, p->opt.source, znamelen + 1); + znamelen = zonesep - p->opt.device; + (void) strlcpy(path_zname, p->opt.device, znamelen + 1); ifr.lifr_zoneid = getzoneidbyname(path_zname); if (ifr.lifr_zoneid == -1) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, @@ -1667,12 +1667,12 @@ pcap_activate_bpf(pcap_t *p) status = PCAP_ERROR; goto bad; } - free(p->opt.source); - p->opt.source = lnamep; + free(p->opt.device); + p->opt.device = lnamep; } #endif - pb->device = strdup(p->opt.source); + pb->device = strdup(p->opt.device); if (pb->device == NULL) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s", pcap_strerror(errno)); @@ -1710,7 +1710,7 @@ pcap_activate_bpf(pcap_t *p) /* * 10.4 (Darwin 8.x). s/en/wlt/ */ - if (strncmp(p->opt.source, "en", 2) != 0) { + if (strncmp(p->opt.device, "en", 2) != 0) { /* * Not an enN device; check * whether the device even exists. @@ -1718,7 +1718,7 @@ pcap_activate_bpf(pcap_t *p) sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd != -1) { strlcpy(ifrname, - p->opt.source, ifnamsiz); + p->opt.device, ifnamsiz); if (ioctl(sockfd, SIOCGIFFLAGS, (char *)&ifr) < 0) { /* @@ -1750,7 +1750,7 @@ pcap_activate_bpf(pcap_t *p) } goto bad; } - wltdev = malloc(strlen(p->opt.source) + 2); + wltdev = malloc(strlen(p->opt.device) + 2); if (wltdev == NULL) { (void)pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", @@ -1759,9 +1759,9 @@ pcap_activate_bpf(pcap_t *p) goto bad; } strcpy(wltdev, "wlt"); - strcat(wltdev, p->opt.source + 2); - free(p->opt.source); - p->opt.source = wltdev; + strcat(wltdev, p->opt.device + 2); + free(p->opt.device); + p->opt.device = wltdev; } /* * Everything else is 10.5 or later; for those, @@ -1776,11 +1776,11 @@ pcap_activate_bpf(pcap_t *p) * try to create the interface if it's not available. */ #if defined(__FreeBSD__) && defined(SIOCIFCREATE2) - if (strncmp(p->opt.source, usbus_prefix, USBUS_PREFIX_LEN) == 0) { + if (strncmp(p->opt.device, usbus_prefix, USBUS_PREFIX_LEN) == 0) { /* * Do we already have an interface with that name? */ - if (if_nametoindex(p->opt.source) == 0) { + if (if_nametoindex(p->opt.device) == 0) { /* * No. We need to create it, and, if we * succeed, remember that we should destroy @@ -1818,16 +1818,16 @@ pcap_activate_bpf(pcap_t *p) /* * Create the interface. */ - strlcpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name)); if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) { if (errno == EINVAL) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Invalid USB bus interface %s", - p->opt.source); + p->opt.device); } else { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "Can't create interface for %s: %s", - p->opt.source, pcap_strerror(errno)); + p->opt.device, pcap_strerror(errno)); } close(s); status = PCAP_ERROR; @@ -1912,10 +1912,10 @@ pcap_activate_bpf(pcap_t *p) status = PCAP_ERROR; goto bad; } - (void)strncpy(ifrname, p->opt.source, ifnamsiz); + (void)strncpy(ifrname, p->opt.device, ifnamsiz); if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s", - p->opt.source, pcap_strerror(errno)); + p->opt.device, pcap_strerror(errno)); status = PCAP_ERROR; goto bad; } @@ -1934,7 +1934,7 @@ pcap_activate_bpf(pcap_t *p) if (ioctl(fd, BIOCSBLEN, (caddr_t)&p->opt.buffer_size) < 0) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "BIOCSBLEN: %s: %s", p->opt.source, + "BIOCSBLEN: %s: %s", p->opt.device, pcap_strerror(errno)); status = PCAP_ERROR; goto bad; @@ -1943,7 +1943,7 @@ pcap_activate_bpf(pcap_t *p) /* * Now bind to the device. */ - (void)strncpy(ifrname, p->opt.source, ifnamsiz); + (void)strncpy(ifrname, p->opt.device, ifnamsiz); #ifdef BIOCSETLIF if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0) #else @@ -1976,7 +1976,7 @@ pcap_activate_bpf(pcap_t *p) */ (void) ioctl(fd, BIOCSBLEN, (caddr_t)&v); - (void)strncpy(ifrname, p->opt.source, ifnamsiz); + (void)strncpy(ifrname, p->opt.device, ifnamsiz); #ifdef BIOCSETLIF if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0) #else @@ -1993,7 +1993,7 @@ pcap_activate_bpf(pcap_t *p) if (v == 0) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSBLEN: %s: No buffer size worked", - p->opt.source); + p->opt.device); status = PCAP_ERROR; goto bad; } @@ -2618,7 +2618,7 @@ monitor_mode(pcap_t *p, int set) } memset(&req, 0, sizeof req); - strncpy(req.ifm_name, p->opt.source, sizeof req.ifm_name); + strncpy(req.ifm_name, p->opt.device, sizeof req.ifm_name); /* * Find out how many media types we have. @@ -2728,7 +2728,7 @@ monitor_mode(pcap_t *p, int set) return (PCAP_ERROR); } memset(&ifr, 0, sizeof(ifr)); - (void)strncpy(ifr.ifr_name, p->opt.source, + (void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name)); ifr.ifr_media = req.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(sock, SIOCSIFMEDIA, &ifr) == -1) { diff --git a/pcap-bt-linux.c b/pcap-bt-linux.c index a398b267..7173805a 100644 --- a/pcap-bt-linux.c +++ b/pcap-bt-linux.c @@ -190,11 +190,11 @@ bt_activate(pcap_t* handle) int err = PCAP_ERROR; /* get bt interface id */ - if (sscanf(handle->opt.source, BT_IFACE"%d", &dev_id) != 1) + if (sscanf(handle->opt.device, BT_IFACE"%d", &dev_id) != 1) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get Bluetooth device index from %s", - handle->opt.source); + handle->opt.device); return PCAP_ERROR; } diff --git a/pcap-can-linux.c b/pcap-can-linux.c index b4e2a008..ef7ca35b 100644 --- a/pcap-can-linux.c +++ b/pcap-can-linux.c @@ -172,7 +172,7 @@ can_activate(pcap_t* handle) /* get interface index */ memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name)); if (ioctl(handle->fd, SIOCGIFINDEX, &ifr) < 0) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, diff --git a/pcap-canusb-linux.c b/pcap-canusb-linux.c index fb5b669f..715a60d0 100644 --- a/pcap-canusb-linux.c +++ b/pcap-canusb-linux.c @@ -371,7 +371,7 @@ static int canusb_activate(pcap_t* handle) handle->linktype = DLT_CAN_SOCKETCAN; handle->set_datalink_op = NULL; - serial = handle->opt.source + strlen(CANUSB_IFACE); + serial = handle->opt.device + strlen(CANUSB_IFACE); canusb->dev = canusb_opendevice(canusb->ctx, serial); if (!canusb->dev) @@ -725,7 +725,7 @@ static int dag_activate(pcap_t* handle) int n; daginf_t* daginf; char * newDev = NULL; - char * device = handle->opt.source; + char * device = handle->opt.device; #ifdef HAVE_DAG_STREAMS_API uint32_t mindata; struct timeval maxwait; diff --git a/pcap-dbus.c b/pcap-dbus.c index 0974f82b..30daba8e 100644 --- a/pcap-dbus.c +++ b/pcap-dbus.c @@ -160,7 +160,7 @@ dbus_activate(pcap_t *handle) #define N_RULES sizeof(rules)/sizeof(rules[0]) struct pcap_dbus *handlep = handle->priv; - const char *dev = handle->opt.source; + const char *dev = handle->opt.device; DBusError error = DBUS_ERROR_INIT; int i; @@ -195,7 +195,7 @@ dbus_activate(pcap_t *handle) } } else { - pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.source); + pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.device); return PCAP_ERROR; } diff --git a/pcap-dlpi.c b/pcap-dlpi.c index 144160e2..38f01a8e 100644 --- a/pcap-dlpi.c +++ b/pcap-dlpi.c @@ -500,7 +500,7 @@ pcap_activate_dlpi(pcap_t *p) #endif bpf_u_int32 buf[MAXDLBUF]; - p->fd = open_dlpi_device(p->opt.source, &ppa, p->errbuf); + p->fd = open_dlpi_device(p->opt.device, &ppa, p->errbuf); if (p->fd < 0) { status = p->fd; goto bad; @@ -194,18 +194,18 @@ static int pcap_activate_dos (pcap_t *pcap) if (pcap->fd == 1) /* first time we're called */ { - if (!init_watt32(pcap, pcap->opt.source, pcap->errbuf) || - !first_init(pcap->opt.source, pcap->errbuf, pcap->opt.promisc)) + if (!init_watt32(pcap, pcap->opt.device, pcap->errbuf) || + !first_init(pcap->opt.device, pcap->errbuf, pcap->opt.promisc)) { return (PCAP_ERROR); } atexit (close_driver); } - else if (stricmp(active_dev->name,pcap->opt.source)) + else if (stricmp(active_dev->name,pcap->opt.device)) { pcap_snprintf (pcap->errbuf, PCAP_ERRBUF_SIZE, "Cannot use different devices simultaneously " - "(`%s' vs. `%s')", active_dev->name, pcap->opt.source); + "(`%s' vs. `%s')", active_dev->name, pcap->opt.device); return (PCAP_ERROR); } handle_to_device [pcap->fd-1] = active_dev; @@ -108,7 +108,7 @@ extern "C" { #define MAXIMUM_SNAPLEN 262144 struct pcap_opt { - char *source; + char *device; int timeout; /* timeout for buffering */ int buffer_size; int promisc; diff --git a/pcap-libdlpi.c b/pcap-libdlpi.c index 0e4aff59..745c0c77 100644 --- a/pcap-libdlpi.c +++ b/pcap-libdlpi.c @@ -106,7 +106,7 @@ pcap_activate_libdlpi(pcap_t *p) * dlpi_open() will not fail if the underlying link does not support * passive mode. See dlpi(7P) for details. */ - retv = dlpi_open(p->opt.source, &dh, DLPI_RAW|DLPI_PASSIVE); + retv = dlpi_open(p->opt.device, &dh, DLPI_RAW|DLPI_PASSIVE); if (retv != DLPI_SUCCESS) { if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK) status = PCAP_ERROR_NO_SUCH_DEVICE; @@ -115,7 +115,7 @@ pcap_activate_libdlpi(pcap_t *p) status = PCAP_ERROR_PERM_DENIED; else status = PCAP_ERROR; - pcap_libdlpi_err(p->opt.source, "dlpi_open", retv, + pcap_libdlpi_err(p->opt.device, "dlpi_open", retv, p->errbuf); return (status); } @@ -133,7 +133,7 @@ pcap_activate_libdlpi(pcap_t *p) /* Bind with DLPI_ANY_SAP. */ if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) { status = PCAP_ERROR; - pcap_libdlpi_err(p->opt.source, "dlpi_bind", retv, p->errbuf); + pcap_libdlpi_err(p->opt.device, "dlpi_bind", retv, p->errbuf); goto bad; } @@ -187,7 +187,7 @@ pcap_activate_libdlpi(pcap_t *p) /* Determine link type. */ if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) { status = PCAP_ERROR; - pcap_libdlpi_err(p->opt.source, "dlpi_info", retv, p->errbuf); + pcap_libdlpi_err(p->opt.device, "dlpi_info", retv, p->errbuf); goto bad; } @@ -258,7 +258,7 @@ dlpromiscon(pcap_t *p, bpf_u_int32 level) err = PCAP_ERROR_PERM_DENIED; else err = PCAP_ERROR; - pcap_libdlpi_err(p->opt.source, "dlpi_promiscon" STRINGIFY(level), + pcap_libdlpi_err(p->opt.device, "dlpi_promiscon" STRINGIFY(level), retv, p->errbuf); return (err); } diff --git a/pcap-linux.c b/pcap-linux.c index 4aeb7ec3..cae2e21a 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -1019,7 +1019,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) struct iwreq ireq; #endif - if (strcmp(handle->opt.source, "any") == 0) { + if (strcmp(handle->opt.device, "any") == 0) { /* * Monitor mode makes no sense on the "any" device. */ @@ -1039,7 +1039,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) * wmaster device, so we don't bother checking whether * a mac80211 device supports the Wireless Extensions. */ - ret = get_mac80211_phydev(handle, handle->opt.source, phydev_path, + ret = get_mac80211_phydev(handle, handle->opt.device, phydev_path, PATH_MAX); if (ret < 0) return ret; /* error */ @@ -1065,7 +1065,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) return PCAP_ERROR; } - if (is_bonding_device(sock_fd, handle->opt.source)) { + if (is_bonding_device(sock_fd, handle->opt.device)) { /* It's a bonding device, so don't even try. */ close(sock_fd); return 0; @@ -1074,7 +1074,7 @@ pcap_can_set_rfmon_linux(pcap_t *handle) /* * Attempt to get the current mode. */ - strlcpy(ireq.ifr_ifrn.ifrn_name, handle->opt.source, + strlcpy(ireq.ifr_ifrn.ifrn_name, handle->opt.device, sizeof ireq.ifr_ifrn.ifrn_name); if (ioctl(sock_fd, SIOCGIWMODE, &ireq) != -1) { /* @@ -1427,7 +1427,7 @@ pcap_activate_linux(pcap_t *handle) int status = 0; int ret; - device = handle->opt.source; + device = handle->opt.device; /* * Make sure the name we were handed will fit into the ioctls we @@ -3291,7 +3291,7 @@ activate_new(pcap_t *handle) { #ifdef HAVE_PF_PACKET_SOCKETS struct pcap_linux *handlep = handle->priv; - const char *device = handle->opt.source; + const char *device = handle->opt.device; int is_any_device = (strcmp(device, "any") == 0); int sock_fd = -1, arptype; #ifdef HAVE_PACKET_AUXDATA @@ -4059,7 +4059,7 @@ create_ring(pcap_t *handle, int *status) return -1; } if (!offload) { - mtu = iface_get_mtu(handle->fd, handle->opt.source, + mtu = iface_get_mtu(handle->fd, handle->opt.device, handle->errbuf); if (mtu == -1) { *status = PCAP_ERROR; @@ -4200,7 +4200,7 @@ create_ring(pcap_t *handle, int *status) hwconfig.rx_filter = HWTSTAMP_FILTER_ALL; memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name)); ifr.ifr_data = (void *)&hwconfig; if (ioctl(handle->fd, SIOCSHWTSTAMP, &ifr) < 0) { @@ -6043,7 +6043,7 @@ iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf) * and not all devices even necessarily *support* hardware time * stamping, so don't report any time stamp types. */ - if (strcmp(handle->opt.source, "any") == 0) { + if (strcmp(handle->opt.device, "any") == 0) { handle->tstamp_type_list = NULL; return 0; } @@ -6059,7 +6059,7 @@ iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf) } memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name)); memset(&info, 0, sizeof(info)); info.cmd = ETHTOOL_GET_TS_INFO; ifr.ifr_data = (caddr_t)&info; @@ -6094,7 +6094,7 @@ iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf) * Other error. */ pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, - "%s: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: %s", handle->opt.source, + "%s: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: %s", handle->opt.device, strerror(save_errno)); return -1; } @@ -6148,7 +6148,7 @@ iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf _U_) * and not all devices even necessarily *support* hardware time * stamping, so don't report any time stamp types. */ - if (strcmp(handle->opt.source, "any") == 0) { + if (strcmp(handle->opt.device, "any") == 0) { handle->tstamp_type_list = NULL; return 0; } @@ -6181,7 +6181,7 @@ iface_ethtool_flag_ioctl(pcap_t *handle, int cmd, const char *cmdname) struct ethtool_value eval; memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name)); eval.cmd = cmd; eval.data = 0; ifr.ifr_data = (caddr_t)&eval; @@ -6196,7 +6196,7 @@ iface_ethtool_flag_ioctl(pcap_t *handle, int cmd, const char *cmdname) return 0; } pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "%s: SIOCETHTOOL(%s) ioctl failed: %s", handle->opt.source, + "%s: SIOCETHTOOL(%s) ioctl failed: %s", handle->opt.device, cmdname, strerror(errno)); return -1; } @@ -6288,7 +6288,7 @@ activate_old(pcap_t *handle) struct pcap_linux *handlep = handle->priv; int arptype; struct ifreq ifr; - const char *device = handle->opt.source; + const char *device = handle->opt.device; struct utsname utsname; int mtu; diff --git a/pcap-netfilter-linux.c b/pcap-netfilter-linux.c index 0b3ec3c7..224a9f68 100644 --- a/pcap-netfilter-linux.c +++ b/pcap-netfilter-linux.c @@ -420,7 +420,7 @@ nfqueue_send_config_mode(const pcap_t *handle, u_int16_t group_id, u_int8_t copy static int netfilter_activate(pcap_t* handle) { - const char *dev = handle->opt.source; + const char *dev = handle->opt.device; unsigned short groups[32]; int group_count = 0; nftype_t type = OTHER; @@ -444,7 +444,7 @@ netfilter_activate(pcap_t* handle) if (group_count == 32) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Maximum 32 netfilter groups! dev: %s", - handle->opt.source); + handle->opt.device); return PCAP_ERROR; } @@ -469,7 +469,7 @@ netfilter_activate(pcap_t* handle) if (type == OTHER || *dev) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get netfilter group(s) index from %s", - handle->opt.source); + handle->opt.device); return PCAP_ERROR; } @@ -285,7 +285,7 @@ pcap_activate_nit(pcap_t *p) goto bad; } snit.snit_family = AF_NIT; - (void)strncpy(snit.snit_ifname, p->opt.source, NITIFSIZ); + (void)strncpy(snit.snit_ifname, p->opt.device, NITIFSIZ); if (bind(fd, (struct sockaddr *)&snit, sizeof(snit))) { /* @@ -325,13 +325,13 @@ pcap_activate_pf(pcap_t *p) * XXX - is there an error that means "no such device"? Is * there one that means "that device doesn't support pf"? */ - p->fd = pfopen(p->opt.source, O_RDWR); + p->fd = pfopen(p->opt.device, O_RDWR); if (p->fd == -1 && errno == EACCES) - p->fd = pfopen(p->opt.source, O_RDONLY); + p->fd = pfopen(p->opt.device, O_RDONLY); if (p->fd < 0) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "pf open: %s: %s\n\ your system may not be properly configured; see the packetfilter(4) man page\n", - p->opt.source, pcap_strerror(errno)); + p->opt.device, pcap_strerror(errno)); goto bad; } pf->OrigMissed = -1; diff --git a/pcap-sita.c b/pcap-sita.c index 0350f40a..6ceb38d9 100644 --- a/pcap-sita.c +++ b/pcap-sita.c @@ -988,7 +988,7 @@ static int pcap_activate_sita(pcap_t *handle) { handle->read_op = pcap_read_acn; handle->stats_op = pcap_stats_acn; - fd = acn_open_live(handle->opt.source, handle->errbuf, + fd = acn_open_live(handle->opt.device, handle->errbuf, &handle->linktype); if (fd == -1) return PCAP_ERROR; @@ -242,7 +242,7 @@ static int snf_activate(pcap_t* p) { struct pcap_snf *ps = p->priv; - char *device = p->opt.source; + char *device = p->opt.device; const char *nr = NULL; int err; int flags = -1, ring_id = -1; diff --git a/pcap-snit.c b/pcap-snit.c index a1f5e035..f7e70ed7 100644 --- a/pcap-snit.c +++ b/pcap-snit.c @@ -348,7 +348,7 @@ pcap_activate_snit(pcap_t *p) } /* request the interface */ - strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name)); ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; si.ic_cmd = NIOCBIND; si.ic_len = sizeof(ifr); diff --git a/pcap-snoop.c b/pcap-snoop.c index 9bf0d261..7128f0b8 100644 --- a/pcap-snoop.c +++ b/pcap-snoop.c @@ -219,7 +219,7 @@ pcap_activate_snoop(pcap_t *p) p->fd = fd; memset(&sr, 0, sizeof(sr)); sr.sr_family = AF_RAW; - (void)strncpy(sr.sr_ifname, p->opt.source, sizeof(sr.sr_ifname)); + (void)strncpy(sr.sr_ifname, p->opt.device, sizeof(sr.sr_ifname)); if (bind(fd, (struct sockaddr *)&sr, sizeof(sr))) { /* * XXX - there's probably a particular bind error that @@ -246,19 +246,19 @@ pcap_activate_snoop(pcap_t *p) /* * XXX hack - map device name to link layer type */ - if (strncmp("et", p->opt.source, 2) == 0 || /* Challenge 10 Mbit */ - strncmp("ec", p->opt.source, 2) == 0 || /* Indigo/Indy 10 Mbit, + if (strncmp("et", p->opt.device, 2) == 0 || /* Challenge 10 Mbit */ + strncmp("ec", p->opt.device, 2) == 0 || /* Indigo/Indy 10 Mbit, O2 10/100 */ - strncmp("ef", p->opt.source, 2) == 0 || /* O200/2000 10/100 Mbit */ - strncmp("eg", p->opt.source, 2) == 0 || /* Octane/O2xxx/O3xxx Gigabit */ - strncmp("gfe", p->opt.source, 3) == 0 || /* GIO 100 Mbit */ - strncmp("fxp", p->opt.source, 3) == 0 || /* Challenge VME Enet */ - strncmp("ep", p->opt.source, 2) == 0 || /* Challenge 8x10 Mbit EPLEX */ - strncmp("vfe", p->opt.source, 3) == 0 || /* Challenge VME 100Mbit */ - strncmp("fa", p->opt.source, 2) == 0 || - strncmp("qaa", p->opt.source, 3) == 0 || - strncmp("cip", p->opt.source, 3) == 0 || - strncmp("el", p->opt.source, 2) == 0) { + strncmp("ef", p->opt.device, 2) == 0 || /* O200/2000 10/100 Mbit */ + strncmp("eg", p->opt.device, 2) == 0 || /* Octane/O2xxx/O3xxx Gigabit */ + strncmp("gfe", p->opt.device, 3) == 0 || /* GIO 100 Mbit */ + strncmp("fxp", p->opt.device, 3) == 0 || /* Challenge VME Enet */ + strncmp("ep", p->opt.device, 2) == 0 || /* Challenge 8x10 Mbit EPLEX */ + strncmp("vfe", p->opt.device, 3) == 0 || /* Challenge VME 100Mbit */ + strncmp("fa", p->opt.device, 2) == 0 || + strncmp("qaa", p->opt.device, 3) == 0 || + strncmp("cip", p->opt.device, 3) == 0 || + strncmp("el", p->opt.device, 2) == 0) { p->linktype = DLT_EN10MB; p->offset = RAW_HDRPAD(sizeof(struct ether_header)); ll_hdrlen = sizeof(struct ether_header); @@ -291,22 +291,22 @@ pcap_activate_snoop(pcap_t *p) p->dlt_list[1] = DLT_DOCSIS; p->dlt_count = 2; } - } else if (strncmp("ipg", p->opt.source, 3) == 0 || - strncmp("rns", p->opt.source, 3) == 0 || /* O2/200/2000 FDDI */ - strncmp("xpi", p->opt.source, 3) == 0) { + } else if (strncmp("ipg", p->opt.device, 3) == 0 || + strncmp("rns", p->opt.device, 3) == 0 || /* O2/200/2000 FDDI */ + strncmp("xpi", p->opt.device, 3) == 0) { p->linktype = DLT_FDDI; p->offset = 3; /* XXX yeah? */ ll_hdrlen = 13; - } else if (strncmp("ppp", p->opt.source, 3) == 0) { + } else if (strncmp("ppp", p->opt.device, 3) == 0) { p->linktype = DLT_RAW; ll_hdrlen = 0; /* DLT_RAW meaning "no PPP header, just the IP packet"? */ - } else if (strncmp("qfa", p->opt.source, 3) == 0) { + } else if (strncmp("qfa", p->opt.device, 3) == 0) { p->linktype = DLT_IP_OVER_FC; ll_hdrlen = 24; - } else if (strncmp("pl", p->opt.source, 2) == 0) { + } else if (strncmp("pl", p->opt.device, 2) == 0) { p->linktype = DLT_RAW; ll_hdrlen = 0; /* Cray UNICOS/mp pseudo link */ - } else if (strncmp("lo", p->opt.source, 2) == 0) { + } else if (strncmp("lo", p->opt.device, 2) == 0) { p->linktype = DLT_NULL; ll_hdrlen = 4; } else { @@ -330,7 +330,7 @@ pcap_activate_snoop(pcap_t *p) * the MTU first and, if that succeeds, trim the snap length * to be no greater than the MTU. */ - (void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name)); + (void)strncpy(ifr.ifr_name, p->opt.device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFMTU, (char *)&ifr) < 0) { pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCGIFMTU: %s", pcap_strerror(errno)); @@ -584,7 +584,7 @@ TcActivate(pcap_t *p) pPpiHeader->Dot3FieldHeader.PfhLength = sizeof(PPI_FIELD_802_3_EXTENSION); pPpiHeader->Dot3FieldHeader.PfhType = PPI_FIELD_TYPE_802_3_EXTENSION; - status = g_TcFunctions.InstanceOpenByName(p->opt.source, &pt->TcInstance); + status = g_TcFunctions.InstanceOpenByName(p->opt.device, &pt->TcInstance); if (status != TC_SUCCESS) { diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index bf526a38..8201209f 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -395,10 +395,10 @@ usb_activate(pcap_t* handle) handle->setnonblock_op = pcap_setnonblock_fd; /*get usb bus index from device name */ - if (sscanf(handle->opt.source, USB_IFACE"%d", &handlep->bus_index) != 1) + if (sscanf(handle->opt.device, USB_IFACE"%d", &handlep->bus_index) != 1) { pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "Can't get USB bus index from %s", handle->opt.source); + "Can't get USB bus index from %s", handle->opt.device); return PCAP_ERROR; } diff --git a/pcap-win32.c b/pcap-win32.c index 17ef874c..2ab6e2af 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -796,7 +796,7 @@ pcap_activate_win32(pcap_t *p) /* Init WinSock */ wsockinit(); - p->adapter = PacketOpenAdapter(p->opt.source); + p->adapter = PacketOpenAdapter(p->opt.device); if (p->adapter == NULL) { @@ -982,7 +982,7 @@ pcap_activate_win32(pcap_t *p) pcap_snprintf(keyname, sizeof(keyname), "%s\\CardParams\\%s", "SYSTEM\\CurrentControlSet\\Services\\DAG", - strstr(_strlwr(p->opt.source), "dag")); + strstr(_strlwr(p->opt.device), "dag")); do { status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &dagkey); @@ -311,10 +311,10 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) } pcap_t * -pcap_create(const char *source, char *errbuf) +pcap_create(const char *device, char *errbuf) { int is_ours; - return (dag_create(source, errbuf, &is_ours)); + return (dag_create(device, errbuf, &is_ours)); } #elif defined(SEPTEL_ONLY) int @@ -324,10 +324,10 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) } pcap_t * -pcap_create(const char *source, char *errbuf) +pcap_create(const char *device, char *errbuf) { int is_ours; - return (septel_create(source, errbuf, &is_ours)); + return (septel_create(device, errbuf, &is_ours)); } #elif defined(SNF_ONLY) int @@ -337,10 +337,10 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) } pcap_t * -pcap_create(const char *source, char *errbuf) +pcap_create(const char *device, char *errbuf) { int is_ours; - return (snf_create(source, errbuf, &is_ours)); + return (snf_create(device, errbuf, &is_ours)); } #else /* regular pcap */ struct capture_source_type { @@ -423,21 +423,21 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) } pcap_t * -pcap_create(const char *source, char *errbuf) +pcap_create(const char *device, char *errbuf) { size_t i; int is_theirs; pcap_t *p; /* - * A null source name is equivalent to the "any" device - + * A null device name is equivalent to the "any" device - * which might not be supported on this platform, but * this means that you'll get a "not supported" error * rather than, say, a crash when we try to dereference * the null pointer. */ - if (source == NULL) - source = "any"; + if (device == NULL) + device = "any"; /* * Try each of the non-local-network-interface capture @@ -446,7 +446,7 @@ pcap_create(const char *source, char *errbuf) */ for (i = 0; capture_source_types[i].create_op != NULL; i++) { is_theirs = 0; - p = capture_source_types[i].create_op(source, errbuf, &is_theirs); + p = capture_source_types[i].create_op(device, errbuf, &is_theirs); if (is_theirs) { /* * The device name refers to a device of the @@ -464,7 +464,7 @@ pcap_create(const char *source, char *errbuf) /* * OK, try it as a regular network interface. */ - return (pcap_create_interface(source, errbuf)); + return (pcap_create_interface(device, errbuf)); } #endif @@ -558,7 +558,7 @@ pcap_alloc_pcap_t(char *ebuf, size_t size) } pcap_t * -pcap_create_common(const char *source, char *ebuf, size_t size) +pcap_create_common(const char *device, char *ebuf, size_t size) { pcap_t *p; @@ -566,8 +566,8 @@ pcap_create_common(const char *source, char *ebuf, size_t size) if (p == NULL) return (NULL); - p->opt.source = strdup(source); - if (p->opt.source == NULL) { + p->opt.device = strdup(device); + if (p->opt.device == NULL) { pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno)); free(p); @@ -792,12 +792,12 @@ pcap_activate(pcap_t *p) } pcap_t * -pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *errbuf) +pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *errbuf) { pcap_t *p; int status; - p = pcap_create(source, errbuf); + p = pcap_create(device, errbuf); if (p == NULL) return (NULL); status = pcap_set_snaplen(p, snaplen); @@ -826,15 +826,15 @@ pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *er return (p); fail: if (status == PCAP_ERROR) - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source, + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device, p->errbuf); else if (status == PCAP_ERROR_NO_SUCH_DEVICE || status == PCAP_ERROR_PERM_DENIED || status == PCAP_ERROR_PROMISC_PERM_DENIED) - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", source, + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", device, pcap_statustostr(status), p->errbuf); else - pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source, + pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", device, pcap_statustostr(status)); pcap_close(p); return (NULL); @@ -850,8 +850,8 @@ pcap_open_offline_common(char *ebuf, size_t size) return (NULL); p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO; - p->opt.source = strdup("(savefile)"); - if (p->opt.source == NULL) { + p->opt.device = strdup("(savefile)"); + if (p->opt.device == NULL) { pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno)); free(p); @@ -2072,8 +2072,8 @@ pcap_inject(pcap_t *p, const void *buf, size_t size) void pcap_close(pcap_t *p) { - if (p->opt.source != NULL) - free(p->opt.source); + if (p->opt.device != NULL) + free(p->opt.device); p->cleanup_op(p); free(p); } |