Esempio n. 1
0
static void
dissect_v8_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
  guint32 message_data_length;
  guint8 type;
  tvbuff_t *message_data_tvb;

  message_data_length = tvb_get_ntohl(message_tvb, V8_LENGTH_OFFSET) - V8_HEADER_LENGTH;
  if ((gint) message_data_length < 1) {
    if (m2pa_tree)
      proto_tree_add_text(m2pa_tree, message_tvb, V8_LENGTH_OFFSET, 4,
        "Invalid message data length: %u", message_data_length);
    THROW(ReportedBoundsError);
  }
  message_data_tvb    = tvb_new_subset(message_tvb, V8_MESSAGE_DATA_OFFSET, message_data_length, message_data_length);
  type                = tvb_get_guint8(message_tvb, V8_TYPE_OFFSET);


  switch(type) {
  case V8_USER_DATA_TYPE:
    dissect_v8_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
    break;
  case V8_LINK_STATUS_TYPE:
    dissect_v8_link_status_message(message_data_tvb, pinfo, m2pa_tree);
    break;
  default:
    dissect_unknown_message(message_data_tvb, m2pa_tree);
  }
}
Esempio n. 2
0
static void
dissect_v8_message_data(tvbuff_t *message_tvb, packet_info *pinfo, proto_item *m2pa_item, proto_tree *m2pa_tree, proto_tree *tree)
{
  guint32 message_data_length;
  guint8 type;
  tvbuff_t *message_data_tvb;

  message_data_length = tvb_get_ntohl(message_tvb, V8_LENGTH_OFFSET) - V8_HEADER_LENGTH;
  if ((gint) message_data_length < 1) {
    proto_tree_add_expert_format(m2pa_tree, pinfo, &ei_length, message_tvb, V8_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, V8_MESSAGE_DATA_OFFSET, message_data_length);
  type                = tvb_get_guint8(message_tvb, V8_TYPE_OFFSET);


  switch(type) {
  case V8_USER_DATA_TYPE:
    dissect_v8_user_data_message(message_data_tvb, pinfo, m2pa_item, m2pa_tree, tree);
    break;
  case V8_LINK_STATUS_TYPE:
    dissect_v8_link_status_message(message_data_tvb, pinfo, m2pa_tree);
    break;
  default:
    dissect_unknown_message(message_data_tvb, m2pa_tree);
  }
}