gint offset = 0; gint next_offset; int datalen; guint16 version, len, port; guint8 message, proto; rmi_type rmitype; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMI"); datalen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); rmitype = get_rmi_type(tvb, offset, datalen); switch(rmitype) { case RMI_OUTPUTSTREAM: version = tvb_get_ntohs(tvb,4); col_add_fstr(pinfo->cinfo, COL_INFO, "JRMI, Version: %d, ", version); proto = tvb_get_guint8(tvb, 6); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(proto, rmi_protocol_str, "Unknown protocol")); break; case RMI_OUTPUTMESSAGE: message = tvb_get_guint8(tvb,0); col_set_str(pinfo->cinfo, COL_INFO,
static void dissect_rmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *ti; proto_tree *rmi_tree; tvbuff_t *next_tvb; gint offset; gint next_offset; int datalen; guint16 version, len, port; guint8 message, proto; rmi_type rmitype; const char *epid_hostname; guint epid_len; offset = 0; /* Make entries in Protocol column and Info column on summary display */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "RMI"); datalen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE); rmitype = get_rmi_type(tvb, offset, datalen); switch(rmitype) { case RMI_OUTPUTSTREAM: version = tvb_get_ntohs(tvb,4); col_add_fstr(pinfo->cinfo, COL_INFO, "JRMI, Version: %d, ", version); proto = tvb_get_guint8(tvb, 6); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(proto, rmi_protocol_str, "Unknown protocol")); break; case RMI_OUTPUTMESSAGE: message = tvb_get_guint8(tvb,0); col_set_str(pinfo->cinfo, COL_INFO, "JRMI, "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(message, rmi_output_message_str, "Unknown message")); break; case RMI_INPUTSTREAM: message = tvb_get_guint8(tvb,0); col_set_str(pinfo->cinfo, COL_INFO, "JRMI, "); col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(message, rmi_input_message_str, "Unknown message")); break; case SERIALIZATION_DATA: version = tvb_get_ntohs(tvb,2); col_add_fstr(pinfo->cinfo, COL_INFO, "Serialization data, Version: %d", version); break; default: col_set_str(pinfo->cinfo, COL_INFO, "Continuation"); break; } if (tree) { ti = proto_tree_add_item(tree, proto_rmi, tvb, 0, -1, ENC_NA); rmi_tree = proto_item_add_subtree(ti, ett_rmi); switch(rmitype) { case RMI_OUTPUTSTREAM: /* XXX - uint, or string? */ proto_tree_add_uint(rmi_tree, hf_rmi_magic, tvb, offset, 4, tvb_get_ntohl(tvb,0)); proto_tree_add_item(rmi_tree, hf_rmi_version, tvb, offset + 4, 2, ENC_BIG_ENDIAN); proto_tree_add_item(rmi_tree, hf_rmi_protocol, tvb, offset + 6, 1, ENC_BIG_ENDIAN); break; case RMI_INPUTSTREAM: message = tvb_get_guint8(tvb, 0); proto_tree_add_uint(rmi_tree, hf_rmi_inputmessage, tvb, offset, 1, message); if(message == RMI_INPUTSTREAM_MESSAGE_ACK) { proto_tree_add_text(rmi_tree, tvb, offset + 1, -1, "EndPointIdentifier"); /* MESSAGE_ACK should include EndpointIdentifier */ len = tvb_get_ntohs(tvb, 1); proto_tree_add_uint(rmi_tree, hf_rmi_epid_length, tvb, offset + 1, 2, len); epid_len = len < ITEM_LABEL_LENGTH ? len : ITEM_LABEL_LENGTH; if (epid_len > 0) { epid_hostname = tvb_format_text(tvb, offset + 3, epid_len); } else { epid_hostname = "[Empty]"; } proto_tree_add_string(rmi_tree, hf_rmi_epid_hostname, tvb, offset + 3, len, epid_hostname); port = tvb_get_ntohs(tvb, offset + len + 5); proto_tree_add_uint(rmi_tree, hf_rmi_epid_port, tvb, offset + len + 5, 2, port); } if(message == RMI_INPUTSTREAM_MESSAGE_RETURNDATA) { proto_tree_add_text(rmi_tree, tvb, offset + 1, -1, "Serialization Data"); next_tvb = tvb_new_subset_remaining(tvb, offset + 1); dissect_ser(next_tvb, tree); } break; case RMI_OUTPUTMESSAGE: message = tvb_get_guint8(tvb, 0); proto_tree_add_uint(rmi_tree, hf_rmi_outputmessage, tvb, offset, 1, message); if(message == RMI_OUTPUTSTREAM_MESSAGE_CALL) { proto_tree_add_text(rmi_tree, tvb, offset + 1, -1, "Serialization Data"); /* XXX */ next_tvb = tvb_new_subset_remaining(tvb, offset + 1); dissect_ser(next_tvb, tree); } if(message == RMI_OUTPUTSTREAM_MESSAGE_DGCACK) { proto_tree_add_text(rmi_tree, tvb, offset + 1, -1, "UniqueIdentifier"); } break; case SERIALIZATION_DATA: dissect_ser(tvb, tree); break; default: break; } } }