]> The Tcpdump Group git mirrors - tcpdump/commitdiff
added ESP-in-UDP printer from RFC3948.
authormcr <mcr>
Wed, 6 Apr 2005 21:33:27 +0000 (21:33 +0000)
committermcr <mcr>
Wed, 6 Apr 2005 21:33:27 +0000 (21:33 +0000)
interface.h
netdissect.h
print-isakmp.c
print-udp.c
udp.h

index c67e6a6a79ba548faed9b41dc489fdb121f5dbea..ae535f43e9f3ae3d06041c09ada02f915ccda400 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.243 2005-03-08 08:52:38 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244 2005-04-06 21:33:27 mcr Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -205,7 +205,6 @@ extern void gre_print(const u_char *, u_int);
 extern void icmp_print(const u_char *, u_int, const u_char *, int);
 extern void igmp_print(const u_char *, u_int);
 extern void igrp_print(const u_char *, u_int, const u_char *);
-extern void ip_print(const u_char *, u_int);
 extern void ipN_print(const u_char *, u_int);
 extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
 extern void ipx_print(const u_char *, u_int);
@@ -260,7 +259,6 @@ extern void timed_print(const u_char *);
 extern void udp_print(const u_char *, u_int, const u_char *, int);
 extern void wb_print(const void *, u_int);
 extern int ah_print(register const u_char *);
-extern void isakmp_print(const u_char *, u_int, const u_char *);
 extern int ipcomp_print(register const u_char *, int *);
 extern void rx_print(register const u_char *, int, int, int, u_char *);
 extern void netbeui_print(u_short, const u_char *, int);
index ab4dae61d705e7ca15023811e8a1756411bc7c2c..43ad4291718f6a76bbdc5a512987c1a1ffb19939 100644 (file)
@@ -21,7 +21,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.14 2004-12-30 03:36:51 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.15 2005-04-06 21:33:27 mcr Exp $ (LBL)
  */
 
 #ifndef netdissect_h
@@ -250,6 +250,11 @@ extern int esp_print(netdissect_options *,
                     register const u_char *bp, int len, register const u_char *bp2,
                     int *nhdr, int *padlen);
 extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
+extern void isakmp_print(netdissect_options *,const u_char *,
+                        u_int, const u_char *);
+extern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
+                                u_int, const u_char *);
+extern void ip_print(netdissect_options *,const u_char *, u_int);
 
 #if 0
 extern void ascii_print_with_offset(netdissect_options *, const char *,
@@ -301,7 +306,6 @@ extern void igmp_print(netdissect_options *,
                       register const u_char *, u_int);
 extern void igrp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
-extern void ip_print(netdissect_options *,const u_char *, u_int);
 extern void ipN_print(netdissect_options *,const u_char *, u_int);
 extern void ipx_print(netdissect_options *,const u_char *, u_int);
 extern void isoclns_print(netdissect_options *,const u_char *,
@@ -374,8 +378,6 @@ extern void wb_print(netdissect_options *,const void *, u_int);
 extern int ah_print(netdissect_options *,register const u_char *,
                    register const u_char *);
 extern void esp_print_decodesecret(netdissect_options *ndo);
-extern void isakmp_print(netdissect_options *,const u_char *,
-                        u_int, const u_char *);
 extern int ipcomp_print(netdissect_options *,register const u_char *,
                        register const u_char *, int *);
 extern void rx_print(netdissect_options *,register const u_char *,
index 6368cf5626b0ef135e8b2432e42b5c2529161af8..a3cbbac0b9e547b043e7d3aed79b8cf55bd084e3 100644 (file)
@@ -30,7 +30,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.49 2004-11-04 07:49:14 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.50 2005-04-06 21:33:27 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -1096,8 +1096,9 @@ isakmp_n_print(const struct isakmp_gen *ext, u_int item_len,
                        break;
                default:
                        /* NULL is dummy */
-                       isakmp_print(cp, item_len - sizeof(*p) - n.spi_size,
-                               NULL);
+                       isakmp_print(gndo, cp,
+                                    item_len - sizeof(*p) - n.spi_size,
+                                    NULL);
                }
                printf(")");
        }
@@ -1273,7 +1274,9 @@ safememcpy(void *p, const void *q, size_t l)
 }
 
 void
-isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
+isakmp_print(netdissect_options *ndo,
+            const u_char *bp, u_int length,
+            const u_char *bp2)
 {
        const struct isakmp *p;
        struct isakmp base;
@@ -1284,7 +1287,7 @@ isakmp_print(const u_char *bp, u_int length, const u_char *bp2)
        int major, minor;
 
        p = (const struct isakmp *)bp;
-       ep = snapend;
+       ep = ndo->ndo_snapend;
 
        if ((struct isakmp *)ep < p + 1) {
                printf("[|isakmp]");
@@ -1383,3 +1386,51 @@ done:
                }
        }
 }
+
+void
+isakmp_rfc3948_print(netdissect_options *ndo,
+                    const u_char *bp, u_int length,
+                    const u_char *bp2)
+{
+       const u_char *ep;
+       ep = ndo->ndo_snapend;
+
+       if(length == 1 && bp[0]==0xff) {
+               ND_PRINT((ndo, "isakmp-nat-keep-alive"));
+               return;
+       }
+
+       ND_TCHECK2(bp, 4);
+
+       /*
+        * see if this is an IKE packet
+        */
+       if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {
+               isakmp_print(ndo, bp+4, length-4, bp2);
+               return;
+       }
+
+       /* must be an ESP packet */
+       {
+               int nh, enh, padlen;
+               int advance;
+
+               advance = esp_print(ndo, bp, length, bp2, &enh, &padlen);
+               if(advance <= 0)
+                       return;
+
+               bp += advance;
+               length -= advance + padlen;
+               nh = enh & 0xff;
+            
+               /* now need to jump into ip_print(). */
+               return;
+       }
+
+trunc:
+       printf("[|isakmp]");
+       return;
+}
+
+  
+
index 1cd16f6064aade49f217492be69437504e7de95a..867c2b6e92f196d0d900df656585cde9dcd4f3f7 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.136 2004-12-27 01:13:44 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.137 2005-04-06 21:33:28 mcr Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -615,11 +615,11 @@ udp_print(register const u_char *bp, u_int length,
 #else
                            0);
 #endif
-               else if (ISPORT(ISAKMP_PORT))
-                       isakmp_print((const u_char *)(up + 1), length, bp2);
+               else if (ISPORT(ISAKMP_PORT) || ISPORT(ISAKMP_PORT_NATT))
+                        isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
 #if 1 /*???*/
-               else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
-                       isakmp_print((const u_char *)(up + 1), length, bp2);
+               else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+                       isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
 #endif
                else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
                        snmp_print((const u_char *)(up + 1), length);
@@ -690,3 +690,12 @@ udp_print(register const u_char *bp, u_int length,
        } else
                (void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
 }
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+
diff --git a/udp.h b/udp.h
index 490645bb9b82acbe3da7d29818d6b7d421f35b46..7446c37b4401175a5c88f7c5c4e1890fae9c8fbc 100644 (file)
--- a/udp.h
+++ b/udp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.7 2004-07-27 17:04:21 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.8 2005-04-06 21:33:28 mcr Exp $ (LBL) */
 /*
  * Copyright (c) 1982, 1986, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -60,6 +60,7 @@ struct udphdr {
 #define KERBEROS_SEC_PORT 750  /*XXX*/
 #define L2TP_PORT 1701         /*XXX*/
 #define SIP_PORT 5060
+#define ISAKMP_PORT_NATT  4500  /* rfc3948 */
 #define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/
 #define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/
 #define RX_PORT_LOW 7000       /*XXX*/