]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rx.c
More UNALIGNED_MEM{CPY,CMP} on IP addresses.
[tcpdump] / print-rx.c
index 02775d3a06ffdb63f02a1b9a12a46a0029fe2855..72c4822b8e18394f1cf482dbd234ab4552852b27 100644 (file)
  * Ken Hornstein <[email protected]>
  */
 
-#ifndef lint
-static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.41 2008-07-01 07:40:39 guy Exp $";
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -50,11 +45,89 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "extract.h"
 
-#include "rx.h"
-
 #include "ip.h"
 
-static struct tok rx_types[] = {
+#define FS_RX_PORT     7000
+#define CB_RX_PORT     7001
+#define PROT_RX_PORT   7002
+#define VLDB_RX_PORT   7003
+#define KAUTH_RX_PORT  7004
+#define VOL_RX_PORT    7005
+#define ERROR_RX_PORT  7006            /* Doesn't seem to be used */
+#define BOS_RX_PORT    7007
+
+#define AFSNAMEMAX 256
+#define AFSOPAQUEMAX 1024
+#define PRNAMEMAX 64
+#define VLNAMEMAX 65
+#define KANAMEMAX 64
+#define BOSNAMEMAX 256
+
+#define        PRSFS_READ              1 /* Read files */
+#define        PRSFS_WRITE             2 /* Write files */
+#define        PRSFS_INSERT            4 /* Insert files into a directory */
+#define        PRSFS_LOOKUP            8 /* Lookup files into a directory */
+#define        PRSFS_DELETE            16 /* Delete files */
+#define        PRSFS_LOCK              32 /* Lock files */
+#define        PRSFS_ADMINISTER        64 /* Change ACL's */
+
+struct rx_header {
+       u_int32_t epoch;
+       u_int32_t cid;
+       u_int32_t callNumber;
+       u_int32_t seq;
+       u_int32_t serial;
+       u_int8_t type;
+#define RX_PACKET_TYPE_DATA            1
+#define RX_PACKET_TYPE_ACK             2
+#define RX_PACKET_TYPE_BUSY            3
+#define RX_PACKET_TYPE_ABORT           4
+#define RX_PACKET_TYPE_ACKALL          5
+#define RX_PACKET_TYPE_CHALLENGE       6
+#define RX_PACKET_TYPE_RESPONSE                7
+#define RX_PACKET_TYPE_DEBUG           8
+#define RX_PACKET_TYPE_PARAMS          9
+#define RX_PACKET_TYPE_VERSION         13
+       u_int8_t flags;
+#define RX_CLIENT_INITIATED    1
+#define RX_REQUEST_ACK         2
+#define RX_LAST_PACKET         4
+#define RX_MORE_PACKETS                8
+#define RX_FREE_PACKET         16
+#define RX_SLOW_START_OK       32
+#define RX_JUMBO_PACKET                32
+       u_int8_t userStatus;
+       u_int8_t securityIndex;
+       u_int16_t spare;                /* How clever: even though the AFS */
+       u_int16_t serviceId;            /* header files indicate that the */
+};                                     /* serviceId is first, it's really */
+                                       /* encoded _after_ the spare field */
+                                       /* I wasted a day figuring that out! */
+
+#define NUM_RX_FLAGS 7
+
+#define RX_MAXACKS 255
+
+struct rx_ackPacket {
+       u_int16_t bufferSpace;          /* Number of packet buffers available */
+       u_int16_t maxSkew;              /* Max diff between ack'd packet and */
+                                       /* highest packet received */
+       u_int32_t firstPacket;          /* The first packet in ack list */
+       u_int32_t previousPacket;       /* Previous packet recv'd (obsolete) */
+       u_int32_t serial;               /* # of packet that prompted the ack */
+       u_int8_t reason;                /* Reason for acknowledgement */
+       u_int8_t nAcks;                 /* Number of acknowledgements */
+       u_int8_t acks[RX_MAXACKS];      /* Up to RX_MAXACKS acknowledgements */
+};
+
+/*
+ * Values for the acks array
+ */
+
+#define RX_ACK_TYPE_NACK       0       /* Don't have this packet */
+#define RX_ACK_TYPE_ACK                1       /* I have this packet */
+
+static const struct tok rx_types[] = {
        { RX_PACKET_TYPE_DATA,          "data" },
        { RX_PACKET_TYPE_ACK,           "ack" },
        { RX_PACKET_TYPE_BUSY,          "busy" },
@@ -68,7 +141,7 @@ static struct tok rx_types[] = {
        { 0,                            NULL },
 };
 
-static struct double_tok {
+static const struct double_tok {
        int flag;               /* Rx flag */
        int packetType;         /* Packet type */
        const char *s;          /* Flag string */
@@ -82,7 +155,7 @@ static struct double_tok {
        { RX_JUMBO_PACKET,      RX_PACKET_TYPE_DATA,    "jumbogram" }
 };
 
-static struct tok fs_req[] = {
+static const struct tok fs_req[] = {
        { 130,          "fetch-data" },
        { 131,          "fetch-acl" },
        { 132,          "fetch-status" },
@@ -127,7 +200,7 @@ static struct tok fs_req[] = {
        { 0,            NULL },
 };
 
-static struct tok cb_req[] = {
+static const struct tok cb_req[] = {
        { 204,          "callback" },
        { 205,          "initcb" },
        { 206,          "probe" },
@@ -149,7 +222,7 @@ static struct tok cb_req[] = {
        { 0,            NULL },
 };
 
-static struct tok pt_req[] = {
+static const struct tok pt_req[] = {
        { 500,          "new-user" },
        { 501,          "where-is-it" },
        { 502,          "dump-entry" },
@@ -176,7 +249,7 @@ static struct tok pt_req[] = {
        { 0,            NULL },
 };
 
-static struct tok vldb_req[] = {
+static const struct tok vldb_req[] = {
        { 501,          "create-entry" },
        { 502,          "delete-entry" },
        { 503,          "get-entry-by-id" },
@@ -214,7 +287,7 @@ static struct tok vldb_req[] = {
        { 0,            NULL },
 };
 
-static struct tok kauth_req[] = {
+static const struct tok kauth_req[] = {
        { 1,            "auth-old" },
        { 21,           "authenticate" },
        { 22,           "authenticate-v2" },
@@ -236,7 +309,7 @@ static struct tok kauth_req[] = {
        { 0,            NULL },
 };
 
-static struct tok vol_req[] = {
+static const struct tok vol_req[] = {
        { 100,          "create-volume" },
        { 101,          "delete-volume" },
        { 102,          "restore" },
@@ -272,7 +345,7 @@ static struct tok vol_req[] = {
        { 0,            NULL },
 };
 
-static struct tok bos_req[] = {
+static const struct tok bos_req[] = {
        { 80,           "create-bnode" },
        { 81,           "delete-bnode" },
        { 82,           "set-status" },
@@ -313,7 +386,7 @@ static struct tok bos_req[] = {
        { 0,            NULL },
 };
 
-static struct tok ubik_req[] = {
+static const struct tok ubik_req[] = {
        { 10000,        "vote-beacon" },
        { 10001,        "vote-debug-old" },
        { 10002,        "vote-sdebug-old" },
@@ -344,14 +417,14 @@ static struct tok ubik_req[] = {
 #define DISK_LOW       20000
 #define DISK_HIGH      20013
 
-static struct tok cb_types[] = {
+static const struct tok cb_types[] = {
        { 1,            "exclusive" },
        { 2,            "shared" },
        { 3,            "dropped" },
        { 0,            NULL },
 };
 
-static struct tok ubik_lock_types[] = {
+static const struct tok ubik_lock_types[] = {
        { 1,            "read" },
        { 2,            "write" },
        { 3,            "wait" },
@@ -360,7 +433,7 @@ static struct tok ubik_lock_types[] = {
 
 static const char *voltype[] = { "read-write", "read-only", "backup" };
 
-static struct tok afs_fs_errors[] = {
+static const struct tok afs_fs_errors[] = {
        { 101,          "salvage volume" },
        { 102,          "no such vnode" },
        { 103,          "no such volume" },
@@ -381,7 +454,7 @@ static struct tok afs_fs_errors[] = {
  * Reasons for acknowledging a packet
  */
 
-static struct tok rx_ack_reasons[] = {
+static const struct tok rx_ack_reasons[] = {
        { 1,            "ack requested" },
        { 2,            "duplicate packet" },
        { 3,            "out of sequence" },
@@ -653,7 +726,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
                        *opcode = rxent->opcode;
                        return(1);
                }
-               if (++i > RX_CACHE_SIZE)
+               if (++i >= RX_CACHE_SIZE)
                        i = 0;
        } while (i != rx_cache_hint);
 
@@ -707,7 +780,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
                        TCHECK2(bp[0], sizeof(u_int64_t)); \
                        i = EXTRACT_64BITS(bp); \
                        bp += sizeof(u_int64_t); \
-                       printf(" " PRIu64, i); \
+                       printf(" %" PRIu64, i); \
                }
 
 #define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
@@ -2261,7 +2334,7 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
                                                printf(" <none!>");
                                }
                                break;
-                               
+
 
                        default:
                                ;