/* $KAME: if_gif.h,v 1.17 2000/09/11 11:36:41 sumikawa Exp $ */12/*-3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.6* Copyright (c) 2018 Andrey V. Elsukov <[email protected]>7* All rights reserved.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the project nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*/3334#ifndef _NET_IF_GIF_H_35#define _NET_IF_GIF_H_3637#ifdef _KERNEL3839struct ip;40struct ip6_hdr;4142extern void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp,43int af);44extern void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m,45int af);46extern int (*ng_gif_output_p)(struct ifnet *ifp, struct mbuf **mp);47extern void (*ng_gif_attach_p)(struct ifnet *ifp);48extern void (*ng_gif_detach_p)(struct ifnet *ifp);4950struct gif_softc {51struct ifnet *gif_ifp;52int gif_family;53int gif_flags;54u_int gif_fibnum;55u_int gif_options;56void *gif_netgraph; /* netgraph node info */57union {58void *hdr;59struct ip *iphdr;60struct ip6_hdr *ip6hdr;61} gif_uhdr;6263CK_LIST_ENTRY(gif_softc) chain;64CK_LIST_ENTRY(gif_softc) srchash;65};66CK_LIST_HEAD(gif_list, gif_softc);67MALLOC_DECLARE(M_GIF);6869#ifndef GIF_HASH_SIZE70#define GIF_HASH_SIZE (1 << 4)71#endif7273#define GIF2IFP(sc) ((sc)->gif_ifp)74#define gif_iphdr gif_uhdr.iphdr75#define gif_hdr gif_uhdr.hdr76#define gif_ip6hdr gif_uhdr.ip6hdr7778#define GIF_MTU (1280) /* Default MTU */79#define GIF_MTU_MIN (1280) /* Minimum MTU */80#define GIF_MTU_MAX (8192) /* Maximum MTU */8182struct etherip_header {83#if BYTE_ORDER == LITTLE_ENDIAN84u_int eip_resvl:4, /* reserved */85eip_ver:4; /* version */86#endif87#if BYTE_ORDER == BIG_ENDIAN88u_int eip_ver:4, /* version */89eip_resvl:4; /* reserved */90#endif91u_int8_t eip_resvh; /* reserved */92} __packed;9394#define ETHERIP_VERSION 0x39596#define GIF_WAIT() epoch_wait_preempt(net_epoch_preempt)9798/* Prototypes */99struct gif_list *gif_hashinit(void);100void gif_hashdestroy(struct gif_list *);101102void gif_input(struct mbuf *, struct ifnet *, int, uint8_t);103int gif_output(struct ifnet *, struct mbuf *, const struct sockaddr *,104struct route *);105106void in_gif_init(void);107void in_gif_uninit(void);108int in_gif_output(struct ifnet *, struct mbuf *, int, uint8_t);109int in_gif_ioctl(struct gif_softc *, u_long, caddr_t);110int in_gif_setopts(struct gif_softc *, u_int);111112void in6_gif_init(void);113void in6_gif_uninit(void);114int in6_gif_output(struct ifnet *, struct mbuf *, int, uint8_t);115int in6_gif_ioctl(struct gif_softc *, u_long, caddr_t);116int in6_gif_setopts(struct gif_softc *, u_int);117#endif /* _KERNEL */118119#define GIFGOPTS _IOWR('i', 150, struct ifreq)120#define GIFSOPTS _IOW('i', 151, struct ifreq)121122#define GIF_NOCLAMP 0x0001123#define GIF_IGNORE_SOURCE 0x0002124#define GIF_OPTMASK (GIF_NOCLAMP|GIF_IGNORE_SOURCE)125126#endif /* _NET_IF_GIF_H_ */127128129