Commit cff877e4 authored by berge's avatar berge
Browse files

Fixed filter issues

parent 6e49bc7a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -102,6 +102,11 @@ bool FilterSet::Match(const ProtocolInfoElement * pProtocolInfo)
	bool bRcvMatch = false;
	iterator it = begin();
	bool bEmptyFilterSet = true;

	std::cerr << "FilterSet::Match() "
		  << pProtocolInfo->GetId() << " "
		  << std::endl;

	while (it != end())
	{
	  bEmptyFilterSet = false;
@@ -109,6 +114,7 @@ bool FilterSet::Match(const ProtocolInfoElement * pProtocolInfo)
		{
		  	delete (*it);
		  	it = erase(it);
			std::cerr << "no match" << std::endl;
		}
		else
		{
@@ -116,8 +122,16 @@ bool FilterSet::Match(const ProtocolInfoElement * pProtocolInfo)
			bSenderMatch |= matchType == EFilterMatch_Sender;
			bRcvMatch |= matchType == EFilterMatch_Receiver;
			++it;
			std::cerr << "match " 
				  << bSenderMatch << " "
				  << bRcvMatch << std::endl;
		}
	}
	if( (pProtocolInfo->GetId() == EProtocolType_Udp) 
	    || (pProtocolInfo->GetId() == EProtocolType_Tcp)) {
	  return (bSenderMatch || bRcvMatch) || bEmptyFilterSet; 
	}
	
	return (bSenderMatch && bRcvMatch) || bEmptyFilterSet; 
}

+7 −0
Original line number Diff line number Diff line
@@ -28,6 +28,13 @@ bool PortFilter::Match(const ProtocolInfoElement * pProtocolInfo)
	if (AreAllPacketsAccepted())
		return true;
	const TransportLayerInfo * pTransInfo = dynamic_cast<const TransportLayerInfo *>(pProtocolInfo);

	std::cout << "PortFilter::Match() "
		  << m_nPort << " "
		  << pTransInfo->GetDestinationPort() << " "
		  << pTransInfo->GetSourcePort() << " "
		  << std::endl;

	return m_nPort == pTransInfo->GetDestinationPort() || 
		m_nPort == pTransInfo->GetSourcePort();
}
+2 −10
Original line number Diff line number Diff line
@@ -14,14 +14,6 @@ namespace t3devlib
#include <t3devlib/t3devlib.h>
#endif

#ifdef WIN32
#include <WinSock2.h>
#define socklen_t int
#else
#include <netinet/in.h>
#endif


enum EProtocolType 
{ 
	EProtocolType_None,
@@ -85,8 +77,8 @@ public:
	virtual bool Match(const ProtocolInfoElement & toCompare) const;
	unsigned short GetSourcePort() const { return m_nSrcPort; }
	unsigned short GetDestinationPort() const { return m_nDstPort; }
	void SetSourcePort(unsigned short nPort) { m_nSrcPort = ntohs(nPort); }
	void SetDestinationPort(unsigned short nPort) { m_nDstPort = ntohs(nPort); }
	void SetSourcePort(unsigned short nPort) { m_nSrcPort = nPort; }
	void SetDestinationPort(unsigned short nPort) { m_nDstPort = nPort; }
 };

class TcpInfo : public TransportLayerInfo
+9 −0
Original line number Diff line number Diff line
#include "UdpDissector.h"
#include "Logger/Logger.h"
#ifdef WIN32
#include <Winsock2.h>
#else
#include <netinet/in.h>
#endif

UdpDissector::UdpDissector() :
	m_udpHdr(0)
@@ -19,6 +24,10 @@ bool UdpDissector::Dissect(const unsigned char * pData, const ssize_t nDataLen)
  if (!m_udpHdr)
    m_udpHdr = new UdpHeader;
  memcpy(m_udpHdr, pData, sizeof(UdpHeader));
#if BYTE_ORDER == LITTLE_ENDIAN
  m_udpHdr->destPort = ntohs(m_udpHdr->destPort);
  m_udpHdr->srcPort = ntohs(m_udpHdr->srcPort);
#endif
  pData += sizeof(UdpHeader);

  SavePayload(pData, nDataLen - sizeof(UdpHeader));