williamr@2: /* IP.H williamr@2: * williamr@4: * Portions Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@2: */ williamr@2: williamr@2: /** @file williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: /* williamr@2: * Copyright (c) 1982, 1986 Regents of the University of California. williamr@2: * All rights reserved. williamr@2: * williamr@2: * Redistribution and use in source and binary forms are permitted williamr@2: * provided that this notice is preserved and that due credit is given williamr@2: * to the University of California at Berkeley. The name of the University williamr@2: * may not be used to endorse or promote products derived from this williamr@2: * software without specific prior written permission. This software williamr@2: * is provided ``as is'' without express or implied warranty. williamr@2: */ williamr@2: williamr@2: /* williamr@2: * Definitions for internet protocol version 4. williamr@2: * Per RFC 791, September 1981. williamr@2: */ williamr@2: williamr@2: #ifndef _NETINET_IP_H williamr@2: #define _NETINET_IP_H williamr@2: williamr@2: #ifdef __cplusplus williamr@2: extern "C" { williamr@2: #endif williamr@2: williamr@2: #define IPVERSION 4 williamr@2: williamr@2: /** williamr@2: Structure of an internet header, naked of options. williamr@2: williamr@2: We declare ip_len and ip_off to be short, rather than u_short williamr@2: pragmatically since otherwise unsigned comparisons can result williamr@2: against negative integers quite easily, and fail in subtle ways. williamr@2: */ williamr@2: struct ip { williamr@2: #ifdef _BIT_FIELDS_LTOH williamr@2: u_char ip_hl:4, /* header length */ williamr@2: ip_v:4; /* version */ williamr@2: #else williamr@2: u_char ip_v:4, /* version */ williamr@2: ip_hl:4; /* header length */ williamr@2: #endif williamr@2: u_char ip_tos; /* type of service */ williamr@2: short ip_len; /* total length */ williamr@2: u_short ip_id; /* identification */ williamr@2: short ip_off; /* fragment offset field */ williamr@2: #define IP_DF 0x4000 /* dont fragment flag */ williamr@2: #define IP_MF 0x2000 /* more fragments flag */ williamr@2: u_char ip_ttl; /* time to live */ williamr@2: u_char ip_p; /* protocol */ williamr@2: u_short ip_sum; /* checksum */ williamr@2: struct in_addr ip_src, ip_dst; /* source and dest address */ williamr@2: }; williamr@2: williamr@2: #define IP_MAXPACKET 65535 /* maximum packet size */ williamr@2: williamr@2: /** williamr@2: Definitions for IP type of service (ip_tos) williamr@2: */ williamr@2: #define IPTOS_LOWDELAY 0x10 williamr@2: #define IPTOS_THROUGHPUT 0x08 williamr@2: #define IPTOS_RELIABILITY 0x04 williamr@2: williamr@2: /** williamr@2: Definitions for IP precedence (also in ip_tos) (hopefully unused) williamr@2: */ williamr@2: #define IPTOS_PREC_NETCONTROL 0xe0 williamr@2: #define IPTOS_PREC_INTERNETCONTROL 0xc0 williamr@2: #define IPTOS_PREC_CRITIC_ECP 0xa0 williamr@2: #define IPTOS_PREC_FLASHOVERRIDE 0x80 williamr@2: #define IPTOS_PREC_FLASH 0x60 williamr@2: #define IPTOS_PREC_IMMEDIATE 0x40 williamr@2: #define IPTOS_PREC_PRIORITY 0x20 williamr@2: #define IPTOS_PREC_ROUTINE 0x00 williamr@2: williamr@2: /** williamr@2: Definitions for options. williamr@2: */ williamr@2: #define IPOPT_COPIED(o) ((o)&0x80) williamr@2: #define IPOPT_CLASS(o) ((o)&0x60) williamr@2: #define IPOPT_NUMBER(o) ((o)&0x1f) williamr@2: williamr@2: #define IPOPT_CONTROL 0x00 williamr@2: #define IPOPT_RESERVED1 0x20 williamr@2: #define IPOPT_DEBMEAS 0x40 williamr@2: #define IPOPT_RESERVED2 0x60 williamr@2: williamr@2: #define IPOPT_EOL 0 /* end of option list */ williamr@2: #define IPOPT_NOP 1 /* no operation */ williamr@2: williamr@2: #define IPOPT_RR 7 /* record packet route */ williamr@2: #define IPOPT_TS 68 /* timestamp */ williamr@2: #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ williamr@2: #define IPOPT_LSRR 131 /* loose source route */ williamr@2: #define IPOPT_SATID 136 /* satnet id */ williamr@2: #define IPOPT_SSRR 137 /* strict source route */ williamr@2: williamr@2: /** williamr@2: Offsets to fields in options other than EOL and NOP. williamr@2: */ williamr@2: #define IPOPT_OPTVAL 0 /* option ID */ williamr@2: #define IPOPT_OLEN 1 /* option length */ williamr@2: #define IPOPT_OFFSET 2 /* offset within option */ williamr@2: #define IPOPT_MINOFF 4 /* min value of above */ williamr@2: williamr@2: /** williamr@2: Time stamp option structure. williamr@2: */ williamr@2: struct ip_timestamp { williamr@2: u_char ipt_code; /* IPOPT_TS */ williamr@2: u_char ipt_len; /* size of structure (variable) */ williamr@2: u_char ipt_ptr; /* index of current entry */ williamr@2: #ifdef _BIT_FIELDS_LTOH williamr@2: u_char ipt_flg:4, /* flags, see below */ williamr@2: ipt_oflw:4; /* overflow counter */ williamr@2: #else williamr@2: u_char ipt_oflw:4, /* overflow counter */ williamr@2: ipt_flg:4; /* flags, see below */ williamr@2: #endif williamr@2: union ipt_timestamp { williamr@2: n_long ipt_time[1]; williamr@2: struct ipt_ta { williamr@2: struct in_addr ipt_addr; williamr@2: n_long ipt_time; williamr@2: } ipt_ta[1]; williamr@2: } ipt_timestamp; williamr@2: }; williamr@2: williamr@2: /** williamr@2: flag bits for ipt_flg williamr@2: */ williamr@2: #define IPOPT_TS_TSONLY 0 /* timestamps only */ williamr@2: #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ williamr@2: #define IPOPT_TS_PRESPEC 2 /* specified modules only */ williamr@2: williamr@2: /** williamr@2: bits for security (not byte swapped) williamr@2: */ williamr@2: #define IPOPT_SECUR_UNCLASS 0x0000 williamr@2: #define IPOPT_SECUR_CONFID 0xf135 williamr@2: #define IPOPT_SECUR_EFTO 0x789a williamr@2: #define IPOPT_SECUR_MMMM 0xbc4d williamr@2: #define IPOPT_SECUR_RESTR 0xaf13 williamr@2: #define IPOPT_SECUR_SECRET 0xd788 williamr@2: #define IPOPT_SECUR_TOPSECRET 0x6bc5 williamr@2: williamr@2: /** williamr@2: Internet implementation parameters. williamr@2: */ williamr@2: #define MAXTTL 255 /* maximum time to live (seconds) */ williamr@2: #define IPFRAGTTL 60 /* time to live for frags, slowhz */ williamr@2: #define IPTTLDEC 1 /* subtracted when forwarding */ williamr@2: williamr@2: #define IP_MSS 576 /* default maximum segment size */ williamr@2: williamr@2: #ifdef __cplusplus williamr@2: } williamr@2: #endif williamr@2: williamr@2: #endif /* _NETINET_IP_H */