udplite.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6.
  3. * See also net/ipv4/udplite.c
  4. *
  5. * Version: $Id: udplite.c,v 1.9 2006/10/19 08:28:10 gerrit Exp $
  6. *
  7. * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
  8. *
  9. * Changes:
  10. * Fixes:
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version
  14. * 2 of the License, or (at your option) any later version.
  15. */
  16. #include "udp_impl.h"
  17. DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6) __read_mostly;
  18. static int udplitev6_rcv(struct sk_buff *skb)
  19. {
  20. return __udp6_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE);
  21. }
  22. static void udplitev6_err(struct sk_buff *skb,
  23. struct inet6_skb_parm *opt,
  24. int type, int code, int offset, __be32 info)
  25. {
  26. __udp6_lib_err(skb, opt, type, code, offset, info, udplite_hash);
  27. }
  28. static struct inet6_protocol udplitev6_protocol = {
  29. .handler = udplitev6_rcv,
  30. .err_handler = udplitev6_err,
  31. .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
  32. };
  33. struct proto udplitev6_prot = {
  34. .name = "UDPLITEv6",
  35. .owner = THIS_MODULE,
  36. .close = udp_lib_close,
  37. .connect = ip6_datagram_connect,
  38. .disconnect = udp_disconnect,
  39. .ioctl = udp_ioctl,
  40. .init = udplite_sk_init,
  41. .destroy = udpv6_destroy_sock,
  42. .setsockopt = udpv6_setsockopt,
  43. .getsockopt = udpv6_getsockopt,
  44. .sendmsg = udpv6_sendmsg,
  45. .recvmsg = udpv6_recvmsg,
  46. .backlog_rcv = udpv6_queue_rcv_skb,
  47. .hash = udp_lib_hash,
  48. .unhash = udp_lib_unhash,
  49. .get_port = udp_v6_get_port,
  50. .obj_size = sizeof(struct udp6_sock),
  51. .h.udp_hash = udplite_hash,
  52. #ifdef CONFIG_COMPAT
  53. .compat_setsockopt = compat_udpv6_setsockopt,
  54. .compat_getsockopt = compat_udpv6_getsockopt,
  55. #endif
  56. };
  57. static struct inet_protosw udplite6_protosw = {
  58. .type = SOCK_DGRAM,
  59. .protocol = IPPROTO_UDPLITE,
  60. .prot = &udplitev6_prot,
  61. .ops = &inet6_dgram_ops,
  62. .capability = -1,
  63. .no_check = 0,
  64. .flags = INET_PROTOSW_PERMANENT,
  65. };
  66. int __init udplitev6_init(void)
  67. {
  68. int ret;
  69. ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  70. if (ret)
  71. goto out;
  72. ret = inet6_register_protosw(&udplite6_protosw);
  73. if (ret)
  74. goto out_udplitev6_protocol;
  75. out:
  76. return ret;
  77. out_udplitev6_protocol:
  78. inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  79. goto out;
  80. }
  81. void udplitev6_exit(void)
  82. {
  83. inet6_unregister_protosw(&udplite6_protosw);
  84. inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
  85. }
  86. #ifdef CONFIG_PROC_FS
  87. static struct file_operations udplite6_seq_fops;
  88. static struct udp_seq_afinfo udplite6_seq_afinfo = {
  89. .owner = THIS_MODULE,
  90. .name = "udplite6",
  91. .family = AF_INET6,
  92. .hashtable = udplite_hash,
  93. .seq_fops = &udplite6_seq_fops,
  94. .seq_ops = {
  95. .show = udp6_seq_show,
  96. },
  97. };
  98. static int udplite6_proc_init_net(struct net *net)
  99. {
  100. return udp_proc_register(net, &udplite6_seq_afinfo);
  101. }
  102. static void udplite6_proc_exit_net(struct net *net)
  103. {
  104. udp_proc_unregister(net, &udplite6_seq_afinfo);
  105. }
  106. static struct pernet_operations udplite6_net_ops = {
  107. .init = udplite6_proc_init_net,
  108. .exit = udplite6_proc_exit_net,
  109. };
  110. int __init udplite6_proc_init(void)
  111. {
  112. return register_pernet_subsys(&udplite6_net_ops);
  113. }
  114. void udplite6_proc_exit(void)
  115. {
  116. unregister_pernet_subsys(&udplite6_net_ops);
  117. }
  118. #endif