1686cdd19SJun-ichiro itojun Hagino /* $FreeBSD$ */ 233841545SHajimu UMEMOTO /* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */ 3686cdd19SJun-ichiro itojun Hagino 4c398230bSWarner Losh /*- 582cd038dSYoshinobu Inoue * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 682cd038dSYoshinobu Inoue * All rights reserved. 782cd038dSYoshinobu Inoue * 882cd038dSYoshinobu Inoue * Redistribution and use in source and binary forms, with or without 982cd038dSYoshinobu Inoue * modification, are permitted provided that the following conditions 1082cd038dSYoshinobu Inoue * are met: 1182cd038dSYoshinobu Inoue * 1. Redistributions of source code must retain the above copyright 1282cd038dSYoshinobu Inoue * notice, this list of conditions and the following disclaimer. 1382cd038dSYoshinobu Inoue * 2. Redistributions in binary form must reproduce the above copyright 1482cd038dSYoshinobu Inoue * notice, this list of conditions and the following disclaimer in the 1582cd038dSYoshinobu Inoue * documentation and/or other materials provided with the distribution. 1682cd038dSYoshinobu Inoue * 3. Neither the name of the project nor the names of its contributors 1782cd038dSYoshinobu Inoue * may be used to endorse or promote products derived from this software 1882cd038dSYoshinobu Inoue * without specific prior written permission. 1982cd038dSYoshinobu Inoue * 2082cd038dSYoshinobu Inoue * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2182cd038dSYoshinobu Inoue * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2282cd038dSYoshinobu Inoue * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2382cd038dSYoshinobu Inoue * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2482cd038dSYoshinobu Inoue * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2582cd038dSYoshinobu Inoue * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2682cd038dSYoshinobu Inoue * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2782cd038dSYoshinobu Inoue * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2882cd038dSYoshinobu Inoue * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2982cd038dSYoshinobu Inoue * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3082cd038dSYoshinobu Inoue * SUCH DAMAGE. 3182cd038dSYoshinobu Inoue */ 3282cd038dSYoshinobu Inoue 3382cd038dSYoshinobu Inoue /* 3482cd038dSYoshinobu Inoue * if_gif.h 3582cd038dSYoshinobu Inoue */ 3682cd038dSYoshinobu Inoue 3782cd038dSYoshinobu Inoue #ifndef _NET_IF_GIF_H_ 3882cd038dSYoshinobu Inoue #define _NET_IF_GIF_H_ 3982cd038dSYoshinobu Inoue 40686cdd19SJun-ichiro itojun Hagino 4120af0ffaSBrooks Davis #ifdef _KERNEL 42686cdd19SJun-ichiro itojun Hagino #include "opt_inet.h" 4320af0ffaSBrooks Davis #include "opt_inet6.h" 44686cdd19SJun-ichiro itojun Hagino 45686cdd19SJun-ichiro itojun Hagino #include <netinet/in.h> 46686cdd19SJun-ichiro itojun Hagino /* xxx sigh, why route have struct route instead of pointer? */ 47686cdd19SJun-ichiro itojun Hagino 48686cdd19SJun-ichiro itojun Hagino struct encaptab; 49686cdd19SJun-ichiro itojun Hagino 5094408d94SBrooks Davis extern void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, 5194408d94SBrooks Davis int af); 5294408d94SBrooks Davis extern void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m, 5394408d94SBrooks Davis int af); 5494408d94SBrooks Davis extern int (*ng_gif_output_p)(struct ifnet *ifp, struct mbuf **mp); 5594408d94SBrooks Davis extern void (*ng_gif_attach_p)(struct ifnet *ifp); 5694408d94SBrooks Davis extern void (*ng_gif_detach_p)(struct ifnet *ifp); 5794408d94SBrooks Davis 5882cd038dSYoshinobu Inoue struct gif_softc { 59fc74a9f9SBrooks Davis struct ifnet *gif_ifp; 6025af0bb5SGleb Smirnoff struct mtx gif_mtx; 6182cd038dSYoshinobu Inoue struct sockaddr *gif_psrc; /* Physical src addr */ 6282cd038dSYoshinobu Inoue struct sockaddr *gif_pdst; /* Physical dst addr */ 6382cd038dSYoshinobu Inoue union { 6482cd038dSYoshinobu Inoue struct route gifscr_ro; /* xxx */ 65686cdd19SJun-ichiro itojun Hagino #ifdef INET6 6682cd038dSYoshinobu Inoue struct route_in6 gifscr_ro6; /* xxx */ 67686cdd19SJun-ichiro itojun Hagino #endif 6882cd038dSYoshinobu Inoue } gifsc_gifscr; 6982cd038dSYoshinobu Inoue int gif_flags; 708b07e49aSJulian Elischer u_int gif_fibnum; 71686cdd19SJun-ichiro itojun Hagino const struct encaptab *encap_cookie4; 72686cdd19SJun-ichiro itojun Hagino const struct encaptab *encap_cookie6; 7394408d94SBrooks Davis void *gif_netgraph; /* ng_gif(4) netgraph node info */ 749426aedfSHajimu UMEMOTO LIST_ENTRY(gif_softc) gif_list; /* all gif's are linked */ 7582cd038dSYoshinobu Inoue }; 76fc74a9f9SBrooks Davis #define GIF2IFP(sc) ((sc)->gif_ifp) 7725af0bb5SGleb Smirnoff #define GIF_LOCK_INIT(sc) mtx_init(&(sc)->gif_mtx, "gif softc", \ 7825af0bb5SGleb Smirnoff NULL, MTX_DEF) 7925af0bb5SGleb Smirnoff #define GIF_LOCK_DESTROY(sc) mtx_destroy(&(sc)->gif_mtx) 8025af0bb5SGleb Smirnoff #define GIF_LOCK(sc) mtx_lock(&(sc)->gif_mtx) 8125af0bb5SGleb Smirnoff #define GIF_UNLOCK(sc) mtx_unlock(&(sc)->gif_mtx) 8225af0bb5SGleb Smirnoff #define GIF_LOCK_ASSERT(sc) mtx_assert(&(sc)->gif_mtx, MA_OWNED) 8382cd038dSYoshinobu Inoue 8482cd038dSYoshinobu Inoue #define gif_ro gifsc_gifscr.gifscr_ro 85686cdd19SJun-ichiro itojun Hagino #ifdef INET6 8682cd038dSYoshinobu Inoue #define gif_ro6 gifsc_gifscr.gifscr_ro6 87686cdd19SJun-ichiro itojun Hagino #endif 8882cd038dSYoshinobu Inoue 8982cd038dSYoshinobu Inoue #define GIF_MTU (1280) /* Default MTU */ 9082cd038dSYoshinobu Inoue #define GIF_MTU_MIN (1280) /* Minimum MTU */ 9182cd038dSYoshinobu Inoue #define GIF_MTU_MAX (8192) /* Maximum MTU */ 9282cd038dSYoshinobu Inoue 938c7e1947SRuslan Ermilov #define MTAG_GIF 1080679712 948c7e1947SRuslan Ermilov #define MTAG_GIF_CALLED 0 958c7e1947SRuslan Ermilov 9673ff045cSAndrew Thompson struct etherip_header { 9773ff045cSAndrew Thompson u_int8_t eip_ver; /* version/reserved */ 9873ff045cSAndrew Thompson u_int8_t eip_pad; /* required padding byte */ 9973ff045cSAndrew Thompson }; 10073ff045cSAndrew Thompson #define ETHERIP_VER_VERS_MASK 0x0f 10173ff045cSAndrew Thompson #define ETHERIP_VER_RSVD_MASK 0xf0 10273ff045cSAndrew Thompson #define ETHERIP_VERSION 0x03 10373ff045cSAndrew Thompson 10482cd038dSYoshinobu Inoue /* Prototypes */ 105929ddbbbSAlfred Perlstein void gif_input(struct mbuf *, int, struct ifnet *); 10634fe62c7SBruce Evans int gif_output(struct ifnet *, struct mbuf *, struct sockaddr *, 10734fe62c7SBruce Evans struct rtentry *); 108929ddbbbSAlfred Perlstein int gif_ioctl(struct ifnet *, u_long, caddr_t); 1099426aedfSHajimu UMEMOTO int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *); 1109426aedfSHajimu UMEMOTO void gif_delete_tunnel(struct ifnet *); 1119426aedfSHajimu UMEMOTO int gif_encapcheck(const struct mbuf *, int, int, void *); 11282cd038dSYoshinobu Inoue 11320af0ffaSBrooks Davis #endif /* _KERNEL */ 11420af0ffaSBrooks Davis 11582cd038dSYoshinobu Inoue #endif /* _NET_IF_GIF_H_ */ 116