Convert LAPD and V.120 dissector to use tvbuff. Convert xdlc dissector-helper,
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 31 May 2000 03:58:56 +0000 (03:58 +0000)
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 31 May 2000 03:58:56 +0000 (03:58 +0000)
too.

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

packet-lapb.c
packet-lapd.c
packet-lapd.h
packet-llc.c
packet-v120.c
packet-v120.h
packet.c
xdlc.c
xdlc.h

index 15cbbdfb072e562b2e193e29ff18aaa861f90443..225f785794c99ad256256d381b74bb76ab019811 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for lapb frame disassembly
  * Olivier Abad <oabad@cybercable.fr>
  *
- * $Id: packet-lapb.c,v 1.20 2000/05/28 17:04:10 oabad Exp $
+ * $Id: packet-lapb.c,v 1.21 2000/05/31 03:58:53 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -55,8 +55,6 @@ dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     proto_tree         *lapb_tree, *ti;
     int                        is_response;
     guint8             byte0;
-    const guint8       *this_pd;
-    int                        this_offset;
     tvbuff_t           *next_tvb;
 
     pinfo->current_proto = "LAPB";
@@ -105,8 +103,7 @@ dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     else
         lapb_tree = NULL;
 
-    tvb_compat(tvb, &this_pd, &this_offset);
-    dissect_xdlc_control(this_pd, this_offset+1, pinfo->fd, lapb_tree, hf_lapb_control,
+    dissect_xdlc_control(tvb, 1, pinfo, lapb_tree, hf_lapb_control,
            ett_lapb_control, is_response, FALSE);
 
     /* not end of frame ==> X.25 */
index bc6f973cc3fc5e17793c40ca5ed63f8da28e7546..75959b5c39637bf52745205a3c7cfef8ca8c583f 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for LAPD frame disassembly
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-lapd.c,v 1.9 2000/05/29 08:57:37 guy Exp $
+ * $Id: packet-lapd.c,v 1.10 2000/05/31 03:58:54 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -84,79 +84,78 @@ static const value_string lapd_sapi_vals[] = {
 };
 
 void
-dissect_lapd(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
-    frame_data *fd, proto_tree *tree)
+dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
        proto_tree      *lapd_tree, *addr_tree;
        proto_item      *ti;
        guint16         control;
        int             lapd_header_len;
-       tvbuff_t        *new_tvb;
+       guint16         address, cr, sapi;
+       gboolean        is_response;
+       tvbuff_t        *next_tvb;
 
-       guint16 address, cr, sapi;
+       pinfo->current_proto = "LAPD";
 
-       gboolean is_response;
+       if (check_col(pinfo->fd, COL_PROTOCOL))
+               col_add_str(pinfo->fd, COL_PROTOCOL, "LAPD");
 
-       if (check_col(fd, COL_PROTOCOL))
-               col_add_str(fd, COL_PROTOCOL, "LAPD");
-
-       address = pntohs(&pd[0]);
+       address = tvb_get_ntohs(tvb, 0);
        cr = address & LAPD_CR;
        sapi = (address & LAPD_SAPI) >> LAPD_SAPI_SHIFT;
        lapd_header_len = 2;    /* address */
 
-       if (pseudo_header->lapd.from_network_to_user) {
+       if (pinfo->pseudo_header->lapd.from_network_to_user) {
                is_response = cr ? FALSE : TRUE;
-               if(check_col(fd, COL_RES_DL_DST))
-                   col_add_str(fd, COL_RES_DL_DST, "User");
-               if(check_col(fd, COL_RES_DL_SRC))
-                   col_add_str(fd, COL_RES_DL_SRC, "Network");
+               if(check_col(pinfo->fd, COL_RES_DL_DST))
+                   col_add_str(pinfo->fd, COL_RES_DL_DST, "User");
+               if(check_col(pinfo->fd, COL_RES_DL_SRC))
+                   col_add_str(pinfo->fd, COL_RES_DL_SRC, "Network");
        }
        else {
                is_response = cr ? TRUE : FALSE;
-               if(check_col(fd, COL_RES_DL_DST))
-                       col_add_str(fd, COL_RES_DL_DST, "Network");
-               if(check_col(fd, COL_RES_DL_SRC))
-                       col_add_str(fd, COL_RES_DL_SRC, "User");
+               if(check_col(pinfo->fd, COL_RES_DL_DST))
+                       col_add_str(pinfo->fd, COL_RES_DL_DST, "Network");
+               if(check_col(pinfo->fd, COL_RES_DL_SRC))
+                       col_add_str(pinfo->fd, COL_RES_DL_SRC, "User");
        }
 
 
        if (tree) {
-               ti = proto_tree_add_item(tree, proto_lapd, NullTVB, 0, 3, NULL);
+               ti = proto_tree_add_item(tree, proto_lapd, tvb, 0, 3, NULL);
                lapd_tree = proto_item_add_subtree(ti, ett_lapd);
 
-               ti = proto_tree_add_item(lapd_tree, hf_lapd_address, NullTVB, 0, 2, address);
+               ti = proto_tree_add_item(lapd_tree, hf_lapd_address, tvb, 0, 2, address);
                addr_tree = proto_item_add_subtree(ti, ett_lapd_address);
 
-               proto_tree_add_item(addr_tree, hf_lapd_sapi, NullTVB,   0, 1, address);
-               proto_tree_add_item(addr_tree, hf_lapd_cr, NullTVB,     0, 1, address);
-               proto_tree_add_item(addr_tree, hf_lapd_ea1, NullTVB,    0, 1, address);
-               proto_tree_add_item(addr_tree, hf_lapd_tei, NullTVB,    1, 1, address);
-               proto_tree_add_item(addr_tree, hf_lapd_ea2, NullTVB,    1, 1, address);
+               proto_tree_add_item(addr_tree, hf_lapd_sapi,tvb, 0, 1, address);
+               proto_tree_add_item(addr_tree, hf_lapd_cr,  tvb, 0, 1, address);
+               proto_tree_add_item(addr_tree, hf_lapd_ea1, tvb, 0, 1, address);
+               proto_tree_add_item(addr_tree, hf_lapd_tei, tvb, 1, 1, address);
+               proto_tree_add_item(addr_tree, hf_lapd_ea2, tvb, 1, 1, address);
        }
        else {
                lapd_tree = NULL;
        }
 
-       control = dissect_xdlc_control(pd, 2, fd, lapd_tree, hf_lapd_control,
+       control = dissect_xdlc_control(tvb, 2, pinfo, lapd_tree, hf_lapd_control,
            ett_lapd_control, is_response, TRUE);
        lapd_header_len += XDLC_CONTROL_LEN(control, TRUE);
 
-       new_tvb = tvb_new_subset(pi.compat_top_tvb, lapd_header_len, -1, -1);
+       next_tvb = tvb_new_subset(tvb, lapd_header_len, -1, -1);
        if (XDLC_IS_INFORMATION(control)) {
                /* call next protocol */
                switch (sapi) {
 
                case LAPD_SAPI_Q931:
-                       dissect_q931(new_tvb, &pi, tree);
+                       dissect_q931(next_tvb, pinfo, tree);
                        break;
 
                default:
-                       dissect_data_tvb(new_tvb, &pi, tree);
+                       dissect_data_tvb(next_tvb, pinfo, tree);
                        break;
                }
        } else
-               dissect_data_tvb(new_tvb, &pi, tree);
+               dissect_data_tvb(next_tvb, pinfo, tree);
 }
 
 void
index f5c0834d7aa32f4cfc807fc87c711f27bb7a62b4..35da1cc7be8e1cf41004b83e3f8cb1a8ec95fd2b 100644 (file)
@@ -1,6 +1,6 @@
 /* packet-lapd.h
  *
- * $Id: packet-lapd.h,v 1.3 2000/05/19 23:06:09 gram Exp $
+ * $Id: packet-lapd.h,v 1.4 2000/05/31 03:58:54 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -22,5 +22,4 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-void dissect_lapd(const union wtap_pseudo_header *, const u_char *, frame_data *,
-    proto_tree *);
+void dissect_lapd(tvbuff_t *, packet_info *, proto_tree *);
index 8ea2942d69d515c15721809c5ea99a6e07e0c35a..b18544c68d9e5cc184034b8ee2ff046eee477988 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for IEEE 802.2 LLC layer
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-llc.c,v 1.63 2000/05/28 22:02:17 guy Exp $
+ * $Id: packet-llc.c,v 1.64 2000/05/31 03:58:54 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -313,10 +313,9 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
         * uses extended operation, so we don't need to determine
         * whether it's basic or extended operation; is that the case?
         */
-       tvb_compat(tvb, &pd, &offset);
-       control = dissect_xdlc_control(pd, offset+2, pinfo->fd, llc_tree,
+       control = dissect_xdlc_control(tvb, 2, pinfo, llc_tree,
                                hf_llc_ctrl, ett_llc_ctrl,
-                               pd[offset+1] & SSAP_CR_BIT, TRUE);
+                               tvb_get_guint8(tvb, 1) & SSAP_CR_BIT, TRUE);
        llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
        if (is_snap)
                llc_header_len += 5;    /* 3 bytes of OUI, 2 bytes of protocol ID */
index bc802d06ad3035da069dd8024ba7d76368784a76..e8a89401259eaa038c62f7d0b1fa9fc8a0f5b186 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for v120 frame disassembly
  * Bert Driehuis <driehuis@playbeing.org>
  *
- * $Id: packet-v120.c,v 1.8 2000/05/19 23:06:09 gram Exp $
+ * $Id: packet-v120.c,v 1.9 2000/05/31 03:58:54 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -51,75 +51,83 @@ static gint ett_v120_address = -1;
 static gint ett_v120_control = -1;
 static gint ett_v120_header = -1;
 
-static int dissect_v120_header(const u_char *pd, int offset, frame_data *fd, proto_tree *tree);
+static int dissect_v120_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
 
 void
-dissect_v120(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
-               frame_data *fd, proto_tree *tree)
+dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-    proto_tree *v120_tree, *ti, *tc, *address_tree;
-    int is_response;
-    int addr;
-    char info[80];
-    int v120len;
-    guint16 control;
-
-    if (check_col(fd, COL_PROTOCOL))
-       col_add_str(fd, COL_PROTOCOL, "V.120");
-
-    if(check_col(fd, COL_RES_DL_SRC))
-       col_add_fstr(fd, COL_RES_DL_SRC, "0x%02X", pd[0]);
-    if ((pd[0] & 0x01) != 0x00 && (pd[1] && 0x01) != 0x01)
+    proto_tree *v120_tree, *tc, *address_tree;
+    proto_item *ti;
+    int                is_response;
+    int                addr;
+    char       info[80];
+    int                v120len;
+    guint8     byte0, byte1;
+    guint16    control;
+    tvbuff_t   *next_tvb;
+
+    pinfo->current_proto = "V.120";
+
+    if (check_col(pinfo->fd, COL_PROTOCOL))
+       col_add_str(pinfo->fd, COL_PROTOCOL, "V.120");
+
+    byte0 = tvb_get_guint8(tvb, 0);
+
+    if(check_col(pinfo->fd, COL_RES_DL_SRC))
+       col_add_fstr(pinfo->fd, COL_RES_DL_SRC, "0x%02X", byte0);
+
+    byte1 = tvb_get_guint8(tvb, 1);
+
+    if ((byte0 & 0x01) != 0x00 && (byte1 && 0x01) != 0x01)
     {
-       if (check_col(fd, COL_INFO))
-           col_add_str(fd, COL_INFO, "Invalid V.120 frame");
+       if (check_col(pinfo->fd, COL_INFO))
+           col_add_str(pinfo->fd, COL_INFO, "Invalid V.120 frame");
        if (tree)
-           ti = proto_tree_add_protocol_format(tree, proto_v120, NullTVB, 0, fd->cap_len,
+           ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, pinfo->fd->cap_len,
                                            "Invalid V.120 frame");
        return;
     }
 
-    if (pseudo_header->x25.flags & FROM_DCE) {
-       if(check_col(fd, COL_RES_DL_DST))
-           col_add_str(fd, COL_RES_DL_DST, "DTE");
-       if(check_col(fd, COL_RES_DL_SRC))
-           col_add_str(fd, COL_RES_DL_SRC, "DCE");
+    if (pinfo->pseudo_header->x25.flags & FROM_DCE) {
+       if(check_col(pinfo->fd, COL_RES_DL_DST))
+           col_add_str(pinfo->fd, COL_RES_DL_DST, "DTE");
+       if(check_col(pinfo->fd, COL_RES_DL_SRC))
+           col_add_str(pinfo->fd, COL_RES_DL_SRC, "DCE");
     }
     else {
-       if(check_col(fd, COL_RES_DL_DST))
-           col_add_str(fd, COL_RES_DL_DST, "DCE");
-       if(check_col(fd, COL_RES_DL_SRC))
-           col_add_str(fd, COL_RES_DL_SRC, "DTE");
+       if(check_col(pinfo->fd, COL_RES_DL_DST))
+           col_add_str(pinfo->fd, COL_RES_DL_DST, "DCE");
+       if(check_col(pinfo->fd, COL_RES_DL_SRC))
+           col_add_str(pinfo->fd, COL_RES_DL_SRC, "DTE");
     }
 
-    if (((pseudo_header->x25.flags & FROM_DCE) && pd[0] & 0x02) ||
-       (!(pseudo_header->x25.flags & FROM_DCE) && !(pd[0] & 0x02)))
+    if (((pinfo->pseudo_header->x25.flags & FROM_DCE) && byte0 & 0x02) ||
+       (!(pinfo->pseudo_header->x25.flags & FROM_DCE) && !(byte0 & 0x02)))
        is_response = TRUE;
     else
        is_response = FALSE;
 
     if (tree) {
-       ti = proto_tree_add_protocol_format(tree, proto_v120, NullTVB, 0, 0,
-                                           "V.120");
+       ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, 0, "V.120");
        v120_tree = proto_item_add_subtree(ti, ett_v120);
-       addr = pd[1] << 8 | pd[0];
+       addr = byte1 << 8 | byte0;
        sprintf(info, "LLI: %d C/R: %s",
-                       ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1),
-                       pd[0] & 0x02 ? "R" : "C");
-       tc = proto_tree_add_text(v120_tree, NullTVB,
+                       ((byte0 & 0xfc) << 5) | ((byte1 & 0xfe) >> 1),
+                       byte0 & 0x02 ? "R" : "C");
+       tc = proto_tree_add_text(v120_tree, tvb,
                        0, 2,
                        "Address field: %s", info);
        address_tree = proto_item_add_subtree(tc, ett_v120_address);
-       proto_tree_add_text(address_tree, NullTVB, 0, 2,
+       proto_tree_add_text(address_tree, tvb, 0, 2,
                    decode_boolean_bitfield(addr, 0x0002, 2*8,
                        "Response", "Command"), NULL);
-       sprintf(info, "LLI: %d", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1));
-       proto_tree_add_text(address_tree, NullTVB, 0, 2,
+       sprintf(info, "LLI: %d", ((byte0 & 0xfc) << 5) | ((byte1 & 0xfe) >> 1));
+       proto_tree_add_text(address_tree, tvb, 0, 2,
                    decode_numeric_bitfield(addr, 0xfefc, 2*8, info));
-       proto_tree_add_text(address_tree, NullTVB, 0, 2,
+       proto_tree_add_text(address_tree, tvb, 0, 2,
                    decode_boolean_bitfield(addr, 0x0001, 2*8,
                        "EA0 = 1 (Error)", "EA0 = 0"), NULL);
-       proto_tree_add_text(address_tree, NullTVB, 0, 2,
+       proto_tree_add_text(address_tree, tvb, 0, 2,
                    decode_boolean_bitfield(addr, 0x0100, 2*8,
                        "EA1 = 1", "EA1 = 0 (Error)"), NULL);
     }
@@ -127,66 +135,69 @@ dissect_v120(const union wtap_pseudo_header *pseudo_header, const u_char *pd,
        v120_tree = NULL;
        ti = NULL;
     }
-    control = dissect_xdlc_control(pd, 2, fd, v120_tree, hf_v120_control,
+    control = dissect_xdlc_control(tvb, 2, pinfo, v120_tree, hf_v120_control,
            ett_v120_control, is_response, TRUE);
     if (tree) {
        v120len = 2 + XDLC_CONTROL_LEN(control, TRUE);
-       if (BYTES_ARE_IN_FRAME(v120len, 1))
-               v120len += dissect_v120_header(pd, v120len, fd, v120_tree);
+       if (tvb_bytes_exist(tvb, v120len, 1))
+               v120len += dissect_v120_header(tvb, v120len, pinfo, v120_tree);
        proto_item_set_len(ti, v120len);
-       if (IS_DATA_IN_FRAME(v120len))
-               dissect_data(&pd[v120len], v120len, fd, v120_tree);
+       next_tvb = tvb_new_subset(tvb, v120len, -1, -1);
+       dissect_data_tvb(next_tvb, pinfo, v120_tree);
     }
 }
 
 static int
-dissect_v120_header(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
+dissect_v120_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 {
        char info[80];
        int header_len, nbits;
        int header;
        proto_tree *h_tree, *tc;
+       guint8  byte0;
+
+       byte0 = tvb_get_guint8(tvb, offset);
 
-       if (pd[offset] & 0x80) {
+       if (byte0 & 0x80) {
                header_len = 1;
-               header = pd[offset];
+               header = byte0;
        } else {
                header_len = 2;
-               header = pd[offset] | pd[offset + 1] << 8;
+               header = byte0 | tvb_get_guint8(tvb, offset + 1) << 8;
        }
        nbits = header_len * 8;
-       sprintf(info, "Header: B: %d F: %d", pd[offset] & 0x02 ? 1:0,
-                       pd[offset] & 0x01 ? 1:0);
-       tc = proto_tree_add_text(tree, NullTVB,
+       sprintf(info, "Header: B: %d F: %d", byte0 & 0x02 ? 1:0,
+                       byte0 & 0x01 ? 1:0);
+       tc = proto_tree_add_text(tree, tvb,
                        offset, header_len,
-                       "Header octet: %s (0x%02X)", info, pd[offset]);
+                       "Header octet: %s (0x%02X)", info, byte0);
        h_tree = proto_item_add_subtree(tc, ett_v120_header);
-       proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+       proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x80, nbits,
                        "No extension octet", "Extension octet follows"), NULL);
-       proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+       proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x40, nbits,
                        "Break condition", "No break condition"), NULL);
        sprintf(info, "Error control C1/C2: %d", (header & 0x0c) >> 2);
-       proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+       proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_numeric_bitfield(header, 0x0c, nbits, info));
-       proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+       proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x02, nbits,
                        "Segmentation bit B", "No segmentation bit B"), NULL);
-       proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+       proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x01, nbits,
                        "Segmentation bit F", "No segmentation bit F"), NULL);
        if (header_len == 2) {
-               proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+               proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x8000, nbits,
                        "E", "E bit not set (Error)"), NULL);
-               proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+               proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x4000, nbits,
                        "DR", "No DR"), NULL);
-               proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+               proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x2000, nbits,
                        "SR", "No SR"), NULL);
-               proto_tree_add_text(h_tree, NullTVB, offset, header_len,
+               proto_tree_add_text(h_tree, tvb, offset, header_len,
                    decode_boolean_bitfield(header, 0x1000, nbits,
                        "RR", "No RR"), NULL);
        }
index 78fc99f9a1d6480547c1e3b8b5983b21ba7ea6f0..fc99d102febcd2ecad24d432e9be41f011a2d1b1 100644 (file)
@@ -1,6 +1,6 @@
 /* packet-v120.h
  *
- * $Id: packet-v120.h,v 1.3 2000/05/19 23:06:09 gram Exp $
+ * $Id: packet-v120.h,v 1.4 2000/05/31 03:58:55 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -22,5 +22,4 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-void dissect_v120(const union wtap_pseudo_header *, const u_char *, frame_data *,
-    proto_tree *);
+void dissect_v120(tvbuff_t *, packet_info *, proto_tree *);
index b22ee768b8215bbd8997a0b7d79de5fe9701c53f..eef7e534620e7f323e97c8e82bd6c9521d208938 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
 /* packet.c
  * Routines for packet disassembly
  *
- * $Id: packet.c,v 1.92 2000/05/29 08:57:41 guy Exp $
+ * $Id: packet.c,v 1.93 2000/05/31 03:58:55 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -1209,10 +1209,10 @@ dissect_packet(union wtap_pseudo_header *pseudo_header, const u_char *pd,
                                dissect_ascend(tvb, &pi, tree);
                                break;
                        case WTAP_ENCAP_LAPD :
-                               dissect_lapd(pseudo_header, pd, fd, tree);
+                               dissect_lapd(tvb, &pi, tree);
                                break;
                        case WTAP_ENCAP_V120 :
-                               dissect_v120(pseudo_header, pd, fd, tree);
+                               dissect_v120(tvb, &pi, tree);
                                break;
                }
        }
diff --git a/xdlc.c b/xdlc.c
index 982820165aa9865bdac7a6af5d4015fd987956a2..e2c3d733f200cca92465f192973f5554c125ee9e 100644 (file)
--- a/xdlc.c
+++ b/xdlc.c
@@ -2,7 +2,7 @@
  * Routines for use by various SDLC-derived protocols, such as HDLC
  * and its derivatives LAPB, IEEE 802.2 LLC, etc..
  *
- * $Id: xdlc.c,v 1.14 2000/05/11 08:16:00 gram Exp $
+ * $Id: xdlc.c,v 1.15 2000/05/31 03:58:55 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -195,7 +195,7 @@ get_xdlc_control(const u_char *pd, int offset, int is_response, int is_extended)
 }
 
 int
-dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
+dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
   proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
   int is_response, int is_extended)
 {
@@ -205,16 +205,16 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
     gchar *frame_type = NULL;
     gchar *modifier;
 
-    switch (pd[offset] & 0x03) {
+    switch (tvb_get_guint8(tvb, offset) & 0x03) {
 
     case XDLC_S:
         /*
         * Supervisory frame.
         */
        if (is_extended)
-               control = pletohs(&pd[offset]);
+               control = tvb_get_letohs(tvb, offset);
        else
-               control = pd[offset];
+               control = tvb_get_guint8(tvb, offset);
        switch (control & XDLC_S_FTYPE_MASK) {
        case XDLC_RR:
            frame_type = "RR";
@@ -245,49 +245,49 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
                            ""),
                        (control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT);
        }
-       if (check_col(fd, COL_INFO))
-           col_add_str(fd, COL_INFO, info);
+       if (check_col(pinfo->fd, COL_INFO))
+           col_add_str(pinfo->fd, COL_INFO, info);
        if (xdlc_tree) {
            if (is_extended) {
-               tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, NullTVB,
+               tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
                        offset, 2,
                        control,
                        "Control field: %s (0x%04X)", info, control);
                control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_numeric_bitfield(control, XDLC_N_R_EXT_MASK, 2*8,
                        "N(R) = %u"));
                if (control & XDLC_P_F_EXT) {
-                   proto_tree_add_text(control_tree, NullTVB, offset, 2,
+                   proto_tree_add_text(control_tree, tvb, offset, 2,
                        decode_boolean_bitfield(control, XDLC_P_F_EXT, 2*8,
                            (is_response ? "Final" : "Poll"), NULL));
                }
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_enumerated_bitfield(control, XDLC_S_FTYPE_MASK, 2*8,
                        stype_vals, "Supervisory frame - %s"));
                /* This will always say it's a supervisory frame */
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_boolean_bitfield(control, 0x03, 2*8,
                        "Supervisory frame", NULL));
            } else {
-               tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, NullTVB,
+               tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
                        offset, 1,
                        control,
                        "Control field: %s (0x%02X)", info, control);
                control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_numeric_bitfield(control, XDLC_N_R_MASK, 1*8,
                        "N(R) = %u"));
                if (control & XDLC_P_F) {
-                   proto_tree_add_text(control_tree, NullTVB, offset, 1,
+                   proto_tree_add_text(control_tree, tvb, offset, 1,
                        decode_boolean_bitfield(control, XDLC_P_F, 1*8,
                            (is_response ? "Final" : "Poll"), NULL));
                }
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_enumerated_bitfield(control, XDLC_S_FTYPE_MASK, 1*8,
                        stype_vals, "%s"));
                /* This will always say it's a supervisory frame */
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_boolean_bitfield(control, 0x03, 1*8,
                        "Supervisory frame", NULL));
            }
@@ -305,7 +305,7 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
         * control field of a U frame, there doesn't appear to be any
         * need for it to be 2 bytes in extended operation.
         */
-       control = pd[offset];
+       control = tvb_get_guint8(tvb, offset);
        if (is_response) {
                modifier = match_strval(control & XDLC_U_MODIFIER_MASK,
                        modifier_short_vals_resp);
@@ -320,25 +320,25 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
                    (is_response ? " F" : " P") :
                    ""),
                modifier);
-       if (check_col(fd, COL_INFO))
-           col_add_str(fd, COL_INFO, info);
+       if (check_col(pinfo->fd, COL_INFO))
+           col_add_str(pinfo->fd, COL_INFO, info);
        if (xdlc_tree) {
-           tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, NullTVB,
+           tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
                        offset, 1,
                        control,
                        "Control field: %s (0x%02X)", info, control);
            control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
            if (control & XDLC_P_F) {
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_boolean_bitfield(control, XDLC_P_F, 1*8,
                        (is_response ? "Final" : "Poll"), NULL));
            }
-           proto_tree_add_text(control_tree, NullTVB, offset, 1,
+           proto_tree_add_text(control_tree, tvb, offset, 1,
                decode_enumerated_bitfield(control, XDLC_U_MODIFIER_MASK, 1*8,
                    (is_response ? modifier_vals_resp : modifier_vals_cmd),
                    "%s"));
            /* This will always say it's an unnumbered frame */
-           proto_tree_add_text(control_tree, NullTVB, offset, 1,
+           proto_tree_add_text(control_tree, tvb, offset, 1,
                decode_boolean_bitfield(control, 0x03, 1*8,
                    "Unnumbered frame", NULL));
        }
@@ -349,9 +349,9 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
         * Information frame.
         */
        if (is_extended)
-               control = pletohs(&pd[offset]);
+               control = tvb_get_letohs(tvb, offset);
        else
-               control = pd[offset];
+               control = tvb_get_guint8(tvb, offset);
        if (is_extended) {
            sprintf(info, "I%s, N(R) = %u, N(S) = %u",
                        ((control & XDLC_P_F_EXT) ? " P" : ""),
@@ -363,10 +363,10 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
                        (control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT,
                        (control & XDLC_N_S_MASK) >> XDLC_N_S_SHIFT);
        }
-       if (check_col(fd, COL_INFO))
-           col_add_str(fd, COL_INFO, info);
+       if (check_col(pinfo->fd, COL_INFO))
+           col_add_str(pinfo->fd, COL_INFO, info);
        if (xdlc_tree) {
-           tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, NullTVB,
+           tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
                        offset, (is_extended) ? 2 : 1,
                        control,
                        (is_extended) ? "Control field: %s (0x%04X)"
@@ -374,35 +374,35 @@ dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
                        info, control);
            control_tree = proto_item_add_subtree(tc, ett_xdlc_control);
            if (is_extended) {
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_numeric_bitfield(control, XDLC_N_R_EXT_MASK, 2*8,
                                "N(R) = %u"));
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_numeric_bitfield(control, XDLC_N_S_EXT_MASK, 2*8,
                                "N(S) = %u"));
                if (control & XDLC_P_F_EXT) {
-                   proto_tree_add_text(control_tree, NullTVB, offset, 2,
+                   proto_tree_add_text(control_tree, tvb, offset, 2,
                        decode_boolean_bitfield(control, XDLC_P_F_EXT, 2*8,
                                "Poll", NULL));
                }
                /* This will always say it's an information frame */
-               proto_tree_add_text(control_tree, NullTVB, offset, 2,
+               proto_tree_add_text(control_tree, tvb, offset, 2,
                    decode_boolean_bitfield(control, 0x01, 2*8,
                        NULL, "Information frame"));
            } else {
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_numeric_bitfield(control, XDLC_N_R_MASK, 1*8,
                                "N(R) = %u"));
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_numeric_bitfield(control, XDLC_N_S_MASK, 1*8,
                                "N(S) = %u"));
                if (control & XDLC_P_F) {
-                   proto_tree_add_text(control_tree, NullTVB, offset, 1,
+                   proto_tree_add_text(control_tree, tvb, offset, 1,
                        decode_boolean_bitfield(control, XDLC_P_F, 1*8,
                                "Poll", NULL));
                }
                /* This will always say it's an information frame */
-               proto_tree_add_text(control_tree, NullTVB, offset, 1,
+               proto_tree_add_text(control_tree, tvb, offset, 1,
                    decode_boolean_bitfield(control, 0x01, 1*8,
                        NULL, "Information frame"));
            }
diff --git a/xdlc.h b/xdlc.h
index 930eb35b8d681f120e3806241bc82b48fe66154b..ff7312077b226fed980087c13613679094357c30 100644 (file)
--- a/xdlc.h
+++ b/xdlc.h
@@ -2,7 +2,7 @@
  * Define *DLC frame types, and routine to dissect the control field of
  * a *DLC frame.
  *
- * $Id: xdlc.h,v 1.12 2000/01/24 02:05:39 guy Exp $
+ * $Id: xdlc.h,v 1.13 2000/05/31 03:58:56 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -79,6 +79,6 @@
 int get_xdlc_control(const u_char *pd, int offset, int is_response,
   int extended);
 
-int dissect_xdlc_control(const u_char *pd, int offset, frame_data *fd,
+int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
   proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
   int is_response, int extended);