#ifndef _NETINET_IP_VAR_H_
#define _NETINET_IP_VAR_H_
#include <sys/queue.h>
struct ipovly {
u_char ih_x1[9];
u_char ih_pr;
u_short ih_len;
struct in_addr ih_src;
struct in_addr ih_dst;
};
#ifdef _KERNEL
struct ipq {
TAILQ_ENTRY(ipq) ipq_list;
u_char ipq_ttl;
u_char ipq_p;
u_short ipq_id;
struct mbuf *ipq_frags;
struct in_addr ipq_src,ipq_dst;
u_char ipq_nfrags;
struct label *ipq_label;
};
#endif
#define MAX_IPOPTLEN 40
struct ipoption {
struct in_addr ipopt_dst;
char ipopt_list[MAX_IPOPTLEN];
};
struct ip_moptions {
struct ifnet *imo_multicast_ifp;
struct in_addr imo_multicast_addr;
u_long imo_multicast_vif;
u_char imo_multicast_ttl;
u_char imo_multicast_loop;
u_short imo_num_memberships;
u_short imo_max_memberships;
struct in_multi **imo_membership;
struct in_mfilter *imo_mfilters;
STAILQ_ENTRY(ip_moptions) imo_link;
};
struct ipstat {
uint64_t ips_total;
uint64_t ips_badsum;
uint64_t ips_tooshort;
uint64_t ips_toosmall;
uint64_t ips_badhlen;
uint64_t ips_badlen;
uint64_t ips_fragments;
uint64_t ips_fragdropped;
uint64_t ips_fragtimeout;
uint64_t ips_forward;
uint64_t ips_fastforward;
uint64_t ips_cantforward;
uint64_t ips_redirectsent;
uint64_t ips_noproto;
uint64_t ips_delivered;
uint64_t ips_localout;
uint64_t ips_odropped;
uint64_t ips_reassembled;
uint64_t ips_fragmented;
uint64_t ips_ofragments;
uint64_t ips_cantfrag;
uint64_t ips_badoptions;
uint64_t ips_noroute;
uint64_t ips_badvers;
uint64_t ips_rawout;
uint64_t ips_toolong;
uint64_t ips_notmember;
uint64_t ips_nogif;
uint64_t ips_badaddr;
};
#ifdef _KERNEL
#include <sys/counter.h>
#include <net/vnet.h>
VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat);
#define IPSTAT_ADD(name, val) \
VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val))
#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val))
#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)
void kmod_ipstat_inc(int statnum);
#define KMOD_IPSTAT_INC(name) \
kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t))
void kmod_ipstat_dec(int statnum);
#define KMOD_IPSTAT_DEC(name) \
kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t))
#define IP_FORWARDING 0x1
#define IP_RAWOUTPUT 0x2
#define IP_SENDONES 0x4
#define IP_SENDTOIF 0x8
#define IP_ROUTETOIF SO_DONTROUTE
#define IP_ALLOWBROADCAST SO_BROADCAST
#define IP_NODEFAULTFLOWID 0x40
#ifdef __NO_STRICT_ALIGNMENT
#define IP_HDR_ALIGNED_P(ip) 1
#else
#define IP_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0)
#endif
struct ip;
struct inpcb;
struct route;
struct sockopt;
VNET_DECLARE(int, ip_defttl);
VNET_DECLARE(int, ipforwarding);
#ifdef IPSTEALTH
VNET_DECLARE(int, ipstealth);
#endif
extern u_char ip_protox[];
VNET_DECLARE(struct socket *, ip_rsvpd);
VNET_DECLARE(struct socket *, ip_mrouter);
extern int (*legal_vif_num)(int);
extern u_long (*ip_mcast_src)(int);
VNET_DECLARE(int, rsvp_on);
VNET_DECLARE(int, drop_redirect);
extern struct pr_usrreqs rip_usrreqs;
#define V_ip_id VNET(ip_id)
#define V_ip_defttl VNET(ip_defttl)
#define V_ipforwarding VNET(ipforwarding)
#ifdef IPSTEALTH
#define V_ipstealth VNET(ipstealth)
#endif
#define V_ip_rsvpd VNET(ip_rsvpd)
#define V_ip_mrouter VNET(ip_mrouter)
#define V_rsvp_on VNET(rsvp_on)
#define V_drop_redirect VNET(drop_redirect)
void inp_freemoptions(struct ip_moptions *);
int inp_getmoptions(struct inpcb *, struct sockopt *);
int inp_setmoptions(struct inpcb *, struct sockopt *);
int ip_ctloutput(struct socket *, struct sockopt *sopt);
void ip_drain(void);
int ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
u_long if_hwassist_flags);
void ip_forward(struct mbuf *m, int srcrt);
void ip_init(void);
#ifdef VIMAGE
void ip_destroy(void);
#endif
extern int
(*ip_mforward)(struct ip *, struct ifnet *, struct mbuf *,
struct ip_moptions *);
int ip_output(struct mbuf *,
struct mbuf *, struct route *, int, struct ip_moptions *,
struct inpcb *);
int ipproto_register(short);
int ipproto_unregister(short);
struct mbuf *
ip_reass(struct mbuf *);
struct in_ifaddr *
ip_rtaddr(struct in_addr, u_int fibnum);
void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *,
struct mbuf *);
void ip_slowtimo(void);
void ip_fillid(struct ip *);
int rip_ctloutput(struct socket *, struct sockopt *);
void rip_ctlinput(int, struct sockaddr *, void *);
void rip_init(void);
#ifdef VIMAGE
void rip_destroy(void);
#endif
int rip_input(struct mbuf **, int *, int);
int rip_output(struct mbuf *, struct socket *, ...);
int ipip_input(struct mbuf **, int *, int);
int rsvp_input(struct mbuf **, int *, int);
int ip_rsvp_init(struct socket *);
int ip_rsvp_done(void);
extern int (*ip_rsvp_vif)(struct socket *, struct sockopt *);
extern void (*ip_rsvp_force_done)(struct socket *);
extern int (*rsvp_input_p)(struct mbuf **, int *, int);
VNET_DECLARE(struct pfil_head, inet_pfil_hook);
#define V_inet_pfil_hook VNET(inet_pfil_hook)
void in_delayed_cksum(struct mbuf *m);
struct ipfw_rule_ref {
uint32_t slot;
uint32_t rulenum;
uint32_t rule_id;
uint32_t chain_id;
uint32_t info;
};
enum {
IPFW_INFO_MASK = 0x0000ffff,
IPFW_INFO_OUT = 0x00000000,
IPFW_INFO_IN = 0x80000000,
IPFW_ONEPASS = 0x40000000,
IPFW_IS_MASK = 0x30000000,
IPFW_IS_DIVERT = 0x20000000,
IPFW_IS_DUMMYNET =0x10000000,
IPFW_IS_PIPE = 0x08000000,
};
#define MTAG_IPFW 1148380143
#define MTAG_IPFW_RULE 1262273568
#define MTAG_IPFW_CALL 1308397630
struct ip_fw_args;
typedef int (*ip_fw_chk_ptr_t)(struct ip_fw_args *args);
typedef int (*ip_fw_ctl_ptr_t)(struct sockopt *);
VNET_DECLARE(ip_fw_ctl_ptr_t, ip_fw_ctl_ptr);
#define V_ip_fw_ctl_ptr VNET(ip_fw_ctl_ptr)
extern void (*ip_divert_ptr)(struct mbuf *m, int incoming);
extern int (*ng_ipfw_input_p)(struct mbuf **, int,
struct ip_fw_args *, int);
extern int (*ip_dn_ctl_ptr)(struct sockopt *);
extern int (*ip_dn_io_ptr)(struct mbuf **, int, struct ip_fw_args *);
#endif
#endif