Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/tcpdump avoid use of bitfield in packet format defi...



details:   https://anonhg.NetBSD.org/src/rev/83620f41d569
branches:  trunk
changeset: 480081:83620f41d569
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sun Jan 02 13:15:53 2000 +0000

description:
avoid use of bitfield in packet format definition.  it is non-portable
(packing constraint is unknown).
avoid use of u_int8_t bitfield.  it is illegal.

diffstat:

 usr.sbin/tcpdump/isakmp.h       |  28 +++++++++++++---------------
 usr.sbin/tcpdump/print-isakmp.c |  14 ++++++++++----
 2 files changed, 23 insertions(+), 19 deletions(-)

diffs (84 lines):

diff -r bdb76162e35e -r 83620f41d569 usr.sbin/tcpdump/isakmp.h
--- a/usr.sbin/tcpdump/isakmp.h Sun Jan 02 11:20:51 2000 +0000
+++ b/usr.sbin/tcpdump/isakmp.h Sun Jan 02 13:15:53 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isakmp.h,v 1.2 1999/07/04 02:57:51 itojun Exp $        */
+/*     $NetBSD: isakmp.h,v 1.3 2000/01/02 13:15:53 itojun Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -100,20 +100,18 @@
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 */
 struct isakmp {
-       cookie_t i_ck;     /* Initiator Cookie */
-       cookie_t r_ck;     /* Responder Cookie */
-       u_int8_t   np;       /* Next Payload Type */
-#if BYTE_ORDER == LITTLE_ENDIAN
-       u_int8_t   v_min:4,  /* MnVer */
-                v_maj:4;  /* MjVer */
-#else
-       u_int8_t   v_maj:4,  /* MnVer */
-                v_min:4;  /* MjVer */
-#endif
-       u_int8_t   etype;    /* Exchange Type */
-       u_int8_t   flags;    /* Flags */
-       msgid_t  msgid;
-       u_int32_t  len;      /* Length */
+       cookie_t i_ck;          /* Initiator Cookie */
+       cookie_t r_ck;          /* Responder Cookie */
+       u_int8_t np;            /* Next Payload Type */
+       u_int8_t vers;
+#define ISAKMP_VERS_MAJOR      0xf0
+#define ISAKMP_VERS_MAJOR_SHIFT        4
+#define ISAKMP_VERS_MINOR      0x0f
+#define ISAKMP_VERS_MINOR_SHIFT        0
+       u_int8_t etype;         /* Exchange Type */
+       u_int8_t flags;         /* Flags */
+       msgid_t msgid;
+       u_int32_t len;          /* Length */
 };
 
 /* Next Payload Type */
diff -r bdb76162e35e -r 83620f41d569 usr.sbin/tcpdump/print-isakmp.c
--- a/usr.sbin/tcpdump/print-isakmp.c   Sun Jan 02 11:20:51 2000 +0000
+++ b/usr.sbin/tcpdump/print-isakmp.c   Sun Jan 02 13:15:53 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print-isakmp.c,v 1.3 1999/12/10 05:45:08 itojun Exp $  */
+/*     $NetBSD: print-isakmp.c,v 1.4 2000/01/02 13:15:54 itojun Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -36,7 +36,7 @@
     "@(#) KAME Header: /cvsroot/kame/kame/kame/kame/tcpdump/print-isakmp.c,v 1.3 1999/12/01 01:41:25 itojun Exp";
 #else
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: print-isakmp.c,v 1.3 1999/12/10 05:45:08 itojun Exp $");
+__RCSID("$NetBSD: print-isakmp.c,v 1.4 2000/01/02 13:15:54 itojun Exp $");
 #endif
 #endif
 
@@ -965,6 +965,7 @@
        u_char np;
        int i;
        int phase;
+       int major, minor;
 
        base = (struct isakmp *)bp;
        ep = (u_char *)snapend;
@@ -975,8 +976,13 @@
        }
 
        printf("isakmp");
-       if (vflag)
-               printf(" %d.%d", base->v_maj, base->v_min);
+       if (vflag) {
+               major = (base->vers & ISAKMP_VERS_MAJOR)
+                               >> ISAKMP_VERS_MAJOR_SHIFT;
+               minor = (base->vers & ISAKMP_VERS_MINOR)
+                               >> ISAKMP_VERS_MINOR_SHIFT;
+               printf(" %d.%d", major, minor);
+       }
 
        if (vflag) {
                printf(" msgid ");



Home | Main Index | Thread Index | Old Index