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.2 12/7/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# if LINUX < 0200 11753024Sguido# define icmp icmphdr 11853024Sguido# define icmp_type type 11953024Sguido# define icmp_code code 12053024Sguido# endif 12153024Sguido 12253024Sguido/* 12353024Sguido * From /usr/include/netinet/ip_var.h 12453024Sguido * !%@#!$@# linux... 12553024Sguido */ 12653024Sguidostruct ipovly { 12753024Sguido caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 12853024Sguido u_char ih_x1; /* (unused) */ 12953024Sguido u_char ih_pr; /* protocol */ 13053024Sguido short ih_len; /* protocol length */ 13153024Sguido struct in_addr ih_src; /* source internet address */ 13253024Sguido struct in_addr ih_dst; /* destination internet address */ 13353024Sguido}; 13453024Sguido 13553024Sguidotypedef struct { 13653024Sguido __u16 th_sport; 13753024Sguido __u16 th_dport; 13853024Sguido __u32 th_seq; 13953024Sguido __u32 th_ack; 14053024Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 14153024Sguido defined(vax) 14253024Sguido __u8 th_res:4; 14353024Sguido __u8 th_off:4; 14453024Sguido#else 14553024Sguido __u8 th_off:4; 14653024Sguido __u8 th_res:4; 14753024Sguido#endif 14853024Sguido __u8 th_flags; 14953024Sguido __u16 th_win; 15053024Sguido __u16 th_sum; 15153024Sguido __u16 th_urp; 15253024Sguido} tcphdr_t; 15353024Sguido 15453024Sguidotypedef struct { 15553024Sguido __u16 uh_sport; 15653024Sguido __u16 uh_dport; 15753024Sguido __s16 uh_ulen; 15853024Sguido __u16 uh_sum; 15953024Sguido} udphdr_t; 16053024Sguido 16153024Sguidotypedef struct { 16253024Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 16353024Sguido defined(vax) 16453024Sguido __u8 ip_hl:4; 16553024Sguido __u8 ip_v:4; 16653024Sguido# else 16753024Sguido __u8 ip_hl:4; 16853024Sguido __u8 ip_v:4; 16953024Sguido# endif 17053024Sguido __u8 ip_tos; 17153024Sguido __u16 ip_len; 17253024Sguido __u16 ip_id; 17353024Sguido __u16 ip_off; 17453024Sguido __u8 ip_ttl; 17553024Sguido __u8 ip_p; 17653024Sguido __u16 ip_sum; 17753024Sguido struct in_addr ip_src; 17853024Sguido struct in_addr ip_dst; 17953024Sguido} ip_t; 18053024Sguido 18153024Sguidotypedef struct { 18253024Sguido __u8 ether_dhost[6]; 18353024Sguido __u8 ether_shost[6]; 18453024Sguido __u16 ether_type; 18553024Sguido} ether_header_t; 18653024Sguido 18753024Sguidotypedef struct icmp { 18853024Sguido u_char icmp_type; /* type of message, see below */ 18953024Sguido u_char icmp_code; /* type sub code */ 19053024Sguido u_short icmp_cksum; /* ones complement cksum of struct */ 19153024Sguido union { 19253024Sguido u_char ih_pptr; /* ICMP_PARAMPROB */ 19353024Sguido struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 19453024Sguido struct ih_idseq { 19553024Sguido n_short icd_id; 19653024Sguido n_short icd_seq; 19753024Sguido } ih_idseq; 19853024Sguido int ih_void; 19953024Sguido } icmp_hun; 20053024Sguido#define icmp_pptr icmp_hun.ih_pptr 20153024Sguido#define icmp_gwaddr icmp_hun.ih_gwaddr 20253024Sguido#define icmp_id icmp_hun.ih_idseq.icd_id 20353024Sguido#define icmp_seq icmp_hun.ih_idseq.icd_seq 20453024Sguido#define icmp_void icmp_hun.ih_void 20553024Sguido union { 20653024Sguido struct id_ts { 20753024Sguido n_time its_otime; 20853024Sguido n_time its_rtime; 20953024Sguido n_time its_ttime; 21053024Sguido } id_ts; 21153024Sguido struct id_ip { 21253024Sguido ip_t idi_ip; 21353024Sguido /* options and then 64 bits of data */ 21453024Sguido } id_ip; 21553024Sguido u_long id_mask; 21653024Sguido char id_data[1]; 21753024Sguido } icmp_dun; 21853024Sguido#define icmp_otime icmp_dun.id_ts.its_otime 21953024Sguido#define icmp_rtime icmp_dun.id_ts.its_rtime 22053024Sguido#define icmp_ttime icmp_dun.id_ts.its_ttime 22153024Sguido#define icmp_ip icmp_dun.id_ip.idi_ip 22253024Sguido#define icmp_mask icmp_dun.id_mask 22353024Sguido#define icmp_data icmp_dun.id_data 22453024Sguido} icmphdr_t; 22553024Sguido 22653024Sguido# define bcopy(a,b,c) memmove(b,a,c) 22753024Sguido# define bcmp(a,b,c) memcmp(a,b,c) 22853024Sguido 22953024Sguido# define ifnet device 23053024Sguido 23153024Sguido#else 23253024Sguido 23353024Sguidotypedef struct udphdr udphdr_t; 23453024Sguidotypedef struct tcphdr tcphdr_t; 23553024Sguidotypedef struct ip ip_t; 23653024Sguidotypedef struct ether_header ether_header_t; 23753024Sguido 23853024Sguido#endif 23953024Sguido 24053024Sguido#if defined(__SVR4) || defined(__svr4__) 24153024Sguido# define bcopy(a,b,c) memmove(b,a,c) 24253024Sguido# define bcmp(a,b,c) memcmp(a,b,c) 24353024Sguido# define bzero(a,b) memset(a,0,b) 24453024Sguido#endif 245