Added Tony Hart's <thart@avici.com> patch to dissect MD5 authentication
authorGilbert Ramirez <gram@alumni.rice.edu>
Tue, 19 Oct 1999 15:59:04 +0000 (15:59 -0000)
committerGilbert Ramirez <gram@alumni.rice.edu>
Tue, 19 Oct 1999 15:59:04 +0000 (15:59 -0000)
data in OSPF. (corrected copy)

svn path=/trunk/; revision=889

packet-ospf.c
packet-ospf.h

index 6848f4c01e50a636f6c4dc790752278ad6a0f3eb..d54aa920c9fbaf9c5bf745e3077bc4260a682691 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for OSPF packet disassembly
  * (c) Copyright Hannes R. Boehm <hannes@boehm.org>
  *
- * $Id: packet-ospf.c,v 1.13 1999/08/26 07:34:41 guy Exp $
+ * $Id: packet-ospf.c,v 1.14 1999/10/19 15:59:03 gram Exp $
  *
  * At this time, this module is able to analyze OSPF
  * packets as specified in RFC2328. MOSPF (RFC1584) and other
@@ -55,11 +55,13 @@ static int proto_ospf = -1;
 void 
 dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
     e_ospfhdr ospfh;
+    e_ospf_crypto *crypto;
+    int i, saved_len, ospflen;
 
     proto_tree *ospf_tree = NULL;
        proto_item *ti; 
     proto_tree *ospf_header_tree;
-    char auth_data[9]="";
+    char auth_data[(2 * 16) + 1]="";
     char *packet_type;
     static value_string pt_vals[] = { {OSPF_HELLO,   "Hello Packet"   },
                                       {OSPF_DB_DESC, "DB Descr."      },
@@ -116,8 +118,19 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
                 proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data: %s", auth_data);
                 break;
            case OSPF_AUTH_CRYPT:
+                 crypto = (e_ospf_crypto *)ospfh.auth_data;
                 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type: crypt");
-                proto_tree_add_text(ospf_header_tree, offset + 16 , 8, "Auth Data (crypt)");
+                 proto_tree_add_text(ospf_header_tree, offset + 18 , 1, "Auth Key ID: %d",
+                                     crypto->key_id);
+                 proto_tree_add_text(ospf_header_tree, offset + 19 , 1, "Auth Data Length: %d",
+                                     crypto->length);
+                 proto_tree_add_text(ospf_header_tree, offset + 20 , 4, "Auth Crypto Sequence Number: 0x%x",
+                                     ntohl(crypto->sequence_num));
+  
+                 ospflen = ntohs(ospfh.length);
+                 for (i = 0; i < crypto->length && i < (sizeof(auth_data)/2); i++)
+                     sprintf(&auth_data[i*2],"%02x",pd[offset + ospflen + i]);
+                 proto_tree_add_text(ospf_header_tree, offset + ospflen , 16, "Auth Data: %s", auth_data);
                 break;
             default:
                 proto_tree_add_text(ospf_header_tree, offset + 14 , 2, "Auth Type (unknown)");
@@ -126,8 +139,18 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
 
     }
 
+    /* Temporarily adjust the captured length to match the size of the OSPF
+     * packet (since the dissect routines use it to work out where the end of
+     * the ospf packet is).
+     */
+    saved_len = pi.captured_len;
+    if (BYTES_ARE_IN_FRAME(offset, ntohs(ospfh.length))) {
+      pi.captured_len = offset + ntohs(ospfh.length);
+    }
+
     /*  Skip over header */
     offset += OSPF_HEADER_LENGTH;
+
     switch(ospfh.packet_type){
        case OSPF_HELLO:
            dissect_ospf_hello(pd, offset, fd, ospf_tree); 
@@ -145,8 +168,10 @@ dissect_ospf(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
            dissect_ospf_ls_ack(pd, offset, fd, ospf_tree);
            break;
        default:
+            pi.captured_len = saved_len;
             dissect_data(pd, offset, fd, tree); 
     }
+    pi.captured_len = saved_len;
 }
 
 void
index 4661b7e27e8dd06379975cbfb94bea722379af26..8acbef40379a3bd04980340604a7a2a759e40af7 100644 (file)
@@ -1,6 +1,6 @@
 /* packet-ospf.h (c) 1998 Hannes Boehm */
 
-/* $Id: packet-ospf.h,v 1.4 1999/10/06 03:33:48 guy Exp $ */
+/* $Id: packet-ospf.h,v 1.5 1999/10/19 15:59:04 gram Exp $ */
 
 #define OSPF_HEADER_LENGTH     24
 
@@ -123,6 +123,13 @@ typedef struct _e_ospf_asexternal_lsa {
     guint32    external_tag;
 } e_ospf_asexternal_lsa;
 
+typedef struct _e_ospf_crypto {
+    guint16   mbz;
+    guint8      key_id;
+    guint8      length;
+    guint32   sequence_num;
+} e_ospf_crypto;
+
 
 void dissect_ospf_hello(const u_char*, int, frame_data*, proto_tree*);
 void dissect_ospf_db_desc(const u_char*, int, frame_data*, proto_tree*);