FreeBSD kernel IPv4 code
ip_options.c File Reference
#include <sys/cdefs.h>
#include "opt_ipstealth.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <net/netisr.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_fib.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/ip_icmp.h>
#include <machine/in_cksum.h>
#include <sys/socketvar.h>
Include dependency graph for ip_options.c:

Go to the source code of this file.

Macros

#define V_ip_dosourceroute   VNET(ip_dosourceroute)
 
#define V_ip_acceptsourceroute   VNET(ip_acceptsourceroute)
 
#define INA   struct in_ifaddr *
 
#define SA   struct sockaddr *
 
#define OPTSIZ   (sizeof(opts->ip_srcrt.nop) + sizeof(opts->ip_srcrt.srcopt))
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE_STATIC (int, ip_dosourceroute)
 
 SYSCTL_INT (_net_inet_ip, IPCTL_SOURCEROUTE, sourceroute, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_dosourceroute), 0, "Enable forwarding source routed IP packets")
 
 VNET_DEFINE_STATIC (int, ip_acceptsourceroute)
 
 SYSCTL_INT (_net_inet_ip, IPCTL_ACCEPTSOURCEROUTE, accept_sourceroute, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_acceptsourceroute), 0, "Enable accepting source routed IP packets")
 
 VNET_DEFINE (int, ip_doopts)
 
 SYSCTL_INT (_net_inet_ip, OID_AUTO, process_options, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(ip_doopts), 0, "Enable IP options processing ([LS]SRR, RR, TS)")
 
static void save_rte (struct mbuf *m, u_char *, struct in_addr)
 
int ip_dooptions (struct mbuf *m, int pass)
 
struct mbuf * ip_srcroute (struct mbuf *m0)
 
void ip_stripoptions (struct mbuf *m)
 
struct mbuf * ip_insertoptions (struct mbuf *m, struct mbuf *opt, int *phlen)
 
int ip_optcopy (struct ip *ip, struct ip *jp)
 
int ip_pcbopts (struct inpcb *inp, int optname, struct mbuf *m)
 
int ip_checkrouteralert (struct mbuf *m)
 

Macro Definition Documentation

◆ INA

#define INA   struct in_ifaddr *

◆ OPTSIZ

#define OPTSIZ   (sizeof(opts->ip_srcrt.nop) + sizeof(opts->ip_srcrt.srcopt))

◆ SA

#define SA   struct sockaddr *

◆ V_ip_acceptsourceroute

#define V_ip_acceptsourceroute   VNET(ip_acceptsourceroute)

Definition at line 82 of file ip_options.c.

◆ V_ip_dosourceroute

#define V_ip_dosourceroute   VNET(ip_dosourceroute)

Definition at line 76 of file ip_options.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ ip_checkrouteralert()

int ip_checkrouteralert ( struct mbuf *  m)

Definition at line 718 of file ip_options.c.

References ip::ip_hl, IPOPT_EOL, IPOPT_NOP, IPOPT_OFFSET, IPOPT_OLEN, IPOPT_OPTVAL, and IPOPT_RA.

Referenced by igmp_input().

Here is the caller graph for this function:

◆ ip_dooptions()

◆ ip_insertoptions()

struct mbuf * ip_insertoptions ( struct mbuf *  m,
struct mbuf *  opt,
int *  phlen 
)

Definition at line 507 of file ip_options.c.

References ip::ip_dst, ip::ip_hl, ip::ip_len, IP_MAXPACKET, ip::ip_v, ipoption::ipopt_dst, ipoption::ipopt_list, IPVERSION, and in_addr::s_addr.

Referenced by ip_output().

Here is the caller graph for this function:

◆ ip_optcopy()

int ip_optcopy ( struct ip ip,
struct ip jp 
)

Definition at line 557 of file ip_options.c.

References ip::ip_hl, IPOPT_COPIED, IPOPT_EOL, IPOPT_NOP, and IPOPT_OLEN.

Referenced by ip_fragment().

Here is the caller graph for this function:

◆ ip_pcbopts()

int ip_pcbopts ( struct inpcb inp,
int  optname,
struct mbuf *  m 
)

Definition at line 601 of file ip_options.c.

References inpcb::inp_options, INP_WLOCK_ASSERT, IPOPT_EOL, IPOPT_LSRR, IPOPT_MINOFF, IPOPT_NOP, IPOPT_OFFSET, IPOPT_OLEN, IPOPT_OPTVAL, IPOPT_SSRR, and MAX_IPOPTLEN.

Referenced by ip_ctloutput().

Here is the caller graph for this function:

◆ ip_srcroute()

struct mbuf * ip_srcroute ( struct mbuf *  m0)

Definition at line 426 of file ip_options.c.

References ipoptrt::dst, ipopt_tag::ip_nhops, ipopt_tag::ip_srcrt, IPOPT_MINOFF, IPOPT_NOP, IPOPT_OFFSET, ipoptrt::nop, OPTSIZ, ipoptrt::route, and ipoptrt::srcopt.

Referenced by ip_savecontrol(), syncache_add(), and syncache_socket().

Here is the caller graph for this function:

◆ ip_stripoptions()

void ip_stripoptions ( struct mbuf *  m)

Definition at line 483 of file ip_options.c.

References ip::ip_hl, and ip::ip_len.

Referenced by tcp_input_with_port().

Here is the caller graph for this function:

◆ save_rte()

static void save_rte ( struct mbuf *  m,
u_char *  option,
struct in_addr  dst 
)
static

Definition at line 399 of file ip_options.c.

References ipoptrt::dst, ipopt_tag::ip_nhops, ipopt_tag::ip_srcrt, IPOPT_OFFSET, IPOPT_OLEN, and ipoptrt::srcopt.

Referenced by ip_dooptions().

Here is the caller graph for this function:

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _net_inet_ip  ,
IPCTL_ACCEPTSOURCEROUTE  ,
accept_sourceroute  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEip_acceptsourceroute,
,
"Enable accepting source routed IP packets"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _net_inet_ip  ,
IPCTL_SOURCEROUTE  ,
sourceroute  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEip_dosourceroute,
,
"Enable forwarding source routed IP packets"   
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _net_inet_ip  ,
OID_AUTO  ,
process_options  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEip_doopts,
,
"Enable IP options processing ([LS]SRR, RR, TS)"   
)

◆ VNET_DEFINE()

VNET_DEFINE ( int  ,
ip_doopts   
)

◆ VNET_DEFINE_STATIC() [1/2]

VNET_DEFINE_STATIC ( int  ,
ip_acceptsourceroute   
)

◆ VNET_DEFINE_STATIC() [2/2]

VNET_DEFINE_STATIC ( int  ,
ip_dosourceroute   
)