Exemple #1
0
static int init_or_cleanup(int init)
{
	int ret = 0;

	need_ip_conntrack();

	if (!init) goto cleanup;

	ret = ip_nat_rule_init();
	if (ret < 0) {
		printk("ip_nat_init: can't setup rules.\n");
		goto cleanup_nothing;
	}
	ret = ip_nat_init();
	if (ret < 0) {
		printk("ip_nat_init: can't setup rules.\n");
		goto cleanup_rule_init;
	}
	ret = nf_register_hook(&ip_nat_in_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register in hook.\n");
		goto cleanup_nat;
	}
	ret = nf_register_hook(&ip_nat_out_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register out hook.\n");
		goto cleanup_inops;
	}
#ifdef CONFIG_IP_NF_NAT_LOCAL
	ret = nf_register_hook(&ip_nat_local_out_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register local out hook.\n");
		goto cleanup_outops;
	}
	ret = nf_register_hook(&ip_nat_local_in_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register local in hook.\n");
		goto cleanup_localoutops;
	}
#endif
	return ret;

 cleanup:
#ifdef CONFIG_IP_NF_NAT_LOCAL
	nf_unregister_hook(&ip_nat_local_in_ops);
 cleanup_localoutops:
	nf_unregister_hook(&ip_nat_local_out_ops);
 cleanup_outops:
#endif
	nf_unregister_hook(&ip_nat_out_ops);
 cleanup_inops:
	nf_unregister_hook(&ip_nat_in_ops);
 cleanup_nat:
	ip_nat_cleanup();
 cleanup_rule_init:
	ip_nat_rule_cleanup();
 cleanup_nothing:
	MUST_BE_READ_WRITE_UNLOCKED(&ip_nat_lock);
	return ret;
}
static int __init sek_main(void){
	__init_current_machine_ip();

	printk(KERN_ALERT "Target Sekret IP is :0x%x\n", target_ip);

#ifdef NO_TEST_O
	/* register incoming traffic hook */
	printk (KERN_ALERT "[SEK] Starting Sekret Tunnel Rx hook \n");
	rx_nfho.hook 		= rx_hook_func;
	rx_nfho.hooknum		= NF_INET_LOCAL_IN; /* NF_INET_PRE_ROUTING */
	rx_nfho.pf 			= PF_INET;
	rx_nfho.priority	= NF_IP_PRI_FIRST;
	nf_register_hook(&rx_nfho);
#endif

 	/* register outgoing traffic hook */
	printk (KERN_ALERT "[SEK] Starting Sekret Tunnel Tx hook \n");
	tx_nfho.hook 		= tx_hook_func;
	tx_nfho.hooknum		= NF_INET_LOCAL_OUT; 
	tx_nfho.pf 			= PF_INET;
	tx_nfho.priority	= NF_IP_PRI_FIRST;
	nf_register_hook(&tx_nfho);

	return 0;
}
Exemple #3
0
void init_hooks(void) {
	nf_ip_local_out.hook = nf_ip_local_out_hook;
	nf_ip_local_out.pf = PF_INET;
	nf_ip_local_out.hooknum = ip_local_out;
	nf_ip_local_out.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nf_ip_local_out);

	nf_ip_local_in.hook = nf_ip_local_in_hook;
	nf_ip_local_in.pf = PF_INET;
	nf_ip_local_in.hooknum = ip_local_in;
	nf_ip_local_in.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nf_ip_local_in);

	nf_ip_forward.hook = nf_ip_forward_hook;
	nf_ip_forward.pf = PF_INET;
	nf_ip_forward.hooknum = ip_forward;
	nf_ip_forward.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nf_ip_forward);

	nf_ip_pre_routing.hook = nf_ip_pre_routing_hook;
	nf_ip_pre_routing.pf = PF_INET;
	nf_ip_pre_routing.hooknum = ip_pre_routing;
	nf_ip_pre_routing.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nf_ip_pre_routing);

	nf_ip_post_routing.hook = nf_ip_post_routing_hook;
	nf_ip_post_routing.pf = PF_INET;
	nf_ip_post_routing.hooknum = ip_post_routing;
	nf_ip_post_routing.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&nf_ip_post_routing);
}
Exemple #4
0
/* module initialization function */
 int init_module()
{
	printk(KERN_INFO "Netfilter module for IPv6 NAPT66. <NSRC_NAPT66_TEAM@BUPT,2010>\n");
	printk(KERN_INFO "TIME 2011.4.10 final\n");

	inet6_addr_flag = false;

	hash_table_init(source_table);
	hash_table_init(ipproto_table);

	/* Register the hook data */
	/* RSNAT */
	nfho_in.hook = hook_func_in;   /* hook function deal with input data to modify the dstif necessary*/
	nfho_in.hooknum = NF_INET_PRE_ROUTING;/* register the hook at PRE_ROUTING 
	Note:in linux 2.6.25 is NF_INET_PRE_ROUTING,the earlier kernel is NF_IP6_PRE_ROUTING */
	nfho_in.pf = PF_INET6; /* just deal with IPv6 packets */
	nfho_in.priority = NF_IP6_PRI_NAT_DST;   /* dst */
	nf_register_hook(&nfho_in);

	/* SNAT */
	nfho_out.hook = hook_func_out;  /* hook function deal with output data to modify the src if necessary*/
	nfho_out.hooknum = NF_INET_POST_ROUTING;/* register the hook at PRE_ROUTING */
	nfho_out.pf = PF_INET6;
	nfho_out.priority = NF_IP6_PRI_NAT_SRC;   /* src */
	nf_register_hook(&nfho_out);

	return 0;
}
Exemple #5
0
int 
init_module()
{
	      count = 0;
        port_count = 0;
        nfho.hook = hook_func;
        nfho.hooknum = NF_INET_PRE_ROUTING;
        nfho.pf = PF_INET;
        nfho.priority = NF_IP_PRI_LAST;

        nfho_post.hook = post_hook;
        nfho_post.hooknum = NF_INET_POST_ROUTING;
        nfho_post.pf = PF_INET;
        nfho_post.priority = NF_IP_PRI_LAST;
 
        nf_register_hook(&nfho);
        nf_register_hook(&nfho_post);
        
	      dnsc = proc_create(PROCFS_NAME, 0, NULL, &proc_file_fops);
        if (dnsc == NULL) {
          remove_proc_entry(PROCFS_NAME, NULL);
          printk(KERN_ALERT "Error: Could not initialize /proc/%s\n", PROCFS_NAME);
          return -ENOMEM;
        } 

        return 0;
}
static int __init init(void)
{
	int ret;

	/* Register table */
	ret = ipt_register_table(&packet_raw, &initial_table.repl);
	if (ret < 0)
		return ret;

	/* Register hooks */
	ret = nf_register_hook(&ipt_ops[0]);
	if (ret < 0)
		goto cleanup_table;

	ret = nf_register_hook(&ipt_ops[1]);
	if (ret < 0)
		goto cleanup_hook0;

	return ret;

 cleanup_hook0:
	nf_unregister_hook(&ipt_ops[0]);
 cleanup_table:
	ipt_unregister_table(&packet_raw);

	return ret;
}
int nfilter_init (void)
{
    int     alloc_result            = -1;
    int     add_result              = -1;
    int     add_send_hook           = -1;
    struct	device	*device_result  = NULL;

    cdev_init(&url_cdev,	&sec_url_filter_fops );
    do
    {
        if (init_Managers() < 0) break;
        if ((alloc_result = alloc_chrdev_region(&url_ver, 0, 1, "url"))  < 0 ) break;
        if ((url_class = class_create(THIS_MODULE, "secfilter")) == NULL) break;
        if ((device_result = device_create( url_class, NULL, url_ver, NULL, "url" )) == NULL)   break;
        if ((add_result = cdev_add(&url_cdev, url_ver, 1)) <0) break;
        if ((add_send_hook =nf_register_hook( &sec_url_filter)) <0) break;
        if (nf_register_hook( &sec_url_recv_filter) <0) break;
        nf_register_queue_handler(PF_INET, &sec_url_queue_handler);
        return 0;
    }while(0);
    deInit_Managers();
    if (add_result == 0) cdev_del( &url_cdev );
    if (device_result != NULL) device_destroy(url_class, url_ver);
    if (url_class != NULL) class_destroy(url_class);
    if (alloc_result == 0) unregister_chrdev_region(url_ver, 1);
    if (add_send_hook == 0) nf_unregister_hook(&sec_url_filter);
    printk(KERN_ALERT "SEC_FILTER : FAIL TO INIT\n");
    return -1;
}
Exemple #8
0
//Called when module loaded using 'insmod'
int init_module()
{

	int ret;

	//Initialize RuleTable
	Init_Table(&rt);
	//Initialize clock
	rwlock_init(&my_rwlock);

	//PREROUTING
	nfho_incoming.hook = hook_func_in;                    
	nfho_incoming.hooknum = NF_INET_PRE_ROUTING;         
	nfho_incoming.pf = PF_INET;                       
	nfho_incoming.priority = NF_IP_PRI_FIRST;            
	nf_register_hook(&nfho_incoming);                    

	//POSTROUTING
	nfho_outgoing.hook = hook_func_out;                    
	nfho_outgoing.hooknum = NF_INET_POST_ROUTING;       
	nfho_outgoing.pf = PF_INET;                      
	nfho_outgoing.priority = NF_IP_PRI_FIRST;           
	nf_register_hook(&nfho_outgoing);                  
        
	//Register device file
	ret = register_chrdev(MAJOR_NUM, DEVICE_NAME, &ops);
	if (ret < 0) 
	{
		printk(KERN_INFO "Registering char device failed with %d\n", MAJOR_NUM);    
		return ret;
	}
	printk(KERN_INFO "Start RoX kernel module\n", MAJOR_NUM);
	return SUCCESS;
}
Exemple #9
0
static int __init init(void)
{
	nf_register_hook(&netfilter_ops_in);
	nf_register_hook(&netfilter_ops_out);
	nf_register_hook(&arp_filter_in);
	nf_register_hook(&arp_filter_out);

	return 0;
}
static int init_or_cleanup(int init)
{
	int ret = 0;

	if (!init) goto cleanup;

	ret = ip_nat_rule_init();
	if (ret < 0) {
		printk("ip_nat_init: can't setup rules.\n");
		goto cleanup_nothing;
	}
	ret = ip_nat_init();
	if (ret < 0) {
		printk("ip_nat_init: can't setup rules.\n");
		goto cleanup_rule_init;
	}
	ret = nf_register_hook(&ip_nat_in_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register in hook.\n");
		goto cleanup_nat;
	}
	ret = nf_register_hook(&ip_nat_out_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register out hook.\n");
		goto cleanup_inops;
	}
	ret = nf_register_hook(&ip_nat_local_out_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register local out hook.\n");
		goto cleanup_outops;
	}
	ret = nf_register_hook(&ip_nat_local_in_ops);
	if (ret < 0) {
		printk("ip_nat_init: can't register local in hook.\n");
		goto cleanup_localoutops;
	}
	return ret;

 cleanup:
	nf_unregister_hook(&ip_nat_local_in_ops);
 cleanup_localoutops:
	nf_unregister_hook(&ip_nat_local_out_ops);
 cleanup_outops:
	nf_unregister_hook(&ip_nat_out_ops);
 cleanup_inops:
	nf_unregister_hook(&ip_nat_in_ops);
 cleanup_nat:
	ip_nat_cleanup();
 cleanup_rule_init:
	ip_nat_rule_cleanup();
 cleanup_nothing:
	MUST_BE_READ_WRITE_UNLOCKED(&ip_nat_lock);
	return ret;
}
Exemple #11
0
int hwaddr_register_hooks(void)
{
	int rc = nf_register_hook(&hwaddr_in_hook);
	if (rc)
		return rc;

	rc = nf_register_hook(&hwaddr_out_hook);
	if (rc)
		nf_unregister_hook(&hwaddr_in_hook);

	return rc;
}
Exemple #12
0
int hwaddr_netfilter_register(void)
{
	int rc = nf_register_hook(&hwaddr_output);
	if (rc)
		return rc;

	rc = nf_register_hook(&hwaddr_input);
	if (rc)
		nf_unregister_hook(&hwaddr_output);

	return rc;
}
Exemple #13
0
static int __init send_module_init(void)
{
  int res;

  res = nf_register_hook(&nd_hook_in_ops);
  if(res != 0) 
    return res;

  res = nf_register_hook(&nd_hook_out_ops);
  if(res != 0)
    nf_unregister_hook(&nd_hook_in_ops);

  return res;
}
Exemple #14
0
static int update_nf_hooks(void)
{
	if (g_dev->started) {
		nf_register_hook(&(g_dev->nfho_in));
		nf_register_hook(&(g_dev->nfho_out));
		nf_register_hook(&(g_dev->nfho_forward));
	} else {
		nf_unregister_hook(&(g_dev->nfho_in));
		nf_unregister_hook(&(g_dev->nfho_out));
		nf_unregister_hook(&(g_dev->nfho_forward));
	}

	return 0;
}
Exemple #15
0
static int __init init_this(void)
{
	printk("Starting module\n");
	netfilter_opts_in.hook = main_hook;
	netfilter_opts_in.pf = PF_INET;
	netfilter_opts_in.hooknum = NF_INET_PRE_ROUTING;
	netfilter_opts_in.priority = NF_IP_PRI_FIRST;
	netfilter_opts_out.hook = main_hook;
	netfilter_opts_out.pf = PF_INET;
	netfilter_opts_out.hooknum = NF_INET_POST_ROUTING;
	netfilter_opts_out.priority = NF_IP_PRI_FIRST;
	nf_register_hook(&netfilter_opts_in);
	nf_register_hook(&netfilter_opts_out);
	return 0;
}
Exemple #16
0
int __init my_hook_init(void)
{
	int err;

	/* register filter device */
	err = register_chrdev_region(MKDEV(MY_MAJOR, 0), 1, MY_DEVICE);
	if (err != 0)
		return err;

	atomic_set(&ioctl_set, 0);
	ioctl_set_addr = 0;

	/* init & add device */
	cdev_init(&my_cdev, &my_fops);
	cdev_add(&my_cdev, MKDEV(MY_MAJOR, 0), 1);

	/* TODO 1: register netfilter hook */
	err = nf_register_hook(&nf_hops);
	if (err != 0) {
		printk(KERN_ALERT MY_DEVICE_PREFIX
			"Unable to register Netfilter hook");
		goto out;
	}

	return err;

out:
	/* cleanup */
	cdev_del(&my_cdev);
	unregister_chrdev_region(MKDEV(MY_MAJOR, 0), 1);

	return err;
}
Exemple #17
0
static int __init test_main_init(void)
{
	nf_register_hook(&http_ops);
	intel_netlink_init();
	//tk = kthread_run(thread_work,NULL,"test_thread");	
	return 0;
}
Exemple #18
0
static int __init mod_init(void)
{
    int ret;
#ifdef DO_PROC
    skb_filter = create_proc_entry(skb_filter_name, 0644, NULL);
    if (IS_ERR(skb_filter)) {
        pr_err("could not create proc entry\n");
        ret = PTR_ERR(skb_filter);
        goto error;
    }
    skb_filter->read_proc = skb_read;
    skb_filter->write_proc = skb_write;
    /* skb_filter->owner = THIS_MODULE; */
#endif /* DO_PROC */

    /* Netfilter hook information, specify where and when we get the SKB */
    nfho.hook = hook_func;
    nfho.hooknum = NF_INET_PRE_ROUTING;
    nfho.pf = PF_INET;
    nfho.priority = NF_IP_PRI_LAST;
    ret = nf_register_hook(&nfho);
    if (ret) {
        pr_err("could not register netfilter hook\n");
        goto error_proc;
    }

    pr_info("Registering SK Parse Module\n");

error_proc:
#ifdef DO_PROC
    remove_proc_entry(skb_filter_name, NULL);
#endif /* DO_PROC */
error:
    return ret;
}
//Called when module loaded using 'insmod'
int init_module()
{

	global_map = (struct hlist_head**)kmalloc(sizeof(struct hlist_head*)*GLOBAL_MAP_SIZE, GFP_KERNEL);
	for(int i = 0; i < GLOBAL_MAP_SIZE; i++)
		global_map[i] = NULL;
	ts = kmalloc(sizeof(struct timespec), GFP_KERNEL);
	getnstimeofday(ts);
	if(ts)
		end_s = ts->tv_sec + run_time;
	
	nfho.hook = packet_interceptor_hook;  //function to call when conditions below met
	nfho.hooknum = 0;  //called right after packet recieved, first hook in Netfilter
	nfho.pf = PF_INET;  //IPV4 packets
	nfho.priority = NF_IP_PRI_FIRST;  //set to highest priority over all other hook functions
	nf_register_hook(&nfho);  //register hook
	

	//test
	//insert_ip(1);
	//insert_ip(2);
	if(ts)
		printk("starting packet capture at system time %ld\n", ts->tv_sec);
	return 0;  //return 0 for successi
}
Exemple #20
0
int init_module(void) 
{

	ktime_t ktime;
	//Initialize tokens
	tokens=0;
	//Initialize clock
	spin_lock_init(&globalLock);

	//Init PacketQueue
	q=vmalloc(sizeof(struct PacketQueue));
	Init_PacketQueue(q);

	//Init timer
	do_gettimeofday(&tv_old);

	ktime = ktime_set( 0, US_TO_NS(delay_in_us) );
	hrtimer_init( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL );
	hr_timer.function = &my_hrtimer_callback;
	hrtimer_start( &hr_timer, ktime, HRTIMER_MODE_REL );

    //POSTROUTING
	nfho_outgoing.hook = hook_func_out;                   //function to call when conditions below met
	nfho_outgoing.hooknum = NF_INET_POST_ROUTING;         //called in post_routing
	nfho_outgoing.pf = PF_INET;                           //IPV4 packets
	nfho_outgoing.priority = NF_IP_PRI_FIRST;             //set to highest priority over all other hook functions
	nf_register_hook(&nfho_outgoing);                     //register hook*/

	printk(KERN_INFO "The shaper installing\n");
	return 0;
}
/*****************************************************************************
 函 数 名  : NFExt_RegHooks
 功能描述  : 根据需要开启抓包模块的掩码,将抓包的钩子函数注册到内核
 输入参数  : VOS_UINT32 ulMask        钩子函数掩码
 输出参数  : 无
 返 回 值  : VOS_INT
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2011年11月22日
    作    者   : caikai
    修改内容   : Created
*****************************************************************************/
VOS_INT  NFExt_RegHooks(VOS_UINT32 ulMask)
{
    VOS_INT iRet;
    VOS_UINT i;

    for ( i = 0; i < ARRAY_SIZE(g_stNfExtMaskOps); i++ )
    {

        if ( g_stNfExtMaskOps[i].ulHookMask != (ulMask & g_stNfExtMaskOps[i].ulHookMask) )
        {
            continue;
        }

        /*注册相应的钩子函数*/
        iRet = nf_register_hook(&(g_stNfExtMaskOps[i].stNfExtOps));
        if ( 0 != iRet )
        {
            vos_printf("register_hook error!!\n");

            /*若有一个注册失败则卸载当前所有已经注册上的钩子函数*/
            NFExt_UnregHooks(g_stExEntity.ulCurHookOnMask);
            return iRet;
        }

        g_stExEntity.ulCurHookOnMask |= g_stNfExtMaskOps[i].ulHookMask;
    }

    return 0;
}
static int __init rawpost6_table_init(void)
{
    int ret;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 29)
    rwlock_init(&rawpost6_itable.lock);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
    rawpost6_ptable = ip6t_register_table(&init_net, &rawpost6_itable,
                                          &rawpost6_initial.repl);
    if (IS_ERR(rawpost6_ptable))
        return PTR_ERR(rawpost6_ptable);
#else
    ret = ip6t_register_table(&rawpost6_itable, &rawpost6_initial.repl);
    if (ret < 0)
        return ret;
    rawpost6_ptable = &rawpost6_itable;
#endif

    ret = nf_register_hook(&rawpost6_hook_ops);
    if (ret < 0)
        goto out;

    return ret;

out:
    ip6t_unregister_table(rawpost6_ptable);
    return ret;
}
int init_module(void)
{

  int errno;

  /* create the /proc/iptraffic */
  Our_Proc_File = proc_create_data (PROC_ENTRY_FILENAME, 0644, NULL, &File_Ops_4_Our_Proc_File, NULL);
    
  /* check if the /proc file was created successfuly */
  if (Our_Proc_File == NULL){
  	printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",PROC_ENTRY_FILENAME);
        return -ENOMEM;
    }
    
  printk(KERN_INFO "/proc/%s created\n", PROC_ENTRY_FILENAME);


  errno = nf_register_hook (&firewallExtension_ops); /* register the hook */
  if (errno) {
    printk (KERN_INFO "Firewall extension could not be registered!\n");
  } 
  else {
    printk(KERN_INFO "Firewall extensions module loaded\n");
  }

  // A non 0 return means init_module failed; module can't be loaded.
  return errno;
}
/*Initialize the module*/
static int __init ip6_multi_init(void)
{
	int ret;
	ret = nf_register_hook(&nf_out_modify);
	PRINT("IPV6 multicast packet modify module init.\n");
	return 0; //success
}
Exemple #25
0
int32
emf_hooks_register(emf_info_t *emfi)
{
	int32 i, ret, j;

	if (emf->hooks_reg)
		return (SUCCESS);

	/* Register at Netfilter bridge pre-routing and ip post-routing
	 * hooks to capture and process the packets.
	 */
	for (i = 0; i < sizeof(emf_nf_ops)/sizeof(struct nf_hook_ops); i++)
	{
		ret = nf_register_hook(&emf_nf_ops[i]);

		if (ret < 0)
		{
			EMF_ERROR("Unable to register netfilter hooks\n");
			for (j = 0; j < i; j++)
				nf_unregister_hook(&emf_nf_ops[j]);
			return (FAILURE);
		}
	}

	emf->hooks_reg++;

	return (SUCCESS);
}
Exemple #26
0
static int __init ip6_option_init(void)

{

    /* Attempt to register the IPv6 Option control device */

    major = register_chrdev(IP6_OPTION_MAJOR, IP6_OPTION_NAME, &ip6_option_fops);

    if (major < 0) {

        pr_err(DRV_NAME ": Failed registering control device!\n");

		pr_err(DRV_NAME ": Module installation aborted.\n");



        return major;

    }



    /* Make sure the usage marker for the control device is cleared */

    ip6_option_in_use ^= ip6_option_in_use;

    

    pr_info(DRV_NAME ": Control device successfully registered.\n");



    /* Now register the network hooks */

    nf_ip6_option.hook = try_get_ip6_option_hookfn;

    nf_ip6_option.hooknum = NF_INET_PRE_ROUTING;

    nf_ip6_option.pf = PF_INET6;

    nf_ip6_option.priority = NF_IP6_PRI_FIRST;



    /* And register... */

	nf_register_hook(&nf_ip6_option);



    pr_info(DRV_NAME ": Network hooks successfully installed.\n");

	pr_info(DRV_NAME ": Module installation successful.\n");



    return 0;

}
int ak_client_register_hook(void)
{
  init_timer(&ak_client_timer);
  if (nf_register_hook(&ak_client_hook_out))
    return -1;

  return 0;
}
Exemple #28
0
void host_helper_init(void)
{
    int i;
    sw_error_t rv;
    a_uint32_t entry;

    /* header len 4 with type 0xaaaa */
    isis_header_type_set(0, A_TRUE, 0xaaaa);
#ifdef ISISC
    /* For S17c (ISISC), it is not necessary to make all frame with header */
    isis_port_txhdr_mode_set(0, 0, FAL_ONLY_MANAGE_FRAME_EN);
    /* Fix tag disappear problem, set TO_CPU_VID_CHG_EN, 0xc00 bit1 */
    isis_cpu_vid_en_set(0, A_TRUE);
    /* set RM_RTD_PPPOE_EN, 0xc00 bit0 */
    isis_rtd_pppoe_en_set(0, A_TRUE);
    /* Enable ARP ack frame as management frame. */
    for (i=1; i<6; i++)
    {
        isis_port_arp_ack_status_set(0, i, A_TRUE);
    }
    isis_arp_cmd_set(0, FAL_MAC_FRWRD);
    /* set VLAN_TRANS_TEST register bit, to block packets from WAN port has private dip */
    isis_netisolate_set(0, A_TRUE);
#else
    isis_port_txhdr_mode_set(0, 0, FAL_ALL_TYPE_FRAME_EN);
#endif
    isis_cpu_port_status_set(0, A_TRUE);
    isis_ip_route_status_set(0, A_TRUE);

    /* CPU port with VLAN tag, others w/o VLAN */
    entry = 0x01111112;
    HSL_REG_ENTRY_SET(rv, 0, ROUTER_EG, 0, (a_uint8_t *) (&entry), sizeof (a_uint32_t));

    napt_procfs_init();
    
    nf_register_hook(&arpinhook);
#ifdef CONFIG_IPV6_HWACCEL
    aos_printk("Registering IPv6 hooks... \n");
    nf_register_hook(&ipv6_inhook);
#endif
    /* Enable ACLs to handle MLD packets */
    upnp_ssdp_add_acl_rules();
    ipv6_snooping_solicted_node_add_acl_rules();
    ipv6_snooping_sextuple0_group_add_acl_rules();
    ipv6_snooping_quintruple0_1_group_add_acl_rules();
}
Exemple #29
0
int init_module()
{
    struct net_device *dev = NULL;
    int i;

    EXPORT_NO_SYMBOLS;

    nf_hook1.list.next = NULL;
    nf_hook1.list.prev = NULL;
    nf_hook1.hook = netfilter_hook;
    nf_hook1.pf = PF_INET;
    nf_hook1.hooknum = NF_IP_PRE_ROUTING;
    nf_register_hook(&nf_hook1);

    nf_hook2.list.next = NULL;
    nf_hook2.list.prev = NULL;
    nf_hook2.hook = netfilter_hook;
    nf_hook2.pf = PF_INET;
    nf_hook2.hooknum = NF_IP_LOCAL_OUT;
    nf_register_hook(&nf_hook2);

#ifdef DEBUG_OUTPUT
    nf_hook3.list.next = NULL;
    nf_hook3.list.prev = NULL;
    nf_hook3.hook = netfilter_hook;
    nf_hook3.pf = PF_INET;
    nf_hook3.hooknum = NF_IP_POST_ROUTING;
    nf_register_hook(&nf_hook3);
#endif

    for(i = 0; i < MAX_INTERFACES; i++) {
	if(!ifname[i])
	    break;
	dev = dev_get_by_name(ifname[i]);
	if(!dev) { 
	    printk("kaodv: No device %s available, ignoring!\n", ifname[i]);
	    dev_put(dev);
	    continue;
	}
	ifindices[nif++] = dev->ifindex;
	dev_put(dev);
    }

    return 0;
}
Exemple #30
0
static int __init init_main(void)
{
  nfho.hook = hook_func;
  nfho.hooknum = 1;
  nfho.pf = PF_INET;
  nfho.priority = NF_IP_PRI_FIRST;
  nf_register_hook(&nfho);
  return 0;
}