123185Smckusick /* 2*29145Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323185Smckusick * All rights reserved. The Berkeley software License Agreement 423185Smckusick * specifies the terms and conditions for redistribution. 523185Smckusick * 6*29145Smckusick * @(#)ip_var.h 7.1 (Berkeley) 06/05/86 723185Smckusick */ 84893Swnj 94893Swnj /* 104893Swnj * Overlay for ip header used by other protocols (tcp, udp). 114893Swnj */ 124893Swnj struct ipovly { 134899Swnj caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 144899Swnj u_char ih_x1; /* (unused) */ 154899Swnj u_char ih_pr; /* protocol */ 164924Swnj short ih_len; /* protocol length */ 174924Swnj struct in_addr ih_src; /* source internet address */ 184924Swnj struct in_addr ih_dst; /* destination internet address */ 194893Swnj }; 204893Swnj 214893Swnj /* 224893Swnj * Ip reassembly queue structure. Each fragment 234893Swnj * being reassembled is attached to one of these structures. 244893Swnj * They are timed out after ipq_ttl drops to 0, and may also 254893Swnj * be reclaimed if memory becomes tight. 264893Swnj */ 274893Swnj struct ipq { 284893Swnj struct ipq *next,*prev; /* to other reass headers */ 294893Swnj u_char ipq_ttl; /* time for reass q to live */ 304893Swnj u_char ipq_p; /* protocol of this fragment */ 314893Swnj u_short ipq_id; /* sequence id for reassembly */ 324893Swnj struct ipasfrag *ipq_next,*ipq_prev; 334893Swnj /* to ip headers of fragments */ 344924Swnj struct in_addr ipq_src,ipq_dst; 354893Swnj }; 364893Swnj 374893Swnj /* 384893Swnj * Ip header, when holding a fragment. 399185Ssam * 409185Ssam * Note: ipf_next must be at same offset as ipq_next above 414893Swnj */ 424893Swnj struct ipasfrag { 439992Ssam #ifdef vax 444893Swnj u_char ip_hl:4, 454893Swnj ip_v:4; 469992Ssam #endif 474893Swnj u_char ipf_mff; /* copied from (ip_off&IP_MF) */ 484893Swnj short ip_len; 494893Swnj u_short ip_id; 504893Swnj short ip_off; 514893Swnj u_char ip_ttl; 524893Swnj u_char ip_p; 534893Swnj u_short ip_sum; 544899Swnj struct ipasfrag *ipf_next; /* next fragment */ 554899Swnj struct ipasfrag *ipf_prev; /* previous fragment */ 564893Swnj }; 574893Swnj 5824815Skarels /* 5924815Skarels * Structure stored in mbuf in inpcb.ip_options 6024815Skarels * and passed to ip_output when ip options are in use. 6124815Skarels * The actual length of the options (including ipopt_dst) 6224815Skarels * is in m_len. 6324815Skarels */ 6424815Skarels #define MAX_IPOPTLEN 40 6524815Skarels 6624815Skarels struct ipoption { 6724815Skarels struct in_addr ipopt_dst; /* first-hop dst if source routed */ 6824815Skarels char ipopt_list[MAX_IPOPTLEN]; /* options proper */ 6924815Skarels }; 7024815Skarels 714924Swnj struct ipstat { 7224815Skarels long ips_total; /* total packets received */ 7324815Skarels long ips_badsum; /* checksum bad */ 7424815Skarels long ips_tooshort; /* packet too short */ 7524815Skarels long ips_toosmall; /* not enough data */ 7624815Skarels long ips_badhlen; /* ip header length < data size */ 7724815Skarels long ips_badlen; /* ip length < ip header length */ 7824815Skarels long ips_fragments; /* fragments received */ 7924815Skarels long ips_fragdropped; /* frags dropped (dups, out of space) */ 8024815Skarels long ips_fragtimeout; /* fragments timed out */ 8121022Skarels long ips_forward; /* packets forwarded */ 8221022Skarels long ips_cantforward; /* packets rcvd for unreachable dest */ 8324815Skarels long ips_redirectsent; /* packets forwarded on same net */ 844924Swnj }; 854924Swnj 864893Swnj #ifdef KERNEL 8712418Ssam /* flags passed to ip_output as last parameter */ 8817051Skarels #define IP_FORWARDING 0x1 /* most of ip header exists */ 8917051Skarels #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ 9017051Skarels #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 9112418Ssam 924924Swnj struct ipstat ipstat; 934893Swnj struct ipq ipq; /* ip reass. queue */ 944893Swnj u_short ip_id; /* ip packet ctr, for ids */ 9524815Skarels 9624815Skarels struct mbuf *ip_srcroute(); 974893Swnj #endif 98