Re: tcpdump: print some more info about md5 auth in ospf

2019-04-11 Thread Alexander Bluhm
On Thu, Apr 11, 2019 at 08:28:37AM +1000, David Gwynne wrote:
> seeing the key-id in particular helped me debug a problem here.
>
> ok?

OK bluhm@

> Index: ospf.h
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/ospf.h,v
> retrieving revision 1.10
> diff -u -p -r1.10 ospf.h
> --- ospf.h4 Aug 2010 16:47:01 -   1.10
> +++ ospf.h10 Apr 2019 22:27:29 -
> @@ -220,6 +220,13 @@ struct ospfhdr {
>  } ospf_un ;
>  } ;
>
> +struct ospf_md5_authdata {
> + uint16_tauth_md5_offset;
> + uint8_t auth_keyid;
> + uint8_t auth_len;
> + uint32_tauth_seq;
> +};
> +
>  #define  ospf_hello  ospf_un.un_hello
>  #define  ospf_db ospf_un.un_db
>  #define  ospf_lsrospf_un.un_lsr
> Index: print-ospf.c
> ===
> RCS file: /cvs/src/usr.sbin/tcpdump/print-ospf.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 print-ospf.c
> --- print-ospf.c  16 Nov 2015 00:16:39 -  1.20
> +++ print-ospf.c  10 Apr 2019 22:27:29 -
> @@ -32,6 +32,7 @@
>
>  #include 
>  #include 
> +#include 
>
>  #include "interface.h"
>  #include "addrtoname.h"
> @@ -554,9 +555,20 @@ ospf_print(const u_char *bp, u_int lengt
>   printf("\"");
>   break;
>
> - case OSPF_AUTH_MD5:
> - printf(" auth MD5");
> + case OSPF_AUTH_MD5: {
> + struct ospf_md5_authdata auth;
> + memcpy(, op->ospf_authdata, sizeof(auth));
> +
> + printf(" auth MD5 key-id %u", auth.auth_keyid);
> + if (vflag)
> + printf(" seq %u", ntohl(auth.auth_seq));
> + if (vflag > 1) {
> + printf(" off %u len %u",
> + ntohs(auth.auth_md5_offset),
> + auth.auth_len);
> + }
>   break;
> + }
>
>   default:
>   printf(" ??authtype-%d??", ntohs(op->ospf_authtype));



tcpdump: print some more info about md5 auth in ospf

2019-04-10 Thread David Gwynne
seeing the key-id in particular helped me debug a problem here.

ok?

Index: ospf.h
===
RCS file: /cvs/src/usr.sbin/tcpdump/ospf.h,v
retrieving revision 1.10
diff -u -p -r1.10 ospf.h
--- ospf.h  4 Aug 2010 16:47:01 -   1.10
+++ ospf.h  10 Apr 2019 22:27:29 -
@@ -220,6 +220,13 @@ struct ospfhdr {
 } ospf_un ;
 } ;
 
+struct ospf_md5_authdata {
+   uint16_tauth_md5_offset;
+   uint8_t auth_keyid;
+   uint8_t auth_len;
+   uint32_tauth_seq;
+};
+
 #defineospf_hello  ospf_un.un_hello
 #defineospf_db ospf_un.un_db
 #defineospf_lsrospf_un.un_lsr
Index: print-ospf.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-ospf.c,v
retrieving revision 1.20
diff -u -p -r1.20 print-ospf.c
--- print-ospf.c16 Nov 2015 00:16:39 -  1.20
+++ print-ospf.c10 Apr 2019 22:27:29 -
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -554,9 +555,20 @@ ospf_print(const u_char *bp, u_int lengt
printf("\"");
break;
 
-   case OSPF_AUTH_MD5:
-   printf(" auth MD5");
+   case OSPF_AUTH_MD5: {
+   struct ospf_md5_authdata auth;
+   memcpy(, op->ospf_authdata, sizeof(auth));
+
+   printf(" auth MD5 key-id %u", auth.auth_keyid);
+   if (vflag)
+   printf(" seq %u", ntohl(auth.auth_seq));
+   if (vflag > 1) {
+   printf(" off %u len %u",
+   ntohs(auth.auth_md5_offset),
+   auth.auth_len);
+   }
break;
+   }
 
default:
printf(" ??authtype-%d??", ntohs(op->ospf_authtype));