static void ofl_msg_print_stats_reply_group_features(struct ofl_msg_multipart_reply_group_features *msg, FILE *stream){ size_t i; enum ofp_action_type j; fprintf(stream, ", types=\"%d\", capabilities=\"%d [", msg->types, msg->capabilities); for(i = 0; i < 4; i++){ ofl_group_type_print(stream, i); fprintf(stream, ": max_groups=%d, actions= ", msg->max_groups[i]); if(msg->actions[i] & 1){ ofl_action_type_print(stream, OFPAT_OUTPUT); fprintf(stream, "/"); } if(msg->actions[i] & OFPAT_COPY_TTL_OUT){ ofl_action_type_print(stream, OFPAT_COPY_TTL_OUT); fprintf(stream, "/"); } if(msg->actions[i] & OFPAT_COPY_TTL_IN){ ofl_action_type_print(stream, OFPAT_COPY_TTL_IN); fprintf(stream, "/"); } for(j = OFPAT_SET_MPLS_TTL; j < OFPAT_POP_PBB; j++){ if (msg->actions[i] & j){ ofl_action_type_print(stream, j); fprintf(stream, "/"); } } if (i < 3) fprintf(stream, ", "); } }
char * ofl_action_type_to_string(uint16_t type) { char *str; size_t str_size; FILE *stream = open_memstream(&str, &str_size); ofl_action_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, "\"} "); }
void ofl_action_print(FILE *stream, struct ofl_action_header *act, struct ofl_exp *exp) { ofl_action_type_print(stream, act->type); switch (act->type) { case OFPAT_OUTPUT: { struct ofl_action_output *a = (struct ofl_action_output *)act; fprintf(stream, ",{\"port\":"); ofl_port_print(stream, a->port); if (a->port == OFPP_CONTROLLER) { fprintf(stream, ", \"mlen\":%u}", a->max_len); } else { fprintf(stream, "}"); } break; } case OFPAT_SET_FIELD:{ size_t size; struct ofl_action_set_field *a = (struct ofl_action_set_field *)act; fprintf(stream, ",{"); size = 4 + OXM_LENGTH(a->field->header); print_oxm_tlv(stream, a->field, &size); fprintf(stream, "}"); break; } case OFPAT_COPY_TTL_OUT: case OFPAT_COPY_TTL_IN: { break; } case OFPAT_SET_MPLS_TTL: { struct ofl_action_mpls_ttl *a = (struct ofl_action_mpls_ttl *)act; fprintf(stream, ",{\"ttl\":%u}", a->mpls_ttl); break; } case OFPAT_DEC_MPLS_TTL: { break; } case OFPAT_PUSH_VLAN: case OFPAT_PUSH_MPLS: case OFPAT_PUSH_PBB:{ struct ofl_action_push *a = (struct ofl_action_push *)act; fprintf(stream, ",{\"eth\":\"0x%04"PRIx16"\"}", a->ethertype); break; } case OFPAT_POP_VLAN: case OFPAT_POP_PBB: { break; } case OFPAT_POP_MPLS: { struct ofl_action_pop_mpls *a = (struct ofl_action_pop_mpls *)act; fprintf(stream, ",{\"eth\":\"0x%04"PRIx16"\"}", a->ethertype); break; } case OFPAT_SET_QUEUE: { struct ofl_action_set_queue *a = (struct ofl_action_set_queue *)act; fprintf(stream, ",{\"q\":"); ofl_queue_print(stream, a->queue_id); fprintf(stream, "}"); break; } case OFPAT_GROUP: { struct ofl_action_group *a = (struct ofl_action_group *)act; fprintf(stream, ",{\"id\":"); ofl_group_print(stream, a->group_id); fprintf(stream, "}"); break; } case OFPAT_SET_NW_TTL: { struct ofl_action_set_nw_ttl *a = (struct ofl_action_set_nw_ttl *)act; fprintf(stream, ",{\"ttl\":%u}", a->nw_ttl); break; } case OFPAT_DEC_NW_TTL: { break; } case OFPAT_EXPERIMENTER: { if (exp == NULL || exp->act == NULL || exp->act->to_string == NULL) { struct ofl_action_experimenter *a = (struct ofl_action_experimenter *)act; fprintf(stream, ",{\"id\":\"0x%"PRIx32"\"}", a->experimenter_id); } else { char *c = exp->act->to_string(act); fprintf(stream, "%s", c); free (c); } break; } } }