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