Пример #1
0
static void
dissect_v2_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
  guint32 message_data_length;
  guint16 type;
  tvbuff_t *message_data_tvb;

  message_data_length = (gint) tvb_get_ntohl(message_tvb, V2_LENGTH_OFFSET);
  if ((gint) message_data_length < 1) {
    if (m2pa_tree)
      proto_tree_add_text(m2pa_tree, message_tvb, V2_LENGTH_OFFSET, 4,
        "Invalid message data length: %u", message_data_length);
    THROW(ReportedBoundsError);
  }

  message_data_tvb    = tvb_new_subset(message_tvb, V2_MESSAGE_DATA_OFFSET, message_data_length, message_data_length);
  type                = tvb_get_ntohs(message_tvb, V2_TYPE_OFFSET);

  switch(type) {
  case V2_USER_DATA_TYPE:
    dissect_v2_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
    break;
  case V2_LINK_STATUS_TYPE:
    dissect_v2_link_status_message(message_data_tvb, pinfo, m2pa_tree);
    break;
  default:
    dissect_unknown_message(message_data_tvb, m2pa_tree);
  }
}
Пример #2
0
static void
dissect_v2_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
  guint32 message_data_length;
  guint16 type;
  tvbuff_t *message_data_tvb;

  message_data_length = (gint) tvb_get_ntohl(message_tvb, V2_LENGTH_OFFSET);
  if ((gint) message_data_length < 1) {
    proto_tree_add_expert_format(m2pa_tree, pinfo, &ei_length, message_tvb, V2_LENGTH_OFFSET, 4,
        "Invalid message data length: %u", message_data_length);
    /* XXX - is this really necessary?  Can we just return since the expert info can
       still find the "malformed" packet? */
    THROW(ReportedBoundsError);
  }

  message_data_tvb    = tvb_new_subset_length(message_tvb, V2_MESSAGE_DATA_OFFSET, message_data_length);
  type                = tvb_get_ntohs(message_tvb, V2_TYPE_OFFSET);

  switch(type) {
  case V2_USER_DATA_TYPE:
    dissect_v2_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
    break;
  case V2_LINK_STATUS_TYPE:
    dissect_v2_link_status_message(message_data_tvb, pinfo, m2pa_tree);
    break;
  default:
    dissect_unknown_message(message_data_tvb, m2pa_tree);
  }
}