NetFilter

wKioL1boyIrypgonAAB9bhvhlM4315.jpg


  1. typedef unsigned int nf_hookfn(unsigned int hooknum,  

  2.                                struct sk_buff *skb,  

  3.                                const struct net_device *in,  

  4.                                const struct net_device *out,  

  5.                                int (*okfn) (struct sk_buff *));  

  6.   

  7. /* 處理函數返回值 */  

  8. #define NF_DROP 0 /* drop the packet, don't continue traversal */  

  9. #define NF_ACCEPT 1 /* continue traversal as normal */  

  10. #define NF_STOLEN 2 /* I've taken over the packet, don't continue traversal */  

  11. #define NF_QUEUE 3 /* queue the packet (usually for userspace handling) */  

  12. #define NF_REPEAT 4 /* call this hook again */  

  13. #define NF_STOP 5  

  14. #define NF_MAX_VERDICT NF_STOP  


在使用Netfilter時,需要定義一個nf_hook_ops實例。

  1. struct nf_hook_ops {  

  2.     struct list_head list;  

  3.     /* User fills in from here down. */  

  4.     nf_hookfn *hook; /* 要註冊的鉤子函數 */  

  5.     struct module *owner;  

  6.     u_int8_t pf; /* 協議類型 */  

  7.     unsigned int hooknum; /* 哪個釣魚臺 */  

  8.     /* Hooks are ordered in asending priority. */  

  9.     int priority; /* 數值越小,優先級越高 */  

  10. };  

  11. typedef __u8 u_int8_t;  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章