#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "ip.h"
int hook_in(Ipifc *, Block *, void *);
int hook_out(Ipifc *, Block *, void *);
void
nfiltestinit(Fs *f)
{
USED(f);
nfil_register_hook(hook_in, 0, Direction_In);
nfil_register_hook(hook_out, 0, Direction_Out);
}
int
hook_in(Ipifc *ifc, Block *bp, void *xtra)
{
Ip4hdr *h = nil;
Fs *f = nil;
Proto *p = nil;
USED(xtra); USED(bp); USED(ifc); USED(h); USED(p);
h = (Ip4hdr *)(bp->rp);
f = (Fs *)xtra;
p = Fsrcvpcol(f, h->proto);
print("nfil filtered a packet of type %s\n", p->name);
return Nfil_Success;
}
int
hook_out(Ipifc *ifc, Block *bp, void *xtra)
{
Ip4hdr *h = (Ip4hdr *)(bp->rp);
Nfil_output_args *args = (Nfil_output_args *)xtra;
Fs *f = args->f;
Proto *p = Fsrcvpcol(f, h->proto);
USED(xtra); USED(bp); USED(ifc); USED(h); USED(p);
print("nfil filtered a packet of type %s outgoing\n", p->name);
return Nfil_Success;
}
|