int Ioss::SideBlock::get_consistent_side_number() const { if (consistentSideNumber == -1) { // It wasn't calculated during the metadata reading of the surfaces. // Determine it now... if (field_exists("element_side")) { int side = 0; if (get_database()->int_byte_size_api() == 8) { std::vector<int64_t> element_side; get_field_data("element_side", element_side); side = internal_consistent_side_number(element_side); } else { std::vector<int> element_side; get_field_data("element_side", element_side); side = internal_consistent_side_number(element_side); } int side_max = get_database()->util().global_minmax(side, Ioss::ParallelUtils::DO_MAX); if (side_max != 999) consistentSideNumber = side_max; else consistentSideNumber = 0; } else { consistentSideNumber = 0; } } return consistentSideNumber; }
void process_input_request(Ioss::Region ®ion, stk::mesh::BulkData &bulk, int step) { region.begin_state(step); // Special processing for nodeblock (all nodes in model)... const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk); // ??? Get field data from nodeblock... get_field_data(bulk, meta.universal_part(), stk::topology::NODE_RANK, region.get_node_blocks()[0], Ioss::Field::TRANSIENT); const stk::mesh::PartVector & all_parts = meta.get_parts(); for ( stk::mesh::PartVector::const_iterator ip = all_parts.begin(); ip != all_parts.end(); ++ip ) { stk::mesh::Part * const part = *ip; const stk::mesh::EntityRank part_rank = part->primary_entity_rank(); // Check whether this part should be output to results database. if (stk::io::is_part_io_part(*part)) { // Get Ioss::GroupingEntity corresponding to this part... Ioss::GroupingEntity *entity = region.get_entity(part->name()); if (entity != NULL) { if (entity->type() == Ioss::SIDESET) { Ioss::SideSet *sset = dynamic_cast<Ioss::SideSet*>(entity); assert(sset != NULL); int block_count = sset->block_count(); for (int i=0; i < block_count; i++) { Ioss::SideBlock *side_block = sset->get_block(i); /// \todo REFACTOR Need filtering mechanism. get_field_data(bulk, *part, part_rank, side_block, Ioss::Field::TRANSIENT); } } else { get_field_data(bulk, *part, part_rank, entity, Ioss::Field::TRANSIENT); } } else { /// \todo IMPLEMENT handle error... Possibly an assert since /// I think the corresponding entity should always exist... } } } region.end_state(step); }
/** Extracts concrete data for a specified field_info label @param pdata supporting structure containing concrete data in byte arrays @param fi field_info label of extracted data @return extracted data in a form of byte array or NULL if failed */ guchar * hf_extract_value(hf_prototree_data *pdata, field_info *fi) { guchar *pd; // if no buffer is attached then we have nothing to extract if (!fi->ds_tvb) return NULL; // if the length is mismatched, it can(but must not) be a problem, but note it in debug mode if (fi->length > tvb_length_remaining(fi->ds_tvb, fi->start)) { if(debug_mode==DEBUG_MODE) { fprintf(stderr,"Length mismatch during data extraction!"); } return NULL; } // find the data for this field pd = hf_copy_value_to_hexa(get_field_data(pdata->src_list, fi),fi->length); return pd; }
/* this function should be unnecessary - we don't want to convert values to hex. */ static const gchar* get_field_hex_value2(GSList* src_list, field_info *fi) { const guint8 *pd; if (fi->length > tvb_length_remaining(fi->ds_tvb, fi->start)) { return "field length invalid!"; } /* Find the data for this field. */ pd = get_field_data(src_list, fi); if (pd) { int i; gchar* buffer; gchar* p; int len; const int chars_per_byte = 2; len = chars_per_byte * fi->length; buffer = ep_alloc_array(gchar, len + 1); buffer[len] = '\0'; /* Ensure NULL termination in bad cases */ p = buffer; /* Print a simple hex dump */ for (i = 0 ; i < fi->length; i++) { g_snprintf(p, len, "%02x", pd[i]); p += chars_per_byte; len -= chars_per_byte; } return buffer; } else { return NULL; } }
/* Print a tree's data, and any child nodes. */ static void proto_tree_print_node(proto_node *node, gpointer data) { field_info *fi = PNODE_FINFO(node); print_data *pdata = (print_data*) data; const guint8 *pd; gchar label_str[ITEM_LABEL_LENGTH]; gchar *label_ptr; __android_log_print(ANDROID_LOG_INFO, "libtshark", "in proto_tree_print_node !"); g_assert(fi && "dissection with an invisible proto tree?"); /* Don't print invisible entries. */ if (PROTO_ITEM_IS_HIDDEN(node)) return; __android_log_print(ANDROID_LOG_INFO, "libtshark", "the proto tree is not invisible"); /* Give up if we've already gotten an error. */ if (!pdata->success) return; __android_log_print(ANDROID_LOG_INFO, "libtshark", "success so far"); /* was a free format label produced? */ if (fi->rep) { label_ptr = fi->rep->representation; __android_log_print(ANDROID_LOG_INFO, "libtshark", "free format"); } else { /* no, make a generic label */ __android_log_print(ANDROID_LOG_INFO, "libtshark", "generic label"); label_ptr = label_str; proto_item_fill_label(fi, label_str); } __android_log_print(ANDROID_LOG_INFO, "libtshark", "A-OK"); if (PROTO_ITEM_IS_GENERATED(node)) { label_ptr = g_strdup_printf("[%s]", label_ptr); } __android_log_print(ANDROID_LOG_INFO, "libtshark", "proto was generated"); //if (!print_line(pdata->stream, pdata->level, label_ptr)) { // pdata->success = FALSE; // return; //} __android_log_print(ANDROID_LOG_INFO, "libtshark", "line: %s", label_ptr); __android_log_print(ANDROID_LOG_INFO, "libtshark", "line is printed"); if (PROTO_ITEM_IS_GENERATED(node)) { g_free(label_ptr); } __android_log_print(ANDROID_LOG_INFO, "libtshark", "item is generated"); /* If it's uninterpreted data, dump it (unless our caller will be printing the entire packet in hex). */ if (fi->hfinfo->id == proto_data && pdata->print_hex_for_data) { /* * Find the data for this field. */ pd = get_field_data(pdata->src_list, fi); __android_log_print(ANDROID_LOG_INFO, "libtshark", "uninterpreted"); if (pd) { if (!print_hex_data_buffer(pdata->stream, pd, fi->length, pdata->encoding)) { pdata->success = FALSE; return; } } } __android_log_print(ANDROID_LOG_INFO, "libtshark", "getting ready to traverse all subtrees"); /* If we're printing all levels, or if this node is one with a subtree and its subtree is expanded, recurse into the subtree, if it exists. */ g_assert(fi->tree_type >= -1 && fi->tree_type < num_tree_types); __android_log_print(ANDROID_LOG_INFO, "libtshark", "passed the assert"); if (pdata->print_dissections == print_dissections_expanded || (pdata->print_dissections == print_dissections_as_displayed && fi->tree_type >= 0 && tree_is_expanded[fi->tree_type])) { __android_log_print(ANDROID_LOG_INFO, "libtshark", "made it in"); if (node->first_child != NULL) { __android_log_print(ANDROID_LOG_INFO, "libtshark", "and we're about to level up"); pdata->level++; __android_log_print(ANDROID_LOG_INFO, "libtshark", "for each child..."); proto_tree_children_foreach(node, proto_tree_print_node, pdata); pdata->level--; if (!pdata->success) return; } } }
/* Print a tree's data, and any child nodes. */ static void proto_tree_print_node(proto_node *node, gpointer data) { field_info *fi = PNODE_FINFO(node); print_data *pdata = (print_data*) data; const guint8 *pd; gchar label_str[ITEM_LABEL_LENGTH]; gchar *label_ptr; /* dissection with an invisible proto tree? */ g_assert(fi); /* Don't print invisible entries. */ if (PROTO_ITEM_IS_HIDDEN(node)) return; /* Give up if we've already gotten an error. */ if (!pdata->success) return; /* was a free format label produced? */ if (fi->rep) { label_ptr = fi->rep->representation; } else { /* no, make a generic label */ label_ptr = label_str; proto_item_fill_label(fi, label_str); } if (PROTO_ITEM_IS_GENERATED(node)) { label_ptr = g_strdup_printf("[%s]", label_ptr); } if (!print_line(pdata->stream, pdata->level, label_ptr)) { pdata->success = FALSE; return; } /* * If -O is specified, only display the protocols which are in the * lookup table. Only check on the first level: once we start printing * a tree, print the rest of the subtree. Otherwise we won't print * subitems whose abbreviation doesn't match the protocol--for example * text items (whose abbreviation is simply "text"). */ if (output_only_tables != NULL && pdata->level == 0 && g_hash_table_lookup(output_only_tables, fi->hfinfo->abbrev) == NULL) { pdata->success = TRUE; return; } if (PROTO_ITEM_IS_GENERATED(node)) { g_free(label_ptr); } /* If it's uninterpreted data, dump it (unless our caller will be printing the entire packet in hex). */ if (fi->hfinfo->id == proto_data && pdata->print_hex_for_data) { /* * Find the data for this field. */ pd = get_field_data(pdata->src_list, fi); if (pd) { if (!print_line(pdata->stream, 0, "")) { pdata->success = FALSE; return; } if (!print_hex_data_buffer(pdata->stream, pd, fi->length, pdata->encoding)) { pdata->success = FALSE; return; } } } /* If we're printing all levels, or if this node is one with a subtree and its subtree is expanded, recurse into the subtree, if it exists. */ g_assert(fi->tree_type >= -1 && fi->tree_type < num_tree_types); if (pdata->print_dissections == print_dissections_expanded || (pdata->print_dissections == print_dissections_as_displayed && fi->tree_type >= 0 && tree_is_expanded[fi->tree_type])) { if (node->first_child != NULL) { pdata->level++; proto_tree_children_foreach(node, proto_tree_print_node, pdata); pdata->level--; if (!pdata->success) return; } } }