1997-05-28 02:16:47 +04:00
|
|
|
/* $NetBSD: ip_compat.h,v 1.1.1.3 1997/05/27 22:18:14 thorpej Exp $ */
|
1997-05-25 15:45:50 +04:00
|
|
|
|
1997-01-05 16:06:38 +03:00
|
|
|
/*
|
1997-05-28 02:16:47 +04:00
|
|
|
* (C)opyright 1995 by Darren Reed.
|
1997-01-05 16:06:38 +03:00
|
|
|
*
|
1997-05-28 02:16:47 +04:00
|
|
|
* This code may be freely distributed as long as it retains this notice
|
|
|
|
* and is not changed in any way. The author accepts no responsibility
|
|
|
|
* for the use of this software. I hate legaleese, don't you ?
|
1997-01-05 16:06:38 +03:00
|
|
|
*
|
1997-05-28 02:16:47 +04:00
|
|
|
* @(#)ip_compat.h 1.2 12/7/95
|
1997-01-05 16:06:38 +03:00
|
|
|
*/
|
|
|
|
|
1997-05-28 02:16:47 +04:00
|
|
|
/*
|
|
|
|
* These #ifdef's are here mainly for linux, but who knows, they may
|
|
|
|
* not be in other places or maybe one day linux will grow up and some
|
|
|
|
* of these will turn up there too.
|
|
|
|
*/
|
|
|
|
#ifndef ICMP_UNREACH
|
|
|
|
# define ICMP_UNREACH ICMP_DEST_UNREACH
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef ICMP_SOURCEQUENCH
|
|
|
|
# define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef ICMP_TIMXCEED
|
|
|
|
# define ICMP_TIMXCEED ICMP_TIME_EXCEEDED
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef ICMP_PARAMPROB
|
|
|
|
# define ICMP_PARAMPROB ICMP_PARAMETERPROB
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IPVERSION
|
|
|
|
# define IPVERSION 4
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IPOPT_MINOFF
|
|
|
|
# define IPOPT_MINOFF 4
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IPOPT_COPIED
|
|
|
|
# define IPOPT_COPIED(x) ((x)&0x80)
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IPOPT_EOL
|
|
|
|
# define IPOPT_EOL 0
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IPOPT_NOP
|
|
|
|
# define IPOPT_NOP 1
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef IP_MF
|
|
|
|
# define IP_MF ((u_short)0x2000)
|
1997-01-05 16:06:38 +03:00
|
|
|
#endif
|
1997-05-28 02:16:47 +04:00
|
|
|
#ifndef ETHERTYPE_IP
|
|
|
|
# define ETHERTYPE_IP ((u_short)0x0800)
|
|
|
|
#endif
|
|
|
|
#ifndef TH_FIN
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_FIN 0x01
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TH_SYN
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_SYN 0x02
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TH_RST
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_RST 0x04
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TH_PUSH
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_PUSH 0x08
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TH_ACK
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_ACK 0x10
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TH_URG
|
1997-01-05 16:06:38 +03:00
|
|
|
# define TH_URG 0x20
|
1997-05-28 02:16:47 +04:00
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_EOL
|
|
|
|
# define IPOPT_EOL 0
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_NOP
|
|
|
|
# define IPOPT_NOP 1
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_RR
|
|
|
|
# define IPOPT_RR 7
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_TS
|
|
|
|
# define IPOPT_TS 68
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECURITY
|
|
|
|
# define IPOPT_SECURITY 130
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_LSRR
|
|
|
|
# define IPOPT_LSRR 131
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SATID
|
|
|
|
# define IPOPT_SATID 136
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SSRR
|
|
|
|
# define IPOPT_SSRR 137
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_UNCLASS
|
|
|
|
# define IPOPT_SECUR_UNCLASS ((u_short)0x0000)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_CONFID
|
|
|
|
# define IPOPT_SECUR_CONFID ((u_short)0xf135)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_EFTO
|
|
|
|
# define IPOPT_SECUR_EFTO ((u_short)0x789a)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_MMMM
|
|
|
|
# define IPOPT_SECUR_MMMM ((u_short)0xbc4d)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_RESTR
|
|
|
|
# define IPOPT_SECUR_RESTR ((u_short)0xaf13)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_SECRET
|
|
|
|
# define IPOPT_SECUR_SECRET ((u_short)0xd788)
|
|
|
|
#endif
|
|
|
|
#ifndef IPOPT_SECUR_TOPSECRET
|
|
|
|
# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef linux
|
|
|
|
# if LINUX < 0200
|
|
|
|
# define icmp icmphdr
|
|
|
|
# define icmp_type type
|
|
|
|
# define icmp_code code
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* From /usr/include/netinet/ip_var.h
|
|
|
|
* !%@#!$@# linux...
|
|
|
|
*/
|
|
|
|
struct ipovly {
|
|
|
|
caddr_t ih_next, ih_prev; /* for protocol sequence q's */
|
|
|
|
u_char ih_x1; /* (unused) */
|
|
|
|
u_char ih_pr; /* protocol */
|
|
|
|
short ih_len; /* protocol length */
|
|
|
|
struct in_addr ih_src; /* source internet address */
|
|
|
|
struct in_addr ih_dst; /* destination internet address */
|
|
|
|
};
|
1997-01-05 16:06:38 +03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__u16 th_sport;
|
|
|
|
__u16 th_dport;
|
|
|
|
__u32 th_seq;
|
|
|
|
__u32 th_ack;
|
1997-05-28 02:16:47 +04:00
|
|
|
# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
|
|
|
|
defined(vax)
|
|
|
|
__u8 th_res:4;
|
|
|
|
__u8 th_off:4;
|
|
|
|
#else
|
|
|
|
__u8 th_off:4;
|
|
|
|
__u8 th_res:4;
|
|
|
|
#endif
|
1997-01-05 16:06:38 +03:00
|
|
|
__u8 th_flags;
|
|
|
|
__u16 th_win;
|
|
|
|
__u16 th_sum;
|
|
|
|
__u16 th_urp;
|
|
|
|
} tcphdr_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
__u16 uh_sport;
|
|
|
|
__u16 uh_dport;
|
1997-05-28 02:16:47 +04:00
|
|
|
__s16 uh_ulen;
|
|
|
|
__u16 uh_sum;
|
1997-01-05 16:06:38 +03:00
|
|
|
} udphdr_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
|
|
|
|
defined(vax)
|
|
|
|
__u8 ip_hl:4;
|
|
|
|
__u8 ip_v:4;
|
|
|
|
# else
|
|
|
|
__u8 ip_hl:4;
|
|
|
|
__u8 ip_v:4;
|
|
|
|
# endif
|
|
|
|
__u8 ip_tos;
|
|
|
|
__u16 ip_len;
|
|
|
|
__u16 ip_id;
|
|
|
|
__u16 ip_off;
|
|
|
|
__u8 ip_ttl;
|
|
|
|
__u8 ip_p;
|
|
|
|
__u16 ip_sum;
|
|
|
|
struct in_addr ip_src;
|
|
|
|
struct in_addr ip_dst;
|
|
|
|
} ip_t;
|
|
|
|
|
1997-05-28 02:16:47 +04:00
|
|
|
typedef struct {
|
|
|
|
__u8 ether_dhost[6];
|
|
|
|
__u8 ether_shost[6];
|
|
|
|
__u16 ether_type;
|
|
|
|
} ether_header_t;
|
|
|
|
|
|
|
|
typedef struct icmp {
|
1997-01-05 16:06:38 +03:00
|
|
|
u_char icmp_type; /* type of message, see below */
|
|
|
|
u_char icmp_code; /* type sub code */
|
|
|
|
u_short icmp_cksum; /* ones complement cksum of struct */
|
|
|
|
union {
|
|
|
|
u_char ih_pptr; /* ICMP_PARAMPROB */
|
|
|
|
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
|
|
|
|
struct ih_idseq {
|
|
|
|
n_short icd_id;
|
|
|
|
n_short icd_seq;
|
|
|
|
} ih_idseq;
|
|
|
|
int ih_void;
|
|
|
|
} icmp_hun;
|
1997-05-28 02:16:47 +04:00
|
|
|
#define icmp_pptr icmp_hun.ih_pptr
|
|
|
|
#define icmp_gwaddr icmp_hun.ih_gwaddr
|
|
|
|
#define icmp_id icmp_hun.ih_idseq.icd_id
|
|
|
|
#define icmp_seq icmp_hun.ih_idseq.icd_seq
|
|
|
|
#define icmp_void icmp_hun.ih_void
|
1997-01-05 16:06:38 +03:00
|
|
|
union {
|
|
|
|
struct id_ts {
|
|
|
|
n_time its_otime;
|
|
|
|
n_time its_rtime;
|
|
|
|
n_time its_ttime;
|
|
|
|
} id_ts;
|
|
|
|
struct id_ip {
|
|
|
|
ip_t idi_ip;
|
|
|
|
/* options and then 64 bits of data */
|
|
|
|
} id_ip;
|
|
|
|
u_long id_mask;
|
|
|
|
char id_data[1];
|
|
|
|
} icmp_dun;
|
1997-05-28 02:16:47 +04:00
|
|
|
#define icmp_otime icmp_dun.id_ts.its_otime
|
|
|
|
#define icmp_rtime icmp_dun.id_ts.its_rtime
|
|
|
|
#define icmp_ttime icmp_dun.id_ts.its_ttime
|
|
|
|
#define icmp_ip icmp_dun.id_ip.idi_ip
|
|
|
|
#define icmp_mask icmp_dun.id_mask
|
|
|
|
#define icmp_data icmp_dun.id_data
|
|
|
|
} icmphdr_t;
|
1997-01-05 16:06:38 +03:00
|
|
|
|
|
|
|
# define bcopy(a,b,c) memmove(b,a,c)
|
|
|
|
# define bcmp(a,b,c) memcmp(a,b,c)
|
|
|
|
|
|
|
|
# define ifnet device
|
|
|
|
|
|
|
|
#else
|
1997-05-28 02:16:47 +04:00
|
|
|
|
1997-05-25 15:45:50 +04:00
|
|
|
typedef struct udphdr udphdr_t;
|
1997-05-28 02:16:47 +04:00
|
|
|
typedef struct tcphdr tcphdr_t;
|
1997-01-05 16:06:38 +03:00
|
|
|
typedef struct ip ip_t;
|
1997-05-28 02:16:47 +04:00
|
|
|
typedef struct ether_header ether_header_t;
|
|
|
|
|
|
|
|
#endif
|
1997-01-05 16:06:38 +03:00
|
|
|
|
1997-05-28 02:16:47 +04:00
|
|
|
#if defined(__SVR4) || defined(__svr4__)
|
|
|
|
# define bcopy(a,b,c) memmove(b,a,c)
|
|
|
|
# define bcmp(a,b,c) memcmp(a,b,c)
|
|
|
|
# define bzero(a,b) memset(a,0,b)
|
|
|
|
#endif
|