ip_compat.h revision 53024
153024Sguido/* 253024Sguido * (C)opyright 1995 by Darren Reed. 353024Sguido * 453024Sguido * This code may be freely distributed as long as it retains this notice 553024Sguido * and is not changed in any way. The author accepts no responsibility 653024Sguido * for the use of this software. I hate legaleese, don't you ? 753024Sguido * 853024Sguido * @(#)ip_compat.h 1.1 9/14/95 953024Sguido */ 1053024Sguido 1153024Sguido/* 1253024Sguido * These #ifdef's are here mainly for linux, but who knows, they may 1353024Sguido * not be in other places or maybe one day linux will grow up and some 1453024Sguido * of these will turn up there too. 1553024Sguido */ 1653024Sguido#ifndef ICMP_UNREACH 1753024Sguido# define ICMP_UNREACH ICMP_DEST_UNREACH 1853024Sguido#endif 1953024Sguido#ifndef ICMP_SOURCEQUENCH 2053024Sguido# define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH 2153024Sguido#endif 2253024Sguido#ifndef ICMP_TIMXCEED 2353024Sguido# define ICMP_TIMXCEED ICMP_TIME_EXCEEDED 2453024Sguido#endif 2553024Sguido#ifndef ICMP_PARAMPROB 2653024Sguido# define ICMP_PARAMPROB ICMP_PARAMETERPROB 2753024Sguido#endif 2853024Sguido#ifndef IPVERSION 2953024Sguido# define IPVERSION 4 3053024Sguido#endif 3153024Sguido#ifndef IPOPT_MINOFF 3253024Sguido# define IPOPT_MINOFF 4 3353024Sguido#endif 3453024Sguido#ifndef IPOPT_COPIED 3553024Sguido# define IPOPT_COPIED(x) ((x)&0x80) 3653024Sguido#endif 3753024Sguido#ifndef IPOPT_EOL 3853024Sguido# define IPOPT_EOL 0 3953024Sguido#endif 4053024Sguido#ifndef IPOPT_NOP 4153024Sguido# define IPOPT_NOP 1 4253024Sguido#endif 4353024Sguido#ifndef IP_MF 4453024Sguido# define IP_MF ((u_short)0x2000) 4553024Sguido#endif 4653024Sguido#ifndef ETHERTYPE_IP 4753024Sguido# define ETHERTYPE_IP ((u_short)0x0800) 4853024Sguido#endif 4953024Sguido#ifndef TH_FIN 5053024Sguido# define TH_FIN 0x01 5153024Sguido#endif 5253024Sguido#ifndef TH_SYN 5353024Sguido# define TH_SYN 0x02 5453024Sguido#endif 5553024Sguido#ifndef TH_RST 5653024Sguido# define TH_RST 0x04 5753024Sguido#endif 5853024Sguido#ifndef TH_PUSH 5953024Sguido# define TH_PUSH 0x08 6053024Sguido#endif 6153024Sguido#ifndef TH_ACK 6253024Sguido# define TH_ACK 0x10 6353024Sguido#endif 6453024Sguido#ifndef TH_URG 6553024Sguido# define TH_URG 0x20 6653024Sguido#endif 6753024Sguido#ifndef IPOPT_EOL 6853024Sguido# define IPOPT_EOL 0 6953024Sguido#endif 7053024Sguido#ifndef IPOPT_NOP 7153024Sguido# define IPOPT_NOP 1 7253024Sguido#endif 7353024Sguido#ifndef IPOPT_RR 7453024Sguido# define IPOPT_RR 7 7553024Sguido#endif 7653024Sguido#ifndef IPOPT_TS 7753024Sguido# define IPOPT_TS 68 7853024Sguido#endif 7953024Sguido#ifndef IPOPT_SECURITY 8053024Sguido# define IPOPT_SECURITY 130 8153024Sguido#endif 8253024Sguido#ifndef IPOPT_LSRR 8353024Sguido# define IPOPT_LSRR 131 8453024Sguido#endif 8553024Sguido#ifndef IPOPT_SATID 8653024Sguido# define IPOPT_SATID 136 8753024Sguido#endif 8853024Sguido#ifndef IPOPT_SSRR 8953024Sguido# define IPOPT_SSRR 137 9053024Sguido#endif 9153024Sguido#ifndef IPOPT_SECUR_UNCLASS 9253024Sguido# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 9353024Sguido#endif 9453024Sguido#ifndef IPOPT_SECUR_CONFID 9553024Sguido# define IPOPT_SECUR_CONFID ((u_short)0xf135) 9653024Sguido#endif 9753024Sguido#ifndef IPOPT_SECUR_EFTO 9853024Sguido# define IPOPT_SECUR_EFTO ((u_short)0x789a) 9953024Sguido#endif 10053024Sguido#ifndef IPOPT_SECUR_MMMM 10153024Sguido# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 10253024Sguido#endif 10353024Sguido#ifndef IPOPT_SECUR_RESTR 10453024Sguido# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 10553024Sguido#endif 10653024Sguido#ifndef IPOPT_SECUR_SECRET 10753024Sguido# define IPOPT_SECUR_SECRET ((u_short)0xd788) 10853024Sguido#endif 10953024Sguido#ifndef IPOPT_SECUR_TOPSECRET 11053024Sguido# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 11153024Sguido#endif 11253024Sguido 11353024Sguido#ifdef linux 11453024Sguido# define icmp icmphdr 11553024Sguido# define icmp_type type 11653024Sguido# define icmp_code code 11753024Sguido 11853024Sguido/* 11953024Sguido * From /usr/include/netinet/ip_var.h 12053024Sguido * !%@#!$@# linux... 12153024Sguido */ 12253024Sguidostruct ipovly { 12353024Sguido caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 12453024Sguido u_char ih_x1; /* (unused) */ 12553024Sguido u_char ih_pr; /* protocol */ 12653024Sguido short ih_len; /* protocol length */ 12753024Sguido struct in_addr ih_src; /* source internet address */ 12853024Sguido struct in_addr ih_dst; /* destination internet address */ 12953024Sguido}; 13053024Sguido 13153024Sguidotypedef struct { 13253024Sguido __u16 th_sport; 13353024Sguido __u16 th_dport; 13453024Sguido __u32 th_seq; 13553024Sguido __u32 th_ack; 13653024Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 13753024Sguido defined(vax) 13853024Sguido __u8 th_res:4; 13953024Sguido __u8 th_off:4; 14053024Sguido#else 14153024Sguido __u8 th_off:4; 14253024Sguido __u8 th_res:4; 14353024Sguido#endif 14453024Sguido __u8 th_flags; 14553024Sguido __u16 th_win; 14653024Sguido __u16 th_sum; 14753024Sguido __u16 th_urp; 14853024Sguido} tcphdr_t; 14953024Sguido 15053024Sguidotypedef struct { 15153024Sguido __u16 uh_sport; 15253024Sguido __u16 uh_dport; 15353024Sguido __s16 uh_ulen; 15453024Sguido __u16 uh_sum; 15553024Sguido} udphdr_t; 15653024Sguido 15753024Sguidotypedef struct { 15853024Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 15953024Sguido defined(vax) 16053024Sguido __u8 ip_hl:4; 16153024Sguido __u8 ip_v:4; 16253024Sguido# else 16353024Sguido __u8 ip_hl:4; 16453024Sguido __u8 ip_v:4; 16553024Sguido# endif 16653024Sguido __u8 ip_tos; 16753024Sguido __u16 ip_len; 16853024Sguido __u16 ip_id; 16953024Sguido __u16 ip_off; 17053024Sguido __u8 ip_ttl; 17153024Sguido __u8 ip_p; 17253024Sguido __u16 ip_sum; 17353024Sguido struct in_addr ip_src; 17453024Sguido struct in_addr ip_dst; 17553024Sguido} ip_t; 17653024Sguido 17753024Sguidotypedef struct { 17853024Sguido __u8 ether_dhost[6]; 17953024Sguido __u8 ether_shost[6]; 18053024Sguido __u16 ether_type; 18153024Sguido} ether_header_t; 18253024Sguido 18353024Sguido# define bcopy(a,b,c) memmove(b,a,c) 18453024Sguido# define bcmp(a,b,c) memcmp(a,b,c) 18553024Sguido 18653024Sguido# define ifnet device 18753024Sguido 18853024Sguido#else 18953024Sguido 19053024Sguidotypedef struct udphdr udphdr_t; 19153024Sguidotypedef struct tcphdr tcphdr_t; 19253024Sguidotypedef struct ip ip_t; 19353024Sguidotypedef struct ether_header ether_header_t; 19453024Sguido 19553024Sguido#endif 19653024Sguido 19753024Sguido#ifdef solaris 19853024Sguido# define bcopy(a,b,c) memmove(b,a,c) 19953024Sguido# define bcmp(a,b,c) memcmp(a,b,c) 20053024Sguido# define bzero(a,b) memset(a,0,b) 20153024Sguido#endif 202