2000-03-02 07:27:05 +00:00
|
|
|
/* packet-h1.c
|
|
|
|
* Routines for Sinec H1 packet disassembly
|
|
|
|
* Gerrit Gehnen <G.Gehnen@atrie.de>
|
|
|
|
*
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
* $Id: packet-h1.c,v 1.12 2000/08/13 14:08:11 deniel Exp $
|
2000-03-02 07:27:05 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include "packet.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
static int proto_h1 = -1;
|
|
|
|
static int hf_h1_header = -1;
|
|
|
|
static int hf_h1_len = -1;
|
|
|
|
static int hf_h1_opfield = -1;
|
|
|
|
static int hf_h1_oplen = -1;
|
|
|
|
static int hf_h1_opcode = -1;
|
|
|
|
static int hf_h1_requestblock = -1;
|
|
|
|
static int hf_h1_requestlen = -1;
|
|
|
|
static int hf_h1_dbnr = -1;
|
|
|
|
static int hf_h1_dwnr = -1;
|
|
|
|
static int hf_h1_dlen = -1;
|
|
|
|
static int hf_h1_org = -1;
|
|
|
|
static int hf_h1_response = -1;
|
|
|
|
static int hf_h1_response_len = -1;
|
|
|
|
static int hf_h1_response_value = -1;
|
|
|
|
static int hf_h1_empty_len = -1;
|
|
|
|
static int hf_h1_empty = -1;
|
|
|
|
|
|
|
|
#define EMPTY_BLOCK 0xFF
|
|
|
|
#define OPCODE_BLOCK 0x01
|
|
|
|
#define REQUEST_BLOCK 0x03
|
|
|
|
#define RESPONSE_BLOCK 0x0F
|
|
|
|
|
|
|
|
static const value_string opcode_vals[] = {
|
|
|
|
{3, "Write Request"},
|
|
|
|
{4, "Write Response"},
|
|
|
|
{5, "Read Request"},
|
|
|
|
{6, "Read Response"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string org_vals[] = {
|
|
|
|
{0x01, "DB"},
|
|
|
|
{0x02, "MB"},
|
|
|
|
{0x03, "EB"},
|
|
|
|
{0x04, "AB"},
|
|
|
|
{0x05, "PB"},
|
|
|
|
{0x06, "ZB"},
|
|
|
|
{0x07, "TB"},
|
|
|
|
{0x08, "BS"},
|
|
|
|
{0x09, "AS"},
|
|
|
|
{0x0a, "DX"},
|
|
|
|
{0x10, "DE"},
|
|
|
|
{0x11, "QB"},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string returncode_vals[] = {
|
|
|
|
{0x00, "No error"},
|
|
|
|
{0x02, "Requested block does not exist"},
|
|
|
|
{0x03, "Requested block too small"},
|
2000-04-28 19:35:41 +00:00
|
|
|
{0xFF, "Error, reason unknown"},
|
2000-03-02 07:27:05 +00:00
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint ett_h1 = -1;
|
|
|
|
static gint ett_opcode = -1;
|
|
|
|
static gint ett_org = -1;
|
|
|
|
static gint ett_response = -1;
|
|
|
|
static gint ett_empty = -1;
|
|
|
|
|
2000-07-21 07:51:34 +00:00
|
|
|
static gboolean dissect_h1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2000-03-02 07:27:05 +00:00
|
|
|
proto_tree *h1_tree = NULL;
|
2000-07-21 07:51:34 +00:00
|
|
|
|
2000-03-02 07:27:05 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *opcode_tree = NULL;
|
|
|
|
proto_tree *org_tree = NULL;
|
|
|
|
proto_tree *response_tree = NULL;
|
|
|
|
proto_tree *empty_tree = NULL;
|
|
|
|
|
2000-05-08 17:19:42 +00:00
|
|
|
unsigned int position = 3;
|
2000-07-21 07:51:34 +00:00
|
|
|
unsigned int offset=0;
|
2000-03-02 07:27:05 +00:00
|
|
|
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
if (!proto_is_protocol_enabled(proto_h1))
|
|
|
|
return FALSE;
|
|
|
|
|
2000-07-21 07:51:34 +00:00
|
|
|
if (!(tvb_get_guint8(tvb,offset) == 'S' && tvb_get_guint8(tvb,offset+1) == '5')) {
|
2000-04-28 19:35:41 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (check_col (pinfo->fd, COL_PROTOCOL))
|
|
|
|
col_add_str (pinfo->fd, COL_PROTOCOL, "H1");
|
|
|
|
if (check_col (pinfo->fd, COL_INFO))
|
|
|
|
col_add_str (pinfo->fd, COL_INFO, "S5: ");
|
2000-03-02 07:27:05 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
ti = proto_tree_add_item (tree, proto_h1, tvb, offset, 16, FALSE);
|
2000-03-02 07:27:05 +00:00
|
|
|
h1_tree = proto_item_add_subtree (ti, ett_h1);
|
2000-07-21 07:51:34 +00:00
|
|
|
proto_tree_add_uint (h1_tree, hf_h1_header, tvb, offset, 2,
|
|
|
|
tvb_get_ntohs(tvb,offset));
|
|
|
|
proto_tree_add_uint (h1_tree, hf_h1_len, tvb, offset + 2, 1,
|
|
|
|
tvb_get_guint8(tvb,offset+2));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
|
2000-07-21 07:51:34 +00:00
|
|
|
while (position < tvb_get_guint8(tvb,offset+2))
|
2000-03-02 07:27:05 +00:00
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
switch (tvb_get_guint8(tvb,offset + position))
|
2000-03-02 07:27:05 +00:00
|
|
|
{
|
|
|
|
case OPCODE_BLOCK:
|
|
|
|
if (h1_tree)
|
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
ti = proto_tree_add_uint (h1_tree, hf_h1_opfield, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset+position+1),
|
|
|
|
tvb_get_guint8(tvb,offset+position));
|
2000-03-02 07:27:05 +00:00
|
|
|
opcode_tree = proto_item_add_subtree (ti, ett_opcode);
|
2000-07-21 07:51:34 +00:00
|
|
|
proto_tree_add_uint (opcode_tree, hf_h1_oplen, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 1, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 1));
|
|
|
|
proto_tree_add_uint (opcode_tree, hf_h1_opcode, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 2, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 2));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (check_col (pinfo->fd, COL_INFO))
|
2000-03-02 07:27:05 +00:00
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
col_append_str (pinfo->fd, COL_INFO,
|
2000-07-21 07:51:34 +00:00
|
|
|
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
2000-04-28 19:35:41 +00:00
|
|
|
opcode_vals,"Unknown Opcode (0x%2.2x)"));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case REQUEST_BLOCK:
|
|
|
|
if (h1_tree)
|
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
ti = proto_tree_add_uint (h1_tree, hf_h1_requestblock, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 1),
|
|
|
|
tvb_get_guint8(tvb,offset + position));
|
2000-03-02 07:27:05 +00:00
|
|
|
org_tree = proto_item_add_subtree (ti, ett_org);
|
2000-07-21 07:51:34 +00:00
|
|
|
proto_tree_add_uint (org_tree, hf_h1_requestlen, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 1, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+1));
|
|
|
|
proto_tree_add_uint (org_tree, hf_h1_org, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 2, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+2));
|
|
|
|
proto_tree_add_uint (org_tree, hf_h1_dbnr, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 3, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+3));
|
|
|
|
proto_tree_add_uint (org_tree, hf_h1_dwnr, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 4, 2,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_ntohs(tvb,offset+position+4));
|
|
|
|
proto_tree_add_int (org_tree, hf_h1_dlen, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 6, 2,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_ntohs(tvb,offset+position+6));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (check_col (pinfo->fd, COL_INFO))
|
2000-03-02 07:27:05 +00:00
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
col_append_fstr (pinfo->fd, COL_INFO, " %s %d",
|
2000-07-21 07:51:34 +00:00
|
|
|
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
2000-04-28 19:35:41 +00:00
|
|
|
org_vals,"Unknown Type (0x%2.2x)"),
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 3));
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
col_append_fstr (pinfo->fd, COL_INFO, " DW %d",
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_ntohs(tvb,offset+position+4));
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
col_append_fstr (pinfo->fd, COL_INFO, " Count %d",
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_ntohs(tvb,offset+position+6));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RESPONSE_BLOCK:
|
|
|
|
if (h1_tree)
|
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
ti = proto_tree_add_uint (h1_tree, hf_h1_response, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 1),
|
|
|
|
tvb_get_guint8(tvb,offset + position));
|
2000-03-02 07:27:05 +00:00
|
|
|
response_tree = proto_item_add_subtree (ti, ett_response);
|
2000-07-21 07:51:34 +00:00
|
|
|
proto_tree_add_uint (response_tree, hf_h1_response_len, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 1, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+1));
|
|
|
|
proto_tree_add_uint (response_tree, hf_h1_response_value, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 2, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+2));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
if (check_col (pinfo->fd, COL_INFO))
|
2000-03-02 07:27:05 +00:00
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
col_append_fstr (pinfo->fd, COL_INFO, " %s",
|
2000-07-21 07:51:34 +00:00
|
|
|
val_to_str (tvb_get_guint8(tvb,offset + position + 2),
|
2000-04-28 19:35:41 +00:00
|
|
|
returncode_vals,"Unknown Returcode (0x%2.2x"));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EMPTY_BLOCK:
|
|
|
|
if (h1_tree)
|
|
|
|
{
|
2000-07-21 07:51:34 +00:00
|
|
|
ti = proto_tree_add_uint (h1_tree, hf_h1_empty, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position + 1),
|
|
|
|
tvb_get_guint8(tvb,offset + position));
|
2000-03-02 07:27:05 +00:00
|
|
|
empty_tree = proto_item_add_subtree (ti, ett_empty);
|
|
|
|
|
2000-07-21 07:51:34 +00:00
|
|
|
proto_tree_add_uint (empty_tree, hf_h1_empty_len, tvb,
|
2000-03-02 07:27:05 +00:00
|
|
|
offset + position + 1, 1,
|
2000-07-21 07:51:34 +00:00
|
|
|
tvb_get_guint8(tvb,offset + position+1));
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2000-05-08 17:19:42 +00:00
|
|
|
/* This is not a valid telegram. So cancel dissection
|
|
|
|
and try the next dissector */
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
2000-07-21 07:51:34 +00:00
|
|
|
position += tvb_get_guint8(tvb,offset + position + 1); /* Goto next section */
|
2000-03-02 07:38:02 +00:00
|
|
|
} /* ..while */
|
2000-07-21 07:51:34 +00:00
|
|
|
next_tvb = tvb_new_subset(tvb, offset+tvb_get_guint8(tvb,offset+2), -1, -1);
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
dissect_data(next_tvb, pinfo, tree);
|
2000-03-02 07:27:05 +00:00
|
|
|
|
2000-07-21 07:51:34 +00:00
|
|
|
return TRUE;
|
2000-03-02 07:27:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_h1 (void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{&hf_h1_header,
|
|
|
|
{"H1-Header", "h1.header", FT_UINT16, BASE_HEX, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_len,
|
|
|
|
{"Length indicator", "h1.len", FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_opfield,
|
|
|
|
{"Operation identifier", "h1.opfield", FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_oplen,
|
|
|
|
{"Operation length", "h1.oplen", FT_UINT8, BASE_HEX, NULL, 0x0, ""}},
|
|
|
|
{&hf_h1_opcode,
|
|
|
|
{"Opcode", "h1.opcode", FT_UINT8, BASE_HEX, VALS (opcode_vals), 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_requestblock,
|
|
|
|
{"Request identifier", "h1.request", FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_requestlen,
|
|
|
|
{"Request length", "h1.reqlen", FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_org,
|
|
|
|
{"Memory type", "h1.org", FT_UINT8, BASE_HEX, VALS (org_vals), 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_dbnr,
|
|
|
|
{"Memory block number", "h1.dbnr", FT_UINT8, BASE_DEC, NULL, 0x0, ""}},
|
|
|
|
{&hf_h1_dwnr,
|
|
|
|
{"Address within memory block", "h1.dwnr", FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_dlen,
|
|
|
|
{"Length in words", "h1.dlen", FT_INT16, BASE_DEC, NULL, 0x0, ""}},
|
|
|
|
{&hf_h1_response,
|
2000-07-21 07:51:34 +00:00
|
|
|
{"Response identifier", "h1.response", FT_UINT8, BASE_HEX, NULL, 0x0, ""}},
|
2000-03-02 07:27:05 +00:00
|
|
|
{&hf_h1_response_len,
|
|
|
|
{"Response length", "h1.reslen", FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
""}},
|
|
|
|
{&hf_h1_response_value,
|
|
|
|
{"Response value", "h1.resvalue", FT_UINT8, BASE_DEC,
|
|
|
|
VALS (returncode_vals), 0x0, ""}},
|
|
|
|
{&hf_h1_empty,
|
2000-04-13 06:26:31 +00:00
|
|
|
{"Empty field", "h1.empty", FT_UINT8, BASE_HEX, NULL, 0x0,
|
2000-03-02 07:27:05 +00:00
|
|
|
""}},
|
|
|
|
{&hf_h1_empty_len,
|
|
|
|
{"Empty field length", "h1.empty_len", FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
""}}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_h1,
|
|
|
|
&ett_opcode,
|
|
|
|
&ett_response,
|
|
|
|
&ett_org,
|
|
|
|
&ett_empty
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_h1 = proto_register_protocol ("Sinec H1 Protocol", "h1");
|
|
|
|
proto_register_field_array (proto_h1, hf, array_length (hf));
|
|
|
|
proto_register_subtree_array (ett, array_length (ett));
|
|
|
|
}
|
Add routines to:
register lists of "heuristic" dissectors, which are handed a
frame that may or may contain a payload for the protocol they
dissect, and that return FALSE if it's not or dissect the packet
and return TRUE if it is;
add a dissector to such a list;
go through such a list, calling each dissector until either a
dissector returns TRUE, in which case the routine returns TRUE,
or it runs out of entries in the list, in which case the routine
returns FALSE.
Have lists of heuristic dissectors for TCP and for COTP when used with
the Inactive Subset of CLNP, and add the GIOP and Yahoo Messenger
dissectors to the first list and the Sinec H1 dissector to the second
list.
Make the dissector name argument to "dissector_add()" and
"dissector_delete()" a "const char *" rarther than just a "char *".
Add "heur_dissector_add()", the routine to add a heuristic dissector to
a list of heuristic dissectors, to the set of routines we can export to
plugins through a table on platforms where dynamically-loaded code can't
call stuff in the main program, and initialize the element in the table
in question for "dissector_add()" (which we'd forgotten to do).
svn path=/trunk/; revision=1909
2000-05-05 09:32:36 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_h1(void)
|
|
|
|
{
|
|
|
|
heur_dissector_add("cotp_is", dissect_h1);
|
|
|
|
}
|