So pass it the interface name, and use the name passed to it rather than
the name in the pcap_t - which hasn't yet been set at that point.
14 files changed:
#endif /* HAVE_ZEROCOPY_BPF */
pcap_t *
#endif /* HAVE_ZEROCOPY_BPF */
pcap_t *
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
{
pcap_t *p;
#ifdef DL_HP_RAWDLS
{
pcap_t *p;
#ifdef DL_HP_RAWDLS
struct pcap_stat stat;
};
struct pcap_stat stat;
};
-pcap_t *pcap_create_interface (char *ebuf)
+pcap_t *pcap_create_interface (const char *device _U_, char *ebuf)
* "pcap_create_common()" allocates and fills in a pcap_t, for use
* by pcap_create routines.
*/
* "pcap_create_common()" allocates and fills in a pcap_t, for use
* by pcap_create routines.
*/
-pcap_t *pcap_create_interface(char *);
+pcap_t *pcap_create_interface(const char *, char *);
pcap_t *pcap_create_common(char *, size_t);
int pcap_do_addexit(pcap_t *);
void pcap_add_to_pcaps_to_close(pcap_t *);
pcap_t *pcap_create_common(char *, size_t);
int pcap_do_addexit(pcap_t *);
void pcap_add_to_pcaps_to_close(pcap_t *);
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
const char *device);
#endif /* HAVE_PF_PACKET_SOCKETS */
#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
const char *device);
#endif /* HAVE_PF_PACKET_SOCKETS */
#if defined(HAVE_LINUX_NET_TSTAMP_H) && defined(PACKET_TIMESTAMP)
-static int iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf);
+static int iface_ethtool_get_ts_info(const char *device, pcap_t *handle,
+ char *ebuf);
#endif
#ifdef HAVE_PACKET_RING
static int iface_get_offload(pcap_t *handle);
#endif
#ifdef HAVE_PACKET_RING
static int iface_get_offload(pcap_t *handle);
#endif /* SO_ATTACH_FILTER */
pcap_t *
#endif /* SO_ATTACH_FILTER */
pcap_t *
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
/*
* See what time stamp types we support.
*/
/*
* See what time stamp types we support.
*/
- if (iface_ethtool_get_ts_info(handle, ebuf) == -1) {
+ if (iface_ethtool_get_ts_info(device, handle, ebuf) == -1) {
pcap_close(handle);
return NULL;
}
pcap_close(handle);
return NULL;
}
* Get a list of time stamping capabilities.
*/
static int
* Get a list of time stamping capabilities.
*/
static int
-iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf)
+iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf)
{
int fd;
struct ifreq ifr;
{
int fd;
struct ifreq ifr;
* and not all devices even necessarily *support* hardware time
* stamping, so don't report any time stamp types.
*/
* and not all devices even necessarily *support* hardware time
* stamping, so don't report any time stamp types.
*/
- if (strcmp(handle->opt.device, "any") == 0) {
+ if (strcmp(device, "any") == 0) {
handle->tstamp_type_list = NULL;
return 0;
}
handle->tstamp_type_list = NULL;
return 0;
}
}
memset(&ifr, 0, sizeof(ifr));
}
memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, handle->opt.device, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
memset(&info, 0, sizeof(info));
info.cmd = ETHTOOL_GET_TS_INFO;
ifr.ifr_data = (caddr_t)&info;
memset(&info, 0, sizeof(info));
info.cmd = ETHTOOL_GET_TS_INFO;
ifr.ifr_data = (caddr_t)&info;
* Other error.
*/
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
* Other error.
*/
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "%s: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: %s", handle->opt.device,
+ "%s: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: %s", device,
strerror(save_errno));
return -1;
}
strerror(save_errno));
return -1;
}
}
#else /* ETHTOOL_GET_TS_INFO */
static int
}
#else /* ETHTOOL_GET_TS_INFO */
static int
-iface_ethtool_get_ts_info(pcap_t *handle, char *ebuf _U_)
+iface_ethtool_get_ts_info(const char *device, pcap_t *handle, char *ebuf _U_)
{
/*
* This doesn't apply to the "any" device; you can't say "turn on
{
/*
* This doesn't apply to the "any" device; you can't say "turn on
* and not all devices even necessarily *support* hardware time
* stamping, so don't report any time stamp types.
*/
* and not all devices even necessarily *support* hardware time
* stamping, so don't report any time stamp types.
*/
- if (strcmp(handle->opt.device, "any") == 0) {
+ if (strcmp(device, "any") == 0) {
handle->tstamp_type_list = NULL;
return 0;
}
handle->tstamp_type_list = NULL;
return 0;
}
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
static char nosup[] = "live packet capture not supported on this system";
pcap_t *
static char nosup[] = "live packet capture not supported on this system";
pcap_t *
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
{
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
return (NULL);
{
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
return (NULL);
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
-pcap_t *pcap_create_interface(char *ebuf) {
+pcap_t *pcap_create_interface(const char *device _U_, char *ebuf) {
pcap_t *p;
p = pcap_create_common(ebuf, 0);
pcap_t *p;
p = pcap_create_common(ebuf, 0);
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
-pcap_create_interface(char *ebuf)
+pcap_create_interface(const char *device _U_, char *ebuf)
/*
* OK, try it as a regular network interface.
*/
/*
* OK, try it as a regular network interface.
*/
- p = pcap_create_interface(errbuf);
+ p = pcap_create_interface(device_str, errbuf);
if (p == NULL) {
/*
* We assume the caller filled in errbuf.
if (p == NULL) {
/*
* We assume the caller filled in errbuf.