udplite.c 3.1 KB

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