133841545SHajimu UMEMOTO /* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */ 2686cdd19SJun-ichiro itojun Hagino 3c398230bSWarner Losh /*- 451369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 551369649SPedro F. Giffuni * 682cd038dSYoshinobu Inoue * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7b941bc1dSAndrey V. Elsukov * Copyright (c) 2018 Andrey V. Elsukov <ae@FreeBSD.org> 882cd038dSYoshinobu Inoue * All rights reserved. 982cd038dSYoshinobu Inoue * 1082cd038dSYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 1182cd038dSYoshinobu Inoue * modification, are permitted provided that the following conditions 1282cd038dSYoshinobu Inoue * are met: 1382cd038dSYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 1482cd038dSYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 1582cd038dSYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 1682cd038dSYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 1782cd038dSYoshinobu Inoue * documentation and/or other materials provided with the distribution. 1882cd038dSYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 1982cd038dSYoshinobu Inoue * may be used to endorse or promote products derived from this software 2082cd038dSYoshinobu Inoue * without specific prior written permission. 2182cd038dSYoshinobu Inoue * 2282cd038dSYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2382cd038dSYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2482cd038dSYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2582cd038dSYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2682cd038dSYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2782cd038dSYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2882cd038dSYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2982cd038dSYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3082cd038dSYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3182cd038dSYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3282cd038dSYoshinobu Inoue * SUCH DAMAGE. 3382cd038dSYoshinobu Inoue */ 3482cd038dSYoshinobu Inoue 3582cd038dSYoshinobu Inoue #ifndef _NET_IF_GIF_H_ 3682cd038dSYoshinobu Inoue #define _NET_IF_GIF_H_ 3782cd038dSYoshinobu Inoue 3820af0ffaSBrooks Davis #ifdef _KERNEL 39686cdd19SJun-ichiro itojun Hagino 400b9f5f8aSAndrey V. Elsukov struct ip; 410b9f5f8aSAndrey V. Elsukov struct ip6_hdr; 42686cdd19SJun-ichiro itojun Hagino 4394408d94SBrooks Davis extern void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, 4494408d94SBrooks Davis int af); 4594408d94SBrooks Davis extern void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m, 4694408d94SBrooks Davis int af); 4794408d94SBrooks Davis extern int (*ng_gif_output_p)(struct ifnet *ifp, struct mbuf **mp); 4894408d94SBrooks Davis extern void (*ng_gif_attach_p)(struct ifnet *ifp); 4994408d94SBrooks Davis extern void (*ng_gif_detach_p)(struct ifnet *ifp); 5094408d94SBrooks Davis 5182cd038dSYoshinobu Inoue struct gif_softc { 52fc74a9f9SBrooks Davis struct ifnet *gif_ifp; 530b9f5f8aSAndrey V. Elsukov int gif_family; 5482cd038dSYoshinobu Inoue int gif_flags; 558b07e49aSJulian Elischer u_int gif_fibnum; 56dbe59260SHiroki Sato u_int gif_options; 570b9f5f8aSAndrey V. Elsukov void *gif_netgraph; /* netgraph node info */ 580b9f5f8aSAndrey V. Elsukov union { 590b9f5f8aSAndrey V. Elsukov void *hdr; 600b9f5f8aSAndrey V. Elsukov struct ip *iphdr; 610b9f5f8aSAndrey V. Elsukov struct ip6_hdr *ip6hdr; 620b9f5f8aSAndrey V. Elsukov } gif_uhdr; 6382cd038dSYoshinobu Inoue 64b941bc1dSAndrey V. Elsukov CK_LIST_ENTRY(gif_softc) chain; 65*009d82eeSAndrey V. Elsukov CK_LIST_ENTRY(gif_softc) srchash; 66b941bc1dSAndrey V. Elsukov }; 67b941bc1dSAndrey V. Elsukov CK_LIST_HEAD(gif_list, gif_softc); 68b941bc1dSAndrey V. Elsukov MALLOC_DECLARE(M_GIF); 69b941bc1dSAndrey V. Elsukov 70b941bc1dSAndrey V. Elsukov #ifndef GIF_HASH_SIZE 71b941bc1dSAndrey V. Elsukov #define GIF_HASH_SIZE (1 << 4) 72b941bc1dSAndrey V. Elsukov #endif 73b941bc1dSAndrey V. Elsukov 74b941bc1dSAndrey V. Elsukov #define GIF2IFP(sc) ((sc)->gif_ifp) 750b9f5f8aSAndrey V. Elsukov #define gif_iphdr gif_uhdr.iphdr 760b9f5f8aSAndrey V. Elsukov #define gif_hdr gif_uhdr.hdr 770b9f5f8aSAndrey V. Elsukov #define gif_ip6hdr gif_uhdr.ip6hdr 7882cd038dSYoshinobu Inoue 7982cd038dSYoshinobu Inoue #define GIF_MTU (1280) /* Default MTU */ 8082cd038dSYoshinobu Inoue #define GIF_MTU_MIN (1280) /* Minimum MTU */ 8182cd038dSYoshinobu Inoue #define GIF_MTU_MAX (8192) /* Maximum MTU */ 8282cd038dSYoshinobu Inoue 8373ff045cSAndrew Thompson struct etherip_header { 84dbe59260SHiroki Sato #if BYTE_ORDER == LITTLE_ENDIAN 85dbe59260SHiroki Sato u_int eip_resvl:4, /* reserved */ 86dbe59260SHiroki Sato eip_ver:4; /* version */ 87dbe59260SHiroki Sato #endif 88dbe59260SHiroki Sato #if BYTE_ORDER == BIG_ENDIAN 89dbe59260SHiroki Sato u_int eip_ver:4, /* version */ 90dbe59260SHiroki Sato eip_resvl:4; /* reserved */ 91dbe59260SHiroki Sato #endif 92dbe59260SHiroki Sato u_int8_t eip_resvh; /* reserved */ 93dbe59260SHiroki Sato } __packed; 94dbe59260SHiroki Sato 95dbe59260SHiroki Sato #define ETHERIP_VERSION 0x3 9673ff045cSAndrew Thompson 97b941bc1dSAndrey V. Elsukov #define GIF_WAIT() epoch_wait_preempt(net_epoch_preempt) 98b941bc1dSAndrey V. Elsukov 9982cd038dSYoshinobu Inoue /* Prototypes */ 100b941bc1dSAndrey V. Elsukov struct gif_list *gif_hashinit(void); 101b941bc1dSAndrey V. Elsukov void gif_hashdestroy(struct gif_list *); 102b941bc1dSAndrey V. Elsukov 1030b9f5f8aSAndrey V. Elsukov void gif_input(struct mbuf *, struct ifnet *, int, uint8_t); 10447e8d432SGleb Smirnoff int gif_output(struct ifnet *, struct mbuf *, const struct sockaddr *, 105279aa3d4SKip Macy struct route *); 106b941bc1dSAndrey V. Elsukov 107b941bc1dSAndrey V. Elsukov void in_gif_init(void); 108b941bc1dSAndrey V. Elsukov void in_gif_uninit(void); 109f188f14dSAndrey V. Elsukov int in_gif_output(struct ifnet *, struct mbuf *, int, uint8_t); 110b941bc1dSAndrey V. Elsukov int in_gif_ioctl(struct gif_softc *, u_long, caddr_t); 111b941bc1dSAndrey V. Elsukov int in_gif_setopts(struct gif_softc *, u_int); 112b941bc1dSAndrey V. Elsukov 113b941bc1dSAndrey V. Elsukov void in6_gif_init(void); 114b941bc1dSAndrey V. Elsukov void in6_gif_uninit(void); 115f188f14dSAndrey V. Elsukov int in6_gif_output(struct ifnet *, struct mbuf *, int, uint8_t); 116b941bc1dSAndrey V. Elsukov int in6_gif_ioctl(struct gif_softc *, u_long, caddr_t); 117b941bc1dSAndrey V. Elsukov int in6_gif_setopts(struct gif_softc *, u_int); 11820af0ffaSBrooks Davis #endif /* _KERNEL */ 11920af0ffaSBrooks Davis 120fb70e72bSHiroki Sato #define GIFGOPTS _IOWR('i', 150, struct ifreq) 121dbe59260SHiroki Sato #define GIFSOPTS _IOW('i', 151, struct ifreq) 122dbe59260SHiroki Sato 123c1b4f79dSAndrey V. Elsukov #define GIF_IGNORE_SOURCE 0x0002 124b1c250ffSHiroki Sato #define GIF_OPTMASK (GIF_IGNORE_SOURCE) 125dbe59260SHiroki Sato 12682cd038dSYoshinobu Inoue #endif /* _NET_IF_GIF_H_ */ 127