123185Smckusick /* 229145Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 332787Sbostic * All rights reserved. 423185Smckusick * 544482Sbostic * %sccs.include.redist.c% 632787Sbostic * 7*54716Ssklower * @(#)ip_var.h 7.8 (Berkeley) 07/06/92 823185Smckusick */ 94893Swnj 104893Swnj /* 114893Swnj * Overlay for ip header used by other protocols (tcp, udp). 124893Swnj */ 134893Swnj struct ipovly { 144899Swnj caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 154899Swnj u_char ih_x1; /* (unused) */ 164899Swnj u_char ih_pr; /* protocol */ 174924Swnj short ih_len; /* protocol length */ 184924Swnj struct in_addr ih_src; /* source internet address */ 194924Swnj struct in_addr ih_dst; /* destination internet address */ 204893Swnj }; 214893Swnj 224893Swnj /* 234893Swnj * Ip reassembly queue structure. Each fragment 244893Swnj * being reassembled is attached to one of these structures. 254893Swnj * They are timed out after ipq_ttl drops to 0, and may also 264893Swnj * be reclaimed if memory becomes tight. 274893Swnj */ 284893Swnj struct ipq { 294893Swnj struct ipq *next,*prev; /* to other reass headers */ 304893Swnj u_char ipq_ttl; /* time for reass q to live */ 314893Swnj u_char ipq_p; /* protocol of this fragment */ 324893Swnj u_short ipq_id; /* sequence id for reassembly */ 334893Swnj struct ipasfrag *ipq_next,*ipq_prev; 344893Swnj /* to ip headers of fragments */ 354924Swnj struct in_addr ipq_src,ipq_dst; 364893Swnj }; 374893Swnj 384893Swnj /* 394893Swnj * Ip header, when holding a fragment. 409185Ssam * 419185Ssam * Note: ipf_next must be at same offset as ipq_next above 424893Swnj */ 434893Swnj struct ipasfrag { 4433283Skarels #if BYTE_ORDER == LITTLE_ENDIAN 454893Swnj u_char ip_hl:4, 464893Swnj ip_v:4; 479992Ssam #endif 4833283Skarels #if BYTE_ORDER == BIG_ENDIAN 4929923Skarels u_char ip_v:4, 5029923Skarels ip_hl:4; 5129923Skarels #endif 524893Swnj u_char ipf_mff; /* copied from (ip_off&IP_MF) */ 534893Swnj short ip_len; 544893Swnj u_short ip_id; 554893Swnj short ip_off; 564893Swnj u_char ip_ttl; 574893Swnj u_char ip_p; 584893Swnj u_short ip_sum; 594899Swnj struct ipasfrag *ipf_next; /* next fragment */ 604899Swnj struct ipasfrag *ipf_prev; /* previous fragment */ 614893Swnj }; 624893Swnj 6324815Skarels /* 6424815Skarels * Structure stored in mbuf in inpcb.ip_options 6524815Skarels * and passed to ip_output when ip options are in use. 6624815Skarels * The actual length of the options (including ipopt_dst) 6724815Skarels * is in m_len. 6824815Skarels */ 6924815Skarels #define MAX_IPOPTLEN 40 7024815Skarels 7124815Skarels struct ipoption { 7224815Skarels struct in_addr ipopt_dst; /* first-hop dst if source routed */ 7324815Skarels char ipopt_list[MAX_IPOPTLEN]; /* options proper */ 7424815Skarels }; 7524815Skarels 76*54716Ssklower /* 77*54716Ssklower * Structure attached to inpcb.ip_moptions and 78*54716Ssklower * passed to ip_output when IP multicast options are in use. 79*54716Ssklower */ 80*54716Ssklower struct ip_moptions { 81*54716Ssklower struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */ 82*54716Ssklower u_char imo_multicast_ttl; /* TTL for outgoing multicasts */ 83*54716Ssklower u_char imo_multicast_loop; /* 1 => hear sends if a member */ 84*54716Ssklower u_short imo_num_memberships; /* no. memberships this socket */ 85*54716Ssklower struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS]; 86*54716Ssklower }; 87*54716Ssklower 884924Swnj struct ipstat { 8924815Skarels long ips_total; /* total packets received */ 9024815Skarels long ips_badsum; /* checksum bad */ 9124815Skarels long ips_tooshort; /* packet too short */ 9224815Skarels long ips_toosmall; /* not enough data */ 9324815Skarels long ips_badhlen; /* ip header length < data size */ 9424815Skarels long ips_badlen; /* ip length < ip header length */ 9524815Skarels long ips_fragments; /* fragments received */ 9624815Skarels long ips_fragdropped; /* frags dropped (dups, out of space) */ 9724815Skarels long ips_fragtimeout; /* fragments timed out */ 9821022Skarels long ips_forward; /* packets forwarded */ 9921022Skarels long ips_cantforward; /* packets rcvd for unreachable dest */ 10024815Skarels long ips_redirectsent; /* packets forwarded on same net */ 10139185Ssklower long ips_noproto; /* unknown or unsupported protocol */ 10239185Ssklower long ips_delivered; /* packets consumed here */ 10339185Ssklower long ips_localout; /* total ip packets generated here */ 10439185Ssklower long ips_odropped; /* lost packets due to nobufs, etc. */ 10539185Ssklower long ips_reassembled; /* total packets reassembled ok */ 10639185Ssklower long ips_fragmented; /* output packets fragmented ok */ 10739185Ssklower long ips_ofragments; /* output fragments created */ 10839185Ssklower long ips_cantfrag; /* don't fragment flag was set, etc. */ 1094924Swnj }; 1104924Swnj 1114893Swnj #ifdef KERNEL 11212418Ssam /* flags passed to ip_output as last parameter */ 11317051Skarels #define IP_FORWARDING 0x1 /* most of ip header exists */ 11417051Skarels #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ 11517051Skarels #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 11612418Ssam 1174924Swnj struct ipstat ipstat; 1184893Swnj struct ipq ipq; /* ip reass. queue */ 1194893Swnj u_short ip_id; /* ip packet ctr, for ids */ 12024815Skarels 12124815Skarels struct mbuf *ip_srcroute(); 1224893Swnj #endif 123