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