diff options
-rw-r--r-- | packet-atm.c | 6 | ||||
-rw-r--r-- | packet-data.c | 16 | ||||
-rw-r--r-- | packet-eth.c | 6 | ||||
-rw-r--r-- | packet-fddi.c | 16 | ||||
-rw-r--r-- | packet-llc.c | 121 | ||||
-rw-r--r-- | packet-llc.h | 4 | ||||
-rw-r--r-- | packet-tr.c | 8 | ||||
-rw-r--r-- | packet-vlan.c | 6 | ||||
-rw-r--r-- | packet.c | 4 | ||||
-rw-r--r-- | packet.h | 3 |
10 files changed, 109 insertions, 81 deletions
diff --git a/packet-atm.c b/packet-atm.c index c0a111c86c..60f7f91715 100644 --- a/packet-atm.c +++ b/packet-atm.c @@ -1,7 +1,7 @@ /* packet-atm.c * Routines for ATM packet disassembly * - * $Id: packet-atm.c,v 1.14 2000/05/11 08:14:56 gram Exp $ + * $Id: packet-atm.c,v 1.15 2000/05/11 22:04:15 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -549,6 +549,7 @@ dissect_atm(const u_char *pd, frame_data *fd, proto_tree *tree) proto_item *ti; guint aal_type; guint hl_type; + tvbuff_t* next_tvb; aal_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_AALTYPE; hl_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_HLTYPE; @@ -712,7 +713,8 @@ dissect_atm(const u_char *pd, frame_data *fd, proto_tree *tree) /* Dissect as WTAP_ENCAP_ATM_RFC1483 */ /* The ATM iptrace capture that we have hows LLC at this point, * so that's what I'm calling */ - dissect_llc(pd, offset, fd, tree); + next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1); + dissect_llc(next_tvb, &pi, tree); break; case ATT_HL_LANE: diff --git a/packet-data.c b/packet-data.c index 924f263649..0d197ed002 100644 --- a/packet-data.c +++ b/packet-data.c @@ -2,7 +2,7 @@ * Routines for raw data (default case) * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-data.c,v 1.16 2000/05/11 08:15:05 gram Exp $ + * $Id: packet-data.c,v 1.17 2000/05/11 22:04:15 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -50,6 +50,20 @@ dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) } } +/* This will become dissect_data() once all dissectors are converted to use tvbuffs */ +void +dissect_data_tvb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + int bytes; + + if (tree) { + bytes = tvb_length(tvb); + proto_tree_add_protocol_format(tree, proto_data, tvb, 0, + bytes, "Data (%d byte%s)", bytes, + plurality(bytes, "", "s")); + } +} + void proto_register_data(void) { diff --git a/packet-eth.c b/packet-eth.c index 3ac60dde14..895e443220 100644 --- a/packet-eth.c +++ b/packet-eth.c @@ -1,7 +1,7 @@ /* packet-eth.c * Routines for ethernet packet disassembly * - * $Id: packet-eth.c,v 1.33 2000/05/11 08:15:08 gram Exp $ + * $Id: packet-eth.c,v 1.34 2000/05/11 22:04:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -144,6 +144,7 @@ dissect_eth(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) proto_tree *fh_tree = NULL; proto_item *ti; int ethhdr_type; /* the type of ethernet frame */ + tvbuff_t *next_tvb; if (!BYTES_ARE_IN_FRAME(offset, ETH_HEADER_SIZE)) { dissect_data(pd, offset, fd, tree); @@ -245,7 +246,8 @@ dissect_eth(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) dissect_ipx(pd, offset, fd, tree); break; case ETHERNET_802_2: - dissect_llc(pd, offset, fd, tree); + next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1); + dissect_llc(next_tvb, &pi, tree); break; case ETHERNET_II: ethertype(etype, offset, pd, fd, tree, fh_tree, hf_eth_type); diff --git a/packet-fddi.c b/packet-fddi.c index 93049c5c90..4268a8c37a 100644 --- a/packet-fddi.c +++ b/packet-fddi.c @@ -3,7 +3,7 @@ * * Laurent Deniel <deniel@worldnet.fr> * - * $Id: packet-fddi.c,v 1.31 2000/05/11 16:52:15 gram Exp $ + * $Id: packet-fddi.c,v 1.32 2000/05/11 22:04:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -256,16 +256,15 @@ void dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean bitswapped) { - int offset = 0, fc; + int fc; proto_tree *fh_tree; proto_item *ti; gchar *fc_str; static u_char src[6], dst[6]; u_char src_swapped[6], dst_swapped[6]; - const u_char *pd; tvbuff_t *next_tvb; - pinfo->current_proto = "fddi"; + pinfo->current_proto = "FDDI"; if (check_col(pinfo->fd, COL_PROTOCOL)) col_add_str(pinfo->fd, COL_PROTOCOL, "FDDI"); @@ -292,10 +291,8 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, SET_ADDRESS(&pi.dl_dst, AT_ETHER, 6, &dst[0]); SET_ADDRESS(&pi.dst, AT_ETHER, 6, &dst[0]); - offset = FDDI_HEADER_SIZE; - if (tree) { - ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, offset, + ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, FDDI_HEADER_SIZE, "Fiber Distributed Data Interface, %s", fc_str); swap_mac_addr(dst_swapped, (u_char*) tvb_get_ptr(tvb, FDDI_P_DHOST, 6)); @@ -317,7 +314,6 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } next_tvb = tvb_new_subset(tvb, FDDI_HEADER_SIZE, -1); - tvb_compat(next_tvb, &pd, &offset); switch (fc) { @@ -339,11 +335,11 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, case FDDI_FC_LLC_ASYNC + 13 : case FDDI_FC_LLC_ASYNC + 14 : case FDDI_FC_LLC_ASYNC + 15 : - dissect_llc(pd, offset, pinfo->fd, tree); + dissect_llc(next_tvb, pinfo, tree); return; default : - dissect_data(pd, offset, pinfo->fd, tree); + dissect_data_tvb(next_tvb, pinfo, tree); return; } /* fc */ diff --git a/packet-llc.c b/packet-llc.c index 463a5aa4e6..ae7c452414 100644 --- a/packet-llc.c +++ b/packet-llc.c @@ -2,7 +2,7 @@ * Routines for IEEE 802.2 LLC layer * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-llc.c,v 1.56 2000/05/11 08:15:22 gram Exp $ + * $Id: packet-llc.c,v 1.57 2000/05/11 22:04:16 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -264,8 +264,8 @@ capture_llc(const u_char *pd, int offset, packet_counts *ld) { } void -dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { - +dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ proto_tree *llc_tree = NULL; proto_item *ti = NULL; int is_snap; @@ -273,30 +273,34 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { int llc_header_len; guint32 oui; guint16 etype; - guint8 dsap; + guint8 dsap, ssap; + tvbuff_t *next_tvb; + const guint8 *pd; + int offset; - if (!BYTES_ARE_IN_FRAME(offset, 2)) { - dissect_data(pd, offset, fd, tree); - return; - } - is_snap = (pd[offset] == SAP_SNAP) && (pd[offset+1] == SAP_SNAP); - llc_header_len = 2; /* DSAP + SSAP */ + pinfo->current_proto = "LLC"; - if (check_col(fd, COL_PROTOCOL)) { - col_add_str(fd, COL_PROTOCOL, "LLC"); + if (check_col(pinfo->fd, COL_PROTOCOL)) { + col_add_str(pinfo->fd, COL_PROTOCOL, "LLC"); } + dsap = tvb_get_guint8(tvb, 0); + ssap = tvb_get_guint8(tvb, 1); + + is_snap = (dsap == SAP_SNAP) && (ssap == SAP_SNAP); + llc_header_len = 2; /* DSAP + SSAP */ + if (tree) { - ti = proto_tree_add_item(tree, proto_llc, NullTVB, offset, 0, NULL); + ti = proto_tree_add_item(tree, proto_llc, tvb, 0, 0, NULL); llc_tree = proto_item_add_subtree(ti, ett_llc); - proto_tree_add_item(llc_tree, hf_llc_dsap, NullTVB, offset, - 1, pd[offset] & SAP_MASK); - proto_tree_add_item(llc_tree, hf_llc_dsap_ig, NullTVB, offset, - 1, pd[offset] & DSAP_GI_BIT); - proto_tree_add_item(llc_tree, hf_llc_ssap, NullTVB, offset+1, - 1, pd[offset+1] & SAP_MASK); - proto_tree_add_item(llc_tree, hf_llc_ssap_cr, NullTVB, offset+1, - 1, pd[offset+1] & SSAP_CR_BIT); + proto_tree_add_item(llc_tree, hf_llc_dsap, tvb, 0, + 1, dsap & SAP_MASK); + proto_tree_add_item(llc_tree, hf_llc_dsap_ig, tvb, 0, + 1, dsap & DSAP_GI_BIT); + proto_tree_add_item(llc_tree, hf_llc_ssap, tvb, 1, + 1, ssap & SAP_MASK); + proto_tree_add_item(llc_tree, hf_llc_ssap_cr, tvb, 1, + 1, ssap & SSAP_CR_BIT); } else llc_tree = NULL; @@ -306,16 +310,14 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { * uses extended operation, so we don't need to determine * whether it's basic or extended operation; is that the case? */ - control = dissect_xdlc_control(pd, offset+2, fd, llc_tree, + tvb_compat(tvb, &pd, &offset); + control = dissect_xdlc_control(pd, offset+2, pinfo->fd, llc_tree, hf_llc_ctrl, ett_llc_ctrl, pd[offset+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 */ - if (!BYTES_ARE_IN_FRAME(offset, llc_header_len)) { - dissect_data(pd, offset, fd, tree); - return; - } + if (tree) proto_item_set_len(ti, llc_header_len); @@ -325,17 +327,24 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { * than overwriting it? */ if (is_snap) { - oui = pd[offset+3] << 16 | pd[offset+4] << 8 | pd[offset+5]; - etype = pntohs(&pd[offset+6]); - if (check_col(fd, COL_INFO)) { - col_add_fstr(fd, COL_INFO, "SNAP, OUI 0x%06X (%s), PID 0x%04X", + oui = tvb_get_guint8(tvb, 3) << 16 | + tvb_get_guint8(tvb, 4) << 8 | + tvb_get_guint8(tvb, 5); + etype = tvb_get_ntohs(tvb, 6); + + if (check_col(pinfo->fd, COL_INFO)) { + col_add_fstr(pinfo->fd, COL_INFO, "SNAP, OUI 0x%06X (%s), PID 0x%04X", oui, val_to_str(oui, oui_vals, "Unknown"), etype); } if (tree) { - proto_tree_add_item(llc_tree, hf_llc_oui, NullTVB, offset+3, 3, + proto_tree_add_item(llc_tree, hf_llc_oui, tvb, 3, 3, oui); } + + next_tvb = tvb_new_subset(tvb, 8, -1); + tvb_compat(next_tvb, &pd, &offset); + switch (oui) { case OUI_ENCAP_ETHER: @@ -349,9 +358,9 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { packet type for AARP packets. */ if (XDLC_IS_INFORMATION(control)) { ethertype(etype, offset+8, pd, - fd, tree, llc_tree, hf_llc_type); + pinfo->fd, tree, llc_tree, hf_llc_type); } else - dissect_data(pd, offset+8, fd, tree); + dissect_data_tvb(next_tvb, pinfo, tree); break; case OUI_CISCO: @@ -362,80 +371,80 @@ dissect_llc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { Ethernet? */ if (tree) { proto_tree_add_item(llc_tree, - hf_llc_pid, NullTVB, offset+6, 2, etype); + hf_llc_pid, tvb, 6, 2, etype); } if (XDLC_IS_INFORMATION(control)) { switch (etype) { #if 0 case 0x0102: - dissect_drip(pd, offset+8, fd, tree); + dissect_drip(pd, offset+8, pinfo->fd, tree); break; #endif case 0x2000: - dissect_cdp(pd, offset+8, fd, tree); + dissect_cdp(pd, offset+8, pinfo->fd, tree); break; case 0x2001: - dissect_cgmp(pd, offset+8, fd, tree); + dissect_cgmp(pd, offset+8, pinfo->fd, tree); break; case 0x2003: - dissect_vtp(pd, offset+8, fd, tree); + dissect_vtp(pd, offset+8, pinfo->fd, tree); break; default: - dissect_data(pd, offset+8, fd, tree); + dissect_data_tvb(tvb, pinfo, tree); break; } } else - dissect_data(pd, offset+8, fd, tree); + dissect_data_tvb(tvb, pinfo, tree); break; case OUI_CABLE_BPDU: /* DOCSIS cable modem spanning tree BPDU */ if (tree) { proto_tree_add_item(llc_tree, - hf_llc_pid, NullTVB, offset+6, 2, etype); + hf_llc_pid, tvb, 6, 2, etype); } - dissect_bpdu(pd, offset+8, fd, tree); + dissect_bpdu(pd, offset+8, pinfo->fd, tree); break; default: if (tree) { proto_tree_add_item(llc_tree, - hf_llc_pid, NullTVB, offset+6, 2, etype); + hf_llc_pid, tvb, 6, 2, etype); } - dissect_data(pd, offset+8, fd, tree); + dissect_data_tvb(tvb, pinfo, tree); break; } - } + } else { - if (check_col(fd, COL_INFO)) { - col_add_fstr(fd, COL_INFO, + if (check_col(pinfo->fd, COL_INFO)) { + col_add_fstr(pinfo->fd, COL_INFO, "DSAP %s %s, SSAP %s %s", - val_to_str(pd[offset] & SAP_MASK, sap_vals, "%02x"), - pd[offset] & DSAP_GI_BIT ? + val_to_str(dsap & SAP_MASK, sap_vals, "%02x"), + dsap & DSAP_GI_BIT ? "Group" : "Individual", - val_to_str(pd[offset+1] & SAP_MASK, sap_vals, "%02x"), - pd[offset+1] & SSAP_CR_BIT ? + val_to_str(ssap & SAP_MASK, sap_vals, "%02x"), + ssap & SSAP_CR_BIT ? "Response" : "Command" ); } if (XDLC_IS_INFORMATION(control)) { + tvb_compat(tvb, &pd, &offset); /* non-SNAP */ - dsap = pd[offset]; offset += llc_header_len; /* do lookup with the subdissector table */ if (!dissector_try_port(subdissector_table, dsap, - pd, offset, fd, tree)) { - dissect_data(pd, offset, fd, tree); + pd, offset, pinfo->fd, tree)) { + dissect_data_tvb(tvb, pinfo, tree); } } else { - offset += llc_header_len; - dissect_data(pd, offset, fd, tree); + next_tvb = tvb_new_subset(tvb, llc_header_len, -1); + dissect_data_tvb(tvb, pinfo, tree); } } } diff --git a/packet-llc.h b/packet-llc.h index 721656c898..52e628e2a4 100644 --- a/packet-llc.h +++ b/packet-llc.h @@ -1,6 +1,6 @@ /* packet-llc.h * - * $Id: packet-llc.h,v 1.1 2000/02/15 21:02:34 gram Exp $ + * $Id: packet-llc.h,v 1.2 2000/05/11 22:04:17 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -23,4 +23,4 @@ */ void capture_llc(const u_char *, int, packet_counts *); -void dissect_llc(const u_char *, int, frame_data *, proto_tree *); +void dissect_llc(tvbuff_t *, packet_info *, proto_tree *); diff --git a/packet-tr.c b/packet-tr.c index 9ccd32f1ce..502bdfcd3c 100644 --- a/packet-tr.c +++ b/packet-tr.c @@ -2,7 +2,7 @@ * Routines for Token-Ring packet disassembly * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-tr.c,v 1.38 2000/05/11 08:15:53 gram Exp $ + * $Id: packet-tr.c,v 1.39 2000/05/11 22:04:17 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -280,6 +280,7 @@ dissect_tr(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { int frame_type; guint8 trn_rif_bytes; guint8 actual_rif_bytes; + tvbuff_t *next_tvb; /* The trn_hdr struct, as separate variables */ guint8 trn_ac; /* access control field */ @@ -479,6 +480,7 @@ dissect_tr(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { offset += 14 + actual_rif_bytes + fixoffset; if (IS_DATA_IN_FRAME(offset)) { + next_tvb = tvb_new_subset(pi.compat_top_tvb, offset, -1); /* The package is either MAC or LLC */ switch (frame_type) { /* MAC */ @@ -486,11 +488,11 @@ dissect_tr(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { dissect_trmac(pd, offset, fd, tree); break; case 1: - dissect_llc(pd, offset, fd, tree); + dissect_llc(next_tvb, &pi, tree); break; default: /* non-MAC, non-LLC, i.e., "Reserved" */ - dissect_data(pd, offset, fd, tree); + dissect_data_tvb(next_tvb, &pi, tree); break; } } diff --git a/packet-vlan.c b/packet-vlan.c index bb5c0a78ab..d747a855b4 100644 --- a/packet-vlan.c +++ b/packet-vlan.c @@ -1,7 +1,7 @@ /* packet-vlan.c * Routines for VLAN 802.1Q ethernet header disassembly * - * $Id: packet-vlan.c,v 1.11 2000/05/11 08:15:55 gram Exp $ + * $Id: packet-vlan.c,v 1.12 2000/05/11 22:04:17 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -72,6 +72,7 @@ static void dissect_vlan(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_tree *ti, *vlan_tree = NULL; guint16 tci,encap_proto; + tvbuff_t *next_tvb; if (!BYTES_ARE_IN_FRAME(offset, 2*sizeof(guint16))) { return; @@ -97,11 +98,12 @@ dissect_vlan(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_tree_add_item(vlan_tree, hf_vlan_id, NullTVB, offset, 2, tci); } + next_tvb = tvb_new_subset(pi.compat_top_tvb, offset+4, -1); if ( encap_proto <= IEEE_802_3_MAX_LEN) { if ( pd[offset+4] == 0xff && pd[offset+5] == 0xff ) { dissect_ipx(pd,offset+4,fd,tree); } else { - dissect_llc(pd,offset+4,fd,tree); + dissect_llc(next_tvb, &pi, tree); } } else { ethertype(encap_proto, offset+4, pd, fd, tree, vlan_tree, hf_vlan_etype); @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.80 2000/05/11 08:15:58 gram Exp $ + * $Id: packet.c,v 1.81 2000/05/11 22:04:18 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -1214,7 +1214,7 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree) } } CATCH(BoundsError) { - proto_tree_add_text(tree, NullTVB, 0, 0, "Short Frame: [%s]", pi.current_proto ); + proto_tree_add_text(tree, NullTVB, 0, 0, "[Short Frame: %s]", pi.current_proto ); } ENDTRY; @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.184 2000/05/11 08:15:59 gram Exp $ + * $Id: packet.h,v 1.185 2000/05/11 22:04:18 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -347,6 +347,7 @@ void init_dissect_rpc(void); */ void dissect_packet(const u_char *, frame_data *, proto_tree *); void dissect_data(const u_char *, int, frame_data *, proto_tree *); +void dissect_data_tvb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); /* These functions are in ethertype.c */ |