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*/ } } }
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*/ } }