541 lines
19 KiB
C
Executable File
541 lines
19 KiB
C
Executable File
#include <linux/types.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/netfilter.h>
|
|
#include <linux/netfilter_ipv4.h>
|
|
#include <linux/init.h>
|
|
#include <linux/inet.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/net.h>
|
|
#include "../api/conntrack_api.h"
|
|
|
|
static unsigned int test_set_correct_value(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
int ret;
|
|
printk(KERN_INFO"[test_set_correct_value]begin!!!!\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set user_version 10\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 10, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value]set user_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set user_version successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set app_id 20\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 20, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set app_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set base_app_id 21\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 21, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set base_app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set base_app_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set user_id 30\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 30, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set user_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set node_index 40\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 40, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value]set node_index failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set node_index successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set policy_version 50\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 50, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set policy_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set policy_version successed\n");
|
|
|
|
ret = cmhi_set_conntrack_action_by_bit(skb, CMHI_EXT_PASS);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set action failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set action successed\n");
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set auth_mark 60\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 60, AUTH_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set auth_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set auth_mark successed\n");
|
|
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set tc_mark 70\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 70, TC_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set tc_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set tc_mark successed\n");
|
|
|
|
|
|
printk(KERN_INFO"[test_set_correct_value] test set pbr_mark 80\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 80, PBR_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_correct_value] set pbr_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_correct_value] set pbr_mark successed\n");
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
goto out;
|
|
out:
|
|
return NF_ACCEPT;
|
|
}
|
|
|
|
static unsigned int test_set_value_by_wrong_interface(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
int ret;
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface]begin!!!!\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set user_version 10\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 10, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface]set user_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set user_version successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set app_id 20\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 20, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set app_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set base_app_id 21\n");
|
|
ret = cmhi_set_conntrack_u32(skb, 21, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set base_app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set base_app_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set user_id 30\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 30, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set user_id successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set node_index 40\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 40, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface]set node_index failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set node_index successed\n");
|
|
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] test set policy_version 50\n");
|
|
ret = cmhi_set_conntrack_u16(skb, 50, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set policy_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_set_value_by_wrong_interface] set policy_version successed\n");
|
|
|
|
|
|
goto out;
|
|
|
|
out:
|
|
return NF_ACCEPT;
|
|
}
|
|
|
|
static unsigned int test_get_value_by_correct_interface(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
int ret;
|
|
u_int32_t user_id;
|
|
u_int16_t user_version;
|
|
u_int32_t node_index;
|
|
u_int16_t app_id;
|
|
u_int16_t base_app_id;
|
|
u_int32_t policy_version;
|
|
u_int32_t action;
|
|
|
|
u_int32_t auth_mark;
|
|
u_int32_t tc_mark;
|
|
u_int32_t pbr_mark;
|
|
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]begin!!!!\n");
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &user_id, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get usr_id: %d successed\n", user_id);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &user_version, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get user_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get user_version: %d successed\n", user_version);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &node_index, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get node_index failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get node_index: %d successed\n", node_index);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &app_id, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get app_id: %d successed\n", app_id);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &base_app_id, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get base_app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get base_app_id: %d successed\n", base_app_id);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &policy_version, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get policy_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get policy_version: %d successed\n", policy_version);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &action, ACTION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get action failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get action: %d successed\n", action);
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &auth_mark, AUTH_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get auth_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get auth_mark: %d successed\n", auth_mark);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &tc_mark, TC_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get tc_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get tc_mark: %d successed\n", tc_mark);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &pbr_mark, PBR_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get pbr_mark failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_correct_interface]: get pbr_mark: %d successed\n", pbr_mark);
|
|
|
|
goto out;
|
|
|
|
out:
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
static unsigned int test_get_value_by_wrong_interface(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
int ret;
|
|
u_int16_t user_id;
|
|
u_int32_t user_version;
|
|
u_int16_t node_index;
|
|
u_int32_t app_id;
|
|
u_int32_t base_app_id;
|
|
u_int16_t policy_version;
|
|
u_int16_t action;
|
|
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]begin!!!!\n");
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &user_id, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get usr_id: %d successed\n", user_id);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &user_version, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get user_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get user_version: %d successed\n", user_version);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &node_index, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get node_index failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get node_index: %d successed\n", node_index);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &app_id, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get app_id: %d successed\n", app_id);
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, &base_app_id, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get base_app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get base_app_id: %d successed\n", base_app_id);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &policy_version, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get policy_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get policy_version: %d successed\n", policy_version);
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, &action, ACTION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get action failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_value_by_wrong_interface]: get action: %d successed\n", action);
|
|
goto out;
|
|
|
|
out:
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
static unsigned int test_get_null_value(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
int ret;
|
|
|
|
printk(KERN_INFO"[test_get_null_value]begin!!!!\n");
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, NULL, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get usr_id successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, NULL, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get user_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get user_version successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, NULL, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get node_index failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get node_index successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, NULL, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get app_id successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u16(skb, NULL, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get base_app_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get base_app_id successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, NULL, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get policy_version failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get policy_version successed\n");
|
|
|
|
ret = cmhi_get_conntrack_u32(skb, NULL, ACTION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_get_null_value]: get action failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_get_null_value]: get action successed\n");
|
|
goto out;
|
|
|
|
out:
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
|
|
static unsigned int test_del_value(void *priv, struct sk_buff *skb, const struct nf_hook_state *state)
|
|
{
|
|
|
|
int ret;
|
|
printk(KERN_INFO"[test_del_value]begin!!!!\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, USER_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del user_id failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del usr_id successed\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, USER_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del USER_VERSION failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del USER_VERSION successed\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del APP_ID failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del APP_ID successed\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, BASE_APP_ID);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del BASE_APP_ID failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del BASE_APP_ID successed\n");
|
|
|
|
|
|
ret = cmhi_del_conntrack(skb, NODE_INDEX);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del NODE_INDEX failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del NODE_INDEX successed\n");
|
|
|
|
|
|
ret = cmhi_del_conntrack(skb, POLICY_VERSION);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del POLICY_VERSION failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del POLICY_VERSION successed\n");
|
|
|
|
printk(KERN_INFO"DomoB: test del action by bit\n");
|
|
ret = cmhi_del_conntrack_action_by_bit(skb, CMHI_EXT_PASS);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"DemoB_test: del action by bit failed");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"DemoB_test: del action by bit successed\n");
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
ret = cmhi_del_conntrack(skb, AUTH_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del AUTH_MARK failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del AUTH_MARK successed\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, TC_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del TC_MARK failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del TC_MARK successed\n");
|
|
|
|
ret = cmhi_del_conntrack(skb, PBR_MARK);
|
|
if(ret == CMHI_EXT_ERR){
|
|
printk(KERN_INFO"[test_del_value]: del PBR_MARK failed\n");
|
|
goto out;
|
|
}
|
|
printk(KERN_INFO"[test_del_value]: del PBR_MARK successed\n");
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
goto out;
|
|
|
|
out:
|
|
return NF_ACCEPT;
|
|
|
|
}
|
|
|
|
static struct nf_hook_ops nfho[] __read_mostly = {
|
|
{
|
|
.hook = (nf_hookfn *)test_set_correct_value,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER,
|
|
},
|
|
{
|
|
.hook = (nf_hookfn *)test_set_value_by_wrong_interface,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER+1,
|
|
},
|
|
{
|
|
.hook = (nf_hookfn *)test_get_value_by_correct_interface,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER+2,
|
|
},
|
|
{
|
|
.hook = (nf_hookfn *)test_get_value_by_wrong_interface,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER+3,
|
|
},
|
|
{
|
|
.hook = (nf_hookfn *)test_get_null_value,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER+4,
|
|
},
|
|
{
|
|
.hook = (nf_hookfn *)test_del_value,
|
|
.hooknum = NF_INET_PRE_ROUTING,
|
|
.pf = NFPROTO_IPV4,
|
|
.priority = NF_IP_PRI_FILTER+5,
|
|
},
|
|
};
|
|
|
|
static int __init DemoA_init(void)
|
|
{
|
|
nf_register_net_hooks(&init_net, nfho, ARRAY_SIZE(nfho));
|
|
printk(KERN_INFO"[DemoA] Module_init\n");
|
|
return 0;
|
|
}
|
|
|
|
static void __exit DemoA_clean(void)
|
|
{
|
|
|
|
nf_unregister_net_hooks(&init_net, nfho, ARRAY_SIZE(nfho));
|
|
printk(KERN_INFO"[DemoA]Module_clean\n");
|
|
return;
|
|
}
|
|
|
|
module_init(DemoA_init);
|
|
module_exit(DemoA_clean);
|
|
MODULE_LICENSE("GPL");
|