Commit 8fa5b1c8 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Applied Pramod's fix of the pcap bpf expression to TCP. Abstracted and removed...

Applied Pramod's fix of the pcap bpf expression to TCP. Abstracted and removed duplicate code. This turns out to fix some puzzling behaviour which we didn't realize was related.
parent 1296f185
......@@ -434,7 +434,20 @@ int KernelTcp::getSock(void) const
return peersock;
}
enum { SNIFF_WAIT = 10 };
namespace
{
void addFilterProtocol(ostringstream & filter, char const * proto,
unsigned short port, char const * address)
{
filter << "(" << proto << " and ("
<< "(src port " << port << " and dst host " << address << ")"
<< " or "
<< "(dst port " << port << " and src host " << address << ")"
<< "))";
}
enum { SNIFF_WAIT = 10 };
}
void KernelTcp::init(void)
{
......@@ -464,8 +477,9 @@ void KernelTcp::init(void)
tempAddr.s_addr = netp;
char *localIPAddr = inet_ntoa(tempAddr);
filter << "(port " << global::peerServerPort << " and tcp)"
" or ( udp and ( (src port " << global::peerUdpServerPort << " and dst host " << localIPAddr<< " ) or (dst port " << global::peerUdpServerPort << " and src host "<<localIPAddr<<" ) ) )";
addFilterProtocol(filter, "tcp", global::peerServerPort, localIPAddr);
filter << " or ";
addFilterProtocol(filter, "udp", global::peerUdpServerPort, localIPAddr);
/* open device for reading.
* NOTE: We use non-promiscuous */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment