* Laurent Deniel <laurent.deniel@free.fr>
* Ralf Schneider <Ralf.Schneider@t-online.de>
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
#include <epan/packet.h>
#include <epan/reassemble.h>
#include <epan/emem.h>
+#include "packet-frame.h"
#include "packet-osi.h"
#include "packet-osi-options.h"
#include "packet-isis.h"
*/
static GHashTable *cotp_segment_table = NULL;
static GHashTable *cotp_reassembled_table = NULL;
+static guint16 cotp_dst_ref = 0;
#define TSAP_DISPLAY_AUTO 0
#define TSAP_DISPLAY_STRING 1
/* function definitions */
#define MAX_TSAP_LEN 32
+
+static void cotp_frame_end(void)
+{
+ cotp_dst_ref = 0;
+}
+
static gboolean is_all_printable(const guchar *stringtocheck, int length)
{
gboolean allprintable;
{
gchar *cur;
- gchar tmp[3];
gboolean allprintable;
+ size_t index = 0, returned_length;
cur=ep_alloc(MAX_TSAP_LEN * 2 + 3);
cur[0] = '\0';
g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "<unsupported TSAP length>");
else {
allprintable = is_all_printable(tsap,length);
- if (!allprintable)
- strcat(cur,"0x");
+ if (!allprintable) {
+ returned_length = g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "0x");
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - 1);
+ }
while (length != 0) {
- if (allprintable)
- g_snprintf(tmp, sizeof(tmp), "%c", *tsap ++);
- else
- g_snprintf(tmp, sizeof(tmp), "%02x", *tsap ++);
- strcat(cur, tmp);
+ if (allprintable) {
+ returned_length = g_snprintf(&cur[index], MAX_TSAP_LEN * 2 + 3 - index, "%c", *tsap ++);
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - index - 1 );
+ } else {
+ returned_length = g_snprintf(&cur[index], MAX_TSAP_LEN * 2 + 3 - index, "%02x", *tsap ++);
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - index - 1);
+ }
length --;
}
}
fragment = TRUE;
is_extended = FALSE;
is_class_234 = FALSE;
- dst_ref = 0;
+ dst_ref = cotp_dst_ref;
break;
default : /* bad TPDU */
col_append_fstr(pinfo->cinfo, COL_INFO, "DT TPDU (%u) dst-ref: 0x%04x %s",
tpdu_nr,
dst_ref,
- (fragment)? "(fragment)" : "EOT");
+ (fragment)? "[COTP Fragment]" : "EOT");
} else {
col_append_fstr(pinfo->cinfo, COL_INFO, "DT TPDU (%u) %s",
tpdu_nr,
- (fragment)? "(fragment)" : "EOT");
+ (fragment)? "[COTP Fragment]" : "EOT");
}
}
pinfo, reassembled_tvb, &ti);
pinfo->fragmented = fragment;
next_tvb = reassembled_tvb;
+
+ cotp_dst_ref++;
+ register_frame_end_routine(cotp_frame_end);
}
}
if (fragment && reassembled_tvb == NULL) {
src_ref = tvb_get_ntohs(tvb, offset + P_SRC_REF);
- class_option = (tvb_get_guint8(tvb, offset + P_CLASS_OPTION) >> 4 ) & 0x0F;
- if (class_option > 4)
+ class_option = tvb_get_guint8(tvb, offset + P_CLASS_OPTION);
+ if (((class_option & 0xF0) >> 4) > 4) /* class 0..4 allowed */
return -1;
dst_ref = tvb_get_ntohs(tvb, offset + P_DST_REF);
if (tree) {
proto_tree_add_text(cotp_tree, tvb, offset, 1,
- "Class option: 0x%02x", class_option);
+ "Class: %1u", (class_option & 0xF0) >> 4);
+ proto_tree_add_text(cotp_tree, tvb, offset, 1,
+ "Option: %1u", (class_option & 0x0F));
}
offset += 1;
li -= 1;
{
fragment_table_init(&clnp_segment_table);
reassembled_table_init(&clnp_reassembled_table);
+ cotp_dst_ref = 0;
}
static void