This example shows how to make a simple packet filter plugin.
#define DT_DLL_SAMPLE __declspec ( dllexport )
#define DT_DLL_SAMPLE_C extern "C" __declspec ( dllexport )
#ifdef _WIN32
#ifdef LGRSAMPLE_EXPORTS
#define DT_DLL_SAMPLE __declspec ( dllexport )
#else
#define DT_DLL_SAMPLE __declspec ( dllimport )
#endif
#else
#define DT_DLL_SAMPLE
#endif
#define DT_LGR_PLUGIN_EXPORT_MACRO DT_DLL_SAMPLE
using namespace MAKLogger;
{
public:
myFilterAllPacketsFlag(false)
{
}
virtual ~SampleFilter()
{
}
{
return new SampleFilter();
}
virtual bool filterPacket(
DtPacket* packet)
{
return myFilterAllPacketsFlag;
}
virtual const DtString& type() const { return theFilterType;}
{
}
virtual void deactivate()
{
}
virtual char* serialize(int& size) const
{
char* buffer = new char[1];
size = 1;
unsigned char* flagPtr = (unsigned char*) buffer;
*flagPtr = myFilterAllPacketsFlag;
return buffer;
}
virtual int setFromSerialization(const char* data,int size)
{
if(size != 1)
{
DtTHROW_NEW(DtInvalidInput,
"SampleFilter: Size does not match expected size");
}
unsigned char* flagPtr = (unsigned char*) data;
myFilterAllPacketsFlag = *flagPtr;
return sizeof(unsigned char);
}
protected:
bool myFilterAllPacketsFlag;
static DtString theFilterType;
};
DtString SampleFilter::theFilterType = "SampleFilter";
extern "C" {
{
}
{
}
{
}
{
SampleFilter* aFilter = new SampleFilter();
simInterface->addFilter(aFilter);
aFilter = 0;
delete simInterface;
}
}