123185Smckusick /* 229145Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 332787Sbostic * All rights reserved. 423185Smckusick * 5*44482Sbostic * %sccs.include.redist.c% 632787Sbostic * 7*44482Sbostic * @(#)ip_var.h 7.7 (Berkeley) 06/28/90 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 764924Swnj struct ipstat { 7724815Skarels long ips_total; /* total packets received */ 7824815Skarels long ips_badsum; /* checksum bad */ 7924815Skarels long ips_tooshort; /* packet too short */ 8024815Skarels long ips_toosmall; /* not enough data */ 8124815Skarels long ips_badhlen; /* ip header length < data size */ 8224815Skarels long ips_badlen; /* ip length < ip header length */ 8324815Skarels long ips_fragments; /* fragments received */ 8424815Skarels long ips_fragdropped; /* frags dropped (dups, out of space) */ 8524815Skarels long ips_fragtimeout; /* fragments timed out */ 8621022Skarels long ips_forward; /* packets forwarded */ 8721022Skarels long ips_cantforward; /* packets rcvd for unreachable dest */ 8824815Skarels long ips_redirectsent; /* packets forwarded on same net */ 8939185Ssklower long ips_noproto; /* unknown or unsupported protocol */ 9039185Ssklower long ips_delivered; /* packets consumed here */ 9139185Ssklower long ips_localout; /* total ip packets generated here */ 9239185Ssklower long ips_odropped; /* lost packets due to nobufs, etc. */ 9339185Ssklower long ips_reassembled; /* total packets reassembled ok */ 9439185Ssklower long ips_fragmented; /* output packets fragmented ok */ 9539185Ssklower long ips_ofragments; /* output fragments created */ 9639185Ssklower long ips_cantfrag; /* don't fragment flag was set, etc. */ 974924Swnj }; 984924Swnj 994893Swnj #ifdef KERNEL 10012418Ssam /* flags passed to ip_output as last parameter */ 10117051Skarels #define IP_FORWARDING 0x1 /* most of ip header exists */ 10217051Skarels #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ 10317051Skarels #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 10412418Ssam 1054924Swnj struct ipstat ipstat; 1064893Swnj struct ipq ipq; /* ip reass. queue */ 1074893Swnj u_short ip_id; /* ip packet ctr, for ids */ 10824815Skarels 10924815Skarels struct mbuf *ip_srcroute(); 1104893Swnj #endif 111