]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-igrp.c
More UNALIGNED_MEM{CPY,CMP} on IP addresses.
[tcpdump] / print-igrp.c
index 4b687033322c663536266aea89333798491a12f6..fb3228cd0b5ea514be55c3bba0aa0116da15c4d6 100644 (file)
  * Initial contribution from Francis Dupont ([email protected])
  */
 
-#ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.8 1999-10-07 23:47:11 mcr Exp $ (LBL)";
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
-#include <sys/param.h>
-#include <sys/types.h>                 /* concession to AIX */
-#include <sys/socket.h>
+#include <tcpdump-stdinc.h>
 
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_var.h>
-#include <netinet/udp.h>
-#include <netinet/udp_var.h>
-
-#include <errno.h>
 #include <stdio.h>
 
 #include "interface.h"
 #include "addrtoname.h"
-#include "igrp.h"
+#include "ip.h"
 #include "extract.h"                   /* must come after interface.h */
 
+/* Cisco IGRP definitions */
+
+/* IGRP Header */
+
+struct igrphdr {
+       u_int8_t ig_vop;        /* protocol version number / opcode */
+#define IGRP_V(x)      (((x) & 0xf0) >> 4)
+#define IGRP_OP(x)     ((x) & 0x0f)
+       u_int8_t ig_ed;         /* edition number */
+       u_int16_t ig_as;        /* autonomous system number */
+       u_int16_t ig_ni;        /* number of subnet in local net */
+       u_int16_t ig_ns;        /* number of networks in AS */
+       u_int16_t ig_nx;        /* number of networks ouside AS */
+       u_int16_t ig_sum;       /* checksum of IGRP header & data */
+};
+
+#define IGRP_UPDATE    1
+#define IGRP_REQUEST   2
+
+/* IGRP routing entry */
+
+struct igrprte {
+       u_int8_t igr_net[3];    /* 3 significant octets of IP address */
+       u_int8_t igr_dly[3];    /* delay in tens of microseconds */
+       u_int8_t igr_bw[3];     /* bandwidth in units of 1 kb/s */
+       u_int8_t igr_mtu[2];    /* MTU in octets */
+       u_int8_t igr_rel;       /* percent packets successfully tx/rx */
+       u_int8_t igr_ld;        /* percent of channel occupied */
+       u_int8_t igr_hct;       /* hop count */
+};
+
+#define IGRP_RTE_SIZE  14      /* don't believe sizeof ! */
+
 static void
 igrp_entry_print(register struct igrprte *igr, register int is_interior,
     register int is_exterior)
@@ -75,26 +97,22 @@ igrp_entry_print(register struct igrprte *igr, register int is_interior,
            mtu, igr->igr_hct);
 }
 
-static struct tok op2str[] = {
+static const struct tok op2str[] = {
        { IGRP_UPDATE,          "update" },
        { IGRP_REQUEST,         "request" },
        { 0,                    NULL }
 };
 
 void
-igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
+igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
 {
        register struct igrphdr *hdr;
-       register struct ip *ip;
        register u_char *cp;
        u_int nint, nsys, next;
 
        hdr = (struct igrphdr *)bp;
-       ip = (struct ip *)bp2;
        cp = (u_char *)(hdr + 1);
-        (void)printf("%s > %s: igrp: ",
-           ipaddr_string(&ip->ip_src),
-           ipaddr_string(&ip->ip_dst));
+        (void)printf("igrp:");
 
        /* Header */
        TCHECK(*hdr);
@@ -103,8 +121,8 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
        next = EXTRACT_16BITS(&hdr->ig_nx);
 
        (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
-           tok2str(op2str, "op-#%d", hdr->ig_op),
-           hdr->ig_v,
+           tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
+           IGRP_V(hdr->ig_vop),
            hdr->ig_ed,
            EXTRACT_16BITS(&hdr->ig_as),
            nint,
@@ -126,7 +144,7 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
                        igrp_entry_print((struct igrprte *)cp, 0, 1);
                        --next;
                } else {
-                       (void)printf("[extra bytes %d]", length);
+                       (void)printf(" [extra bytes %d]", length);
                        break;
                }
                cp += IGRP_RTE_SIZE;
@@ -135,5 +153,5 @@ igrp_print(register const u_char *bp, u_int length, register const u_char *bp2)
        if (nint == 0 && nsys == 0 && next == 0)
                return;
 trunc:
-       fputs("[|igrp]", stdout);
+       fputs(" [|igrp]", stdout);
 }