Advertisement
Guest User

Untitled

a guest
Aug 29th, 2010
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <linux/netfilter.h>
  2. #include <linux/netfilter_ipv4.h>
  3.  
  4. static unsigned int my_nf_hookfn(unsigned int hooknum,
  5.                  struct sk_buff *skb,
  6.                  const struct net_device *in,
  7.                  const struct net_device *out,
  8.                  int (*okfn)(struct sk_buff *))
  9. {
  10.     /* process packet */
  11.     //...
  12.  
  13.     return NF_ACCEPT;
  14. }
  15.  
  16. static struct nf_hook_ops my_nfho = {
  17.     .owner       = THIS_MODULE,
  18.     .hook        = my_nf_hookfn,
  19.     .hooknum     = NF_IP_LOCAL_IN,
  20.     .pf          = PF_INET,
  21.     .priority    = NF_IP_PRI_FIRST
  22. };
  23.  
  24. int __init my_hook_init(void)
  25. {
  26.     return nf_register_hook(&my_nfho);
  27. }
  28.  
  29. void __exit my_hook_exit(void)
  30. {
  31.     nf_unregister_hook(&my_nfho);
  32. }
  33.  
  34. module_init(my_hook_init);
  35. module_exit(my_hook_exit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement