]> The Tcpdump Group git mirrors - tcpdump/blobdiff - ip.h
When checking for pcap_if_t, add $V_INCLS to CFLAGS, so we look at the
[tcpdump] / ip.h
diff --git a/ip.h b/ip.h
index adba2e6cdaeea12956ca6ad959c59042fef677b1..eba63668b92c10dad0022aa8fbcad91f06947388 100644 (file)
--- a/ip.h
+++ b/ip.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.2 2000-09-24 07:40:45 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.10 2002-12-11 07:13:53 guy Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
  *     @(#)ip.h        8.2 (Berkeley) 6/1/94
  */
 
-#ifndef BYTE_ORDER
-#define        LITTLE_ENDIAN   1234    /* least-significant byte first (vax, pc) */
-#define        BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
-#define        PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp)*/
-
-#ifdef WORDS_BIGENDIAN
-#define BYTE_ORDER     BIG_ENDIAN
-#else
-#define BYTE_ORDER     LITTLE_ENDIAN
-#endif /* WORDS_BIGENDIAN */
-#endif /* BYTE_ORDER */
-
-#if !defined(BYTE_ORDER) || \
-    (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
-    BYTE_ORDER != PDP_ENDIAN)
-       /* you must determine what the correct bit order is for
-        * your compiler - the next line is an intentional error
-        * which will force your compiles to bomb until you fix
-        * the above macros.
-        */
-  #error "Undefined or invalid BYTE_ORDER";
-#endif
-
 /*
  * Definitions for internet protocol version 4.
  * Per RFC 791, September 1981.
  * against negative integers quite easily, and fail in subtle ways.
  */
 struct ip {
-#if BYTE_ORDER == LITTLE_ENDIAN 
-       u_char  ip_hl:4,                /* header length */
-               ip_v:4;                 /* version */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN 
-       u_char  ip_v:4,                 /* version */
-               ip_hl:4;                /* header length */
-#endif
-       u_char  ip_tos;                 /* type of service */
-       short   ip_len;                 /* total length */
-       u_short ip_id;                  /* identification */
-       short   ip_off;                 /* fragment offset field */
+       u_int8_t        ip_vhl;         /* header length, version */
+#define IP_V(ip)       (((ip)->ip_vhl & 0xf0) >> 4)
+#define IP_HL(ip)      ((ip)->ip_vhl & 0x0f)
+       u_int8_t        ip_tos;         /* type of service */
+       u_int16_t       ip_len;         /* total length */
+       u_int16_t       ip_id;          /* identification */
+       u_int16_t       ip_off;         /* fragment offset field */
 #define        IP_DF 0x4000                    /* dont fragment flag */
 #define        IP_MF 0x2000                    /* more fragments flag */
 #define        IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
-       u_char  ip_ttl;                 /* time to live */
-       u_char  ip_p;                   /* protocol */
-       u_short ip_sum;                 /* checksum */
+       u_int8_t        ip_ttl;         /* time to live */
+       u_int8_t        ip_p;           /* protocol */
+       u_int16_t       ip_sum;         /* checksum */
        struct  in_addr ip_src,ip_dst;  /* source and dest address */
 };
 
@@ -147,22 +119,17 @@ struct ip {
  * Time stamp option structure.
  */
 struct ip_timestamp {
-       u_char  ipt_code;               /* IPOPT_TS */
-       u_char  ipt_len;                /* size of structure (variable) */
-       u_char  ipt_ptr;                /* index of current entry */
-#if BYTE_ORDER == LITTLE_ENDIAN 
-       u_char  ipt_flg:4,              /* flags, see below */
-               ipt_oflw:4;             /* overflow counter */
-#endif
-#if BYTE_ORDER == BIG_ENDIAN 
-       u_char  ipt_oflw:4,             /* overflow counter */
-               ipt_flg:4;              /* flags, see below */
-#endif
+       u_int8_t        ipt_code;       /* IPOPT_TS */
+       u_int8_t        ipt_len;        /* size of structure (variable) */
+       u_int8_t        ipt_ptr;        /* index of current entry */
+       u_int8_t        ipt_oflwflg;    /* flags, overflow counter */
+#define IPTS_OFLW(ip)  (((ipt)->ipt_oflwflg & 0xf0) >> 4)
+#define IPTS_FLG(ip)   ((ipt)->ipt_oflwflg & 0x0f)
        union ipt_timestamp {
-               n_long  ipt_time[1];
+               u_int32_t ipt_time[1];
                struct  ipt_ta {
                        struct in_addr ipt_addr;
-                       n_long ipt_time;
+                       u_int32_t ipt_time;
                } ipt_ta[1];
        } ipt_timestamp;
 };
@@ -190,3 +157,6 @@ struct      ip_timestamp {
 #define        IPTTLDEC        1               /* subtracted when forwarding */
 
 #define        IP_MSS          576             /* default maximum segment size */
+
+/* in print-ip.c */
+extern u_int32_t ip_finddst(const struct ip *);