FreeBSD kernel IPv4 code
|
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/jail.h>
#include <sys/systm.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <net/if_gre.h>
#include <machine/in_cksum.h>
Go to the source code of this file.
Data Structures | |
struct | in_gre_socket |
Macros | |
#define | GRE_TTL 30 |
#define | V_ip_gre_ttl VNET(ip_gre_ttl) |
#define | V_ipv4_sockets VNET(ipv4_sockets) |
#define | V_ipv4_hashtbl VNET(ipv4_hashtbl) |
#define | V_ipv4_srchashtbl VNET(ipv4_srchashtbl) |
#define | GRE_HASH(src, dst) |
#define | GRE_SRCHASH(src) |
#define | GRE_SOCKHASH(src) |
#define | GRE_HASH_SC(sc) |
Functions | |
__FBSDID ("$FreeBSD$") | |
VNET_DEFINE (int, ip_gre_ttl) | |
SYSCTL_INT (_net_inet_ip, OID_AUTO, grettl, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_gre_ttl), 0, "Default TTL value for encapsulated packets") | |
VNET_DEFINE_STATIC (struct gre_sockets *, ipv4_sockets) | |
VNET_DEFINE_STATIC (struct gre_list *, ipv4_hashtbl) | |
VNET_DEFINE_STATIC (struct gre_list *, ipv4_srchashtbl) | |
static uint32_t | in_gre_hashval (in_addr_t src, in_addr_t dst) |
static struct gre_socket * | in_gre_lookup_socket (in_addr_t addr) |
static int | in_gre_checkdup (const struct gre_softc *sc, in_addr_t src, in_addr_t dst, uint32_t opts) |
static int | in_gre_lookup (const struct mbuf *m, int off, int proto, void **arg) |
static void | in_gre_set_running (struct gre_softc *sc) |
static void | in_gre_srcaddr (void *arg __unused, const struct sockaddr *sa, int event __unused) |
static void | in_gre_udp_input (struct mbuf *m, int off, struct inpcb *inp, const struct sockaddr *sa, void *ctx) |
static int | in_gre_setup_socket (struct gre_softc *sc) |
static int | in_gre_attach (struct gre_softc *sc) |
int | in_gre_setopts (struct gre_softc *sc, u_long cmd, uint32_t value) |
int | in_gre_ioctl (struct gre_softc *sc, u_long cmd, caddr_t data) |
int | in_gre_output (struct mbuf *m, int af, int hlen) |
void | in_gre_init (void) |
void | in_gre_uninit (void) |
Variables | |
static const struct srcaddrtab * | ipv4_srcaddrtab = NULL |
static const struct encaptab * | ecookie = NULL |
static const struct encap_config | ipv4_encap_cfg |
#define GRE_HASH | ( | src, | |
dst | |||
) |
#define GRE_HASH_SC | ( | sc | ) |
#define GRE_SOCKHASH | ( | src | ) |
#define GRE_SRCHASH | ( | src | ) |
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
Definition at line 348 of file ip_gre.c.
References GRE_HASH_SC, GRE_SRCHASH, in_gre_set_running(), in_gre_setup_socket(), in_pseudo(), IPPROTO_UDP, and IPVERSION.
Referenced by in_gre_ioctl(), and in_gre_setopts().
|
static |
Definition at line 125 of file ip_gre.c.
References GRE_HASH, and in_gre_lookup_socket().
Referenced by in_gre_ioctl(), and in_gre_setopts().
void in_gre_init | ( | void | ) |
Definition at line 556 of file ip_gre.c.
References ecookie, in_gre_srcaddr(), ip_encap_attach(), ip_encap_register_srcaddr(), ipv4_encap_cfg, and ipv4_srcaddrtab.
int in_gre_ioctl | ( | struct gre_softc * | sc, |
u_long | cmd, | ||
caddr_t | data | ||
) |
Definition at line 434 of file ip_gre.c.
References in_gre_attach(), in_gre_checkdup(), INADDR_ANY, ip::ip_dst, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_len, V_ipv4_hashtbl, V_ipv4_sockets, and V_ipv4_srchashtbl.
|
static |
Definition at line 157 of file ip_gre.c.
References ENCAP_DRV_LOOKUP, GRE_HASH, ip::ip_dst, in_addr::s_addr, and V_ipv4_hashtbl.
|
static |
Definition at line 111 of file ip_gre.c.
References in_gre_socket::addr, in_gre_socket::base, and GRE_SOCKHASH.
Referenced by in_gre_checkdup(), and in_gre_setup_socket().
int in_gre_output | ( | struct mbuf * | m, |
int | af, | ||
int | hlen | ||
) |
Definition at line 516 of file ip_gre.c.
References ip_fillid(), IP_FORWARDING, ip_id, ip_output(), ip_tos, and V_ip_gre_ttl.
|
static |
Definition at line 188 of file ip_gre.c.
References in_localip().
Referenced by in_gre_attach(), and in_gre_srcaddr().
int in_gre_setopts | ( | struct gre_softc * | sc, |
u_long | cmd, | ||
uint32_t | value | ||
) |
Definition at line 392 of file ip_gre.c.
References in_gre_attach(), and in_gre_checkdup().
|
static |
Definition at line 246 of file ip_gre.c.
References in_gre_socket::addr, in_gre_socket::base, GRE_SOCKHASH, in_gre_lookup_socket(), in_gre_udp_input(), IPPROTO_IP, IPPROTO_UDP, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_len, sockaddr_in::sin_port, and udp_set_kernel_tunneling().
Referenced by in_gre_attach().
|
static |
Definition at line 203 of file ip_gre.c.
References GRE_SRCHASH, in_gre_set_running(), in_addr::s_addr, sockaddr_in::sin_addr, and V_ipv4_hashtbl.
Referenced by in_gre_init().
|
static |
Definition at line 223 of file ip_gre.c.
References IPPROTO_UDP.
Referenced by in_gre_setup_socket().
void in_gre_uninit | ( | void | ) |
Definition at line 567 of file ip_gre.c.
References ecookie, ip_encap_detach(), ip_encap_unregister_srcaddr(), ipv4_srcaddrtab, V_ipv4_hashtbl, V_ipv4_sockets, and V_ipv4_srchashtbl.
SYSCTL_INT | ( | _net_inet_ip | , |
OID_AUTO | , | ||
grettl | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEip_gre_ttl, | ||
0 | , | ||
"Default TTL value for encapsulated packets" | |||
) |
VNET_DEFINE | ( | int | , |
ip_gre_ttl | |||
) |
VNET_DEFINE_STATIC | ( | struct gre_list * | , |
ipv4_hashtbl | |||
) |
VNET_DEFINE_STATIC | ( | struct gre_list * | , |
ipv4_srchashtbl | |||
) |
VNET_DEFINE_STATIC | ( | struct gre_sockets * | , |
ipv4_sockets | |||
) |
|
static |
Definition at line 546 of file ip_gre.c.
Referenced by in_gre_init(), and in_gre_uninit().
|
static |
Definition at line 547 of file ip_gre.c.
Referenced by in_gre_init().
|
static |
Definition at line 545 of file ip_gre.c.
Referenced by in_gre_init(), and in_gre_uninit().