Support for the new restart TLV, from Hannes Gredler.
[obnox/wireshark/wip.git] / packet-kerberos.c
index fea11c6839d0e53d926c143539e2933fe4d96efe..e6da1efcce3d51d28566fa2d8be37c77c15d37ee 100644 (file)
@@ -3,11 +3,11 @@
  * Wes Hardaker (c) 2000
  * wjhardaker@ucdavis.edu
  *
- * $Id: packet-kerberos.c,v 1.16 2001/04/15 08:50:37 guy Exp $
+ * $Id: packet-kerberos.c,v 1.20 2002/01/21 07:36:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * Copyright 1998 Didier Jorand
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -38,9 +38,9 @@
 
 #include <glib.h>
 
-#include "packet.h"
+#include <epan/packet.h>
 
-#include "strutil.h"
+#include <epan/strutil.h>
 
 #include "asn1.h"
 
@@ -395,14 +395,14 @@ krb_proto_tree_add_time(proto_tree *tree, tvbuff_t *tvb, int offset,
    start = asn1p->offset; \
    ret = asn1_header_decode (asn1p, &cls, &con, &tag, &def, &item_len); \
    if (ret != ASN1_ERR_NOERROR) {\
-       if (check_col(pinfo->fd, COL_INFO)) \
-           col_add_fstr(pinfo->fd, COL_INFO, "ERROR: Problem at %s: %s", \
+       if (check_col(pinfo->cinfo, COL_INFO)) \
+           col_add_fstr(pinfo->cinfo, COL_INFO, "ERROR: Problem at %s: %s", \
                     token, to_error_str(ret)); \
        return -1; \
    } \
    if (!def) {\
-       if (check_col(pinfo->fd, COL_INFO)) \
-           col_add_fstr(pinfo->fd, COL_INFO, "not definite: %s", token); \
+       if (check_col(pinfo->cinfo, COL_INFO)) \
+           col_add_fstr(pinfo->cinfo, COL_INFO, "not definite: %s", token); \
        fprintf(stderr,"not definite: %s\n", token); \
        return -1; \
    } \
@@ -424,8 +424,8 @@ krb_proto_tree_add_time(proto_tree *tree, tvbuff_t *tvb, int offset,
 
 #define DIE_WITH_BAD_TYPE(token, expected_tag) \
     { \
-      if (check_col(pinfo->fd, COL_INFO)) \
-         col_add_fstr(pinfo->fd, COL_INFO, "ERROR: Problem at %s: %s (tag=%d exp=%d)", \
+      if (check_col(pinfo->cinfo, COL_INFO)) \
+         col_add_fstr(pinfo->cinfo, COL_INFO, "ERROR: Problem at %s: %s (tag=%d exp=%d)", \
                       token, to_error_str(ASN1_ERR_WRONG_TYPE), tag, expected_tag); \
       return -1; \
     }
@@ -441,8 +441,8 @@ krb_proto_tree_add_time(proto_tree *tree, tvbuff_t *tvb, int offset,
 #define KRB_SEQ_HEAD_DECODE_OR_DIE(token) \
    ret = asn1_sequence_decode (asn1p, &item_len, &header_len); \
    if (ret != ASN1_ERR_NOERROR) {\
-       if (check_col(pinfo->fd, COL_INFO)) \
-           col_add_fstr(pinfo->fd, COL_INFO, "ERROR: Problem at %s: %s", \
+       if (check_col(pinfo->cinfo, COL_INFO)) \
+           col_add_fstr(pinfo->cinfo, COL_INFO, "ERROR: Problem at %s: %s", \
                     token, to_error_str(ret)); \
        return -1; \
    } \
@@ -451,8 +451,8 @@ krb_proto_tree_add_time(proto_tree *tree, tvbuff_t *tvb, int offset,
 #define KRB_DECODE_OR_DIE(token, fn, val) \
     ret = fn (asn1p, &val, &length); \
     if (ret != ASN1_ERR_NOERROR) { \
-       if (check_col(pinfo->fd, COL_INFO)) \
-         col_add_fstr(pinfo->fd, COL_INFO, "ERROR: Problem at %s: %s", \
+       if (check_col(pinfo->cinfo, COL_INFO)) \
+         col_add_fstr(pinfo->cinfo, COL_INFO, "ERROR: Problem at %s: %s", \
                      token, to_error_str(ret)); \
         return -1; \
     } \
@@ -463,8 +463,8 @@ krb_proto_tree_add_time(proto_tree *tree, tvbuff_t *tvb, int offset,
 #define KRB_DECODE_STRING_OR_DIE(token, expected_tag, val, val_len, item_len) \
     ret = asn1_string_decode (asn1p, &val, &val_len, &item_len, expected_tag); \
     if (ret != ASN1_ERR_NOERROR) { \
-       if (check_col(pinfo->fd, COL_INFO)) \
-         col_add_fstr(pinfo->fd, COL_INFO, "ERROR: Problem at %s: %s", \
+       if (check_col(pinfo->cinfo, COL_INFO)) \
+         col_add_fstr(pinfo->cinfo, COL_INFO, "ERROR: Problem at %s: %s", \
                      token, to_error_str(ret)); \
         return -1; \
     }
@@ -548,10 +548,11 @@ dissect_kerberos_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     ASN1_SCK asn1, *asn1p = &asn1;
     proto_item *item = NULL;
 
-    guint length;
+    gint length;
     guint cls, con, tag;
     gboolean def;
-    guint item_len, total_len;
+    gint item_len;
+    guint total_len;
     int start, end, message_end, sequence_end;
 
     int ret;
@@ -606,8 +607,8 @@ dissect_kerberos_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     }
     offset += length;
 
-    if (check_col(pinfo->fd, COL_INFO))
-        col_add_str(pinfo->fd, COL_INFO, val_to_str(msg_type, krb5_msg_types,
+    if (check_col(pinfo->cinfo, COL_INFO))
+        col_add_str(pinfo->cinfo, COL_INFO, val_to_str(msg_type, krb5_msg_types,
                                              "Unknown msg type %#x"));
 
         /* is preauthentication present? */
@@ -1024,8 +1025,8 @@ dissect_kerberos_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 static void
 dissect_kerberos(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-        col_set_str(pinfo->fd, COL_PROTOCOL, "KRB5");
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+        col_set_str(pinfo->cinfo, COL_PROTOCOL, "KRB5");
 
     dissect_kerberos_main(tvb, pinfo, tree);
 }
@@ -1263,11 +1264,12 @@ dissect_Ticket(char *title, ASN1_SCK *asn1p, packet_info *pinfo,
 
     int start;
     guint cls, con, tag;
-    guint header_len, item_len, total_len;
+    guint header_len, total_len;
+    gint item_len;
     int ret;
 
     proto_item *item = NULL;
-    guint length;
+    gint length;
     gboolean def;
     guint32 val;
 
@@ -1352,10 +1354,11 @@ proto_register_kerberos(void) {
 void
 proto_reg_handoff_kerberos(void)
 {
-    dissector_add("udp.port", UDP_PORT_KERBEROS, dissect_kerberos,
-       proto_kerberos);
-    dissector_add("tcp.port", TCP_PORT_KERBEROS, dissect_kerberos,
-       proto_kerberos);
+    dissector_handle_t kerberos_handle;
+
+    kerberos_handle = create_dissector_handle(dissect_kerberos, proto_kerberos);
+    dissector_add("udp.port", UDP_PORT_KERBEROS, kerberos_handle);
+    dissector_add("tcp.port", TCP_PORT_KERBEROS, kerberos_handle);
 }
 
 /*