char * ofl_oxm_type_to_string(uint16_t type) { char *str; size_t str_size; FILE *stream = open_memstream(&str, &str_size); ofl_oxm_type_print(stream, type); fclose(stream); return str; }
void ofl_structs_table_properties_print(FILE * stream, struct ofl_table_feature_prop_header* s){ int i; fprintf(stream, "{property=\""); ofl_properties_type_print(stream, s->type); switch(s->type){ case OFPTFPT_INSTRUCTIONS: case OFPTFPT_INSTRUCTIONS_MISS:{ struct ofl_table_feature_prop_instructions *insts = (struct ofl_table_feature_prop_instructions*) s; fprintf(stream, "["); if(insts->ids_num) { for(i = 0; i < insts->ids_num -1; i++){ ofl_instruction_type_print(stream, insts->instruction_ids[i].type); fprintf(stream, ", "); } ofl_instruction_type_print(stream, insts->instruction_ids[insts->ids_num-1].type); } fprintf(stream, "]"); break; } case OFPTFPT_NEXT_TABLES: case OFPTFPT_NEXT_TABLES_MISS:{ struct ofl_table_feature_prop_next_tables *tbls = (struct ofl_table_feature_prop_next_tables*) s; fprintf(stream, "["); if(tbls->table_num) { for(i = 0; i < tbls->table_num -1; i++){ fprintf(stream, "%d, ", tbls->next_table_ids[i]); } fprintf(stream, "%d]", tbls->next_table_ids[tbls->table_num -1]); } break; } case OFPTFPT_APPLY_ACTIONS: case OFPTFPT_APPLY_ACTIONS_MISS: case OFPTFPT_WRITE_ACTIONS: case OFPTFPT_WRITE_ACTIONS_MISS:{ struct ofl_table_feature_prop_actions *acts = (struct ofl_table_feature_prop_actions*) s; fprintf(stream, "["); if(acts->actions_num) { for(i = 0; i < acts->actions_num -1; i++){ ofl_action_type_print(stream, acts->action_ids[i].type); fprintf(stream, ", "); } ofl_action_type_print(stream, acts->action_ids[acts->actions_num-1].type); } fprintf(stream, "]"); break; } case OFPTFPT_MATCH: case OFPTFPT_WILDCARDS: case OFPTFPT_APPLY_SETFIELD: case OFPTFPT_APPLY_SETFIELD_MISS: case OFPTFPT_WRITE_SETFIELD: case OFPTFPT_WRITE_SETFIELD_MISS:{ struct ofl_table_feature_prop_oxm *oxms = (struct ofl_table_feature_prop_oxm*) s; fprintf(stream, "["); if(oxms->oxm_num) { for(i = 0; i < oxms->oxm_num -1; i++){ ofl_oxm_type_print(stream, oxms->oxm_ids[i]); fprintf(stream, ", " ); } ofl_oxm_type_print(stream, oxms->oxm_ids[oxms->oxm_num -1]); } fprintf(stream, "]"); break; } } fprintf(stream, "\"} "); }