-Add new kind of Filter: HookingFilter
git-svn-id: file:///Users/braun/svn/vermont/trunk/vermont@71 aef3b71b-58ee-0310-9ba9-8811b9f0742fmaster
parent
27930ca97e
commit
cf7fd648f1
|
@ -0,0 +1,20 @@
|
|||
#include "HookingFilter.h"
|
||||
#include "packet_hook.h"
|
||||
|
||||
bool HookingFilter::processPacket(const Packet *p)
|
||||
{
|
||||
struct packet_hook ph;
|
||||
|
||||
/* marshall data into C struct - just pointers */
|
||||
ph.data=p->data;
|
||||
ph.ip_header=p->ipHeader;
|
||||
ph.transport_header=p->transportHeader;
|
||||
|
||||
ph.timestamp=&(p->timestamp);
|
||||
ph.length=p->length;
|
||||
|
||||
/* call hooking function */
|
||||
hook((void *)&ph);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Hooking Filter
|
||||
(c) by Ronny T. Lampert
|
||||
|
||||
This filter calls a given function pointer for every packet it receives.
|
||||
Because we assume standard C code that doesn't know about class Packet
|
||||
we have to marshall the relevant pointers into a struct first.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef HOOKING_FILTER_H
|
||||
#define HOOKING_FILTER_H
|
||||
|
||||
#include "Globals.h"
|
||||
#include "PacketProcessor.h"
|
||||
|
||||
class HookingFilter : public PacketProcessor {
|
||||
|
||||
public:
|
||||
|
||||
HookingFilter(void (*f)(void *)) {
|
||||
hook=f;
|
||||
}
|
||||
|
||||
~HookingFilter() {
|
||||
|
||||
}
|
||||
|
||||
virtual bool processPacket(const Packet *p);
|
||||
|
||||
protected:
|
||||
|
||||
void (*hook)(void *);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue