mpls_proto.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* $OpenBSD: mpls_proto.c,v 1.10 2015/07/18 15:51:17 mpi Exp $ */
  2. /*
  3. * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the project nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. */
  31. #include <sys/param.h>
  32. #include <sys/socket.h>
  33. #include <sys/protosw.h>
  34. #include <sys/domain.h>
  35. #include <sys/mbuf.h>
  36. #include <net/if.h>
  37. #include <net/if_var.h>
  38. #include <net/rtable.h>
  39. #include <netmpls/mpls.h>
  40. /*
  41. * MPLS protocol family:
  42. */
  43. struct protosw mplssw[] = {
  44. { 0, &mplsdomain, 0, 0,
  45. 0, 0, 0, 0,
  46. 0,
  47. mpls_init, 0, 0, 0, mpls_sysctl
  48. },
  49. { SOCK_DGRAM, &mplsdomain, 0, PR_ATOMIC|PR_ADDR,
  50. 0, 0, 0, 0,
  51. mpls_raw_usrreq,
  52. 0, 0, 0, 0, mpls_sysctl,
  53. },
  54. /* raw wildcard */
  55. { SOCK_RAW, &mplsdomain, 0, PR_ATOMIC|PR_ADDR,
  56. 0, 0, 0, 0,
  57. mpls_raw_usrreq,
  58. 0, 0, 0, 0, mpls_sysctl,
  59. },
  60. };
  61. struct domain mplsdomain = {
  62. AF_MPLS, "mpls", mpls_init, 0, 0,
  63. mplssw,
  64. &mplssw[nitems(mplssw)], 0,
  65. rtable_attach,
  66. offsetof(struct sockaddr_mpls, smpls_label) << 3,
  67. sizeof(struct sockaddr_mpls)
  68. };