Example #1
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP))
		goto err;
#if IS_ENABLED(CONFIG_IPV6)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		goto err;
	}
#endif
#if IS_ENABLED(CONFIG_MPLS)
	if (inet_add_protocol(&tunnelmpls4_protocol, IPPROTO_MPLS)) {
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
#if IS_ENABLED(CONFIG_IPV6)
		inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6);
#endif
		goto err;
	}
#endif
	return 0;

err:
	pr_err("%s: can't add protocol\n", __func__);
	return -EAGAIN;
}
Example #2
0
static inline int
openswan_inet_add_protocol(struct inet_protocol *prot, unsigned protocol)
{
#ifdef NETDEV_25
	return inet_add_protocol(prot, protocol);
#else
	inet_add_protocol(prot);
	return 0;
#endif
}
Example #3
0
static inline int
openswan_inet_add_protocol(struct inet_protocol *prot, unsigned protocol, char*protstr)
{
#ifdef IPSKB_XFRM_TUNNEL_SIZE
	inet_add_protocol(prot, protocol);
#else
	inet_add_protocol(prot);
#endif
	return 0;
}
int __init ipip_init(void)
{
	printk(banner);

	ipip_fb_tunnel_dev.priv = (void*)&ipip_fb_tunnel;
	register_netdev(&ipip_fb_tunnel_dev);
	inet_add_protocol(&ipip_protocol);
#ifdef CONFIG_NET_IPIP_IPV6
	inet_add_protocol(&ipip6_protocol);
#endif
	return 0;
}
Example #5
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
		printk(KERN_ERR "tunnel4 init: can't add protocol\n");
		return -EAGAIN;
	}
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		printk(KERN_ERR "tunnel64 init: can't add protocol\n");
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		return -EAGAIN;
	}
#endif
	return 0;
}
Example #6
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
		pr_err("%s: can't add protocol\n", __func__);
		return -EAGAIN;
	}
#if IS_ENABLED(CONFIG_IPV6)
	if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
		pr_err("tunnel64 init: can't add protocol\n");
		inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
		return -EAGAIN;
	}
#endif
	return 0;
}
static int cse536_add_protocol(void)
{
	/* Register protocol with inet layer.  */
	if (inet_add_protocol(&cse536_protocol, IPPROTO_CSE536) < 0)
		return -EAGAIN;
	return 0;
}
Example #8
0
static int __init rbping_init(void)
{
 
  if( strlen(magicstr) > MAX_LEN_BUF ) {

    printk("rbping_init: error: magicstr too long (%d bytes string permitted)", MAX_LEN_BUF);
    return -1;
  }  
	
  strncpy(_magicstr,magicstr,MAX_LEN_BUF); 

  rbping_proc_entry = create_proc_entry( LKM_NAME, 0644, NULL );
  if( !rbping_proc_entry ){  
    
    remove_proc_entry( LKM_NAME, NULL);
    printk("rbping_init: cannot create /proc entry.");
    return -ENOMEM;
  }
  rbping_proc_entry->read_proc = rbping_proc_read;
  rbping_proc_entry->write_proc = rbping_proc_write;
  
  if ( inet_add_protocol( &new_protocol, 163 ) < 0 ){        
    
    printk("rbping_init: Cannot add ICMP protocol\n");  
    if( inet_del_protocol( &new_protocol, 163 ) < 0 )
      printk("rbping_init: Cannot delete ICMP protocol\n");  
    return -1;
    
  }

  printk("%s-%s: Module loaded\n",LKM_NAME, LKM_VERSION);
  return 0;
  
};
Example #9
0
File: ipv4.c Project: panyfx/ath
static int __init dccp_v4_init(void)
{
	int err = proto_register(&dccp_v4_prot, 1);

	if (err != 0)
		goto out;

	err = inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
	if (err != 0)
		goto out_proto_unregister;

	inet_register_protosw(&dccp_v4_protosw);

	err = register_pernet_subsys(&dccp_v4_ops);
	if (err)
		goto out_destroy_ctl_sock;
out:
	return err;
out_destroy_ctl_sock:
	inet_unregister_protosw(&dccp_v4_protosw);
	inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
out_proto_unregister:
	proto_unregister(&dccp_v4_prot);
	goto out;
}
static int __init gre_init(void)
{
	pr_info("GRE over IPv4 demultiplexor driver\n");

	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("can't add protocol\n");
		goto err;
	}

	if (gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO) < 0) {
		pr_info("%s: can't add ipgre handler\n", __func__);
		goto err_gre;
	}

	if (gre_offload_init()) {
		pr_err("can't add protocol offload\n");
		goto err_gso;
	}

	return 0;
err_gso:
	gre_del_protocol(&ipgre_protocol, GREPROTO_CISCO);
err_gre:
	inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
err:
	return -EAGAIN;
}
Example #11
0
int __init sit_init(void)
{
	int err;

	printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n");

	if (inet_add_protocol(&sit_protocol, IPPROTO_IPV6) < 0) {
		printk(KERN_INFO "sit init: Can't add protocol\n");
		return -EAGAIN;
	}

	ipip6_fb_tunnel_dev = alloc_netdev(sizeof(struct ip_tunnel), "sit0", 
					   ipip6_tunnel_setup);
	if (!ipip6_fb_tunnel_dev) {
		err = -ENOMEM;
		goto err1;
	}

	ipip6_fb_tunnel_dev->init = ipip6_fb_tunnel_init;

	if ((err =  register_netdev(ipip6_fb_tunnel_dev)))
		goto err2;

 out:
	return err;
 err2:
	free_netdev(ipip6_fb_tunnel_dev);
 err1:
	inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
	goto out;
}
Example #12
0
static int __init mptp_init(void)
{
	int rc;

	rc = proto_register(&mptp_prot, 1);
	if (unlikely(rc)) {
		log_error("Error registering mptp protocol\n");
		goto out;
	}

	rc = inet_add_protocol(&mptp_protocol, IPPROTO_MPTP);
	if (unlikely(rc)) {
		log_error("Error adding mptp protocol\n");
		goto out_unregister;
	}

	inet_register_protosw(&mptp_protosw);
	log_debug("MPTP entered\n");

	return 0;

 out_unregister:
	proto_unregister(&mptp_prot);

 out:
	return rc;
}
Example #13
0
static inline int
openswan_inet_add_protocol(struct inet_protocol *prot, unsigned protocol, char *protstr)
{
	int err = inet_add_protocol(prot, protocol);
	if (err)
		printk(KERN_ERR "KLIPS: can not register %s protocol - recompile with CONFIG_INET_%s disabled or as module\n", protstr,protstr);
	return err;
}
Example #14
0
static int __init tunnel4_init(void)
{
	if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP)) {
		printk(KERN_ERR "tunnel4 init: can't add protocol\n");
		return -EAGAIN;
	}
	return 0;
}
Example #15
0
int __init ipip_init(void)
{
	printk(banner);

	ipip_fb_tunnel_dev.priv = (void*)&ipip_fb_tunnel;
	register_netdev(&ipip_fb_tunnel_dev);
	inet_add_protocol(&ipip_protocol);
	return 0;
}
Example #16
0
int __init sit_init(void)
{
	printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n");

	ipip6_fb_tunnel_dev.priv = (void*)&ipip6_fb_tunnel;
	strcpy(ipip6_fb_tunnel_dev.name, ipip6_fb_tunnel.parms.name);
	register_netdev(&ipip6_fb_tunnel_dev);
	inet_add_protocol(&sit_protocol);
	return 0;
}
Example #17
0
static int __init gre_init(void)
{
	pr_info("GRE over IPv4 demultiplexor driver\n");

	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("can't add protocol\n");
		return -EAGAIN;
	}
	return 0;
}
static int __init ipcomp4_init(void)
{
	if (xfrm_register_type(&ipcomp_type, AF_INET) < 0) {
		pr_info("%s: can't add xfrm type\n", __func__);
		return -EAGAIN;
	}
	if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) {
		pr_info("%s: can't add protocol\n", __func__);
		xfrm_unregister_type(&ipcomp_type, AF_INET);
		return -EAGAIN;
	}
	return 0;
}
static int __init ah4_init(void)
{
	if (xfrm_register_type(&ah_type, AF_INET) < 0) {
		printk(KERN_INFO "ip ah init: can't add xfrm type\n");
		return -EAGAIN;
	}
	if (inet_add_protocol(&ah4_protocol, IPPROTO_AH) < 0) {
		printk(KERN_INFO "ip ah init: can't add protocol\n");
		xfrm_unregister_type(&ah_type, AF_INET);
		return -EAGAIN;
	}
	return 0;
}
Example #20
0
/* 1. 向全局协议簇数组中,注册协议簇	proto_ops结构
 * 2. 向全局传输层协议链表中,注册传输层协议 	proto结构 
 * 3. 初始化arp模块	向全局变量ptype_base中注册处理函数,供链路层向上传递数据	注册定时时间,清理arp项过期
 * 4. 初始化ip模块	向全局变量ptype_base中注册处理函数,供链路层向上传递数据
 */
void inet_proto_init(struct net_proto *pro)
{
	struct inet_protocol *p;
	int i;


	printk("Swansea University Computer Society TCP/IP for NET3.019\n");

	/*
	 *	Tell SOCKET that we are alive... 
	 *  向SOCKET模块注册协议簇
	 */
   
  	(void) sock_register(inet_proto_ops.family, &inet_proto_ops);

  	seq_offset = CURRENT_TIME*250;

	/*
	 *	Add all the protocols. 
	 */
	 
	for(i = 0; i < SOCK_ARRAY_SIZE; i++) 
	{
		tcp_prot.sock_array[i] = NULL;
		udp_prot.sock_array[i] = NULL;
		raw_prot.sock_array[i] = NULL;
  	}
	tcp_prot.inuse = 0;
	tcp_prot.highestinuse = 0;
	udp_prot.inuse = 0;
	udp_prot.highestinuse = 0;
	raw_prot.inuse = 0;
	raw_prot.highestinuse = 0;

	printk("IP Protocols: ");
	for(p = inet_protocol_base; p != NULL;) 
	{
		struct inet_protocol *tmp = (struct inet_protocol *) p->next;
		inet_add_protocol(p);
		printk("%s%s",p->name,tmp?", ":"\n");
		p = tmp;
	}
	/*
	 *	Set the ARP module up
	 */
	arp_init();
  	/*
  	 *	Set the IP module up
  	 */
	ip_init();
}
Example #21
0
int __init sit_init(void)
{
    printk(KERN_INFO "IPv6 over IPv4 tunneling driver\n");

    if (inet_add_protocol(&sit_protocol, IPPROTO_IPV6) < 0) {
        printk(KERN_INFO "sit init: Can't add protocol\n");
        return -EAGAIN;
    }

    ipip6_fb_tunnel_dev.priv = (void*)&ipip6_fb_tunnel;
    strcpy(ipip6_fb_tunnel_dev.name, ipip6_fb_tunnel.parms.name);
    register_netdev(&ipip6_fb_tunnel_dev);
    return 0;
}
Example #22
0
static int gre_init(void)
{
	int err;

	if (inited)
		return 0;

	inited = true;
	err = inet_add_protocol(&gre_protocol_handlers, IPPROTO_GRE);
	if (err)
		pr_warn("cannot register gre protocol handler\n");

	return err;
}
Example #23
0
static int __init ipip_init(void)
{
	SET_MODULE_OWNER(&ipip_type);
	if (xfrm_register_type(&ipip_type, AF_INET) < 0) {
		printk(KERN_INFO "ipip init: can't add xfrm type\n");
		return -EAGAIN;
	}
	if (inet_add_protocol(&ipip_protocol, IPPROTO_IPIP) < 0) {
		printk(KERN_INFO "ipip init: can't add protocol\n");
		xfrm_unregister_type(&ipip_type, AF_INET);
		return -EAGAIN;
	}
	return 0;
}
Example #24
0
__initfunc(int ipip_init(void))
#endif
{
	printk(KERN_INFO "IPv4 over IPv4 tunneling driver\n");

	ipip_fb_tunnel_dev.priv = (void*)&ipip_fb_tunnel;
	ipip_fb_tunnel_dev.name = ipip_fb_tunnel.parms.name;
#ifdef MODULE
	register_netdev(&ipip_fb_tunnel_dev);
#else
	register_netdevice(&ipip_fb_tunnel_dev);
#endif

	inet_add_protocol(&ipip_protocol);
	return 0;
}
Example #25
0
int xfrm4_protocol_register(struct xfrm4_protocol *handler,
			    unsigned char protocol)
{
	struct xfrm4_protocol __rcu **pprev;
	struct xfrm4_protocol *t;
	bool add_netproto = false;

	int ret = -EEXIST;
	int priority = handler->priority;

	if (!proto_handlers(protocol) || !netproto(protocol))
		return -EINVAL;

	mutex_lock(&xfrm4_protocol_mutex);

	if (!rcu_dereference_protected(*proto_handlers(protocol),
				       lockdep_is_held(&xfrm4_protocol_mutex)))
		add_netproto = true;

	for (pprev = proto_handlers(protocol);
	     (t = rcu_dereference_protected(*pprev,
			lockdep_is_held(&xfrm4_protocol_mutex))) != NULL;
	     pprev = &t->next) {
		if (t->priority < priority)
			break;
		if (t->priority == priority)
			goto err;
	}

	handler->next = *pprev;
	rcu_assign_pointer(*pprev, handler);

	ret = 0;

err:
	mutex_unlock(&xfrm4_protocol_mutex);

	if (add_netproto) {
		if (inet_add_protocol(netproto(protocol), protocol)) {
			pr_err("%s: can't add protocol\n", __func__);
			ret = -EAGAIN;
		}
	}

	return ret;
}
Example #26
0
void __init udplite4_register(void)
{
	if (proto_register(&udplite_prot, 1))
		goto out_register_err;

	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
		goto out_unregister_proto;

	inet_register_protosw(&udplite4_protosw);

	if (udplite4_proc_init())
		printk(KERN_ERR "%s: Cannot register /proc!\n", __func__);
	return;

out_unregister_proto:
	proto_unregister(&udplite_prot);
out_register_err:
	printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __FUNCTION__);
}
Example #27
0
void __init udplite4_register(void)
{
	udp_table_init(&udplite_table, "UDP-Lite");
	if (proto_register(&udplite_prot, 1))
		goto out_register_err;

	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
		goto out_unregister_proto;

	inet_register_protosw(&udplite4_protosw);

	if (udplite4_proc_init())
		pr_err("%s: Cannot register /proc!\n", __func__);
	return;

out_unregister_proto:
	proto_unregister(&udplite_prot);
out_register_err:
	pr_crit("%s: Cannot add UDP-Lite protocol\n", __func__);
}
Example #28
0
static int gre_compat_init(void)
{
	int err;

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
	if (inet_add_protocol(&net_gre_protocol, IPPROTO_GRE) < 0) {
		pr_err("%s: cannot register gre protocol handler\n", __func__);
		return -EAGAIN;
	}
#endif
	err = gre_add_protocol(&ipgre_protocol, GREPROTO_CISCO);
	if (err) {
		pr_warn("%s: cannot register gre_cisco protocol handler\n", __func__);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
		inet_del_protocol(&net_gre_protocol, IPPROTO_GRE);
#endif
	}

	return err;
}
Example #29
0
void __init udplite4_register(void)
{
	if (proto_register(&udplite_prot, 1))
		goto out_register_err;

	if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
		goto out_unregister_proto;

	inet_register_protosw(&udplite4_protosw);

#ifdef CONFIG_PROC_FS
	if (udp_proc_register(&udplite4_seq_afinfo)) /* udplite4_proc_init() */
		printk(KERN_ERR "%s: Cannot register /proc!\n", __FUNCTION__);
#endif
	return;

out_unregister_proto:
	proto_unregister(&udplite_prot);
out_register_err:
	printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __FUNCTION__);
}
Example #30
0
void inet_proto_init(struct net_proto *proto)
{
    int i;
    struct inet_protocol *p;

    (void)sock_register(inet_protocol.family,&inet_protocol);

    for(i = 0;i < SOCK_ARRAY_SIZE;i++)
    {
        tcp_prot.sock_array[i] = NULL;
        udp_prot.sock_array[i] = NULL;
        raw_prot.sock_array[i] = NULL;

    }
    tcp_prot.inuse = 0;
    tcp_prot.highestinuse = 0; 

    udp_prot.inuse = 0;
    udp_prot.highestinuse = 0; 

    raw_prot.inuse = 0;
    raw_prot.highestinuse = 0; 

    printk("IP Protocols:\n");

    for(p = inet_protocol_base ; p!=NULL; )
    {

        struct inet_protocol *tmp = p->next;
        inet_add_protocol(p);
        printk("%s%s",p->name,tmp?",":"\n");

    }

    arp_init();

    ip_init();

    return;
}