2005-12-11 02:21:38 +03:00
|
|
|
/* $NetBSD: if_gre.h,v 1.15 2005/12/10 23:21:38 elad Exp $ */
|
1998-09-14 00:27:47 +04:00
|
|
|
|
|
|
|
/*
|
1998-10-08 03:33:02 +04:00
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
1998-09-14 00:27:47 +04:00
|
|
|
* All rights reserved
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Heiko W.Rupp <hwr@pilhuhn.de>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
2005-02-27 01:45:09 +03:00
|
|
|
*
|
1998-09-14 00:27:47 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2005-12-11 02:21:38 +03:00
|
|
|
#ifndef _NET_IF_GRE_H_
|
|
|
|
#define _NET_IF_GRE_H_
|
1998-09-14 00:27:47 +04:00
|
|
|
|
2000-07-05 22:14:13 +04:00
|
|
|
#include <sys/queue.h>
|
|
|
|
|
1998-09-14 00:27:47 +04:00
|
|
|
struct gre_softc {
|
|
|
|
struct ifnet sc_if;
|
2000-07-05 22:14:13 +04:00
|
|
|
LIST_ENTRY(gre_softc) sc_list;
|
1998-09-14 00:27:47 +04:00
|
|
|
int gre_unit;
|
|
|
|
int gre_flags;
|
2001-05-10 05:23:51 +04:00
|
|
|
struct in_addr g_src; /* source address of gre packets */
|
|
|
|
struct in_addr g_dst; /* destination address of gre packets */
|
1998-09-14 00:27:47 +04:00
|
|
|
struct route route; /* routing entry that determines, where a
|
2001-05-10 05:23:51 +04:00
|
|
|
encapsulated packet should go */
|
1998-09-14 00:27:47 +04:00
|
|
|
u_char g_proto; /* protocol of encapsulator */
|
2005-02-27 01:45:09 +03:00
|
|
|
};
|
1998-09-14 00:27:47 +04:00
|
|
|
|
|
|
|
|
|
|
|
struct gre_h {
|
|
|
|
u_int16_t flags; /* GRE flags */
|
2005-02-27 01:45:09 +03:00
|
|
|
u_int16_t ptype; /* protocol type of payload typically
|
2001-05-10 05:23:51 +04:00
|
|
|
Ether protocol type*/
|
2005-02-27 01:45:09 +03:00
|
|
|
/*
|
|
|
|
* from here on: fields are optional, presence indicated by flags
|
1998-09-14 00:27:47 +04:00
|
|
|
*
|
2001-05-10 05:23:51 +04:00
|
|
|
u_int_16 checksum checksum (one-complements of GRE header
|
|
|
|
and payload
|
|
|
|
Present if (ck_pres | rt_pres == 1).
|
|
|
|
Valid if (ck_pres == 1).
|
|
|
|
u_int_16 offset offset from start of routing filed to
|
|
|
|
first octet of active SRE (see below).
|
|
|
|
Present if (ck_pres | rt_pres == 1).
|
|
|
|
Valid if (rt_pres == 1).
|
|
|
|
u_int_32 key inserted by encapsulator e.g. for
|
|
|
|
authentication
|
|
|
|
Present if (key_pres ==1 ).
|
|
|
|
u_int_32 seq_num Sequence number to allow for packet order
|
|
|
|
Present if (seq_pres ==1 ).
|
|
|
|
struct gre_sre[] routing Routing fileds (see below)
|
|
|
|
Present if (rt_pres == 1)
|
|
|
|
*/
|
1999-11-19 23:41:19 +03:00
|
|
|
} __attribute__((__packed__));
|
1998-09-14 00:27:47 +04:00
|
|
|
|
|
|
|
struct greip {
|
|
|
|
struct ip gi_i;
|
|
|
|
struct gre_h gi_g;
|
1999-11-19 23:41:19 +03:00
|
|
|
} __attribute__((__packed__));
|
1998-09-14 00:27:47 +04:00
|
|
|
|
2001-05-10 05:23:51 +04:00
|
|
|
#define gi_pr gi_i.ip_p
|
|
|
|
#define gi_len gi_i.ip_len
|
|
|
|
#define gi_src gi_i.ip_src
|
|
|
|
#define gi_dst gi_i.ip_dst
|
1998-09-14 00:27:47 +04:00
|
|
|
#define gi_ptype gi_g.ptype
|
|
|
|
#define gi_flags gi_g.flags
|
|
|
|
|
2001-05-10 05:23:51 +04:00
|
|
|
#define GRE_CP 0x8000 /* Checksum Present */
|
|
|
|
#define GRE_RP 0x4000 /* Routing Present */
|
|
|
|
#define GRE_KP 0x2000 /* Key Present */
|
|
|
|
#define GRE_SP 0x1000 /* Sequence Present */
|
1998-09-14 00:27:47 +04:00
|
|
|
#define GRE_SS 0x0800 /* Strict Source Route */
|
|
|
|
|
2001-05-10 05:23:51 +04:00
|
|
|
/*
|
|
|
|
* gre_sre defines a Source route Entry. These are needed if packets
|
|
|
|
* should be routed over more than one tunnel hop by hop
|
1998-09-14 00:27:47 +04:00
|
|
|
*/
|
|
|
|
struct gre_sre {
|
2003-11-10 11:51:51 +03:00
|
|
|
u_int16_t sre_family; /* address family */
|
2001-05-10 05:23:51 +04:00
|
|
|
u_char sre_offset; /* offset to first octet of active entry */
|
2005-02-27 01:45:09 +03:00
|
|
|
u_char sre_length; /* number of octets in the SRE.
|
2001-05-10 05:23:51 +04:00
|
|
|
sre_lengthl==0 -> last entry. */
|
|
|
|
u_char *sre_rtinfo; /* the routing information */
|
1998-09-14 00:27:47 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct greioctl {
|
|
|
|
int unit;
|
2001-05-10 05:23:51 +04:00
|
|
|
struct in_addr addr;
|
1998-09-14 00:27:47 +04:00
|
|
|
};
|
|
|
|
|
1998-09-30 09:59:27 +04:00
|
|
|
/* for mobile encaps */
|
|
|
|
|
|
|
|
struct mobile_h {
|
|
|
|
u_int16_t proto; /* protocol and S-bit */
|
|
|
|
u_int16_t hcrc; /* header checksum */
|
|
|
|
u_int32_t odst; /* original destination address */
|
|
|
|
u_int32_t osrc; /* original source addr, if S-bit set */
|
1999-11-19 23:41:19 +03:00
|
|
|
} __attribute__((__packed__));
|
1998-09-30 09:59:27 +04:00
|
|
|
|
|
|
|
struct mobip_h {
|
2001-05-10 05:23:51 +04:00
|
|
|
struct ip mi;
|
|
|
|
struct mobile_h mh;
|
1999-11-19 23:41:19 +03:00
|
|
|
} __attribute__((__packed__));
|
1998-09-30 09:59:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
#define MOB_H_SIZ_S (sizeof(struct mobile_h) - sizeof(u_int32_t))
|
|
|
|
#define MOB_H_SIZ_L (sizeof(struct mobile_h))
|
|
|
|
#define MOB_H_SBIT 0x0080
|
|
|
|
|
2002-02-24 20:22:20 +03:00
|
|
|
#define GRE_TTL 30
|
|
|
|
extern int ip_gre_ttl;
|
1998-09-30 09:59:27 +04:00
|
|
|
|
2005-02-27 01:45:09 +03:00
|
|
|
/*
|
|
|
|
* ioctls needed to manipulate the interface
|
1998-09-30 09:59:27 +04:00
|
|
|
*/
|
|
|
|
|
2001-05-10 05:23:51 +04:00
|
|
|
#define GRESADDRS _IOW('i', 101, struct ifreq)
|
2005-02-27 01:45:09 +03:00
|
|
|
#define GRESADDRD _IOW('i', 102, struct ifreq)
|
2001-05-10 05:23:51 +04:00
|
|
|
#define GREGADDRS _IOWR('i', 103, struct ifreq)
|
|
|
|
#define GREGADDRD _IOWR('i', 104, struct ifreq)
|
|
|
|
#define GRESPROTO _IOW('i' , 105, struct ifreq)
|
|
|
|
#define GREGPROTO _IOWR('i', 106, struct ifreq)
|
1998-09-14 00:27:47 +04:00
|
|
|
|
1998-12-22 04:33:45 +03:00
|
|
|
#ifdef _KERNEL
|
2000-07-06 02:45:25 +04:00
|
|
|
LIST_HEAD(gre_softc_head, gre_softc);
|
|
|
|
extern struct gre_softc_head gre_softc_list;
|
1998-09-30 09:59:27 +04:00
|
|
|
|
2001-05-10 05:23:51 +04:00
|
|
|
int gre_ioctl __P((struct ifnet *, u_long, caddr_t));
|
|
|
|
int gre_output __P((struct ifnet *, struct mbuf *, struct sockaddr *,
|
2003-07-08 11:13:50 +04:00
|
|
|
struct rtentry *));
|
2003-09-06 03:02:40 +04:00
|
|
|
u_int16_t gre_in_cksum(u_short *, u_int);
|
1998-12-22 04:33:45 +03:00
|
|
|
#endif /* _KERNEL */
|
1998-09-30 09:59:27 +04:00
|
|
|
|
2005-12-11 02:21:38 +03:00
|
|
|
#endif /* !_NET_IF_GRE_H_ */
|