Michael Richardson <[EMAIL PROTECTED]> writes:

> >>>>> "Bill" == Bill Fenner <[EMAIL PROTECTED]> writes:
>     Bill> Actually, with all the recent brouhaha over licenses, do we really
>     Bill> want to add more advertising clasues?  Does "this software" mean
>     Bill> "print-vrrp.c" or "tcpdump"?
> 
>   New code should take "LICENSE" file as template right?

Just speaking about this particular case, when I initially wrote my
version of print-vrrp.c I had missed its availability in the
tcpdump.org repository, and when committing it to the NetBSD
repository to have it tested out there I decided to contribute it to
The NetBSD Foundation using their template...

Anyway, here's a small diff that improves the plain text output for
VRRP somewhat to the extent it had in NetBSD; I'm also avoiding
control characters in the auth-simple output, like print-ospf.c
already does.


- Klaus

Index: print-vrrp.c
===================================================================
RCS file: /tcpdump/master/tcpdump/print-vrrp.c,v
retrieving revision 1.3
diff -u -r1.3 print-vrrp.c
--- print-vrrp.c        2000/10/10 05:05:08     1.3
+++ print-vrrp.c        2001/07/19 15:15:42
@@ -64,30 +64,47 @@
  *    |                     Authentication Data (2)                   |
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
+
+/* Type */
+#define        VRRP_TYPE_ADVERTISEMENT 1
+
+static const struct tok type2str[] = {
+       { VRRP_TYPE_ADVERTISEMENT,      "advertisement" },
+       { 0,                            NULL            }
+};
+
+/* Auth Type */
+#define        VRRP_AUTH_NONE          0
+#define        VRRP_AUTH_SIMPLE        1
+#define        VRRP_AUTH_AH            2
+
+static const struct tok auth2str[] = {
+       { VRRP_AUTH_NONE,               "none"          },
+       { VRRP_AUTH_SIMPLE,             "simple"        },
+       { VRRP_AUTH_AH,                 "ah"            },
+       { 0,                            NULL            }
+};
+
 void
 vrrp_print(register const u_char *bp, register u_int len, int ttl)
 {
        int version, type, auth_type;
-       char *type_s;
+       const char *type_s;
 
        TCHECK(bp[0]);
        version = (bp[0] & 0xf0) >> 4;
        type = bp[0] & 0x0f;
-       if (type == 1)
-               type_s = "advertise";
-       else
-               type_s = "unknown";
+       type_s = tok2str(type2str, "type#%d", type);
        printf("VRRPv%d-%s %d: ", version, type_s, len);
        if (ttl != 255)
                printf("[ttl=%d!] ", ttl);
-       if (version != 2 || type != 1)
+       if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
                return;
        TCHECK(bp[2]);
        printf("vrid=%d prio=%d", bp[1], bp[2]);
        TCHECK(bp[5]);
        auth_type = bp[4];
-       if (auth_type != 0)
-               printf(" authtype=%d", auth_type);
+       printf(" authtype=%s", tok2str(auth2str, NULL, auth_type));
        printf(" intvl=%d", bp[5]);
        if (vflag) {
                int naddrs = bp[3];
@@ -109,9 +126,11 @@
                        c = ',';
                        bp += 4;
                }
-               if (auth_type == 1) { /* simple text password */
+               if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
                        TCHECK(bp[7]);
-                       printf(" auth %.8s", bp);
+                       printf(" auth \"");
+                       fn_printn(bp, bp[7] - bp[0] + 1, NULL);
+                       printf("\"");
                }
        }
        return;

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

Reply via email to