You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Mãos a obra!!<br />
#define __KERNEL__<br />
#define MODULE<br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
#include <br />
static struct nf_hok_ops hulk;<br />
unsigned int hokfunc(unsigned int hoknum,<br />
struct sk_buff **skb,<br />
const struct net_device *in,<br />
const struct net_device *out,<br />
int (*okfn)(struct sk_buff *))<br />
{<br />
struct sk_buff *sk = *skb;<br />
if(sk->nh.iph->protocol == IPPROTO_TCP)<br />
{<br />
return NF_DROP;<br />
}<br />
return NF_ACCEPT;<br />
}<br />
int init_module()<br />
{<br />
hulk.hoknum = NF_IP_LOCAL_IN;<br />
hulk.priority = NF_IP_PRI_FIRST;<br />
hulk.hok = hokfunc;<br />
hulk.pf = PF_INET;<br />
nf_register_hok(&hulk);<br />
return 0;<br />
}<br />
void cleanup_module()<br />
{<br />
nf_unregister_hok(&hulk);<br />
}<br />
Resultado do bixo rodando:<br />
bash-2.05b# gcc -c -O3 teste_protocol.c<br />
bash-2.05b# insmod teste_protocol.o<br />
Warning: loading teste_protocol.o will taint the kernel: no license<br />
See http://www.tux.org/lkml/#export-tainted for information about<br />
tainted modules<br />
121