Пример #1
0
gint
decode_visit(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
    guint32 to_visit_len;
    guint32 visited_len;
    guint32 i;

    to_visit_len = tvb_get_ntohl(tvb, offset);
    proto_tree_add_uint(tree, hf_scribe_to_visit_len, tvb, offset, 4, to_visit_len);
    offset += 4;
    for (i = 0; i < to_visit_len; ++i){
      offset = decode_nodehandle(tvb, tree, offset, ep_strdup_printf("NodeHandle to visit #%d", i+1));
      if (offset == -1){
        return -1;
      }
    }/*end for each to_visit*/

    visited_len = tvb_get_ntohl(tvb, offset);
    proto_tree_add_uint(tree, hf_scribe_visited_len, tvb, offset, 4, visited_len);
    offset += 4;
    for (i = 0; i < visited_len; ++i){
      offset = decode_nodehandle(tvb, tree, offset, ep_strdup_printf("Visited NodeHandle #%d", i+1));
      if (offset == -1){
        return -1;
      }
    }/*end for each visited*/
    return offset;
}
Пример #2
0
static void
decode_lookup_msg(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  if (tree){
    guint8 has_content = tvb_get_guint8(tvb, offset);
    proto_tree_add_item(tree, hf_past_has_content, tvb, offset, 1, FALSE);
    switch (has_content){
      case 0:
        offset++;
        break;
      case 1:
        offset = decode_past_content(tvb, tree, offset + 1);
        break;
      case 2:
        offset = decode_past_error(tvb, tree, offset + 1);
        break;
      case 3:
      default:
        proto_tree_add_text(tree, tvb, offset + 6, -1, "Not supported by dissector.");
        return;
    }
    if (offset != -1){
      guint8 has_node_handle;
      if (tvb_reported_length_remaining(tvb, offset) < 1){
        proto_tree_add_text(tree, tvb, offset, -1, "Too short attributes!");
        return;
      }
      has_node_handle = tvb_get_guint8(tvb, offset);
      proto_tree_add_item(tree, hf_past_has_nodehandle, tvb, offset, 1, FALSE);
      offset++;
      if (has_node_handle != 0){
        offset = decode_nodehandle(tvb, tree, offset, "Handle");
        if (offset == -1){
          return;
        }
      }

      offset = decode_type_and_id(tvb, tree, offset);
      if (offset != -1) {
        if (tvb_reported_length_remaining(tvb, offset) < 1){
          proto_tree_add_text(tree, tvb, offset, -1, "Missing attribute!");
        } else {
          proto_tree_add_item(tree, hf_past_cached, tvb, offset, 1, FALSE);
        }
      }
    }
  }
}
Пример #3
0
void
decode_subscribe(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
  if (tree){
    gboolean has_content = FALSE;
    gboolean has_previous_parent = FALSE;

    /*visit*/
    offset = decode_visit(tvb, tree, offset);
    if (offset == -1){
        return;
    }

    /*has content?*/
    if (tvb_get_guint8(tvb, offset) != 0){
      has_content = TRUE;
    }
    proto_tree_add_boolean(tree, hf_scribe_has_content, tvb, offset, 1, has_content);
    offset++;

    if (has_content){
      decode_content(tvb, tree, offset);
    } else {
      proto_tree_add_item(tree, hf_scribe_id, tvb, offset, 4, FALSE);
      offset += 4;
      /*has previous parent?*/
      if (tvb_get_guint8(tvb, offset) != 0){
        has_previous_parent = TRUE;
      }
      proto_tree_add_boolean(tree, hf_scribe_has_previous_parent, tvb, offset, 1, has_previous_parent);
      offset++;

      if (has_previous_parent){
        proto_tree_add_item(tree, hf_scribe_previous_parent_type, tvb, offset, 2, FALSE);
        offset += 2;
        proto_tree_add_string(tree, hf_scribe_previous_parent, tvb, offset, 20, get_id_full(tvb, offset));
        offset +=20;
      }

      decode_nodehandle(tvb, tree, offset, "Subscriber");
    }
  }
}
Пример #4
0
static void
dissect_scribe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_item *ti = NULL;
	proto_tree *scribe_tree = NULL;
  const gchar *type_string = NULL;
  guint16 type;
  gboolean has_source = FALSE;
  gint offset = 0;

  if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
			col_set_str(pinfo->cinfo, COL_PROTOCOL, "Scribe");

  type = tvb_get_ntohs(tvb, offset);
  type_string = val_to_str(type, scribe_msg_type, "<Unknown type %d>");

  if (check_col(pinfo->cinfo, COL_INFO)){
    col_clear (pinfo->cinfo, COL_INFO);
    col_add_fstr(pinfo->cinfo, COL_INFO, "%d > %d %s",
      pinfo->srcport, pinfo->destport, type_string);
  }
  
  /*has source?*/
  if (tvb_get_guint8(tvb, offset+3) != 0){
    has_source = TRUE;
  }

  if (tree){
    ti = proto_tree_add_item(tree, proto_scribe, tvb, 0, -1, FALSE);
    scribe_tree = proto_item_add_subtree(ti, ett_scribe);
    proto_tree_add_item(scribe_tree, hf_scribe_type, tvb, offset, 2, FALSE);
    proto_tree_add_item(scribe_tree, hf_scribe_version, tvb, offset + 2, 1, FALSE);
    proto_tree_add_boolean(scribe_tree, hf_scribe_has_source, tvb, offset + 3, 1, has_source);
    if (has_source){
      offset = decode_nodehandle(tvb, scribe_tree, offset + 4 , "Source");
    }
  } else {
    if (has_source){
      offset = get_node_handle_len(tvb, offset + 3);
    }
  }
  if (offset == -1){
    return;
  }

  if(check_col(pinfo->cinfo,COL_INFO)){
    print_id_into_col_info(tvb, pinfo, offset, "Topic");
  }

  if (tree){
    offset = decode_type_and_id(tvb, scribe_tree, offset);
    if (offset == -1){
      return;
    }

    switch (type){
      case SCRIBE_ANYCAST_MSG:
        decode_anycast(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_MSG:
        decode_subscribe(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_ACK_MSG:
        decode_scribe_subscribe_ack(tvb, scribe_tree, offset);
        break;
      case SCRIBE_SUBSCRIBE_FAILED_MSG:
        decode_scribe_failed(tvb, scribe_tree, offset);
        break;
      case SCRIBE_PUBLISH_MSG:
      case SCRIBE_PUBLISH_REQUEST_MSG:
        decode_content(tvb, scribe_tree, offset);
        break;
      case SCRIBE_DROP_MSG:
      case SCRIBE_UNSUBSCRIBE_MSG:
      default:
        return;/*stop dissection*/
    }
  }
}
Пример #5
0
static void
dissect_past(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_item *ti = NULL;
	proto_tree *past_tree = NULL;
  guint16 type;
  const gchar *type_string = NULL;
  gint offset = 0;
  gint offset_dest = 0;

  if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
			col_set_str(pinfo->cinfo, COL_PROTOCOL, "PAST");

  type = tvb_get_ntohs(tvb, offset);
  type_string = val_to_str(type, past_msg_type, "<Unknown type %d>");

  if (check_col(pinfo->cinfo, COL_INFO)){
    col_clear (pinfo->cinfo, COL_INFO);
    col_add_fstr(pinfo->cinfo, COL_INFO, "%d > %d %s",
      pinfo->srcport, pinfo->destport, type_string);
  }
  
  /*7 = 2 + 1 + 4 (args before ID)*/
  offset_dest = offset + 7;

  if (tree){
    ti = proto_tree_add_item(tree, proto_past, tvb, 0, -1, FALSE);
    past_tree = proto_item_add_subtree(ti, ett_past);
    proto_tree_add_item(past_tree, hf_past_type, tvb, offset, 2, FALSE);
    offset += 2;
    proto_tree_add_item(past_tree, hf_past_version, tvb, offset, 1, FALSE);
    offset++;
    proto_tree_add_item(past_tree, hf_past_msg_id, tvb, offset, 4, FALSE);
    offset = decode_type_and_id(tvb, past_tree, offset_dest);
    if (offset == -1){
      return;
    }
    offset = decode_nodehandle(tvb, past_tree, offset, "Source");
    if (offset == -1){
      return;
    }
    proto_tree_add_item(past_tree, hf_past_is_response, tvb, offset, 1, FALSE);
  } else {
    offset = get_node_handle_len(tvb, offset + 29);
    if (offset == -1){
      return;
    }
  }

  if(check_col(pinfo->cinfo,COL_INFO)){
    if (tvb_get_guint8(tvb,offset) == 0){
      print_id_into_col_info(tvb, pinfo, offset_dest, "Request");
    } else {
      print_id_into_col_info(tvb, pinfo, offset_dest, "Response");
    }
  }

  offset++;

  switch (type){
    case CACHE_MSG:
      decode_cache_msg(tvb, past_tree, offset);
      break;
    case FETCH_HANDLE_MSG:
      decode_fetch_handle_msg(tvb, past_tree, offset);
      break;
    case FETCH_MSG:
      decode_fetch_msg(tvb, past_tree, offset);
      break;
    case INSERT_MSG:
      decode_insert_msg(tvb, past_tree, offset);
      break;
    case LOOKUP_HANDLES_MSG:
      decode_lookup_handle_message(tvb, past_tree, offset);
      break;
    case LOOKUP_MSG:
      decode_lookup_msg(tvb, past_tree, offset);
      break;
    default:
      return;/*stop dissection*/
  }

}