|
From: <cn...@us...> - 2024-06-24 19:19:36
|
Revision: 1475
http://sourceforge.net/p/seq/svn/1475
Author: cn187
Date: 2024-06-24 19:19:34 +0000 (Mon, 24 Jun 2024)
Log Message:
-----------
Fixes for capture filter logic
Modified Paths:
--------------
showeq/branches/cn187_devel/src/packetcapture.cpp
Modified: showeq/branches/cn187_devel/src/packetcapture.cpp
===================================================================
--- showeq/branches/cn187_devel/src/packetcapture.cpp 2024-06-19 19:27:23 UTC (rev 1474)
+++ showeq/branches/cn187_devel/src/packetcapture.cpp 2024-06-24 19:19:34 UTC (rev 1475)
@@ -82,16 +82,11 @@
{
char ebuf[PCAP_ERRBUF_SIZE]; // pcap error buffer
char filter_buf[256]; // pcap filter buffer
- struct bpf_program bpp;
struct sched_param sp;
- bpf_u_int32 mask; // sniff device netmask
- bpf_u_int32 net; // sniff device ip
seqInfo("Initializing Packet Capture Thread: ");
m_pcache_closed = false;
- this->setFilter(device, host, realtime, address_type, 0, 0);
-
/* A word about pcap_open_live() from the docs
** to_ms specifies the read timeout in milliseconds. The
** read timeout is used to arrange that the read not necessarily
@@ -140,20 +135,8 @@
exit(0);
}
- if (pcap_compile(m_pcache_pcap, &bpp, filter_buf, 1, net) == -1)
- {
- pcap_perror (m_pcache_pcap, (char*)"pcap_error:pcap_compile");
- exit(0);
- }
+ this->setFilter(device, host, realtime, address_type, 0, 0);
- if (pcap_setfilter (m_pcache_pcap, &bpp) == -1)
- {
- pcap_perror (m_pcache_pcap, (char*)"pcap_error:pcap_setfilter");
- exit(0);
- }
-
- pcap_freecode(&bpp);
-
m_pcache_first = m_pcache_last = NULL;
pthread_create (&m_tid, NULL, loop, (void*)this);
@@ -366,8 +349,8 @@
char ebuf[PCAP_ERRBUF_SIZE];
struct bpf_program bpp;
struct sched_param sp;
- bpf_u_int32 mask; // sniff device netmask
- bpf_u_int32 net; // sniff device ip
+ bpf_u_int32 mask = 0; // sniff device netmask
+ bpf_u_int32 net = 0 ; // sniff device ip
// Fetch the netmask for the device to use later with the filter
if (pcap_lookupnet(device, &net, &mask, ebuf) == -1)
@@ -395,13 +378,13 @@
{
if (hostname && strcmp(hostname, AUTOMATIC_CLIENT_IP) != 0)
// host was specified/detected
- pfb += sprintf(" and host %s", hostname);
+ pfb += sprintf(pfb, " and host %s", hostname);
}
else if (address_type == MAC_ADDRESS_TYPE)
{
if (hostname && strcmp(hostname, AUTOMATIC_CLIENT_IP) != 0)
// mac was specified
- pfb += sprintf(" and ether host %s", hostname);
+ pfb += sprintf(pfb, " and ether host %s", hostname);
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|