Move the definition of the FROM_DCE bit in the "flags" field of a
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 9 Apr 2002 08:15:04 +0000 (08:15 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 9 Apr 2002 08:15:04 +0000 (08:15 +0000)
"struct x25_phdr" to "wiretap/wtap.h".

Have two X.25 dissectors, one of which assumes that there's a "struct
x25_phdr" pseudo-header and one of which doesn't; the former uses the
information in that pseudo-header to determine whether the packet is
DTE->DCE or DCE->DTE, and the latter assumes it has no clue whether the
packet is DTE->DCE or DCE->TDE.  Use the former one in the LAPB
dissector, and the latter one in the XOT dissector and in the LLC
dissector table.

In the X.25-over-TCP dissector, handle multiple X.25 packets per TCP
segment, and handle X.25 packets split across TCP segments.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5134 f5534014-38df-0310-8fa8-9805f1628bb7

packet-lapb.c
packet-v120.c
packet-x25.c
packet-xot.c
wiretap/i4btrace.c
wiretap/nettl.c
wiretap/ngsniffer.c
wiretap/radcom.c
wiretap/visual.c
wiretap/wtap.h

index 79e25b514706885dc93d6d200b1afedc61489560..f781a0c78b47f6a939cc85ea7948bfd992cb6f6d 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for lapb frame disassembly
  * Olivier Abad <oabad@cybercable.fr>
  *
- * $Id: packet-lapb.c,v 1.34 2002/01/24 09:20:49 guy Exp $
+ * $Id: packet-lapb.c,v 1.35 2002/04/09 08:15:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -37,8 +37,6 @@
 #include <epan/packet.h>
 #include "xdlc.h"
 
-#define FROM_DCE       0x80
-
 static int proto_lapb = -1;
 static int hf_lapb_address = -1;
 static int hf_lapb_control = -1;
@@ -46,7 +44,7 @@ static int hf_lapb_control = -1;
 static gint ett_lapb = -1;
 static gint ett_lapb_control = -1;
 
-static dissector_handle_t x25_handle;
+static dissector_handle_t x25_dir_handle;
 
 static void
 dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -108,7 +106,7 @@ dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     /* not end of frame ==> X.25 */
     if (tvb_reported_length(tvb) > 2) {
            next_tvb = tvb_new_subset(tvb, 2, -1, -1);
-           call_dissector(x25_handle, next_tvb, pinfo, tree);
+           call_dissector(x25_dir_handle, next_tvb, pinfo, tree);
     }
 }
 
@@ -143,9 +141,10 @@ proto_reg_handoff_lapb(void)
     dissector_handle_t lapb_handle;
 
     /*
-     * Get a handle for the X.25 dissector.
+     * Get a handle for the X.25 dissector; we will be getting an
+     * X.25 pseudo-header, so call the dissector that can handle it.
      */
-    x25_handle = find_dissector("x.25");
+    x25_dir_handle = find_dissector("x.25_dir");
 
     lapb_handle = find_dissector("lapb");
     dissector_add("wtap_encap", WTAP_ENCAP_LAPB, lapb_handle);
index 9d762020f888d0c431fe1f970181e7437889358a..f69fb70d041ee82a7fe5a1bf6d85c16964a20687 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for v120 frame disassembly
  * Bert Driehuis <driehuis@playbeing.org>
  *
- * $Id: packet-v120.c,v 1.24 2002/01/21 07:36:44 guy Exp $
+ * $Id: packet-v120.c,v 1.25 2002/04/09 08:15:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -37,8 +37,6 @@
 #include <epan/packet.h>
 #include "xdlc.h"
 
-#define FROM_DCE       0x80
-
 static int proto_v120 = -1;
 static int hf_v120_address = -1;
 static int hf_v120_control = -1;
index 3e0dfaee087246dfda5d4f7c21344c6f275dbdfa..953a9fbe9783daef4aabb958d218a2d85419665b 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for x25 packet disassembly
  * Olivier Abad <oabad@cybercable.fr>
  *
- * $Id: packet-x25.c,v 1.64 2002/01/24 09:20:53 guy Exp $
+ * $Id: packet-x25.c,v 1.65 2002/04/09 08:15:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
 #include "nlpid.h"
 #include "x264_prt_id.h"
 
-#define FROM_DCE                       0x80
+/*
+ * Direction of packet.
+ */
+typedef enum {
+       X25_FROM_DCE,           /* DCE->DTE */
+       X25_FROM_DTE,           /* DTE->DCE */
+       X25_UNKNOWN             /* direction unknown */
+} x25_dir_t;
 
 #define        X25_CALL_REQUEST                0x0B
 #define        X25_CALL_ACCEPTED               0x0F
@@ -1482,7 +1489,8 @@ static const value_string sharing_strategy_vals[] = {
 };
 
 static void
-dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_x25_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+    x25_dir_t dir)
 {
     proto_tree *x25_tree=0, *gfi_tree=0, *userdata_tree=0;
     proto_item *ti;
@@ -1494,6 +1502,7 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     gboolean toa;         /* TOA/NPI address format */
     guint16 bytes0_1;
     guint8 pkt_type;
+    char *short_name = NULL, *long_name = NULL;
     tvbuff_t *next_tvb;
     gboolean q_bit_set = FALSE;
 
@@ -1552,18 +1561,30 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
     switch (pkt_type) {
     case X25_CALL_REQUEST:
+        switch (dir) {
+
+       case X25_FROM_DCE:
+           short_name = "Inc. call";
+           long_name = "Incoming call";
+           break;
+
+       case X25_FROM_DTE:
+           short_name = "Call req.";
+           long_name = "Call request";
+           break;
+
+       case X25_UNKNOWN:
+           short_name = "Inc. call/Call req.";
+           long_name = "Incoming call/Call request";
+           break;
+       }
        if (check_col(pinfo->cinfo, COL_INFO))
-           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d",
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Inc. call"
-                                                                : "Call req." ,
-                    vc);
+           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d", short_name, vc);
        if (x25_tree) {
            proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb,
                    0, 2, bytes0_1);
            proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
-                   X25_CALL_REQUEST,
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Incoming call"
-                                                                : "Call request");
+                   X25_CALL_REQUEST, "%s", long_name);
        }
        localoffset = 3;
        if (localoffset < x25_pkt_len) /* calling/called addresses */
@@ -1789,17 +1810,29 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
        break;
     case X25_CALL_ACCEPTED:
+        switch (dir) {
+
+       case X25_FROM_DCE:
+           short_name = "Call conn.";
+           long_name = "Call connected";
+           break;
+
+       case X25_FROM_DTE:
+           short_name = "Call acc.";
+           long_name = "Call accepted";
+           break;
+
+       case X25_UNKNOWN:
+           short_name = "Call conn./Call acc.";
+           long_name = "Call connected/Call accepted";
+           break;
+       }
        if(check_col(pinfo->cinfo, COL_INFO))
-           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d",
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Call conn."
-                                                                : "Call acc." ,
-                   vc);
+           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d", short_name, vc);
        if (x25_tree) {
            proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
            proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
-                   X25_CALL_ACCEPTED,
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Call connected"
-                                                                : "Call accepted");
+                   X25_CALL_ACCEPTED, "%s", long_name);
        }
        localoffset = 3;
         if (localoffset < x25_pkt_len) /* calling/called addresses */
@@ -1816,10 +1849,25 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
        break;
     case X25_CLEAR_REQUEST:
+        switch (dir) {
+
+       case X25_FROM_DCE:
+           short_name = "Clear ind.";
+           long_name = "Clear indication";
+           break;
+
+       case X25_FROM_DTE:
+           short_name = "Clear req.";
+           long_name = "Clear request";
+           break;
+
+       case X25_UNKNOWN:
+           short_name = "Clear ind./Clear req.";
+           long_name = "Clear indication/Clear request";
+           break;
+       }
        if(check_col(pinfo->cinfo, COL_INFO)) {
-           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d %s - %s",
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Clear ind."
-                                                                : "Clear req." ,
+           col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d %s - %s", short_name,
                    vc, clear_code(tvb_get_guint8(tvb, 3)),
                    clear_diag(tvb_get_guint8(tvb, 4)));
        }
@@ -1827,9 +1875,7 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (x25_tree) {
            proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
            proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb,
-                   localoffset+2, 1, X25_CLEAR_REQUEST,
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Clear indication"
-                                                                : "Clear request");
+                   localoffset+2, 1, X25_CLEAR_REQUEST, "%s", long_name);
            proto_tree_add_text(x25_tree, tvb, 3, 1,
                    "Cause : %s", clear_code(tvb_get_guint8(tvb, 3)));
            proto_tree_add_text(x25_tree, tvb, 4, 1,
@@ -1887,20 +1933,33 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        localoffset = x25_pkt_len;
        break;
     case X25_RESET_REQUEST:
+        switch (dir) {
+
+       case X25_FROM_DCE:
+           short_name = "Reset ind.";
+           long_name = "Reset indication";
+           break;
+
+       case X25_FROM_DTE:
+           short_name = "Reset req.";
+           long_name = "Reset request";
+           break;
+
+       case X25_UNKNOWN:
+           short_name = "Reset ind./Reset req.";
+           long_name = "Reset indication/Reset request";
+           break;
+       }
        if(check_col(pinfo->cinfo, COL_INFO)) {
            col_add_fstr(pinfo->cinfo, COL_INFO, "%s VC:%d %s - Diag.:%d",
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Reset ind."
-                                                                : "Reset req.",
-                   vc, reset_code(tvb_get_guint8(tvb, 3)),
+                   short_name, vc, reset_code(tvb_get_guint8(tvb, 3)),
                    (int)tvb_get_guint8(tvb, 4));
        }
        x25_hash_add_proto_end(vc, pinfo->fd->abs_secs, pinfo->fd->abs_usecs);
        if (x25_tree) {
            proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
            proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
-                   X25_RESET_REQUEST,
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Reset indication"
-                                                                 : "Reset request");
+                   X25_RESET_REQUEST, "%s", long_name);
            proto_tree_add_text(x25_tree, tvb, 3, 1,
                    "Cause : %s", reset_code(tvb_get_guint8(tvb, 3)));
            proto_tree_add_text(x25_tree, tvb, 4, 1,
@@ -1919,18 +1978,32 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        localoffset = x25_pkt_len;
        break;
     case X25_RESTART_REQUEST:
+        switch (dir) {
+
+       case X25_FROM_DCE:
+           short_name = "Restart ind.";
+           long_name = "Restart indication";
+           break;
+
+       case X25_FROM_DTE:
+           short_name = "Restart req.";
+           long_name = "Restart request";
+           break;
+
+       case X25_UNKNOWN:
+           short_name = "Restart ind./Restart req.";
+           long_name = "Restart indication/Restart request";
+           break;
+       }
        if(check_col(pinfo->cinfo, COL_INFO)) {
            col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s - Diag.:%d",
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Restart ind."
-                                                                : "Restart req.",
+                   short_name,
                    restart_code(tvb_get_guint8(tvb, 3)),
                    (int)tvb_get_guint8(tvb, 3));
        }
        if (x25_tree) {
            proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
-                   X25_RESTART_REQUEST,
-                   (pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Restart indication"
-                                                                : "Restart request");
+                   X25_RESTART_REQUEST, "%s", long_name);
            proto_tree_add_text(x25_tree, tvb, 3, 1,
                    "Cause : %s", restart_code(tvb_get_guint8(tvb, 3)));
            proto_tree_add_text(x25_tree, tvb, 4, 1,
@@ -2175,6 +2248,31 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     call_dissector(data_handle, next_tvb, pinfo, tree);
 }
 
+/*
+ * X.25 dissector for use when "pinfo->pseudo_header" points to a
+ * "struct x25_phdr".
+ */
+static void
+dissect_x25_dir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    dissect_x25_common(tvb, pinfo, tree,
+       (pinfo->pseudo_header->x25.flags & FROM_DCE) ? X25_FROM_DCE :
+                                                      X25_FROM_DTE);
+}
+
+/*
+ * X.25 dissector for use when "pinfo->pseudo_header" doesn't point to a
+ * "struct x25_phdr".
+ */
+static void
+dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+    /*
+     * We don't know if this packet is DTE->DCE or DCE->DCE.
+     */
+    dissect_x25_common(tvb, pinfo, tree, X25_UNKNOWN);
+}
+
 void
 proto_register_x25(void)
 {
@@ -2256,6 +2354,7 @@ proto_register_x25(void)
        "X.25 secondary protocol identifier", FT_UINT8, BASE_HEX);
     register_heur_dissector_list("x.25", &x25_heur_subdissector_list);
 
+    register_dissector("x.25_dir", dissect_x25_dir, proto_x25);
     register_dissector("x.25", dissect_x25, proto_x25);
 
     /* Preferences */
index 72696e061caca43251d5b81985acfa8eefd11956..17b3451528d4e00ec3159336f0354097ed4f8a09 100644 (file)
@@ -1,9 +1,9 @@
 /* packet-xot.c
- * Routines for X25 over TCP dissection (RFC 1613)
+ * Routines for X.25 over TCP dissection (RFC 1613)
  *
  * Copyright 2000, Paul Ionescu        <paul@acorp.ro>
  *
- * $Id: packet-xot.c,v 1.9 2002/01/21 07:36:48 guy Exp $
+ * $Id: packet-xot.c,v 1.10 2002/04/09 08:15:02 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -35,6 +35,8 @@
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
+#include "packet-frame.h"
+#include "prefs.h"
 
 #define TCP_PORT_XOT 1998
 
@@ -44,39 +46,133 @@ static gint hf_xot_length = -1;
 
 static gint ett_xot = -1;
 
+/* desegmentation of X.25 over TCP */
+static gboolean xot_desegment = TRUE;
+
 static dissector_handle_t x25_handle;
 
 static void dissect_xot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
+  volatile int offset = 0;
+  int length_remaining;
+  guint16 version;
+  guint16 plen;
+  int length;
   proto_item *ti;
   proto_tree *xot_tree;
-  guint16 version,len;
   tvbuff_t   *next_tvb; 
-    
-  if (check_col(pinfo->cinfo, COL_PROTOCOL))
-      col_set_str(pinfo->cinfo, COL_PROTOCOL, "XOT");
-  if (check_col(pinfo->cinfo, COL_INFO))
-      col_clear(pinfo->cinfo, COL_INFO);
-
-  version = tvb_get_ntohs(tvb,0);
-  len     = tvb_get_ntohs(tvb,2);
-
-  if (check_col(pinfo->cinfo, COL_INFO)) 
-     col_add_fstr(pinfo->cinfo, COL_INFO, "XOT Version = %u, size = %u",version,len );
-
-  if (tree) {
-       
-      ti = proto_tree_add_protocol_format(tree, proto_xot, tvb, 0, 4, "X.25 over TCP");
-      xot_tree = proto_item_add_subtree(ti, ett_xot);
-     
-      proto_tree_add_uint(xot_tree, hf_xot_version, tvb, 0, 2, version);
-      proto_tree_add_uint(xot_tree, hf_xot_length, tvb, 2, 2, len);
 
+  while (tvb_reported_length_remaining(tvb, offset) != 0) {
+    length_remaining = tvb_length_remaining(tvb, offset);
+
+    /*
+     * Can we do reassembly?
+     */
+    if (xot_desegment && pinfo->can_desegment) {
+      /*
+       * Yes - is the X.25-over-TCP header split across segment boundaries?
+       */
+      if (length_remaining < 4) {
+       /*
+        * Yes.  Tell the TCP dissector where the data for this message
+        * starts in the data it handed us, and how many
+        * more bytes we need, and return.
+        */
+       pinfo->desegment_offset = offset;
+       pinfo->desegment_len = 4 - length_remaining;
+       return;
+      }
+    }
+
+    /*
+     * Get the length of the XOT packet.
+     */
+    version = tvb_get_ntohs(tvb, offset + 0);
+    if (version != 0)
+      return;
+    plen    = tvb_get_ntohs(tvb, offset + 2);
+
+    /*
+     * Can we do reassembly?
+     */
+    if (xot_desegment && pinfo->can_desegment) {
+      /*
+       * Yes - is the XOT packet split across segment boundaries?
+       */
+      if (length_remaining < plen + 4) {
+       /*
+        * Yes.  Tell the TCP dissector where the data for this message
+        * starts in the data it handed us, and how many more bytes we
+        * need, and return.
+        */
+       pinfo->desegment_offset = offset;
+       pinfo->desegment_len = (plen + 4) - length_remaining;
+       return;
+      }
+    }
+
+    /*
+     * Dissect the X.25-over-TCP packet.
+     *
+     * Catch the ReportedBoundsError exception; if this particular message
+     * happens to get a ReportedBoundsError exception, that doesn't mean
+     * that we should stop dissecting X.25-over-TCP messages within this
+     * frame or chunk of reassembled data.
+     *
+     * If it gets a BoundsError, we can stop, as there's nothing more to see,
+     * so we just re-throw it.
+     */
+    TRY {
+      if (check_col(pinfo->cinfo, COL_PROTOCOL))
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "XOT");
+      if (check_col(pinfo->cinfo, COL_INFO)) 
+       col_add_fstr(pinfo->cinfo, COL_INFO, "XOT Version = %u, size = %u",
+                    version,plen );
+
+      if (tree) {
+       ti = proto_tree_add_protocol_format(tree, proto_xot, tvb, offset, 4,
+                                           "X.25 over TCP");
+       xot_tree = proto_item_add_subtree(ti, ett_xot);
+     
+       proto_tree_add_uint(xot_tree, hf_xot_version, tvb, offset, 2, version);
+       proto_tree_add_uint(xot_tree, hf_xot_length, tvb, offset + 2, 2, plen);
+      }
+
+      /*
+       * Construct a tvbuff containing the amount of the payload we have
+       * available.  Make its reported length the amount of data in the
+       * X.25-over-TCP packet.
+       *
+       * XXX - if reassembly isn't enabled. the subdissector will throw a
+       * BoundsError exception, rather than a ReportedBoundsError exception.
+       * We really want a tvbuff where the length is "length", the reported
+       * length is "plen + 4", and the "if the snapshot length were infinite"
+       * length is the minimum of the reported length of the tvbuff handed
+       * to us and "plen+4", with a new type of exception thrown if the offset
+       * is within the reported length but beyond that third length, with that
+       * exception getting the "Unreassembled Packet" error.
+       */
+      length = length_remaining - 4;
+      if (length > plen)
+        length = plen;
+      next_tvb = tvb_new_subset(tvb, offset + 4, length, plen);
+      call_dissector(x25_handle,next_tvb,pinfo,tree);
+    }
+    CATCH(BoundsError) {
+      RETHROW;
+    }
+    CATCH(ReportedBoundsError) {
+      show_reported_bounds_error(tvb, pinfo, tree);
+    }
+    ENDTRY;
+
+    /*
+     * Skip the X.25-over-TCP header and the payload.
+     */
+    offset += plen + 4;
   }
-  next_tvb =  tvb_new_subset(tvb,4, -1 , -1);
-  call_dissector(x25_handle,next_tvb,pinfo,tree);
 }
+
 /* Register the protocol with Ethereal */
 void 
 proto_register_xot(void)
@@ -95,11 +191,18 @@ proto_register_xot(void)
        static gint *ett[] = {
                &ett_xot,
        };
+       module_t *xot_module;
 
        proto_xot = proto_register_protocol("X.25 over TCP", "XOT", "xot");
        proto_register_field_array(proto_xot, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
-};
+
+       xot_module = prefs_register_protocol(proto_xot, NULL);
+       prefs_register_bool_preference(xot_module, "desegment",
+           "Desegment all X.25-over-TCP messages spanning multiple TCP segments",
+           "Whether the X.25-over-TCP dissector should desegment all messages spanning multiple TCP segments",
+           &xot_desegment);
+}
 
 void
 proto_reg_handoff_xot(void)
index 0c2294f5219837fb1102f9e646e27363ebf26af2..9b9eec20667379ef5a1a9617ef57db678faf0677 100644 (file)
@@ -1,6 +1,6 @@
 /* i4btrace.c
  *
- * $Id: i4btrace.c,v 1.19 2002/03/05 08:39:29 guy Exp $
+ * $Id: i4btrace.c,v 1.20 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
@@ -338,7 +338,7 @@ i4b_set_pseudo_header(wtap *wth, i4b_trace_hdr_t *hdr,
                         * V.120.
                         */
                        pseudo_header->x25.flags =
-                           (hdr->dir == FROM_TE) ? 0x00 : 0x80;
+                           (hdr->dir == FROM_TE) ? 0x00 : FROM_DCE;
                }
                break;
        }
index 28a111befe02f43c584abac763ca06626f18c7a2..7f6bf20b368c4fea76aead70f0cb47fc381e3a4d 100644 (file)
@@ -1,6 +1,6 @@
 /* nettl.c
  *
- * $Id: nettl.c,v 1.25 2002/03/05 08:39:29 guy Exp $
+ * $Id: nettl.c,v 1.26 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -300,7 +300,8 @@ nettl_read_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
 
            phdr->ts.tv_sec = pntohl(&lapb_hdr.sec);
            phdr->ts.tv_usec = pntohl(&lapb_hdr.usec);
-           pseudo_header->x25.flags = (lapb_hdr.from_dce & 0x20 ? 0x80 : 0x00);
+           pseudo_header->x25.flags =
+               (lapb_hdr.from_dce & 0x20 ? FROM_DCE : 0x00);
            break;
        default:
            g_message("nettl: network type %u unknown or unsupported",
index 88b29b5daae9f41714d5b769a13e60bec5c562d2..e867752443fb782f2b8d522e27078eea7fa58f22 100644 (file)
@@ -1,6 +1,6 @@
 /* ngsniffer.c
  *
- * $Id: ngsniffer.c,v 1.76 2002/03/05 08:39:29 guy Exp $
+ * $Id: ngsniffer.c,v 1.77 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -1030,7 +1030,7 @@ static void set_pseudo_header_frame2(union wtap_pseudo_header *pseudo_header,
         * or 0xcc, and "flags" was either 0 or 0x18,
         * with no obvious correlation with anything.
         */
-       pseudo_header->x25.flags = (frame2->fs & 0x80) ? 0x00 : 0x80;
+       pseudo_header->x25.flags = (frame2->fs & 0x80) ? 0x00 : FROM_DCE;
 }
 
 static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random,
@@ -1294,7 +1294,7 @@ static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     rec_hdr.time_high = htoles(t_high);
     rec_hdr.size = htoles(phdr->caplen);
     if (wdh->encap == WTAP_ENCAP_LAPB || wdh->encap == WTAP_ENCAP_PPP)
-       rec_hdr.fs = (pseudo_header->x25.flags & 0x80) ? 0x00 : 0x80;
+       rec_hdr.fs = (pseudo_header->x25.flags & FROM_DCE) ? 0x00 : 0x80;
     else
        rec_hdr.fs = 0;
     rec_hdr.flags = 0;
index 4337ea1dda337b13161d32ec4c431a68be258ef3..c603474347a9e10de5748012fb330c302611e232 100644 (file)
@@ -1,6 +1,6 @@
 /* radcom.c
  *
- * $Id: radcom.c,v 1.35 2002/03/05 08:39:29 guy Exp $
+ * $Id: radcom.c,v 1.36 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -279,7 +279,7 @@ static gboolean radcom_read(wtap *wth, int *err, long *data_offset)
        tm.tm_isdst = -1;
        wth->phdr.ts.tv_sec = mktime(&tm);
        wth->phdr.ts.tv_usec = pletohl(&hdr.date.usec);
-       wth->pseudo_header.x25.flags = (hdr.dce & 0x1) ? 0x00 : 0x80;
+       wth->pseudo_header.x25.flags = (hdr.dce & 0x1) ? 0x00 : FROM_DCE;
 
        /*
         * Read the packet data.
@@ -332,7 +332,7 @@ radcom_seek_read(wtap *wth, long seek_off,
                return FALSE;
        }
 
-       pseudo_header->x25.flags = (hdr.dce & 0x1) ? 0x00 : 0x80;
+       pseudo_header->x25.flags = (hdr.dce & 0x1) ? 0x00 : FROM_DCE;
 
        /*
         * Read the packet data.
index faa5a99084f8390acb9b430f394497d463477ffc..100441ae7a1502e190e58a7cbcaed5ec4c868d92 100644 (file)
@@ -2,7 +2,7 @@
  * File read and write routines for Visual Networks cap files.
  * Copyright (c) 2001, Tom Nisbet  tnisbet@visualnetworks.com
  *
- * $Id: visual.c,v 1.5 2002/03/05 08:39:29 guy Exp $
+ * $Id: visual.c,v 1.6 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -299,7 +299,8 @@ static gboolean visual_read(wtap *wth, int *err, long *data_offset)
 
     case WTAP_ENCAP_FRELAY:
     case WTAP_ENCAP_LAPB:
-        wth->pseudo_header.x25.flags = (packet_status & PS_SENT) ? 0x00 : 0x80;
+        wth->pseudo_header.x25.flags =
+            (packet_status & PS_SENT) ? 0x00 : FROM_DCE;
         break;
     }
 
@@ -376,7 +377,7 @@ static gboolean visual_seek_read (wtap *wth, long seek_off,
 
     case WTAP_ENCAP_FRELAY:
     case WTAP_ENCAP_LAPB:
-        pseudo_header->x25.flags = (packet_status & PS_SENT) ? 0x00 : 0x80;
+        pseudo_header->x25.flags = (packet_status & PS_SENT) ? 0x00 : FROM_DCE;
         break;
     }
 
@@ -523,7 +524,8 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
 
     case WTAP_ENCAP_FRELAY:
     case WTAP_ENCAP_LAPB:
-        packet_status |= ((pseudo_header->x25.flags & 0x80) ? 0x00 : PS_SENT);
+        packet_status |=
+            ((pseudo_header->x25.flags & FROM_DCE) ? 0x00 : PS_SENT);
         break;
     }
     vpkt_hdr.status = htolel(packet_status);
index 1aa567f210e1049aa804722a2539dbac6116578d..84bf02f1fc7e98521aa1d05e29ddd83df0bc246f 100644 (file)
@@ -1,6 +1,6 @@
 /* wtap.h
  *
- * $Id: wtap.h,v 1.109 2002/04/08 09:44:42 guy Exp $
+ * $Id: wtap.h,v 1.110 2002/04/09 08:15:04 guy Exp $
  *
  * Wiretap Library
  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
@@ -18,7 +18,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
  */
 
 #ifndef __WTAP_H__
  */
 
 /* Packet "pseudo-header" information for X.25 capture files. */
+#define FROM_DCE                       0x80
 struct x25_phdr {
-       guint8  flags; /* ENCAP_LAPB : 1st bit means From DCE */
+       guint8  flags; /* ENCAP_LAPB, ENCAP_V120 : 1st bit means From DCE */
 };
 
 /* Packet "pseudo-header" for ATM Sniffer capture files. */