if_gif.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */
  2. /*-
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. *
  5. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  6. * Copyright (c) 2018 Andrey V. Elsukov <ae@FreeBSD.org>
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the project nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. * SUCH DAMAGE.
  32. */
  33. #ifndef _NET_IF_GIF_H_
  34. #define _NET_IF_GIF_H_
  35. #ifdef _KERNEL
  36. struct ip;
  37. struct ip6_hdr;
  38. extern void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp,
  39. int af);
  40. extern void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m,
  41. int af);
  42. extern int (*ng_gif_output_p)(struct ifnet *ifp, struct mbuf **mp);
  43. extern void (*ng_gif_attach_p)(struct ifnet *ifp);
  44. extern void (*ng_gif_detach_p)(struct ifnet *ifp);
  45. struct gif_softc {
  46. struct ifnet *gif_ifp;
  47. int gif_family;
  48. int gif_flags;
  49. u_int gif_fibnum;
  50. u_int gif_options;
  51. void *gif_netgraph; /* netgraph node info */
  52. union {
  53. void *hdr;
  54. struct ip *iphdr;
  55. struct ip6_hdr *ip6hdr;
  56. } gif_uhdr;
  57. CK_LIST_ENTRY(gif_softc) chain;
  58. CK_LIST_ENTRY(gif_softc) srchash;
  59. };
  60. CK_LIST_HEAD(gif_list, gif_softc);
  61. MALLOC_DECLARE(M_GIF);
  62. #ifndef GIF_HASH_SIZE
  63. #define GIF_HASH_SIZE (1 << 4)
  64. #endif
  65. #define GIF2IFP(sc) ((sc)->gif_ifp)
  66. #define gif_iphdr gif_uhdr.iphdr
  67. #define gif_hdr gif_uhdr.hdr
  68. #define gif_ip6hdr gif_uhdr.ip6hdr
  69. #define GIF_MTU (1280) /* Default MTU */
  70. #define GIF_MTU_MIN (1280) /* Minimum MTU */
  71. #define GIF_MTU_MAX (8192) /* Maximum MTU */
  72. struct etherip_header {
  73. #if BYTE_ORDER == LITTLE_ENDIAN
  74. u_int eip_resvl:4, /* reserved */
  75. eip_ver:4; /* version */
  76. #endif
  77. #if BYTE_ORDER == BIG_ENDIAN
  78. u_int eip_ver:4, /* version */
  79. eip_resvl:4; /* reserved */
  80. #endif
  81. u_int8_t eip_resvh; /* reserved */
  82. } __packed;
  83. #define ETHERIP_VERSION 0x3
  84. #define GIF_WAIT() epoch_wait_preempt(net_epoch_preempt)
  85. /* Prototypes */
  86. struct gif_list *gif_hashinit(void);
  87. void gif_hashdestroy(struct gif_list *);
  88. void gif_input(struct mbuf *, struct ifnet *, int, uint8_t);
  89. int gif_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
  90. struct route *);
  91. void in_gif_init(void);
  92. void in_gif_uninit(void);
  93. int in_gif_output(struct ifnet *, struct mbuf *, int, uint8_t);
  94. int in_gif_ioctl(struct gif_softc *, u_long, caddr_t);
  95. int in_gif_setopts(struct gif_softc *, u_int);
  96. void in6_gif_init(void);
  97. void in6_gif_uninit(void);
  98. int in6_gif_output(struct ifnet *, struct mbuf *, int, uint8_t);
  99. int in6_gif_ioctl(struct gif_softc *, u_long, caddr_t);
  100. int in6_gif_setopts(struct gif_softc *, u_int);
  101. #endif /* _KERNEL */
  102. #define GIFGOPTS _IOWR('i', 150, struct ifreq)
  103. #define GIFSOPTS _IOW('i', 151, struct ifreq)
  104. #define GIF_IGNORE_SOURCE 0x0002
  105. #define GIF_OPTMASK (GIF_IGNORE_SOURCE)
  106. #endif /* _NET_IF_GIF_H_ */