1 /* $NetBSD: ip_compat.h,v 1.1.1.1 2012/03/23 21:20:06 christos Exp $ */ 2 3 /* 4 * (C)opyright 1995 by Darren Reed. 5 * 6 * This code may be freely distributed as long as it retains this notice 7 * and is not changed in any way. The author accepts no responsibility 8 * for the use of this software. I hate legaleese, don't you ? 9 * 10 * @(#)ip_compat.h 1.1 9/14/95 11 */ 12 13 /* 14 * These #ifdef's are here mainly for linux, but who knows, they may 15 * not be in other places or maybe one day linux will grow up and some 16 * of these will turn up there too. 17 */ 18 #ifndef ICMP_UNREACH 19 # define ICMP_UNREACH ICMP_DEST_UNREACH 20 #endif 21 #ifndef ICMP_SOURCEQUENCH 22 # define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH 23 #endif 24 #ifndef ICMP_TIMXCEED 25 # define ICMP_TIMXCEED ICMP_TIME_EXCEEDED 26 #endif 27 #ifndef ICMP_PARAMPROB 28 # define ICMP_PARAMPROB ICMP_PARAMETERPROB 29 #endif 30 #ifndef IPVERSION 31 # define IPVERSION 4 32 #endif 33 #ifndef IPOPT_MINOFF 34 # define IPOPT_MINOFF 4 35 #endif 36 #ifndef IPOPT_COPIED 37 # define IPOPT_COPIED(x) ((x)&0x80) 38 #endif 39 #ifndef IPOPT_EOL 40 # define IPOPT_EOL 0 41 #endif 42 #ifndef IPOPT_NOP 43 # define IPOPT_NOP 1 44 #endif 45 #ifndef IP_MF 46 # define IP_MF ((u_short)0x2000) 47 #endif 48 #ifndef ETHERTYPE_IP 49 # define ETHERTYPE_IP ((u_short)0x0800) 50 #endif 51 #ifndef TH_FIN 52 # define TH_FIN 0x01 53 #endif 54 #ifndef TH_SYN 55 # define TH_SYN 0x02 56 #endif 57 #ifndef TH_RST 58 # define TH_RST 0x04 59 #endif 60 #ifndef TH_PUSH 61 # define TH_PUSH 0x08 62 #endif 63 #ifndef TH_ACK 64 # define TH_ACK 0x10 65 #endif 66 #ifndef TH_URG 67 # define TH_URG 0x20 68 #endif 69 #ifndef IPOPT_EOL 70 # define IPOPT_EOL 0 71 #endif 72 #ifndef IPOPT_NOP 73 # define IPOPT_NOP 1 74 #endif 75 #ifndef IPOPT_RR 76 # define IPOPT_RR 7 77 #endif 78 #ifndef IPOPT_TS 79 # define IPOPT_TS 68 80 #endif 81 #ifndef IPOPT_SECURITY 82 # define IPOPT_SECURITY 130 83 #endif 84 #ifndef IPOPT_LSRR 85 # define IPOPT_LSRR 131 86 #endif 87 #ifndef IPOPT_SATID 88 # define IPOPT_SATID 136 89 #endif 90 #ifndef IPOPT_SSRR 91 # define IPOPT_SSRR 137 92 #endif 93 #ifndef IPOPT_SECUR_UNCLASS 94 # define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 95 #endif 96 #ifndef IPOPT_SECUR_CONFID 97 # define IPOPT_SECUR_CONFID ((u_short)0xf135) 98 #endif 99 #ifndef IPOPT_SECUR_EFTO 100 # define IPOPT_SECUR_EFTO ((u_short)0x789a) 101 #endif 102 #ifndef IPOPT_SECUR_MMMM 103 # define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 104 #endif 105 #ifndef IPOPT_SECUR_RESTR 106 # define IPOPT_SECUR_RESTR ((u_short)0xaf13) 107 #endif 108 #ifndef IPOPT_SECUR_SECRET 109 # define IPOPT_SECUR_SECRET ((u_short)0xd788) 110 #endif 111 #ifndef IPOPT_SECUR_TOPSECRET 112 # define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 113 #endif 114 115 #ifdef linux 116 # define icmp icmphdr 117 # define icmp_type type 118 # define icmp_code code 119 120 /* 121 * From /usr/include/netinet/ip_var.h 122 * !%@#!$@# linux... 123 */ 124 struct ipovly { 125 caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 126 u_char ih_x1; /* (unused) */ 127 u_char ih_pr; /* protocol */ 128 short ih_len; /* protocol length */ 129 struct in_addr ih_src; /* source internet address */ 130 struct in_addr ih_dst; /* destination internet address */ 131 }; 132 133 typedef struct { 134 __u16 th_sport; 135 __u16 th_dport; 136 __u32 th_seq; 137 __u32 th_ack; 138 # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 139 defined(vax) 140 __u8 th_res:4; 141 __u8 th_off:4; 142 #else 143 __u8 th_off:4; 144 __u8 th_res:4; 145 #endif 146 __u8 th_flags; 147 __u16 th_win; 148 __u16 th_sum; 149 __u16 th_urp; 150 } tcphdr_t; 151 152 typedef struct { 153 __u16 uh_sport; 154 __u16 uh_dport; 155 __s16 uh_ulen; 156 __u16 uh_sum; 157 } udphdr_t; 158 159 typedef struct { 160 # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 161 defined(vax) 162 __u8 ip_hl:4; 163 __u8 ip_v:4; 164 # else 165 __u8 ip_hl:4; 166 __u8 ip_v:4; 167 # endif 168 __u8 ip_tos; 169 __u16 ip_len; 170 __u16 ip_id; 171 __u16 ip_off; 172 __u8 ip_ttl; 173 __u8 ip_p; 174 __u16 ip_sum; 175 struct in_addr ip_src; 176 struct in_addr ip_dst; 177 } ip_t; 178 179 typedef struct { 180 __u8 ether_dhost[6]; 181 __u8 ether_shost[6]; 182 __u16 ether_type; 183 } ether_header_t; 184 185 # define bcopy(a,b,c) memmove(b,a,c) 186 # define bcmp(a,b,c) memcmp(a,b,c) 187 188 # define ifnet device 189 190 #else 191 192 typedef struct udphdr udphdr_t; 193 typedef struct tcphdr tcphdr_t; 194 typedef struct ip ip_t; 195 typedef struct ether_header ether_header_t; 196 197 #endif 198 199 #ifdef solaris 200 # define bcopy(a,b,c) memmove(b,a,c) 201 # define bcmp(a,b,c) memcmp(a,b,c) 202 # define bzero(a,b) memset(a,0,b) 203 #endif 204