Convert OSI CLNP into new protocol tree dissectors.

svn path=/trunk/; revision=688
This commit is contained in:
Laurent Deniel 1999-09-18 15:51:31 +00:00
parent 89e7f49262
commit 86220d8c7a
1 changed files with 396 additions and 355 deletions

View File

@ -1,7 +1,7 @@
/* packet-osi.c
* Routines for ISO/OSI network and transport protocol packet disassembly
*
* $Id: packet-osi.c,v 1.9 1999/09/11 16:41:19 deniel Exp $
* $Id: packet-osi.c,v 1.10 1999/09/18 15:51:31 deniel Exp $
* Laurent Deniel <deniel@worldnet.fr>
*
* Ethereal - Network traffic analyzer
@ -45,7 +45,22 @@
#include <glib.h>
#include "packet.h"
/* protocols and fields */
static int proto_clnp = -1;
static int hf_clnp_id = -1;
static int hf_clnp_length = -1;
static int hf_clnp_version = -1;
static int hf_clnp_ttl = -1;
static int hf_clnp_type = -1;
static int hf_clnp_pdu_length = -1;
static int hf_clnp_checksum = -1;
static int hf_clnp_dest_length = -1;
static int hf_clnp_dest = -1;
static int hf_clnp_src_length = -1;
static int hf_clnp_src = -1;
static int proto_cotp = -1;
/* Network layer protocol identifiers */
@ -471,7 +486,8 @@ static int osi_decode_ED(const u_char *pd, int offset,
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "COTP");
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "ED TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
col_add_fstr(fd, COL_INFO, "ED TPDU (%d) dst-ref: 0x%04x",
tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, proto_cotp, offset, li + 1, NULL);
@ -553,7 +569,8 @@ static int osi_decode_RJ(const u_char *pd, int offset,
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "COTP");
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "RJ TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
col_add_fstr(fd, COL_INFO, "RJ TPDU (%d) dst-ref: 0x%04x",
tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, proto_cotp, offset, li + 1, NULL);
@ -1224,7 +1241,8 @@ static int osi_decode_EA(const u_char *pd, int offset,
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "COTP");
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "EA TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
col_add_fstr(fd, COL_INFO,
"EA TPDU (%d) dst-ref: 0x%04x", tpdu_nr, dst_ref);
if (tree) {
ti = proto_tree_add_item(tree, proto_cotp, offset, li + 1, NULL);
@ -1331,7 +1349,8 @@ static int osi_decode_ER(const u_char *pd, int offset,
} /* osi_decode_ER */
void dissect_cotp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void dissect_cotp(const u_char *pd, int offset, frame_data *fd,
proto_tree *tree)
{
int status = -1;
@ -1423,7 +1442,8 @@ static gchar *print_nsap(const u_char *nsap, int length)
} /* print_nsap */
void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void dissect_clnp(const u_char *pd, int offset, frame_data *fd,
proto_tree *tree)
{
struct clnp_header clnp;
@ -1451,26 +1471,31 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
if (tree) {
ti = proto_tree_add_item(tree, proto_clnp, offset, clnp.cnf_hdr_len, NULL);
clnp_tree = proto_item_add_subtree(ti, ETT_CLNP);
proto_tree_add_text(clnp_tree, offset, 1,
"Protocol identifier: 0x%02x", clnp.cnf_proto_id);
proto_tree_add_text(clnp_tree, offset + 1, 1,
"Length: %d", clnp.cnf_hdr_len);
proto_tree_add_text(clnp_tree, offset + 2, 1,
"Version: %d", clnp.cnf_vers);
proto_tree_add_text(clnp_tree, offset + 3, 1,
proto_tree_add_item_format(clnp_tree, hf_clnp_id, offset, 1,
clnp.cnf_proto_id,
"Protocol identifier: 0x%02x",
clnp.cnf_proto_id);
proto_tree_add_item(clnp_tree, hf_clnp_length, offset + 1, 1,
clnp.cnf_hdr_len);
proto_tree_add_item(clnp_tree, hf_clnp_version, offset + 2, 1,
clnp.cnf_vers);
proto_tree_add_item_format(clnp_tree, hf_clnp_ttl, offset + 3, 1,
clnp.cnf_ttl,
"TTL: %d (%d secs)",
clnp.cnf_ttl, clnp.cnf_ttl / 2);
proto_tree_add_text(clnp_tree, offset + 4, 1,
proto_tree_add_item_format(clnp_tree, hf_clnp_type, offset + 4, 1,
clnp.cnf_type,
"Type code: 0x%02x (%s%s%s%s)",
clnp.cnf_type,
(clnp.cnf_type & CNF_SEG_OK) ? "S " : "",
(clnp.cnf_type & CNF_MORE_SEGS) ? "M " : "",
(clnp.cnf_type & CNF_ERR_OK) ? "E " : "",
(clnp.cnf_type & CNF_TYPE) == DT_NPDU ? "DT" : "ER");
proto_tree_add_text(clnp_tree, offset + 5, 2,
"PDU segment length: %d",
(clnp.cnf_type & CNF_TYPE) == DT_NPDU ?
"DT" : "ER");
proto_tree_add_item(clnp_tree, hf_clnp_pdu_length, offset + 5, 2,
EXTRACT_SHORT(&clnp.cnf_seglen_msb));
proto_tree_add_text(clnp_tree, offset + 7, 2,
proto_tree_add_item_format(clnp_tree, hf_clnp_checksum, offset + 7, 2,
EXTRACT_SHORT(&clnp.cnf_cksum_msb),
"Checksum: 0x%04x",
EXTRACT_SHORT(&clnp.cnf_cksum_msb));
} /* tree */
@ -1490,14 +1515,17 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
src_len = pd[offset + dst_len + 1];
if (tree) {
proto_tree_add_text(clnp_tree, offset, 1,
"Destination address length: 0x%02x", dst_len);
proto_tree_add_text(clnp_tree, offset + 1 , dst_len,
proto_tree_add_item(clnp_tree, hf_clnp_dest_length, offset, 1,
dst_len);
proto_tree_add_item_format(clnp_tree, hf_clnp_dest, offset + 1 , dst_len,
&pd[offset + 1],
"Destination address: %s",
print_nsap(&pd[offset + 1], dst_len));
proto_tree_add_text(clnp_tree, offset + 1 + dst_len, 1,
"Source address length: 0x%02x", src_len);
proto_tree_add_text(clnp_tree, offset + dst_len + 2, src_len,
proto_tree_add_item(clnp_tree, hf_clnp_src_length,
offset + 1 + dst_len, 1, src_len);
proto_tree_add_item_format(clnp_tree, hf_clnp_src,
offset + dst_len + 2, src_len,
&pd[offset + dst_len + 2],
"Source address: %s",
print_nsap(&pd[offset + dst_len + 2], src_len));
}
@ -1556,7 +1584,8 @@ void dissect_clnp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree
/* main entry point */
void dissect_osi(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
void dissect_osi(const u_char *pd, int offset, frame_data *fd,
proto_tree *tree)
{
switch (pd[offset]) {
@ -1564,40 +1593,34 @@ void dissect_osi(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
/* only CLNP is currently decoded */
case ISO8473_CLNP:
if (check_col(fd, COL_PROTOCOL))
{
if (check_col(fd, COL_PROTOCOL)) {
col_add_str(fd, COL_PROTOCOL, "CLNP");
}
dissect_clnp(pd, offset, fd, tree);
break;
case ISO9542_ESIS:
if (check_col(fd, COL_PROTOCOL))
{
if (check_col(fd, COL_PROTOCOL)) {
col_add_str(fd, COL_PROTOCOL, "ESIS");
}
dissect_data(pd, offset, fd, tree);
break;
case ISO9542X25_ESIS:
if (check_col(fd, COL_PROTOCOL))
{
if (check_col(fd, COL_PROTOCOL)) {
col_add_str(fd, COL_PROTOCOL, "ESIS(X25)");
}
dissect_data(pd, offset, fd, tree);
break;
case ISO10589_ISIS:
if (check_col(fd, COL_PROTOCOL))
{
if (check_col(fd, COL_PROTOCOL)) {
col_add_str(fd, COL_PROTOCOL, "ISIS");
}
dissect_data(pd, offset, fd, tree);
break;
default:
if (check_col(fd, COL_PROTOCOL))
{
if (check_col(fd, COL_PROTOCOL)) {
col_add_str(fd, COL_PROTOCOL, "ISO");
}
if (check_col(fd, COL_INFO))
{
if (check_col(fd, COL_INFO)) {
col_add_fstr(fd, COL_INFO, "Unknown ISO protocol (%02x)", pd[offset]);
}
dissect_data(pd, offset, fd, tree);
@ -1606,22 +1629,40 @@ void dissect_osi(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
} /* dissect_osi */
void
proto_register_clnp(void)
void proto_register_clnp(void)
{
/* static hf_register_info hf[] = {
{ &variable,
{ "Name", "clnp.abbreviation", TYPE, VALS_POINTER }},
};*/
static hf_register_info hf[] = {
{ &hf_clnp_id,
{ "Protocol identifier", "clnp.id", FT_UINT8, NULL }},
{ &hf_clnp_length,
{ "Length", "clnp.len", FT_UINT8, NULL }},
{ &hf_clnp_version,
{ "Version", "clnp.version", FT_UINT8, NULL }},
{ &hf_clnp_ttl,
{ "TTL", "clnp.ttl", FT_UINT8, NULL }},
{ &hf_clnp_type,
{ "Type code", "clnp.type", FT_UINT8, NULL }},
{ &hf_clnp_pdu_length,
{ "PDU segment length", "clnp.pdu.len", FT_UINT16, NULL }},
{ &hf_clnp_checksum,
{ "Checksum", "clnp.checksum",FT_UINT16, NULL }},
{ &hf_clnp_dest_length,
{ "Destination address length", "clnp.dsap.len", FT_UINT8, NULL }},
{ &hf_clnp_dest,
{ "Destination address", "clnp.dsap", FT_BYTES, NULL }},
{ &hf_clnp_src_length,
{ "Source address length","clnp.ssap.len",FT_UINT8, NULL }},
{ &hf_clnp_src,
{ "Source address", "clnp.ssap", FT_BYTES, NULL }},
};
proto_clnp = proto_register_protocol("ISO CLNP", "clnp");
/* proto_register_field_array(proto_clnp, hf, array_length(hf));*/
proto_register_field_array(proto_clnp, hf, array_length(hf));
}
void
proto_register_cotp(void)
void proto_register_cotp(void)
{
/* static hf_register_info hf[] = {
/* static hf_register_info hf[] = {
{ &variable,
{ "Name", "cotp.abbreviation", TYPE, VALS_POINTER }},
};*/