#ifndef _NETINET_IP_VAR_H_
#define _NETINET_IP_VAR_H_
#include <sys/queue.h>
#include <net/route.h>
struct ipovly {
u_int8_t ih_x1[9];
u_int8_t ih_pr;
u_int16_t ih_len;
struct in_addr ih_src;
struct in_addr ih_dst;
};
#ifdef __CTASSERT
__CTASSERT(sizeof(struct ipovly) == 20);
#endif
struct ipflow {
TAILQ_ENTRY(ipflow) ipf_list;
TAILQ_ENTRY(ipflow) ipf_hash;
size_t ipf_hashidx;
struct in_addr ipf_dst;
struct in_addr ipf_src;
uint8_t ipf_tos;
struct route ipf_ro;
u_long ipf_uses;
u_long ipf_last_uses;
u_long ipf_dropped;
u_long ipf_errors;
u_int ipf_timer;
};
TAILQ_HEAD(ipqehead, ipqent);
struct ipqent {
TAILQ_ENTRY(ipqent) ipqe_q;
struct mbuf *ipqe_m;
TAILQ_ENTRY(ipqent) ipqe_timeq;
u_int32_t ipqe_seq;
u_int32_t ipqe_len;
u_int32_t ipqe_flags;
};
#define MAX_IPOPTLEN 40
struct ipoption {
struct in_addr ipopt_dst;
int8_t ipopt_list[MAX_IPOPTLEN];
};
struct ip_moptions {
if_index_t imo_multicast_if_index;
struct in_addr imo_multicast_addr;
u_int8_t imo_multicast_ttl;
u_int8_t imo_multicast_loop;
u_int16_t imo_num_memberships;
struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
};
struct ip_pktopts {
struct sockaddr_in ippo_laddr;
struct ip_moptions *ippo_imo;
struct ip_moptions ippo_imobuf;
};
#define IP_STAT_TOTAL 0
#define IP_STAT_BADSUM 1
#define IP_STAT_TOOSHORT 2
#define IP_STAT_TOOSMALL 3
#define IP_STAT_BADHLEN 4
#define IP_STAT_BADLEN 5
#define IP_STAT_FRAGMENTS 6
#define IP_STAT_FRAGDROPPED 7
#define IP_STAT_FRAGTIMEOUT 8
#define IP_STAT_FORWARD 9
#define IP_STAT_FASTFORWARD 10
#define IP_STAT_CANTFORWARD 11
#define IP_STAT_REDIRECTSENT 12
#define IP_STAT_NOPROTO 13
#define IP_STAT_DELIVERED 14
#define IP_STAT_LOCALOUT 15
#define IP_STAT_ODROPPED 16
#define IP_STAT_REASSEMBLED 17
#define IP_STAT_FRAGMENTED 18
#define IP_STAT_OFRAGMENTS 19
#define IP_STAT_CANTFRAG 20
#define IP_STAT_BADOPTIONS 21
#define IP_STAT_NOROUTE 22
#define IP_STAT_BADVERS 23
#define IP_STAT_RAWOUT 24
#define IP_STAT_BADFRAGS 25
#define IP_STAT_RCVMEMDROP 26
#define IP_STAT_TOOLONG 27
#define IP_STAT_NOGIF 28
#define IP_STAT_BADADDR 29
#define IP_STAT_NOL2TP 30
#define IP_STAT_NOIPSEC 31
#define IP_STAT_PFILDROP_IN 32
#define IP_STAT_PFILDROP_OUT 33
#define IP_STAT_IPSECDROP_IN 34
#define IP_STAT_IPSECDROP_OUT 35
#define IP_STAT_IFDROP 36
#define IP_STAT_TIMXCEED 37
#define IP_STAT_IFNOADDR 38
#define IP_STAT_RTREJECT 39
#define IP_STAT_BCASTDENIED 40
#define IP_NSTATS 41
#ifdef _KERNEL
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
#include "opt_mbuftrace.h"
#endif
#define IP_FORWARDING 0x0001
#define IP_RAWOUTPUT 0x0002
#define IP_RETURNMTU 0x0004
#define IP_NOIPNEWID 0x0008
__CTASSERT(SO_DONTROUTE == 0x0010);
__CTASSERT(SO_BROADCAST == 0x0020);
#define IP_ROUTETOIF SO_DONTROUTE
#define IP_ALLOWBROADCAST SO_BROADCAST
#define IP_IGMP_MCAST 0x0040
#define IP_MTUDISC 0x0400
#define IP_ROUTETOIFINDEX 0x0800
extern struct domain inetdomain;
extern const struct pr_usrreqs rip_usrreqs;
extern int ip_defttl;
extern int ipforwarding;
extern int ip_mtudisc;
extern int ip_mtudisc_timeout;
extern int anonportmin;
extern int anonportmax;
extern int lowportmin;
extern int lowportmax;
extern int ip_do_loopback_cksum;
extern struct rttimer_queue *ip_mtudisc_timeout_q;
#ifdef MBUFTRACE
extern struct mowner ip_rx_mowner;
extern struct mowner ip_tx_mowner;
#endif
struct inpcb;
struct sockopt;
void ip_init(void);
void in_init(void);
int ip_ctloutput(int, struct socket *, struct sockopt *);
int ip_setpktopts(struct mbuf *, struct ip_pktopts *, int *,
struct inpcb *, kauth_cred_t);
void ip_drain(void);
void ip_drainstub(void);
void ip_freemoptions(struct ip_moptions *);
int ip_optcopy(struct ip *, struct ip *);
u_int ip_optlen(struct inpcb *);
int ip_output(struct mbuf *, struct mbuf *, struct route *, int,
struct ip_moptions *, struct inpcb *);
int ip_fragment(struct mbuf *, struct ifnet *, u_long);
void ip_reass_init(void);
int ip_reass_packet(struct mbuf **);
void ip_reass_slowtimo(void);
void ip_reass_drain(void);
void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
struct mbuf *);
void ip_slowtimo(void);
void ip_fasttimo(void);
struct mbuf *
ip_srcroute(struct mbuf *);
int ip_sysctl(int *, u_int, void *, size_t *, void *, size_t);
void ip_statinc(u_int);
void * rip_ctlinput(int, const struct sockaddr *, void *);
int rip_ctloutput(int, struct socket *, struct sockopt *);
void rip_init(void);
void rip_input(struct mbuf *, int, int);
int rip_output(struct mbuf *, struct inpcb *, struct mbuf *, struct lwp *);
int rip_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *);
int ip_setmoptions(struct ip_moptions **, const struct sockopt *sopt);
int ip_getmoptions(struct ip_moptions *, struct sockopt *sopt);
int ip_if_output(struct ifnet * const, struct mbuf * const,
const struct sockaddr * const, const struct rtentry *);
void ipflow_init(void);
void ipflow_poolinit(void);
void ipflow_create(struct route *, struct mbuf *);
void ipflow_slowtimo(void);
int ipflow_invalidate_all(int);
#endif
#endif