diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-11-18 10:38:33 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-11-18 10:38:33 +0000 |
commit | c8196a1d1ca5a5021388cfc1bcbb64cdda5e9dc3 (patch) | |
tree | 5e117f446c6e233d14b642596d67c985e685f328 /packet-osi.c | |
parent | 56a0c40c18271046d22bffcc5db10cfb16a2bf6c (diff) | |
download | wireshark-c8196a1d1ca5a5021388cfc1bcbb64cdda5e9dc3.tar.gz wireshark-c8196a1d1ca5a5021388cfc1bcbb64cdda5e9dc3.tar.bz2 wireshark-c8196a1d1ca5a5021388cfc1bcbb64cdda5e9dc3.zip |
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors.
Register the IP dissector and have dissectors that call it directly
(rather than through a port table) call it through a handle.
Add a routine "tvb_set_reported_length()" which a dissector can use if
it was handed a tvbuff that contains more data than is actually in its
part of the packet - for example, handing a padded Ethernet frame to IP;
the routine sets the reported length of the tvbuff (and also adjusts the
actual length, as appropriate). Then use it in IP.
Given that, "ethertype()" can determine how much of the Ethernet frame
was actually part of an IP datagram (and can do the same for other
protocols under Ethernet that use "tvb_set_reported_length()"; have it
return the actual length, and have "dissect_eth()" and "dissect_vlan()"
use that to mark trailer data in Ethernet II frames as well as in 802.3
frames.
svn path=/trunk/; revision=2658
Diffstat (limited to 'packet-osi.c')
-rw-r--r-- | packet-osi.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/packet-osi.c b/packet-osi.c index e2a9c8c5e3..0a39f27a94 100644 --- a/packet-osi.c +++ b/packet-osi.c @@ -2,7 +2,7 @@ * Routines for ISO/OSI network and transport protocol packet disassembly * Main entrance point and common functions * - * $Id: packet-osi.c,v 1.35 2000/11/17 06:02:21 guy Exp $ + * $Id: packet-osi.c,v 1.36 2000/11/18 10:38:24 guy Exp $ * Laurent Deniel <deniel@worldnet.fr> * Ralf Schneider <Ralf.Schneider@t-online.de> * @@ -176,25 +176,29 @@ gchar *print_nsap_net( const u_char *buffer, int length) } /* print_nsap */ -gchar *calc_checksum( const u_char *buffer, u_int len, u_int checksum) { +gchar *calc_checksum( tvbuff_t *tvb, int offset, u_int len, u_int checksum) { u_int calc_sum = 0; u_int count = 0; + const gchar *buffer; + guint available_len; - static char *checksum_string[] = { "Not Used", - "Is good", - "Is wrong" }; if ( 0 == checksum ) - return( checksum_string[0] ); + return( "Not Used" ); + available_len = tvb_length_remaining( tvb, offset ); + if ( available_len < len ) + return( "Not checkable - not all of packet was captured" ); + + buffer = tvb_get_ptr( tvb, offset, len ); for ( count = 0; count < len; count++ ) { calc_sum += (u_int) buffer[count]; } calc_sum %= 255; /* modulo 255 divison */ if ( 0 == calc_sum ) - return( checksum_string[1] ); + return( "Is good" ); else - return( checksum_string[2] ); + return( "Is wrong" ); /* XXX - what should the checksum be? */ } @@ -222,37 +226,42 @@ const value_string nlpid_vals[] = { static dissector_table_t subdissector_table; -void dissect_osi(const u_char *pd, int offset, frame_data *fd, - proto_tree *tree) +void dissect_osi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + guint8 nlpid; + + pinfo->current_proto = "OSI"; + + nlpid = tvb_get_guint8(tvb, 0); + /* do lookup with the subdissector table */ - if (old_dissector_try_port(subdissector_table, pd[offset], pd, offset, fd, tree)) + if (dissector_try_port(subdissector_table, nlpid, tvb, pinfo, tree)) return; - switch (pd[offset]) { + switch (nlpid) { /* ESIS (X.25) is not currently decoded */ case NLPID_ISO9542X25_ESIS: - if (check_col(fd, COL_PROTOCOL)) { - col_add_str(fd, COL_PROTOCOL, "ESIS (X.25)"); + if (check_col(pinfo->fd, COL_PROTOCOL)) { + col_add_str(pinfo->fd, COL_PROTOCOL, "ESIS (X.25)"); } - old_dissect_data(pd, offset, fd, tree); + dissect_data(tvb, 0, pinfo, tree); break; case NLPID_ISO10747_IDRP: - if (check_col(fd, COL_PROTOCOL)) { - col_add_str(fd, COL_PROTOCOL, "IDRP"); + if (check_col(pinfo->fd, COL_PROTOCOL)) { + col_add_str(pinfo->fd, COL_PROTOCOL, "IDRP"); } - old_dissect_data(pd, offset, fd, tree); + dissect_data(tvb, 0, pinfo, tree); break; default: - if (check_col(fd, COL_PROTOCOL)) { - col_add_str(fd, COL_PROTOCOL, "ISO"); + if (check_col(pinfo->fd, COL_PROTOCOL)) { + col_add_str(pinfo->fd, COL_PROTOCOL, "ISO"); } - if (check_col(fd, COL_INFO)) { - col_add_fstr(fd, COL_INFO, "Unknown ISO protocol (%02x)", pd[offset]); + if (check_col(pinfo->fd, COL_INFO)) { + col_add_fstr(pinfo->fd, COL_INFO, "Unknown ISO protocol (%02x)", nlpid); } - old_dissect_data(pd, offset, fd, tree); + dissect_data(tvb, 0, pinfo, tree); break; } } /* dissect_osi */ @@ -269,6 +278,6 @@ proto_register_osi(void) void proto_reg_handoff_osi(void) { - old_dissector_add("llc.dsap", SAP_OSINL, dissect_osi); - old_dissector_add("null.type", BSD_AF_ISO, dissect_osi); + dissector_add("llc.dsap", SAP_OSINL, dissect_osi); + dissector_add("null.type", BSD_AF_ISO, dissect_osi); } |