2 * UDPLITE An implementation of the UDP-Lite protocol (RFC 3828).
4 * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
15 struct hlist_head udplite_hash
[UDP_HTABLE_SIZE
];
17 static int udplite_rcv(struct sk_buff
*skb
)
19 return __udp4_lib_rcv(skb
, udplite_hash
, IPPROTO_UDPLITE
);
22 static void udplite_err(struct sk_buff
*skb
, u32 info
)
24 __udp4_lib_err(skb
, info
, udplite_hash
);
27 static struct net_protocol udplite_protocol
= {
28 .handler
= udplite_rcv
,
29 .err_handler
= udplite_err
,
34 struct proto udplite_prot
= {
37 .close
= udp_lib_close
,
38 .connect
= ip4_datagram_connect
,
39 .disconnect
= udp_disconnect
,
41 .init
= udplite_sk_init
,
42 .destroy
= udp_destroy_sock
,
43 .setsockopt
= udp_setsockopt
,
44 .getsockopt
= udp_getsockopt
,
45 .sendmsg
= udp_sendmsg
,
46 .recvmsg
= udp_recvmsg
,
47 .sendpage
= udp_sendpage
,
48 .backlog_rcv
= udp_queue_rcv_skb
,
50 .unhash
= udp_lib_unhash
,
51 .get_port
= udp_v4_get_port
,
52 .obj_size
= sizeof(struct udp_sock
),
53 .h
.udp_hash
= udplite_hash
,
55 .compat_setsockopt
= compat_udp_setsockopt
,
56 .compat_getsockopt
= compat_udp_getsockopt
,
60 static struct inet_protosw udplite4_protosw
= {
62 .protocol
= IPPROTO_UDPLITE
,
63 .prot
= &udplite_prot
,
64 .ops
= &inet_dgram_ops
,
66 .no_check
= 0, /* must checksum (RFC 3828) */
67 .flags
= INET_PROTOSW_PERMANENT
,
71 static struct udp_seq_afinfo udplite4_seq_afinfo
= {
74 .hashtable
= udplite_hash
,
79 .show
= udp4_seq_show
,
83 static int udplite4_proc_init_net(struct net
*net
)
85 return udp_proc_register(net
, &udplite4_seq_afinfo
);
88 static void udplite4_proc_exit_net(struct net
*net
)
90 udp_proc_unregister(net
, &udplite4_seq_afinfo
);
93 static struct pernet_operations udplite4_net_ops
= {
94 .init
= udplite4_proc_init_net
,
95 .exit
= udplite4_proc_exit_net
,
98 static __init
int udplite4_proc_init(void)
100 return register_pernet_subsys(&udplite4_net_ops
);
103 static inline int udplite4_proc_init(void)
109 void __init
udplite4_register(void)
111 if (proto_register(&udplite_prot
, 1))
112 goto out_register_err
;
114 if (inet_add_protocol(&udplite_protocol
, IPPROTO_UDPLITE
) < 0)
115 goto out_unregister_proto
;
117 inet_register_protosw(&udplite4_protosw
);
119 if (udplite4_proc_init())
120 printk(KERN_ERR
"%s: Cannot register /proc!\n", __func__
);
123 out_unregister_proto
:
124 proto_unregister(&udplite_prot
);
126 printk(KERN_CRIT
"%s: Cannot add UDP-Lite protocol.\n", __func__
);
129 EXPORT_SYMBOL(udplite_hash
);
130 EXPORT_SYMBOL(udplite_prot
);