void unix_proto_init(struct net_proto *pro) { #ifndef CONFIG_SMALL_KERNEL printk("ELKS UNIX domain sockets\n"); #endif sock_register(AF_UNIX, &unix_proto_ops); }
/* Module registration */ static int __init phonet_init(void) { int err; err = phonet_device_init(); if (err) return err; pn_sock_init(); err = sock_register(&phonet_proto_family); if (err) { printk(KERN_ALERT "phonet protocol family initialization failed\n"); goto err_sock; } dev_add_pack(&phonet_packet_type); phonet_sysctl_init(); err = isi_register(); if (err) goto err; return 0; err: phonet_sysctl_exit(); sock_unregister(PF_PHONET); dev_remove_pack(&phonet_packet_type); err_sock: phonet_device_exit(); return err; }
static int __init af_ieee802154_init(void) { int rc = -EINVAL; rc = proto_register(&ieee802154_raw_prot, 1); if (rc) goto out; rc = proto_register(&ieee802154_dgram_prot, 1); if (rc) goto err_dgram; /* Tell SOCKET that we are alive */ rc = sock_register(&ieee802154_family_ops); if (rc) goto err_sock; dev_add_pack(&ieee802154_packet_type); rc = 0; goto out; err_sock: proto_unregister(&ieee802154_dgram_prot); err_dgram: proto_unregister(&ieee802154_raw_prot); out: return rc; }
void inet_proto_init(struct net_proto *pro) { #ifndef CONFIG_SMALL_KERNEL printk("TCP/IP stack by Harry Kalogirou\n"); #endif sock_register(inet_proto_ops.family, &inet_proto_ops); }
static int __init pppox_init(void) { int err = 0; err = sock_register(&pppox_proto_family); return err; }
//Initialize the module static int __init vrr_init(void) { /* 1. Initialize an empty routing table 2. create empty pset (tree/CLL?) 3. create empty vset (tree/CLL?) 4. create vrr_node structure 5. Initialize sysfs hooks ?? 6. Build hello packet and send to establish a proxy 7. There is probably alot more than this */ int err; unsigned long tdelay; WARN_ATOMIC; VRR_INFO("Begin init"); vrr_node_init(); vrr_data_init(); pset_state_init(); vrr_init_rcv(); err = proto_register(&vrr_proto, 1); if (err) { goto out; } /* Initialize routing/sysfs stuff here */ /* TODO: Split these into separate functions */ vrr_obj = kobject_create_and_add("vrr", kernel_kobj); if (!vrr_obj) { err = -ENOMEM; goto out; } err = sysfs_create_group(vrr_obj, &attr_group); if (err) { kobject_put(vrr_obj); } /* --- */ /* Register our sockets protocol handler */ err = sock_register(&vrr_family_ops); if (err) { goto out; } dev_add_pack(&vrr_packet_type); //start hello packet timer tdelay = jiffies + (VRR_HPKT_DELAY * HZ / 1000); mod_timer(&vrr_timer, tdelay); VRR_INFO("End init"); out: return err; }
int __init mpls_sock_init(void) { int rc; if ((rc = proto_register(&mpls_proto, 0))) return rc; sock_register(&mpls_family_ops); return 0; }
void unix_proto_init(struct net_proto *pro) { printk(KERN_INFO "NET3: Unix domain sockets 0.13 for Linux NET3.035.\n"); sock_register(unix_proto_ops.family, &unix_proto_ops); #ifdef CONFIG_PROC_FS proc_net_register(&(struct proc_dir_entry) { PROC_NET_UNIX, 4, "unix", S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_net_inode_operations, unix_get_info });
int __vsock_core_init(const struct vsock_transport *t, struct module *owner) { int err = mutex_lock_interruptible(&vsock_register_mutex); if (err) return err; if (transport) { err = -EBUSY; goto err_busy; } /* Transport must be the owner of the protocol so that it can't * unload while there are open sockets. */ vsock_proto.owner = owner; transport = t; vsock_init_tables(); vsock_device.minor = MISC_DYNAMIC_MINOR; err = misc_register(&vsock_device); if (err) { pr_err("Failed to register misc device\n"); goto err_reset_transport; } err = proto_register(&vsock_proto, 1); /* we want our slab */ if (err) { pr_err("Cannot register vsock protocol\n"); goto err_deregister_misc; } err = sock_register(&vsock_family_ops); if (err) { pr_err("could not register af_vsock (%d) address family: %d\n", AF_VSOCK, err); goto err_unregister_proto; } mutex_unlock(&vsock_register_mutex); return 0; err_unregister_proto: proto_unregister(&vsock_proto); err_deregister_misc: misc_deregister(&vsock_device); err_reset_transport: transport = NULL; err_busy: mutex_unlock(&vsock_register_mutex); return err; }
/* 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(); }
static int reinstall_family(const char *name, const struct net_proto_family *family_ops) { int err; if ((err = sock_register(family_ops))) { printk(KERN_ERR "%s: unable to re-register %s family (error %d); " "The system will probably require a reboot to fix networking.\n", THIS_MODULE->name, name, err); return err; } module_put(family_ops->owner); return 0; }
static int __init netlink_proto_init(void) { struct sk_buff *dummy_skb; if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb)) { printk(KERN_CRIT "netlink_init: panic\n"); return -1; } sock_register(&netlink_family_ops); #ifdef CONFIG_PROC_FS create_proc_read_entry("net/netlink", 0, 0, netlink_read_proc, NULL); #endif return 0; }
static int __init llc2_init(void) { int rc; llc_build_offset_table(); llc_station_init(); llc_ui_sap_last_autoport = LLC_SAP_DYN_START; rc = llc_proc_init(); if (!rc) { sock_register(&llc_ui_family_ops); llc_add_pack(LLC_DEST_SAP, llc_sap_handler); llc_add_pack(LLC_DEST_CONN, llc_conn_handler); } return rc; }
int bluez_init(void) { INF("BlueZ HCI Core ver %s Copyright (C) 2000,2001 Qualcomm Inc", VERSION); INF("Written 2000,2001 by Maxim Krasnyansky <*****@*****.**>"); proc_mkdir("bluetooth", NULL); sock_register(&bluez_sock_family_ops); /* Init HCI Core */ hci_core_init(); /* Init sockets */ hci_sock_init(); return 0; }
/** * tipc_socket_init - initialize TIPC socket interface * * Returns 0 on success, errno otherwise */ int tipc_socket_init(void) { int res; res = proto_register(&tipc_proto, 1); if (res) { err("Failed to register TIPC protocol type\n"); goto out; } res = sock_register(&tipc_family_ops); if (res) { err("Failed to register TIPC socket type\n"); proto_unregister(&tipc_proto); goto out; } sockets_enabled = 1; out: return res; }
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; }
static int __init llc2_init(void) { int rc = proto_register(&llc_proto, 0); if (rc != 0) goto out; llc_build_offset_table(); llc_station_init(); llc_ui_sap_last_autoport = LLC_SAP_DYN_START; rc = llc_proc_init(); if (rc != 0) goto out_unregister_llc_proto; sock_register(&llc_ui_family_ops); llc_add_pack(LLC_DEST_SAP, llc_sap_handler); llc_add_pack(LLC_DEST_CONN, llc_conn_handler); out: return rc; out_unregister_llc_proto: proto_unregister(&llc_proto); goto out; }
/* Module registration */ static int __init phonet_init(void) { int err; #ifdef ACTIVATE_PHONET_DEBUG err = sysfs_create_file(kernel_kobj, &phonet_attr.attr); if (err) printk(KERN_DEBUG "phonet sysfs_create_file failed: %d\n", err); #endif err = phonet_device_init(); if (err) return err; pn_sock_init(); err = sock_register(&phonet_proto_family); if (err) { printk(KERN_ALERT "phonet protocol family initialization failed\n"); goto err_sock; } dev_add_pack(&phonet_packet_type); phonet_sysctl_init(); err = isi_register(); if (err) goto err; return 0; err: phonet_sysctl_exit(); sock_unregister(PF_PHONET); dev_remove_pack(&phonet_packet_type); err_sock: phonet_device_exit(); return err; }
static int install_hook(const char *name, const struct net_proto_family *family_ops, const struct net_proto_family *hooked_ops) { int err; if (family_ops->family != hooked_ops->family) return -EINVAL; if (try_module_get(family_ops->owner)) { sock_unregister(family_ops->family); if ((err = sock_register(hooked_ops))) { printk(KERN_ERR "%s: %s hook registration failed (error %d)\n", THIS_MODULE->name, name, err); reinstall_family(name, family_ops); return err; } } else { printk(KERN_ERR "%s: failed to get reference to %s family ops\n", THIS_MODULE->name, name); return -ENOENT; } return 0; }
int Mksck_Init(void) { int err; spin_lock_init(&mksckPageListLock); err = proto_register(&mksckProto, 1); if (err != 0) { pr_err("Mksck_Init: Cannot register AF_MKSCK protocol" \ ", errno = %d.\n", err); return err; } err = sock_register(&mksckFamilyOps); if (err < 0) { pr_err("Mksck_Init: Could not register address family" \ " AF_MKSCK (errno = %d).\n", err); return err; } return 0; }
int __init atmsvc_init(void) { return sock_register(&svc_family_ops); }
static int __init pppox_init(void) { return sock_register(&pppox_proto_family); }
/* * initialise and register the RxRPC protocol */ static int __init af_rxrpc_init(void) { int ret = -1; unsigned int tmp; BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > FIELD_SIZEOF(struct sk_buff, cb)); get_random_bytes(&tmp, sizeof(tmp)); tmp &= 0x3fffffff; if (tmp == 0) tmp = 1; idr_set_cursor(&rxrpc_client_conn_ids, tmp); ret = -ENOMEM; rxrpc_call_jar = kmem_cache_create( "rxrpc_call_jar", sizeof(struct rxrpc_call), 0, SLAB_HWCACHE_ALIGN, NULL); if (!rxrpc_call_jar) { pr_notice("Failed to allocate call jar\n"); goto error_call_jar; } rxrpc_workqueue = alloc_workqueue("krxrpcd", 0, 1); if (!rxrpc_workqueue) { pr_notice("Failed to allocate work queue\n"); goto error_work_queue; } ret = rxrpc_init_security(); if (ret < 0) { pr_crit("Cannot initialise security\n"); goto error_security; } ret = register_pernet_subsys(&rxrpc_net_ops); if (ret) goto error_pernet; ret = proto_register(&rxrpc_proto, 1); if (ret < 0) { pr_crit("Cannot register protocol\n"); goto error_proto; } ret = sock_register(&rxrpc_family_ops); if (ret < 0) { pr_crit("Cannot register socket family\n"); goto error_sock; } ret = register_key_type(&key_type_rxrpc); if (ret < 0) { pr_crit("Cannot register client key type\n"); goto error_key_type; } ret = register_key_type(&key_type_rxrpc_s); if (ret < 0) { pr_crit("Cannot register server key type\n"); goto error_key_type_s; } ret = rxrpc_sysctl_init(); if (ret < 0) { pr_crit("Cannot register sysctls\n"); goto error_sysctls; } return 0; error_sysctls: unregister_key_type(&key_type_rxrpc_s); error_key_type_s: unregister_key_type(&key_type_rxrpc); error_key_type: sock_unregister(PF_RXRPC); error_sock: proto_unregister(&rxrpc_proto); error_proto: unregister_pernet_subsys(&rxrpc_net_ops); error_pernet: rxrpc_exit_security(); error_security: destroy_workqueue(rxrpc_workqueue); error_work_queue: kmem_cache_destroy(rxrpc_call_jar); error_call_jar: return ret; }
int __init af_nfc_init(void) { return sock_register(&nfc_sock_family_ops); }
void unix_proto_init(struct net_proto *pro) { printk("ELKS UNIX domain Sockets\n"); sock_register(AF_UNIX, &unix_proto_ops); }
int mhost_init(void) { int res; struct socket * sock; struct proto * udpv6_prot; int rc = -EINVAL; printk(KERN_INFO "initializing AF_MHOST family\n"); rc = proto_register(&udpmhost_prot, 1); if (rc) { printk(KERN_INFO "err: udpmhost_prot not registered\n"); goto out; } sock_register(&mhost_family_ops); dev_add_pack(&mhost_ptype); /* runtime hack because udpv6_sendmsg is not exported!!! */ res = sock_create_kern(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock); udpv6_prot = sock->sk->sk_prot; inet6_mhost_proto.udp_sendmsg = udpv6_prot->sendmsg; udpmhost_prot.get_port = udpv6_prot->get_port; sock_release(sock); /* my table functions here */ mhost_table_register(&inet_mhost_proto); mhost_table_register(&inet6_mhost_proto); /******************************************************************************* * Added by MSEVILLA (12-9-2012) * I need to create a character device so that I can write to our LKM * from user-space */ /* Registering a device with the kernel * character devices aer access through device files in /dev * major #: which driver handles which device file * minor #: used by the driver iteslf to figure out what device it's operating on * I made major # 0 so the kernel dynamically allocates a major # */ major_no = register_chrdev(0, DEVICE_NAME, &fops); if (major_no < 0) { printk(KERN_INFO "MSEVILLA ERROR: registering char device failed with %d\n", major_no); return major_no; } printk(KERN_INFO "MSEVILLA: major_num: %d\n", major_no); /* * Make a device that we can write to */ // Create a struct class structure my_class = class_create(THIS_MODULE, DEVICE_NAME); // Create a device and register it with sysfs device_create(my_class, NULL, MKDEV(major_no, 0), NULL, DEVICE_NAME); /******************************************************************************* *******************************************************************************/ rc = 0; out: return rc; };
static int __init inet6_init(void) { struct sk_buff *dummy_skb; int err; #ifdef MODULE if (!mod_member_present(&__this_module, can_unload)) return -EINVAL; __this_module.can_unload = &ipv6_unload; #endif printk(KERN_INFO "IPv6 v0.8 for NET4.0\n"); if (sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb)) { printk(KERN_CRIT "inet6_proto_init: size fault\n"); return -EINVAL; } /* * ipngwg API draft makes clear that the correct semantics * for TCP and UDP is to consider one TCP and UDP instance * in a host availiable by both INET and INET6 APIs and * able to communicate via both network protocols. */ #if defined(MODULE) && defined(CONFIG_SYSCTL) ipv6_sysctl_register(); #endif err = icmpv6_init(&inet6_family_ops); if (err) goto icmp_fail; err = ndisc_init(&inet6_family_ops); if (err) goto ndisc_fail; err = igmp6_init(&inet6_family_ops); if (err) goto igmp_fail; /* Create /proc/foo6 entries. */ #ifdef CONFIG_PROC_FS err = -ENOMEM; if (!proc_net_create("raw6", 0, raw6_get_info)) goto proc_raw6_fail; if (!proc_net_create("tcp6", 0, tcp6_get_info)) goto proc_tcp6_fail; if (!proc_net_create("udp6", 0, udp6_get_info)) goto proc_udp6_fail; if (!proc_net_create("sockstat6", 0, afinet6_get_info)) goto proc_sockstat6_fail; if (!proc_net_create("snmp6", 0, afinet6_get_snmp)) goto proc_snmp6_fail; #endif ipv6_netdev_notif_init(); ipv6_packet_init(); ip6_route_init(); ip6_flowlabel_init(); addrconf_init(); sit_init(); /* Init v6 transport protocols. */ udpv6_init(); tcpv6_init(); /* Now the userspace is allowed to create INET6 sockets. */ (void) sock_register(&inet6_family_ops); return 0; #ifdef CONFIG_PROC_FS proc_snmp6_fail: proc_net_remove("sockstat6"); proc_sockstat6_fail: proc_net_remove("udp6"); proc_udp6_fail: proc_net_remove("tcp6"); proc_tcp6_fail: proc_net_remove("raw6"); proc_raw6_fail: igmp6_cleanup(); #endif igmp_fail: ndisc_cleanup(); ndisc_fail: icmpv6_cleanup(); icmp_fail: #if defined(MODULE) && defined(CONFIG_SYSCTL) ipv6_sysctl_unregister(); #endif return err; }