Don't call subdissectors / expert...() / col...() under 'if (tree)'

Also:
 Remove some uneeded initializers;
 Do some whitespace cleanup and re-formatting.

svn path=/trunk/; revision=43681
This commit is contained in:
Bill Meier 2012-07-12 17:22:47 +00:00
parent 02d23f97b0
commit 859affc2bd
8 changed files with 1556 additions and 1575 deletions

View File

@ -2479,132 +2479,130 @@ dissect_eigrp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* correctly, building or updating whatever state information is necessary,
* in either case.
*/
if (tree) {
/* NOTE: The offset and length values in the call to
* "proto_tree_add_item()" define what data bytes to highlight in the
* hex display window when the line in the protocol tree display
* corresponding to that item is selected.
*/
/* NOTE: The offset and length values in the call to
* "proto_tree_add_item()" define what data bytes to highlight in the
* hex display window when the line in the protocol tree display
* corresponding to that item is selected.
*/
/* create display subtree for the protocol */
ti = proto_tree_add_protocol_format(tree, proto_eigrp, tvb, 0, -1,
"Cisco EIGRP");
eigrp_tree = proto_item_add_subtree(ti, ett_eigrp);
proto_tree_add_item(eigrp_tree, hf_eigrp_version, tvb, 0, 1,
ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_opcode, tvb, 1, 1,
ENC_BIG_ENDIAN);
/* create display subtree for the protocol */
ti = proto_tree_add_protocol_format(tree, proto_eigrp, tvb, 0, -1,
"Cisco EIGRP");
eigrp_tree = proto_item_add_subtree(ti, ett_eigrp);
proto_tree_add_item(eigrp_tree, hf_eigrp_version, tvb, 0, 1,
ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_opcode, tvb, 1, 1,
ENC_BIG_ENDIAN);
size = tvb_length(tvb);
checksum = tvb_get_ntohs(tvb, 2);
cacl_checksum = ip_checksum(tvb_get_ptr(tvb, 0, size), size);
size = tvb_length(tvb);
checksum = tvb_get_ntohs(tvb, 2);
cacl_checksum = ip_checksum(tvb_get_ptr(tvb, 0, size), size);
if (cacl_checksum == checksum) {
proto_tree_add_text(eigrp_tree, tvb, 2, 2,
"Checksum: 0x%02x [incorrect]",
checksum);
expert_add_info_format(pinfo, ti, PI_RESPONSE_CODE, PI_NOTE,
"Checksum: 0x%02x [incorrect, should be 0x%02x]",
checksum, cacl_checksum);
} else {
proto_tree_add_text(eigrp_tree, tvb, 2, 2,
"Checksum: 0x%02x [correct]", checksum);
}
if (cacl_checksum == checksum) {
proto_tree_add_text(eigrp_tree, tvb, 2, 2,
"Checksum: 0x%02x [incorrect]",
checksum);
expert_add_info_format(pinfo, ti, PI_RESPONSE_CODE, PI_NOTE,
"Checksum: 0x%02x [incorrect, should be 0x%02x]",
checksum, cacl_checksum);
} else {
proto_tree_add_text(eigrp_tree, tvb, 2, 2,
"Checksum: 0x%02x [correct]", checksum);
}
/* Decode the EIGRP Flags Field */
proto_tree_add_bitmask(eigrp_tree, tvb, 4, hf_eigrp_flags, ett_eigrp_flags,
eigrp_flag_fields, ENC_BIG_ENDIAN);
/* Decode the EIGRP Flags Field */
proto_tree_add_bitmask(eigrp_tree, tvb, 4, hf_eigrp_flags, ett_eigrp_flags,
eigrp_flag_fields, ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_sequence, tvb, 8, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_acknowledge, tvb, 12, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_sequence, tvb, 8, 4,
ENC_BIG_ENDIAN);
proto_tree_add_item(eigrp_tree, hf_eigrp_acknowledge, tvb, 12, 4,
ENC_BIG_ENDIAN);
/* print out what family we dealing with... */
ti = proto_tree_add_item(eigrp_tree, hf_eigrp_vrid, tvb, 16, 2,
ENC_BIG_ENDIAN);
vrid = (tvb_get_ntohs(tvb, 16) & EIGRP_VRID_MASK);
proto_item_append_text(ti, " %s", val_to_str(vrid, eigrp_vrid2string,
""));
/* print out what family we dealing with... */
ti = proto_tree_add_item(eigrp_tree, hf_eigrp_vrid, tvb, 16, 2,
ENC_BIG_ENDIAN);
vrid = (tvb_get_ntohs(tvb, 16) & EIGRP_VRID_MASK);
proto_item_append_text(ti, " %s", val_to_str(vrid, eigrp_vrid2string,
""));
/* print autonomous-system */
proto_tree_add_item(eigrp_tree, hf_eigrp_as, tvb, 18, 2,
ENC_BIG_ENDIAN);
/* print autonomous-system */
proto_tree_add_item(eigrp_tree, hf_eigrp_as, tvb, 18, 2,
ENC_BIG_ENDIAN);
switch (opcode) {
case EIGRP_OPC_IPXSAP:
call_dissector(ipxsap_handle,
tvb_new_subset(tvb, EIGRP_HEADER_LENGTH, -1, -1), pinfo,
eigrp_tree);
break;
switch (opcode) {
case EIGRP_OPC_IPXSAP:
call_dissector(ipxsap_handle,
tvb_new_subset(tvb, EIGRP_HEADER_LENGTH, -1, -1), pinfo,
eigrp_tree);
break;
default:
while (tvb_reported_length_remaining(tvb, offset) > 0) {
tlv = tvb_get_ntohs(tvb, offset);
default:
while (tvb_reported_length_remaining(tvb, offset) > 0) {
tlv = tvb_get_ntohs(tvb, offset);
/* its a rose by the wrong name... */
if (tlv == EIGRP_TLV_MTR_TIDLIST) {
tlv = EIGRP_TLV_PEER_TIDLIST;
}
size = tvb_get_ntohs(tvb, offset + 2);
if (size == 0) {
ti = proto_tree_add_text(eigrp_tree, tvb, offset, -1,
"Corrupt TLV (Zero Size)");
expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR,
"Corrupt TLV (Zero Size)");
return(tvb_length(tvb));
}
ti = proto_tree_add_text(eigrp_tree, tvb, offset, size, "%s",
val_to_str(tlv, eigrp_tlv2string, "Unknown TLV (0x%04x)"));
tlv_tree = proto_item_add_subtree(ti, ett_eigrp_tlv);
proto_tree_add_item(tlv_tree, hf_eigrp_tlv_type, tvb,
offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_eigrp_tlv_len, tvb,
(offset + 2), 2, ENC_BIG_ENDIAN);
switch (tlv & EIGRP_TLV_RANGEMASK) {
case EIGRP_TLV_GENERAL:
dissect_eigrp_general_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_IPv4:
dissect_eigrp_ipv4_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_ATALK:
dissect_eigrp_atalk_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), tlv);
break;
case EIGRP_TLV_IPX:
dissect_eigrp_ipx_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_IPv6:
dissect_eigrp_ipv6_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_MP:
dissect_eigrp_multi_protocol_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1),
pinfo, tlv);
break;
case EIGRP_TLV_MTR:
dissect_eigrp_multi_topology_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1),
pinfo, tlv);
break;
default:
expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN,
"Unknown TLV Group (0x%04x)", tlv);
}
offset += size;
/* its a rose by the wrong name... */
if (tlv == EIGRP_TLV_MTR_TIDLIST) {
tlv = EIGRP_TLV_PEER_TIDLIST;
}
break;
size = tvb_get_ntohs(tvb, offset + 2);
if (size == 0) {
ti = proto_tree_add_text(eigrp_tree, tvb, offset, -1,
"Corrupt TLV (Zero Size)");
expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR,
"Corrupt TLV (Zero Size)");
return(tvb_length(tvb));
}
ti = proto_tree_add_text(eigrp_tree, tvb, offset, size, "%s",
val_to_str(tlv, eigrp_tlv2string, "Unknown TLV (0x%04x)"));
tlv_tree = proto_item_add_subtree(ti, ett_eigrp_tlv);
proto_tree_add_item(tlv_tree, hf_eigrp_tlv_type, tvb,
offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_eigrp_tlv_len, tvb,
(offset + 2), 2, ENC_BIG_ENDIAN);
switch (tlv & EIGRP_TLV_RANGEMASK) {
case EIGRP_TLV_GENERAL:
dissect_eigrp_general_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_IPv4:
dissect_eigrp_ipv4_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_ATALK:
dissect_eigrp_atalk_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), tlv);
break;
case EIGRP_TLV_IPX:
dissect_eigrp_ipx_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_IPv6:
dissect_eigrp_ipv6_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1), pinfo, tlv);
break;
case EIGRP_TLV_MP:
dissect_eigrp_multi_protocol_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1),
pinfo, tlv);
break;
case EIGRP_TLV_MTR:
dissect_eigrp_multi_topology_tlv(ti, tlv_tree, tvb_new_subset(tvb, (offset + 4), (size - 4), -1),
pinfo, tlv);
break;
default:
expert_add_info_format(pinfo, ti, PI_UNDECODED, PI_WARN,
"Unknown TLV Group (0x%04x)", tlv);
}
offset += size;
}
break;
}
/* Return the amount of data this dissector was able to dissect */

View File

@ -43,7 +43,7 @@
#include <epan/expert.h>
#define FCOE_HEADER_LEN 14 /* header: version, SOF, and padding */
#define FCOE_TRAILER_LEN 8 /* trailer: CRC, EOF, and padding */
#define FCOE_TRAILER_LEN 8 /* trailer: CRC, EOF, and padding */
typedef enum {
FCOE_EOFn = 0x41,
@ -68,14 +68,14 @@ typedef enum {
} fcoe_sof_t;
static const value_string fcoe_eof_vals[] = {
{FCOE_EOFn, "EOFn" },
{FCOE_EOFt, "EOFt" },
{FCOE_EOFrt, "EOFrt" },
{FCOE_EOFdt, "EOFdt" },
{FCOE_EOFni, "EOFni" },
{FCOE_EOFn, "EOFn" },
{FCOE_EOFt, "EOFt" },
{FCOE_EOFrt, "EOFrt" },
{FCOE_EOFdt, "EOFdt" },
{FCOE_EOFni, "EOFni" },
{FCOE_EOFdti, "EOFdti" },
{FCOE_EOFrti, "EOFrti" },
{FCOE_EOFa, "EOFa" },
{FCOE_EOFa, "EOFa" },
{0, NULL}
};
@ -109,27 +109,27 @@ static dissector_handle_t fc_handle;
static void
dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
gint crc_offset;
gint eof_offset;
gint frame_len = 0;
gint header_len = FCOE_HEADER_LEN;
guint version;
gint crc_offset;
gint eof_offset;
gint frame_len = 0;
gint header_len = FCOE_HEADER_LEN;
guint version;
const char *ver;
guint16 len_sof;
gint bytes_remaining;
guint8 sof = 0;
guint8 eof = 0;
guint16 len_sof;
gint bytes_remaining;
guint8 sof = 0;
guint8 eof = 0;
const char *eof_str;
const char *crc_msg;
const char *len_msg;
proto_item *ti;
proto_item *item;
proto_tree *fcoe_tree = NULL;
proto_tree *fcoe_tree;
proto_tree *crc_tree;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
guint32 crc = 0;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
guint32 crc = 0;
/*
* For now, handle both the version defined before and after August 2007.
@ -167,90 +167,87 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (bytes_remaining > frame_len)
bytes_remaining = frame_len; /* backing length */
next_tvb = tvb_new_subset(tvb, header_len, bytes_remaining, frame_len);
if (tree) {
eof_str = "none";
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
eof = tvb_get_guint8(tvb, eof_offset);
eof_str = val_to_str(eof, fcoe_eof_vals, "0x%x");
eof_str = "none";
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
eof = tvb_get_guint8(tvb, eof_offset);
eof_str = val_to_str(eof, fcoe_eof_vals, "0x%x");
}
/*
* Check the CRC.
*/
crc_msg = "";
crc_exists = tvb_bytes_exist(tvb, crc_offset, 4);
if (crc_exists) {
crc = tvb_get_ntohl(tvb, crc_offset);
crc_computed = crc32_802_tvb(next_tvb, frame_len);
if (crc != crc_computed) {
crc_msg = " [bad FC CRC]";
}
}
len_msg = "";
if ((frame_len % 4) != 0 || frame_len < 24) {
len_msg = " [invalid length]";
}
/*
* Check the CRC.
*/
crc_msg = "";
crc_exists = tvb_bytes_exist(tvb, crc_offset, 4);
if (crc_exists) {
crc = tvb_get_ntohl(tvb, crc_offset);
crc_computed = crc32_802_tvb(next_tvb, frame_len);
if (crc != crc_computed) {
crc_msg = " [bad FC CRC]";
}
}
len_msg = "";
if ((frame_len % 4) != 0 || frame_len < 24) {
len_msg = " [invalid length]";
}
ti = proto_tree_add_protocol_format(tree, proto_fcoe, tvb, 0,
header_len,
"FCoE %s(%s/%s) %d bytes%s%s", ver,
val_to_str(sof, fcoe_sof_vals,
"0x%x"),
eof_str, frame_len, crc_msg,
len_msg);
ti = proto_tree_add_protocol_format(tree, proto_fcoe, tvb, 0,
header_len,
"FCoE %s(%s/%s) %d bytes%s%s", ver,
val_to_str(sof, fcoe_sof_vals,
"0x%x"),
eof_str, frame_len, crc_msg,
len_msg);
/* Dissect the FCoE header */
/* Dissect the FCoE header */
fcoe_tree = proto_item_add_subtree(ti, ett_fcoe);
proto_tree_add_uint(fcoe_tree, hf_fcoe_ver, tvb, 0, 1, version);
if (tvb_get_guint8(tvb, 1)) {
proto_tree_add_uint(fcoe_tree, hf_fcoe_len, tvb, 0, 2, frame_len);
}
proto_tree_add_uint(fcoe_tree, hf_fcoe_sof, tvb,
header_len - 1, 1, sof);
fcoe_tree = proto_item_add_subtree(ti, ett_fcoe);
proto_tree_add_uint(fcoe_tree, hf_fcoe_ver, tvb, 0, 1, version);
if (tvb_get_guint8(tvb, 1)) {
proto_tree_add_uint(fcoe_tree, hf_fcoe_len, tvb, 0, 2, frame_len);
}
proto_tree_add_uint(fcoe_tree, hf_fcoe_sof, tvb,
header_len - 1, 1, sof);
/*
* Create the CRC information.
*/
if (crc_exists) {
if (crc == crc_computed) {
item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x [valid]", crc);
} else {
item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x "
"[error: should be %8.8x]",
crc, crc_computed);
expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR,
"Bad FC CRC %8.8x %8.x",
crc, crc_computed);
}
proto_tree_set_appendix(fcoe_tree, tvb, crc_offset,
tvb_length_remaining (tvb, crc_offset));
/*
* Create the CRC information.
*/
if (crc_exists) {
if (crc == crc_computed) {
item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x [valid]", crc);
} else {
item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0,
"CRC: [missing]");
item = proto_tree_add_uint_format(fcoe_tree, hf_fcoe_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x "
"[error: should be %8.8x]",
crc, crc_computed);
expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR,
"Bad FC CRC %8.8x %8.x",
crc, crc_computed);
}
crc_tree = proto_item_add_subtree(item, ett_fcoe_crc);
ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb,
crc_offset, 4,
crc_exists && crc != crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_good, tvb,
crc_offset, 4,
crc_exists && crc == crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
proto_tree_set_appendix(fcoe_tree, tvb, crc_offset,
tvb_length_remaining (tvb, crc_offset));
} else {
item = proto_tree_add_text(fcoe_tree, tvb, crc_offset, 0,
"CRC: [missing]");
}
crc_tree = proto_item_add_subtree(item, ett_fcoe_crc);
ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_bad, tvb,
crc_offset, 4,
crc_exists && crc != crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_boolean(crc_tree, hf_fcoe_crc_good, tvb,
crc_offset, 4,
crc_exists && crc == crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
/*
* Interpret the EOF.
*/
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
proto_tree_add_item(fcoe_tree, hf_fcoe_eof, tvb, eof_offset, 1, ENC_BIG_ENDIAN);
}
/*
* Interpret the EOF.
*/
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
proto_tree_add_item(fcoe_tree, hf_fcoe_eof, tvb, eof_offset, 1, ENC_BIG_ENDIAN);
}
/* Set the SOF/EOF flags in the packet_info header */
@ -268,7 +265,7 @@ dissect_fcoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
/* Call the FC Dissector if this is carrying an FC frame */
if (fc_handle) {
call_dissector(fc_handle, next_tvb, pinfo, tree);
} else if (data_handle) {
@ -322,17 +319,13 @@ proto_register_fcoe(void)
prefs_register_obsolete_preference(fcoe_module, "ethertype");
}
/*
* This function name is required because a script is used to find these
* routines and create the code that calls these routines.
*/
void
proto_reg_handoff_fcoe(void)
{
dissector_handle_t fcoe_handle;
fcoe_handle = create_dissector_handle(dissect_fcoe, proto_fcoe);
dissector_add_uint("ethertype", ETHERTYPE_FCOE, fcoe_handle);
data_handle = find_dissector("data");
fc_handle = find_dissector("fc");
fc_handle = find_dissector("fc");
}

View File

@ -53,8 +53,8 @@
#endif
#define FCOIB_HEADER_LEN 16 /* header: encap. header, SOF, and padding */
#define FCOIB_TRAILER_LEN 8 /* trailer: FC-CRC, EOF and padding */
#define FCOIB_VER_OFFSET 2 /* offset of ver field (in bytes) inside FCoIB Encap. header */
#define FCOIB_TRAILER_LEN 8 /* trailer: FC-CRC, EOF and padding */
#define FCOIB_VER_OFFSET 2 /* offset of ver field (in bytes) inside FCoIB Encap. header */
/* Forward declaration we need below (for using proto_reg_handoff as a prefs callback) */
void proto_reg_handoff_fcoib(void);
@ -121,15 +121,15 @@ static dissector_handle_t data_handle;
static dissector_handle_t fc_handle;
/* global preferences */
static gboolean gPREF_HEUR_EN = TRUE;
static gboolean gPREF_MAN_EN = FALSE;
static gint gPREF_TYPE[2] = {0};
static const char *gPREF_ID[2] = {NULL};
static guint gPREF_QP[2] = {0};
static gboolean gPREF_HEUR_EN = TRUE;
static gboolean gPREF_MAN_EN = FALSE;
static gint gPREF_TYPE[2] = {0};
static const char *gPREF_ID[2] = {NULL};
static guint gPREF_QP[2] = {0};
/* source/destination addresses from preferences menu (parsed from gPREF_TYPE[?], gPREF_ID[?]) */
static address manual_addr[2];
static void *manual_addr_data[2];
static address manual_addr[2];
static void *manual_addr_data[2];
static enum_val_t pref_address_types[] = {
{"lid", "LID", 0},
@ -160,29 +160,29 @@ manual_addr_match(packet_info *pinfo) {
static gboolean
dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
gint crc_offset;
gint eof_offset;
gint sof_offset;
gint frame_len = 0;
guint version;
gint crc_offset;
gint eof_offset;
gint sof_offset;
gint frame_len;
guint version;
const char *ver;
gint bytes_remaining;
guint8 sof = 0;
guint8 eof = 0;
guint8 sig = 0;
gint bytes_remaining;
guint8 sof = 0;
guint8 eof = 0;
guint8 sig = 0;
const char *eof_str;
const char *sof_str;
const char *crc_msg;
const char *len_msg;
proto_item *ti;
proto_item *item;
proto_tree *fcoib_tree = NULL;
proto_tree *fcoib_tree;
proto_tree *crc_tree;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
guint32 crc = 0;
gboolean packet_match_manual = FALSE;
tvbuff_t *next_tvb;
gboolean crc_exists;
guint32 crc_computed = 0;
guint32 crc = 0;
gboolean packet_match_manual;
tree = proto_tree_get_root(tree); /* we don't want to add FCoIB under the Infiniband tree */
@ -227,97 +227,95 @@ dissect_fcoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
bytes_remaining = frame_len; /* backing length */
next_tvb = tvb_new_subset(tvb, FCOIB_HEADER_LEN, bytes_remaining, frame_len);
if (tree) {
/*
* Only version 0 is defined at this point.
* Don't print the version in the short summary if it is zero.
*/
ver = "";
version = tvb_get_guint8(tvb, 0 + FCOIB_VER_OFFSET) >> 4;
if (version != 0)
ver = ep_strdup_printf(ver, "ver %d ", version);
/*
* Only version 0 is defined at this point.
* Don't print the version in the short summary if it is zero.
*/
ver = "";
version = tvb_get_guint8(tvb, 0 + FCOIB_VER_OFFSET) >> 4;
if (version != 0)
ver = ep_strdup_printf(ver, "ver %d ", version);
eof_str = "none";
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
eof_str = val_to_str(eof, fcoib_eof_vals, "0x%x");
eof_str = "none";
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
eof_str = val_to_str(eof, fcoib_eof_vals, "0x%x");
}
sof_str = "none";
if (tvb_bytes_exist(tvb, sof_offset, 1)) {
sof_str = val_to_str(sof, fcoib_sof_vals, "0x%x");
}
/*
* Check the CRC.
*/
crc_msg = "";
crc_exists = tvb_bytes_exist(tvb, crc_offset, 4);
if (crc_exists) {
crc = tvb_get_ntohl(tvb, crc_offset);
crc_computed = crc32_802_tvb(next_tvb, frame_len);
if (crc != crc_computed) {
crc_msg = " [bad FC CRC]";
}
}
len_msg = "";
if ((frame_len % 4) != 0 || frame_len < 24) {
len_msg = " [invalid length]";
}
sof_str = "none";
if (tvb_bytes_exist(tvb, sof_offset, 1)) {
sof_str = val_to_str(sof, fcoib_sof_vals, "0x%x");
}
ti = proto_tree_add_protocol_format(tree, proto_fcoib, tvb, 0,
FCOIB_HEADER_LEN,
"FCoIB %s(%s/%s) %d bytes%s%s", ver,
sof_str, eof_str,
frame_len, crc_msg,
len_msg);
/*
* Check the CRC.
*/
crc_msg = "";
crc_exists = tvb_bytes_exist(tvb, crc_offset, 4);
if (crc_exists) {
crc = tvb_get_ntohl(tvb, crc_offset);
crc_computed = crc32_802_tvb(next_tvb, frame_len);
if (crc != crc_computed) {
crc_msg = " [bad FC CRC]";
}
}
len_msg = "";
if ((frame_len % 4) != 0 || frame_len < 24) {
len_msg = " [invalid length]";
}
/* Dissect the FCoIB Encapsulation header */
ti = proto_tree_add_protocol_format(tree, proto_fcoib, tvb, 0,
FCOIB_HEADER_LEN,
"FCoIB %s(%s/%s) %d bytes%s%s", ver,
sof_str, eof_str,
frame_len, crc_msg,
len_msg);
fcoib_tree = proto_item_add_subtree(ti, ett_fcoib);
proto_tree_add_uint(fcoib_tree, hf_fcoib_sig, tvb, 0, 1, sig);
proto_tree_add_uint(fcoib_tree, hf_fcoib_ver, tvb, FCOIB_VER_OFFSET, 1, version);
proto_tree_add_uint(fcoib_tree, hf_fcoib_sof, tvb, sof_offset, 1, sof);
/* Dissect the FCoIB Encapsulation header */
fcoib_tree = proto_item_add_subtree(ti, ett_fcoib);
proto_tree_add_uint(fcoib_tree, hf_fcoib_sig, tvb, 0, 1, sig);
proto_tree_add_uint(fcoib_tree, hf_fcoib_ver, tvb, FCOIB_VER_OFFSET, 1, version);
proto_tree_add_uint(fcoib_tree, hf_fcoib_sof, tvb, sof_offset, 1, sof);
/*
* Create the CRC information.
*/
if (crc_exists) {
if (crc == crc_computed) {
item = proto_tree_add_uint_format(fcoib_tree, hf_fcoib_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x [valid]", crc);
} else {
item = proto_tree_add_uint_format(fcoib_tree, hf_fcoib_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x "
"[error: should be %8.8x]",
crc, crc_computed);
expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR,
"Bad FC CRC %8.8x %8.x",
crc, crc_computed);
}
proto_tree_set_appendix(fcoib_tree, tvb, crc_offset,
tvb_length_remaining (tvb, crc_offset));
/*
* Create the CRC information.
*/
if (crc_exists) {
if (crc == crc_computed) {
item = proto_tree_add_uint_format(fcoib_tree, hf_fcoib_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x [valid]", crc);
} else {
item = proto_tree_add_text(fcoib_tree, tvb, crc_offset, 0,
"CRC: [missing]");
item = proto_tree_add_uint_format(fcoib_tree, hf_fcoib_crc, tvb,
crc_offset, 4, crc,
"CRC: %8.8x "
"[error: should be %8.8x]",
crc, crc_computed);
expert_add_info_format(pinfo, item, PI_CHECKSUM, PI_ERROR,
"Bad FC CRC %8.8x %8.x",
crc, crc_computed);
}
crc_tree = proto_item_add_subtree(item, ett_fcoib_crc);
ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_bad, tvb,
crc_offset, 4,
crc_exists && crc != crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_good, tvb,
crc_offset, 4,
crc_exists && crc == crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
proto_tree_set_appendix(fcoib_tree, tvb, crc_offset,
tvb_length_remaining (tvb, crc_offset));
} else {
item = proto_tree_add_text(fcoib_tree, tvb, crc_offset, 0,
"CRC: [missing]");
}
crc_tree = proto_item_add_subtree(item, ett_fcoib_crc);
ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_bad, tvb,
crc_offset, 4,
crc_exists && crc != crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_boolean(crc_tree, hf_fcoib_crc_good, tvb,
crc_offset, 4,
crc_exists && crc == crc_computed);
PROTO_ITEM_SET_GENERATED(ti);
/*
* Interpret the EOF.
*/
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
proto_tree_add_item(fcoib_tree, hf_fcoib_eof, tvb, eof_offset, 1, ENC_BIG_ENDIAN);
}
/*
* Interpret the EOF.
*/
if (tvb_bytes_exist(tvb, eof_offset, 1)) {
proto_tree_add_item(fcoib_tree, hf_fcoib_eof, tvb, eof_offset, 1, ENC_BIG_ENDIAN);
}
/* Set the SOF/EOF flags in the packet_info header */
@ -415,10 +413,6 @@ proto_register_fcoib(void)
"QP Number for address B", 10, &gPREF_QP[1]);
}
/*
* This function name is required because a script is used to find these
* routines and create the code that calls these routines.
*/
void
proto_reg_handoff_fcoib(void)
{

View File

@ -169,30 +169,30 @@ dissect_glbp_hello(tvbuff_t *tvb, int offset,
guint8 addrtype;
guint8 addrlen;
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown10, tvb, offset, 1, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown10, tvb, offset, 1, ENC_NA);
offset ++;
proto_tree_add_item(tlv_tree, hf_glbp_hello_vgstate, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_vgstate, tvb, offset, 1, ENC_BIG_ENDIAN);
offset ++;
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown11, tvb, offset, 1, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown11, tvb, offset, 1, ENC_NA);
offset ++;
proto_tree_add_item(tlv_tree, hf_glbp_hello_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown12, tvb, offset, 2, ENC_NA);
offset += 2;
proto_tree_add_item(tlv_tree, hf_glbp_hello_helloint, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_helloint, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tlv_tree, hf_glbp_hello_holdint, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_holdint, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(tlv_tree, hf_glbp_hello_redirect, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_redirect, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tlv_tree, hf_glbp_hello_timeout, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_timeout, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tlv_tree, hf_glbp_hello_unknown13, tvb, offset, 2, ENC_NA);
offset += 2;
proto_tree_add_item(tlv_tree, hf_glbp_hello_addrtype, tvb, offset, 1, ENC_BIG_ENDIAN);
addrtype = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tlv_tree, hf_glbp_hello_addrtype, tvb, offset, 1, ENC_BIG_ENDIAN);
addrtype = tvb_get_guint8( tvb, offset);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_hello_addrlen, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_hello_addrlen, tvb, offset, 1, ENC_BIG_ENDIAN);
addrlen = tvb_get_guint8(tvb, offset);
offset++;
switch (addrtype) {
@ -227,17 +227,17 @@ static int
dissect_glbp_reqresp(tvbuff_t *tvb, int offset,
packet_info *pinfo _U_, proto_tree *tlv_tree)
{
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_forwarder, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_forwarder, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_vfstate, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_vfstate, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_unknown21, tvb, offset, 1, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_unknown21, tvb, offset, 1, ENC_NA);
offset += 1;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_weight, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_weight, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_unknown22, tvb, offset, 7, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_unknown22, tvb, offset, 7, ENC_NA);
offset += 7;
proto_tree_add_item(tlv_tree, hf_glbp_reqresp_virtualmac, tvb, offset, 6, ENC_NA);
offset += 6;
@ -252,10 +252,10 @@ dissect_glbp_auth(tvbuff_t *tvb, int offset,
guint8 authtype;
guint8 authlength;
proto_tree_add_item(tlv_tree, hf_glbp_auth_authtype, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_auth_authtype, tvb, offset, 1, ENC_BIG_ENDIAN);
authtype = tvb_get_guint8(tvb, offset);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_auth_authlength, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_auth_authlength, tvb, offset, 1, ENC_BIG_ENDIAN);
authlength = tvb_get_guint8(tvb, offset);
offset++;
switch(authtype) {
@ -264,12 +264,12 @@ dissect_glbp_auth(tvbuff_t *tvb, int offset,
offset += authlength;
break;
case 2:
proto_tree_add_item(tlv_tree, hf_glbp_auth_md5hash, tvb, offset, authlength, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_auth_md5hash, tvb, offset, authlength, ENC_NA);
offset += authlength;
break;
case 3:
proto_tree_add_item(tlv_tree, hf_glbp_auth_md5chainindex, tvb, offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_glbp_auth_md5chainhash, tvb, offset+4, authlength-4, ENC_NA);
proto_tree_add_item(tlv_tree, hf_glbp_auth_md5chainhash, tvb, offset+4, authlength-4, ENC_NA);
offset += authlength;
break;
default:
@ -294,80 +294,78 @@ dissect_glbp_unknown(tvbuff_t *tvb, int offset, guint32 length,
static int
dissect_glbp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *glbp_tree = NULL;
proto_tree *tlv_tree = NULL;
proto_item *ti = NULL;
guint8 type;
int offset = 0;
int lastoffset;
guint8 length;
guint16 group;
proto_tree *glbp_tree;
proto_tree *tlv_tree;
proto_item *ti;
guint8 type;
int offset = 0;
int lastoffset;
guint8 length;
guint16 group;
group = tvb_get_ntohs(tvb, 2);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "GLBP");
col_add_fstr(pinfo->cinfo, COL_INFO, "G: %d", group);
if (tree) {
ti = proto_tree_add_item(tree, proto_glbp, tvb, 0, -1, ENC_NA);
glbp_tree = proto_item_add_subtree(ti, ett_glbp);
ti = proto_tree_add_item(tree, proto_glbp, tvb, 0, -1, ENC_NA);
glbp_tree = proto_item_add_subtree(ti, ett_glbp);
/* glbp header? */
proto_tree_add_item(glbp_tree, hf_glbp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(glbp_tree, hf_glbp_unknown1, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(glbp_tree, hf_glbp_group, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(glbp_tree, hf_glbp_unknown2, tvb, offset, 2, ENC_NA);
offset += 2;
proto_tree_add_item(glbp_tree, hf_glbp_ownerid, tvb, offset, 6, ENC_NA);
offset += 6;
while (tvb_length_remaining(tvb, offset) > 0) {
/* glbp header? */
proto_tree_add_item(glbp_tree, hf_glbp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(glbp_tree, hf_glbp_unknown1, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(glbp_tree, hf_glbp_group, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(glbp_tree, hf_glbp_unknown2, tvb, offset, 2, ENC_NA);
offset += 2;
proto_tree_add_item(glbp_tree, hf_glbp_ownerid, tvb, offset, 6, ENC_NA);
offset += 6;
while (tvb_length_remaining(tvb, offset) > 0) {
type = tvb_get_guint8(tvb, offset);
length = tvb_get_guint8(tvb, offset+1);
if (length < 2) {
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "Length %u too small", length);
return offset;
}
length -= 2;
ti = proto_tree_add_item(glbp_tree, hf_glbp_tlv, tvb, offset, length+2, ENC_BIG_ENDIAN);
tlv_tree = proto_item_add_subtree(ti, ett_glbp_tlv);
proto_item_append_text(ti, " l=%d, t=%s", length+2,
val_to_str(type, glbp_type_vals, "%d"));
proto_tree_add_item(tlv_tree, hf_glbp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_length, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(type, glbp_type_vals, "%d"));
lastoffset = offset;
switch(type) {
case 1: /* Hello */
offset = dissect_glbp_hello(tvb, offset, pinfo, tlv_tree);
break;
case 2: /* Request/Response */
offset = dissect_glbp_reqresp(tvb, offset, pinfo, tlv_tree);
break;
case 3: /* Plaintext auth */
offset = dissect_glbp_auth(tvb, offset, pinfo, tlv_tree);
break;
default:
offset = dissect_glbp_unknown(tvb, offset, length, pinfo, tlv_tree);
break;
}
if (lastoffset >= offset) {
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "Zero or negative length");
return lastoffset;
}
/* Skip over trailing bytes before starting with the next element */
if (lastoffset + length > offset)
offset = lastoffset + length;
type = tvb_get_guint8(tvb, offset);
length = tvb_get_guint8(tvb, offset+1);
if (length < 2) {
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "Length %u too small", length);
return offset;
}
length -= 2;
ti = proto_tree_add_item(glbp_tree, hf_glbp_tlv, tvb, offset, length+2, ENC_BIG_ENDIAN);
tlv_tree = proto_item_add_subtree(ti, ett_glbp_tlv);
proto_item_append_text(ti, " l=%d, t=%s", length+2,
val_to_str(type, glbp_type_vals, "%d"));
proto_tree_add_item(tlv_tree, hf_glbp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
proto_tree_add_item(tlv_tree, hf_glbp_length, tvb, offset, 1, ENC_BIG_ENDIAN);
offset++;
col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
val_to_str(type, glbp_type_vals, "%d"));
lastoffset = offset;
switch(type) {
case 1: /* Hello */
offset = dissect_glbp_hello(tvb, offset, pinfo, tlv_tree);
break;
case 2: /* Request/Response */
offset = dissect_glbp_reqresp(tvb, offset, pinfo, tlv_tree);
break;
case 3: /* Plaintext auth */
offset = dissect_glbp_auth(tvb, offset, pinfo, tlv_tree);
break;
default:
offset = dissect_glbp_unknown(tvb, offset, length, pinfo, tlv_tree);
break;
}
if (lastoffset >= offset) {
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR, "Zero or negative length");
return lastoffset;
}
/* Skip over trailing bytes before starting with the next element */
if (lastoffset + length > offset)
offset = lastoffset + length;
}
return offset;
}

File diff suppressed because it is too large Load Diff

View File

@ -28,16 +28,16 @@
*
* See
*
* http://www.irchelp.org/irchelp/rfc/
* http://www.irchelp.org/irchelp/rfc/
*
* and the RFCs and other documents it mentions, such as RFC 1459, RFCs
* 2810, 2811, 2812, and 2813,
*
* http://www.irchelp.org/irchelp/rfc/ctcpspec.html
* http://www.irchelp.org/irchelp/rfc/ctcpspec.html
*
* and
*
* http://www.invlogic.com/irc/ctcp.html
* http://www.invlogic.com/irc/ctcp.html
*/
#ifdef HAVE_CONFIG_H
@ -73,498 +73,495 @@ static gint ett_irc_response_command = -1;
static const guint8 TAG_DELIMITER[] = {0x01, 0x00};
#define TCP_PORT_IRC 6667
#define TCP_PORT_DIRCPROXY 57000
/* good candidate for dynamic port specification */
#define TCP_PORT_IRC 6667
#define TCP_PORT_DIRCPROXY 57000
/* good candidate for dynamic port specification */
static void
dissect_irc_tag_data(proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offset, int datalen, packet_info *pinfo, guint8* command)
{
guchar found_start_needle = 0,
found_end_needle = 0;
gint tag_start_offset, tag_end_offset;
guchar found_start_needle = 0,
found_end_needle = 0;
gint tag_start_offset, tag_end_offset;
tag_start_offset = tvb_pbrk_guint8(tvb, offset, datalen, TAG_DELIMITER, &found_start_needle);
if (tag_start_offset == -1)
{
/* no tag data */
return;
}
tag_start_offset = tvb_pbrk_guint8(tvb, offset, datalen, TAG_DELIMITER, &found_start_needle);
if (tag_start_offset == -1)
{
/* no tag data */
return;
}
tag_end_offset = tvb_pbrk_guint8(tvb, offset, datalen-offset, TAG_DELIMITER, &found_end_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
tag_end_offset = tvb_pbrk_guint8(tvb, offset, datalen-offset, TAG_DELIMITER, &found_end_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
if ((strcmp(command, "NOTICE") != 0) &&
(strcmp(command, "PRIVMSG") != 0))
{
expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Tag data outside of NOTICE or PRIVMSG command");
}
if ((strcmp(command, "NOTICE") != 0) &&
(strcmp(command, "PRIVMSG") != 0))
{
expert_add_info_format(pinfo, item, PI_PROTOCOL, PI_WARN, "Tag data outside of NOTICE or PRIVMSG command");
}
/* Placeholder to call CTCP dissector, strip out delimiter */
proto_tree_add_item(tree, hf_irc_ctcp, tvb, offset+1, datalen-2, ENC_ASCII|ENC_NA);
/* Placeholder to call CTCP dissector, strip out delimiter */
proto_tree_add_item(tree, hf_irc_ctcp, tvb, offset+1, datalen-2, ENC_ASCII|ENC_NA);
}
static void
dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int linelen)
{
proto_tree *request_tree, *command_tree = NULL;
proto_item *request_item, *command_item;
int start_offset = offset;
int end_offset = start_offset+linelen;
gint eop_offset = -1,
eoc_offset = -1,
eocp_offset,
tag_start_offset, tag_end_offset;
guint8* str_command;
guchar found_needle = 0,
found_tag_needle = 0;
gboolean first_command_param = TRUE;
proto_tree *request_tree, *command_tree = NULL;
proto_item *request_item, *command_item;
int start_offset = offset;
int end_offset = start_offset+linelen;
gint eop_offset = -1,
eoc_offset = -1,
eocp_offset,
tag_start_offset, tag_end_offset;
guint8* str_command;
guchar found_needle = 0,
found_tag_needle = 0;
gboolean first_command_param = TRUE;
request_item = proto_tree_add_item(tree, hf_irc_request, tvb, offset, linelen, ENC_ASCII|ENC_NA);
if (linelen <= 0)
return;
request_item = proto_tree_add_item(tree, hf_irc_request, tvb, offset, linelen, ENC_ASCII|ENC_NA);
if (linelen <= 0)
return;
request_tree = proto_item_add_subtree(request_item, ett_irc_request );
request_tree = proto_item_add_subtree(request_item, ett_irc_request );
/* Check if message has a prefix */
if (tvb_get_guint8(tvb, offset) == ':')
{
/* find the end of the prefix */
eop_offset = tvb_pbrk_guint8(tvb, offset+1, linelen-1, " ", &found_needle);
if (eop_offset == -1)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Prefix missing ending <space>");
return;
}
/* Check if message has a prefix */
if (tvb_get_guint8(tvb, offset) == ':')
{
/* find the end of the prefix */
eop_offset = tvb_pbrk_guint8(tvb, offset+1, linelen-1, " ", &found_needle);
if (eop_offset == -1)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Prefix missing ending <space>");
return;
}
proto_tree_add_item(request_tree, hf_irc_request_prefix, tvb, offset+1, eop_offset-offset-1, ENC_ASCII|ENC_NA);
found_needle = 0;
offset = eop_offset+1;
}
proto_tree_add_item(request_tree, hf_irc_request_prefix, tvb, offset+1, eop_offset-offset-1, ENC_ASCII|ENC_NA);
found_needle = 0;
offset = eop_offset+1;
}
/* clear out any whitespace before command */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Request has no command");
return;
}
/* clear out any whitespace before command */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Request has no command");
return;
}
eoc_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
if (eoc_offset == -1)
{
proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", tvb_get_ephemeral_string(tvb, offset, linelen-offset));
eoc_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
if (eoc_offset == -1)
{
proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", tvb_get_ephemeral_string(tvb, offset, linelen-offset));
/* Warn if there is a "numeric" command */
if ((linelen-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
expert_add_info_format(pinfo, request_item, PI_PROTOCOL, PI_WARN, "Numeric command not allowed in request");
}
return;
}
/* Warn if there is a "numeric" command */
if ((linelen-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
expert_add_info_format(pinfo, request_item, PI_PROTOCOL, PI_WARN, "Numeric command not allowed in request");
}
return;
}
proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA);
str_command = tvb_get_ephemeral_string(tvb, offset, eoc_offset-offset);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command);
proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA);
str_command = tvb_get_ephemeral_string(tvb, offset, eoc_offset-offset);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command);
/* Warn if there is a "numeric" command */
if ((eoc_offset-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
expert_add_info_format(pinfo, request_item, PI_PROTOCOL, PI_WARN, "Numeric command not allowed in request");
}
/* Warn if there is a "numeric" command */
if ((eoc_offset-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
expert_add_info_format(pinfo, request_item, PI_PROTOCOL, PI_WARN, "Numeric command not allowed in request");
}
found_needle = 0;
offset = eoc_offset+1;
found_needle = 0;
offset = eoc_offset+1;
/* clear out any whitespace before command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
/* No command parameters */
return;
}
/* clear out any whitespace before command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
/* No command parameters */
return;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(request_tree, hf_irc_request_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(request_tree, request_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(request_tree, hf_irc_request_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(request_tree, request_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
while(offset < end_offset)
{
eocp_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
tag_start_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, TAG_DELIMITER, &found_tag_needle);
while(offset < end_offset)
{
eocp_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
tag_start_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, TAG_DELIMITER, &found_tag_needle);
/* Create subtree when the first parameter is found */
if (first_command_param)
{
command_item = proto_tree_add_text(request_tree, tvb, offset, linelen-offset, "Command parameters");
command_tree = proto_item_add_subtree(command_item, ett_irc_request_command );
first_command_param = FALSE;
}
/* Create subtree when the first parameter is found */
if (first_command_param)
{
command_item = proto_tree_add_text(request_tree, tvb, offset, linelen-offset, "Command parameters");
command_tree = proto_item_add_subtree(command_item, ett_irc_request_command );
first_command_param = FALSE;
}
if (((eocp_offset == -1) && (tag_start_offset == -1)) ||
((eocp_offset != -1) && (tag_start_offset == -1)) ||
(eocp_offset < tag_start_offset))
{
/* regular message should be dissected */
if (((eocp_offset == -1) && (tag_start_offset == -1)) ||
((eocp_offset != -1) && (tag_start_offset == -1)) ||
(eocp_offset < tag_start_offset))
{
/* regular message should be dissected */
found_needle = 0;
if (eocp_offset == -1)
{
proto_tree_add_item(command_tree, hf_irc_request_command_param, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
return;
}
found_needle = 0;
if (eocp_offset == -1)
{
proto_tree_add_item(command_tree, hf_irc_request_command_param, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
return;
}
proto_tree_add_item(command_tree, hf_irc_request_command_param, tvb, offset, eocp_offset-offset, ENC_ASCII|ENC_NA);
offset = eocp_offset+1;
proto_tree_add_item(command_tree, hf_irc_request_command_param, tvb, offset, eocp_offset-offset, ENC_ASCII|ENC_NA);
offset = eocp_offset+1;
/* clear out any whitespace before next command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
break;
}
/* clear out any whitespace before next command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
break;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(request_tree, hf_irc_request_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(request_tree, request_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
}
else if (((eocp_offset == -1) && (tag_start_offset != -1)) ||
(eocp_offset > tag_start_offset))
{
/* tag data dissected */
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(request_tree, hf_irc_request_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(request_tree, request_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
}
else if (((eocp_offset == -1) && (tag_start_offset != -1)) ||
(eocp_offset > tag_start_offset))
{
/* tag data dissected */
found_tag_needle = 0;
tag_end_offset = tvb_pbrk_guint8(tvb, tag_start_offset+1, linelen-tag_start_offset-1, TAG_DELIMITER, &found_tag_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
found_tag_needle = 0;
tag_end_offset = tvb_pbrk_guint8(tvb, tag_start_offset+1, linelen-tag_start_offset-1, TAG_DELIMITER, &found_tag_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, request_item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
dissect_irc_tag_data(request_tree, request_item, tvb, tag_start_offset, tag_end_offset-tag_start_offset, pinfo, str_command);
offset = tag_end_offset+1;
}
}
dissect_irc_tag_data(request_tree, request_item, tvb, tag_start_offset, tag_end_offset-tag_start_offset, pinfo, str_command);
offset = tag_end_offset+1;
}
}
}
static void
dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int linelen)
{
proto_tree *response_tree, *command_tree = NULL;
proto_item *response_item, *command_item, *hidden_item;
int start_offset = offset;
int end_offset = start_offset+linelen;
gint eop_offset = -1,
eoc_offset = -1,
eocp_offset,
tag_start_offset, tag_end_offset;
guint8* str_command;
guint16 num_command;
guchar found_needle = 0,
found_tag_needle = 0;
gboolean first_command_param = TRUE;
proto_tree *response_tree, *command_tree = NULL;
proto_item *response_item, *command_item, *hidden_item;
int start_offset = offset;
int end_offset = start_offset+linelen;
gint eop_offset = -1,
eoc_offset = -1,
eocp_offset,
tag_start_offset, tag_end_offset;
guint8* str_command;
guint16 num_command;
guchar found_needle = 0,
found_tag_needle = 0;
gboolean first_command_param = TRUE;
response_item = proto_tree_add_item(tree, hf_irc_response, tvb, offset, linelen, ENC_ASCII|ENC_NA);
if (linelen <= 0)
return;
response_item = proto_tree_add_item(tree, hf_irc_response, tvb, offset, linelen, ENC_ASCII|ENC_NA);
if (linelen <= 0)
return;
response_tree = proto_item_add_subtree(response_item, ett_irc_response );
response_tree = proto_item_add_subtree(response_item, ett_irc_response );
/* Check if message has a prefix */
if (tvb_get_guint8(tvb, offset) == ':')
{
/* find the end of the prefix */
eop_offset = tvb_pbrk_guint8(tvb, offset+1, linelen-1, " ", &found_needle);
if (eop_offset == -1)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Prefix missing ending <space>");
return;
}
/* Check if message has a prefix */
if (tvb_get_guint8(tvb, offset) == ':')
{
/* find the end of the prefix */
eop_offset = tvb_pbrk_guint8(tvb, offset+1, linelen-1, " ", &found_needle);
if (eop_offset == -1)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Prefix missing ending <space>");
return;
}
proto_tree_add_item(response_tree, hf_irc_response_prefix, tvb, offset+1, eop_offset-offset-1, ENC_ASCII|ENC_NA);
found_needle = 0;
offset = eop_offset+1;
}
proto_tree_add_item(response_tree, hf_irc_response_prefix, tvb, offset+1, eop_offset-offset-1, ENC_ASCII|ENC_NA);
found_needle = 0;
offset = eop_offset+1;
}
/* clear out any whitespace before command */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Response has no command");
return;
}
/* clear out any whitespace before command */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Response has no command");
return;
}
eoc_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
if (eoc_offset == -1)
{
proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", tvb_get_ephemeral_string(tvb, offset, linelen-offset));
eoc_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
if (eoc_offset == -1)
{
proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", tvb_get_ephemeral_string(tvb, offset, linelen-offset));
/* if response command is numeric, allow it to be filtered as an integer */
if ((linelen-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30);
hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, linelen-offset, num_command);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
return;
}
/* if response command is numeric, allow it to be filtered as an integer */
if ((linelen-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30);
hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, linelen-offset, num_command);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
return;
}
proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA);
str_command = tvb_get_ephemeral_string(tvb, offset, eoc_offset-offset);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command);
proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA);
str_command = tvb_get_ephemeral_string(tvb, offset, eoc_offset-offset);
col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command);
/* if response command is numeric, allow it to be filtered as an integer */
if ((eoc_offset-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30);
hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, eoc_offset-offset, num_command);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
/* if response command is numeric, allow it to be filtered as an integer */
if ((eoc_offset-offset == 3) &&
(isdigit(tvb_get_guint8(tvb, offset))) &&
(isdigit(tvb_get_guint8(tvb, offset+1))) &&
(isdigit(tvb_get_guint8(tvb, offset+2))))
{
num_command = ((tvb_get_guint8(tvb, offset)-0x30)*100) + ((tvb_get_guint8(tvb, offset+1)-0x30)*10) + (tvb_get_guint8(tvb, offset+2)-0x30);
hidden_item = proto_tree_add_uint(response_tree, hf_irc_response_num_command, tvb, offset, eoc_offset-offset, num_command);
PROTO_ITEM_SET_HIDDEN(hidden_item);
}
found_needle = 0;
offset = eoc_offset+1;
found_needle = 0;
offset = eoc_offset+1;
/* clear out any whitespace before command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
/* No command parameters */
return;
}
/* clear out any whitespace before command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
/* No command parameters */
return;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(response_tree, hf_irc_response_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(response_tree, response_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(response_tree, hf_irc_response_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(response_tree, response_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
while(offset < end_offset)
{
eocp_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
tag_start_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, TAG_DELIMITER, &found_tag_needle);
while(offset < end_offset)
{
eocp_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, " ", &found_needle);
tag_start_offset = tvb_pbrk_guint8(tvb, offset, linelen-offset, TAG_DELIMITER, &found_tag_needle);
/* Create subtree when the first parameter is found */
if (first_command_param)
{
command_item = proto_tree_add_text(response_tree, tvb, offset, linelen-offset, "Command parameters");
command_tree = proto_item_add_subtree(command_item, ett_irc_response_command );
first_command_param = FALSE;
}
/* Create subtree when the first parameter is found */
if (first_command_param)
{
command_item = proto_tree_add_text(response_tree, tvb, offset, linelen-offset, "Command parameters");
command_tree = proto_item_add_subtree(command_item, ett_irc_response_command );
first_command_param = FALSE;
}
if (((eocp_offset == -1) && (tag_start_offset == -1)) ||
((eocp_offset != -1) && (tag_start_offset == -1)) ||
(eocp_offset < tag_start_offset))
{
/* regular message should be dissected */
if (((eocp_offset == -1) && (tag_start_offset == -1)) ||
((eocp_offset != -1) && (tag_start_offset == -1)) ||
(eocp_offset < tag_start_offset))
{
/* regular message should be dissected */
found_needle = 0;
if (eocp_offset == -1)
{
proto_tree_add_item(command_tree, hf_irc_response_command_param, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
return;
}
found_needle = 0;
if (eocp_offset == -1)
{
proto_tree_add_item(command_tree, hf_irc_response_command_param, tvb, offset, linelen-offset, ENC_ASCII|ENC_NA);
return;
}
proto_tree_add_item(command_tree, hf_irc_response_command_param, tvb, offset, eocp_offset-offset, ENC_ASCII|ENC_NA);
offset = eocp_offset+1;
proto_tree_add_item(command_tree, hf_irc_response_command_param, tvb, offset, eocp_offset-offset, ENC_ASCII|ENC_NA);
offset = eocp_offset+1;
/* clear out any whitespace before next command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
break;
}
/* clear out any whitespace before next command parameter */
while(offset < end_offset && tvb_get_guint8(tvb, offset) == ' ')
{
offset++;
}
if (offset == end_offset)
{
break;
}
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(response_tree, hf_irc_response_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(response_tree, response_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
}
else if (((eocp_offset == -1) && (tag_start_offset != -1)) ||
(eocp_offset > tag_start_offset))
{
/* tag data dissected */
/* Check if message has a trailer */
if (tvb_get_guint8(tvb, offset) == ':')
{
proto_tree_add_item(response_tree, hf_irc_response_trailer, tvb, offset+1, linelen-offset-1, ENC_ASCII|ENC_NA);
dissect_irc_tag_data(response_tree, response_item, tvb, offset+1, linelen-offset-1, pinfo, str_command);
return;
}
}
else if (((eocp_offset == -1) && (tag_start_offset != -1)) ||
(eocp_offset > tag_start_offset))
{
/* tag data dissected */
found_tag_needle = 0;
tag_end_offset = tvb_pbrk_guint8(tvb, tag_start_offset+1, linelen-tag_start_offset-1, TAG_DELIMITER, &found_tag_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
found_tag_needle = 0;
tag_end_offset = tvb_pbrk_guint8(tvb, tag_start_offset+1, linelen-tag_start_offset-1, TAG_DELIMITER, &found_tag_needle);
if (tag_end_offset == -1)
{
expert_add_info_format(pinfo, response_item, PI_MALFORMED, PI_ERROR, "Missing ending tag delimited (0x01)");
return;
}
dissect_irc_tag_data(response_tree, response_item, tvb, tag_start_offset, tag_end_offset-tag_start_offset, pinfo, str_command);
offset = tag_end_offset+1;
}
}
dissect_irc_tag_data(response_tree, response_item, tvb, tag_start_offset, tag_end_offset-tag_start_offset, pinfo, str_command);
offset = tag_end_offset+1;
}
}
}
static void
dissect_irc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *irc_tree, *ti;
gint offset = 0;
gint next_offset;
int linelen;
proto_tree *irc_tree, *ti;
gint offset = 0;
gint next_offset;
int linelen;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IRC");
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IRC");
if (check_col(pinfo->cinfo, COL_INFO))
{
col_set_str(pinfo->cinfo, COL_INFO,
(pinfo->match_uint == pinfo->destport) ? "Request" : "Response");
}
if (check_col(pinfo->cinfo, COL_INFO))
{
col_set_str(pinfo->cinfo, COL_INFO,
(pinfo->match_uint == pinfo->destport) ? "Request" : "Response");
}
if (tree)
{
ti = proto_tree_add_item(tree, proto_irc, tvb, 0, -1, ENC_NA);
irc_tree = proto_item_add_subtree(ti, ett_irc);
ti = proto_tree_add_item(tree, proto_irc, tvb, 0, -1, ENC_NA);
irc_tree = proto_item_add_subtree(ti, ett_irc);
/*
* Process the packet data, a line at a time.
*/
while (tvb_reported_length_remaining(tvb, offset) > 0)
{
/*
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
if (next_offset == offset) {
/*
* XXX - we really want the "show data a
* line at a time" loops in various
* dissectors to do reassembly and to
* throw an exception if there's no
* line ending in the current packet
* and we're not doing reassembly.
*/
break;
}
/*
* Process the packet data, a line at a time.
*/
while (tvb_reported_length_remaining(tvb, offset) > 0)
{
/*
* Find the end of the line.
*/
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
if (next_offset == offset) {
/*
* XXX - we really want the "show data a
* line at a time" loops in various
* dissectors to do reassembly and to
* throw an exception if there's no
* line ending in the current packet
* and we're not doing reassembly.
*/
break;
}
if (linelen != 0)
{
if (pinfo->match_uint == pinfo->destport)
{
dissect_irc_request(irc_tree, tvb, pinfo, offset, linelen);
}
else
{
dissect_irc_response(irc_tree, tvb, pinfo, offset, linelen);
}
}
offset = next_offset;
}
}
if (linelen != 0)
{
if (pinfo->match_uint == pinfo->destport)
{
dissect_irc_request(irc_tree, tvb, pinfo, offset, linelen);
}
else
{
dissect_irc_response(irc_tree, tvb, pinfo, offset, linelen);
}
}
offset = next_offset;
}
}
void
proto_register_irc(void)
{
static hf_register_info hf[] = {
{ &hf_irc_response, { "Response", "irc.response", FT_STRING, BASE_NONE,
NULL, 0x0, "Line of response message", HFILL }},
static hf_register_info hf[] = {
{ &hf_irc_response, { "Response", "irc.response", FT_STRING, BASE_NONE,
NULL, 0x0, "Line of response message", HFILL }},
{ &hf_irc_request, { "Request", "irc.request", FT_STRING, BASE_NONE,
NULL, 0x0, "Line of request message", HFILL }},
{ &hf_irc_request, { "Request", "irc.request", FT_STRING, BASE_NONE,
NULL, 0x0, "Line of request message", HFILL }},
{ &hf_irc_request_prefix, { "Prefix", "irc.request.prefix", FT_STRING, BASE_NONE,
NULL, 0x0, "Request prefix", HFILL }},
{ &hf_irc_request_prefix, { "Prefix", "irc.request.prefix", FT_STRING, BASE_NONE,
NULL, 0x0, "Request prefix", HFILL }},
{ &hf_irc_request_command, { "Command", "irc.request.command", FT_STRING, BASE_NONE,
NULL, 0x0, "Request command", HFILL }},
{ &hf_irc_request_command, { "Command", "irc.request.command", FT_STRING, BASE_NONE,
NULL, 0x0, "Request command", HFILL }},
{ &hf_irc_request_command_param, { "Parameter", "irc.request.command_parameter", FT_STRING, BASE_NONE,
NULL, 0x0, "Request command parameter", HFILL }},
{ &hf_irc_request_command_param, { "Parameter", "irc.request.command_parameter", FT_STRING, BASE_NONE,
NULL, 0x0, "Request command parameter", HFILL }},
{ &hf_irc_request_trailer, { "Trailer", "irc.request.trailer", FT_STRING, BASE_NONE,
NULL, 0x0, "Request trailer", HFILL }},
{ &hf_irc_request_trailer, { "Trailer", "irc.request.trailer", FT_STRING, BASE_NONE,
NULL, 0x0, "Request trailer", HFILL }},
{ &hf_irc_response_prefix, { "Prefix", "irc.response.prefix", FT_STRING, BASE_NONE,
NULL, 0x0, "Response prefix", HFILL }},
{ &hf_irc_response_prefix, { "Prefix", "irc.response.prefix", FT_STRING, BASE_NONE,
NULL, 0x0, "Response prefix", HFILL }},
{ &hf_irc_response_command, { "Command", "irc.response.command", FT_STRING, BASE_NONE,
NULL, 0x0, "Response command", HFILL }},
{ &hf_irc_response_command, { "Command", "irc.response.command", FT_STRING, BASE_NONE,
NULL, 0x0, "Response command", HFILL }},
{ &hf_irc_response_num_command, { "Command", "irc.response.command", FT_UINT16, BASE_DEC,
NULL, 0x0, "Response (numeric) command", HFILL }},
{ &hf_irc_response_num_command, { "Command", "irc.response.command", FT_UINT16, BASE_DEC,
NULL, 0x0, "Response (numeric) command", HFILL }},
{ &hf_irc_response_command_param, { "Parameter", "irc.response.command_parameter", FT_STRING, BASE_NONE,
NULL, 0x0, "Response command parameter", HFILL }},
{ &hf_irc_response_command_param, { "Parameter", "irc.response.command_parameter", FT_STRING, BASE_NONE,
NULL, 0x0, "Response command parameter", HFILL }},
{ &hf_irc_response_trailer, { "Trailer", "irc.response.trailer", FT_STRING, BASE_NONE,
NULL, 0x0, "Response trailer", HFILL }},
{ &hf_irc_response_trailer, { "Trailer", "irc.response.trailer", FT_STRING, BASE_NONE,
NULL, 0x0, "Response trailer", HFILL }},
{ &hf_irc_ctcp, { "CTCP Data", "irc.ctcp", FT_STRING, BASE_NONE,
NULL, 0x0, "Placeholder to dissect CTCP data", HFILL }}
};
{ &hf_irc_ctcp, { "CTCP Data", "irc.ctcp", FT_STRING, BASE_NONE,
NULL, 0x0, "Placeholder to dissect CTCP data", HFILL }}
};
static gint *ett[] = {
&ett_irc,
&ett_irc_request,
&ett_irc_request_command,
&ett_irc_response,
&ett_irc_response_command
};
static gint *ett[] = {
&ett_irc,
&ett_irc_request,
&ett_irc_request_command,
&ett_irc_response,
&ett_irc_response_command
};
proto_irc = proto_register_protocol("Internet Relay Chat", "IRC", "irc");
proto_register_field_array(proto_irc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
proto_irc = proto_register_protocol("Internet Relay Chat", "IRC", "irc");
proto_register_field_array(proto_irc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_irc(void)
{
dissector_handle_t irc_handle;
dissector_handle_t irc_handle;
irc_handle = create_dissector_handle(dissect_irc, proto_irc);
dissector_add_uint("tcp.port", TCP_PORT_IRC, irc_handle);
dissector_add_uint("tcp.port", TCP_PORT_DIRCPROXY, irc_handle);
irc_handle = create_dissector_handle(dissect_irc, proto_irc);
dissector_add_uint("tcp.port", TCP_PORT_IRC, irc_handle);
dissector_add_uint("tcp.port", TCP_PORT_DIRCPROXY, irc_handle);
}

View File

@ -882,15 +882,13 @@ dissect_memcache_message (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
if (tvb_reported_length_remaining (tvb, offset) != 0) {
/* Dissect a request or a response. */
if (is_request_or_reply && reqresp_dissector) {
if (tree) {
next_offset = reqresp_dissector (tvb, pinfo, memcache_tree,
offset, line, lineend, opcode);
if (next_offset == -1) {
/* Error in dissecting. */
return -1;
}
offset = next_offset;
next_offset = reqresp_dissector (tvb, pinfo, memcache_tree,
offset, line, lineend, opcode);
if (next_offset == -1) {
/* Error in dissecting. */
return -1;
}
offset = next_offset;
}
}

View File

@ -170,18 +170,18 @@ typedef struct _p_mul_id_key {
} p_mul_id_key;
typedef struct _p_mul_seq_val {
gint msg_type; /* Message type */
guint32 prev_msg_id; /* Previous message package num */
nstime_t prev_msg_time; /* Previous message receive time */
guint32 addr_id; /* PDU package num for Address_PDU */
nstime_t addr_time; /* PDU received time for Address_PDU */
guint32 pdu_id; /* PDU package num */
nstime_t pdu_time; /* PDU receive time */
guint32 prev_pdu_id; /* Previous PDU package num */
nstime_t prev_pdu_time; /* Previous PDU receive time */
guint16 last_found_pdu; /* Last PDU num */
nstime_t first_msg_time; /* First message receive time */
guint32 msg_resend_count; /* Message resend counter */
gint msg_type; /* Message type */
guint32 prev_msg_id; /* Previous message package num */
nstime_t prev_msg_time; /* Previous message receive time */
guint32 addr_id; /* PDU package num for Address_PDU */
nstime_t addr_time; /* PDU received time for Address_PDU */
guint32 pdu_id; /* PDU package num */
nstime_t pdu_time; /* PDU receive time */
guint32 prev_pdu_id; /* Previous PDU package num */
nstime_t prev_pdu_time; /* Previous PDU receive time */
guint16 last_found_pdu; /* Last PDU num */
nstime_t first_msg_time; /* First message receive time */
guint32 msg_resend_count; /* Message resend counter */
GHashTable *ack_data;
} p_mul_seq_val;
@ -296,14 +296,14 @@ static guint16 checksum (guint8 *buffer, gint len, gint offset)
static guint p_mul_id_hash (gconstpointer k)
{
p_mul_id_key *p_mul=(p_mul_id_key *)k;
p_mul_id_key *p_mul = (p_mul_id_key *)k;
return p_mul->id;
}
static gint p_mul_id_hash_equal (gconstpointer k1, gconstpointer k2)
{
p_mul_id_key *p_mul1=(p_mul_id_key *)k1;
p_mul_id_key *p_mul2=(p_mul_id_key *)k2;
p_mul_id_key *p_mul1 = (p_mul_id_key *)k1;
p_mul_id_key *p_mul2 = (p_mul_id_key *)k2;
if (p_mul1->id != p_mul2->id)
return 0;
@ -317,8 +317,8 @@ static gint p_mul_id_hash_equal (gconstpointer k1, gconstpointer k2)
static p_mul_seq_val *lookup_seq_val (guint32 message_id, guint16 seq_no,
address *addr)
{
p_mul_seq_val *pkg_data = NULL;
p_mul_id_key *p_mul_key = se_alloc (sizeof (p_mul_id_key));
p_mul_seq_val *pkg_data;
p_mul_id_key *p_mul_key = se_alloc (sizeof (p_mul_id_key));
p_mul_key->id = message_id;
p_mul_key->seq = seq_no;
@ -357,14 +357,14 @@ static p_mul_seq_val *register_p_mul_id (packet_info *pinfo, address *addr, guin
guint8 pdu_type, guint32 message_id,
guint16 seq_no, gint no_missing)
{
p_mul_seq_val *p_mul_data = NULL, *pkg_data = NULL;
p_mul_id_key *p_mul_key = NULL;
p_mul_seq_val *p_mul_data = NULL, *pkg_data = NULL;
p_mul_id_key *p_mul_key;
p_mul_ack_data *ack_data = NULL;
nstime_t addr_time, prev_time;
guint addr_id = 0, prev_id = 0;
guint16 last_found_pdu = 0;
gboolean missing_pdu = FALSE, set_address = FALSE;
GHashTable *pkg_list = NULL;
nstime_t addr_time, prev_time;
guint addr_id = 0, prev_id = 0;
guint16 last_found_pdu = 0;
gboolean missing_pdu = FALSE, set_address = FALSE;
GHashTable *pkg_list;
if (pinfo->flags.in_error_pkt) {
/* No analysis of error packets */
@ -522,13 +522,14 @@ static void add_ack_analysis (tvbuff_t *tvb, packet_info *pinfo, proto_tree *p_m
gint offset, guint8 pdu_type, address *src, address *dst,
guint32 message_id, gint no_missing)
{
proto_tree *analysis_tree = NULL;
proto_item *sa = NULL, *en = NULL;
p_mul_seq_val *pkg_data = NULL;
p_mul_ack_data *ack_data = NULL;
gboolean item_added = FALSE;
guint32 dstIp;
nstime_t ns;
proto_tree *analysis_tree = NULL;
proto_item *sa = NULL;
proto_item *en = NULL;
p_mul_seq_val *pkg_data = NULL;
p_mul_ack_data *ack_data = NULL;
gboolean item_added = FALSE;
guint32 dstIp;
nstime_t ns;
if (pinfo->flags.in_error_pkt) {
/* No analysis of error packets */
@ -669,11 +670,11 @@ static p_mul_seq_val *add_seq_analysis (tvbuff_t *tvb, packet_info *pinfo,
guint8 pdu_type, guint32 message_id,
guint16 seq_no, gint no_missing)
{
p_mul_seq_val *pkg_data = NULL;
proto_tree *analysis_tree = NULL;
proto_item *sa = NULL, *en = NULL, *eh = NULL;
gboolean item_added = FALSE;
nstime_t ns;
p_mul_seq_val *pkg_data;
proto_tree *analysis_tree;
proto_item *sa, *en = NULL, *eh = NULL;
gboolean item_added = FALSE;
nstime_t ns;
pkg_data = register_p_mul_id (pinfo, src, 0, pdu_type, message_id, seq_no,
no_missing);
@ -788,9 +789,7 @@ static p_mul_seq_val *add_seq_analysis (tvbuff_t *tvb, packet_info *pinfo,
static void dissect_reassembled_data (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
if (tvb == NULL || tree == NULL) {
return;
}
DISSECTOR_ASSERT(tvb != NULL);
switch (decode_option) {
case DECODE_BER:
@ -807,18 +806,18 @@ static void dissect_reassembled_data (tvbuff_t *tvb, packet_info *pinfo, proto_t
static void dissect_p_mul (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *p_mul_tree = NULL, *field_tree = NULL, *checksum_tree = NULL;
proto_item *ti = NULL, *en = NULL, *len_en = NULL;
gboolean save_fragmented;
fragment_data *frag_msg = NULL;
guint32 message_id = 0, ip;
guint16 no_dest = 0, count = 0, len = 0, data_len = 0;
guint16 checksum1, checksum2, pdu_length = 0, no_pdus = 0, seq_no = 0;
guint8 pdu_type = 0, *value = NULL, map = 0, fec_len;
gint i, tot_no_missing = 0, no_missing = 0, offset = 0;
address src, dst;
proto_tree *p_mul_tree, *field_tree, *checksum_tree;
proto_item *ti, *en, *len_en;
gboolean save_fragmented;
guint32 message_id = 0, ip;
guint16 no_dest = 0, count = 0, len, data_len = 0;
guint16 checksum1, checksum2;
guint16 pdu_length, no_pdus = 0, seq_no = 0;
guint8 pdu_type, *value, map = 0, fec_len;
gint i, tot_no_missing = 0, no_missing = 0, offset = 0;
address src, dst;
emem_strbuf_t *message_id_list = NULL;
nstime_t ts;
nstime_t ts;
col_set_str (pinfo->cinfo, COL_PROTOCOL, "P_MUL");
col_clear (pinfo->cinfo, COL_INFO);
@ -1298,7 +1297,8 @@ static void dissect_p_mul (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
fragment_start_seq_check (pinfo, message_id, p_mul_fragment_table,
no_pdus - 1);
} else if (pdu_type == Data_PDU) {
tvbuff_t *new_tvb = NULL;
fragment_data *frag_msg;
tvbuff_t *new_tvb;
pinfo->fragmented = TRUE;