static void
ofl_msg_print_flow_mod(struct ofl_msg_flow_mod *msg, FILE *stream, struct ofl_exp *exp) {
    size_t i;

    fprintf(stream, "{table=\"");
    ofl_table_print(stream, msg->table_id);
    fprintf(stream, "\", cmd=\"");
    ofl_flow_mod_command_print(stream, msg->command);
    fprintf(stream, "\", cookie=\"0x%"PRIx64"\", mask=\"0x%"PRIx64"\", "
                          "idle=\"%u\", hard=\"%u\", prio=\"%u\", buf=\"",
                  msg->cookie, msg->cookie_mask,
                  msg->idle_timeout, msg->hard_timeout, msg->priority);
    ofl_buffer_print(stream, msg->buffer_id);
    fprintf(stream, "\", port=\"");
    ofl_port_print(stream, msg->out_port);
    fprintf(stream, "\", group=\"");
    ofl_group_print(stream, msg->out_group);
    fprintf(stream, "\", flags=\"0x%"PRIx16"\", match=",msg->flags);
    ofl_structs_match_print(stream, msg->match, exp);
    fprintf(stream, ", insts=[");
    for(i=0; i<msg->instructions_num; i++) {
        ofl_structs_instruction_print(stream, msg->instructions[i], exp);
        if (i < msg->instructions_num - 1) { fprintf(stream, ", "); }
    }
    fprintf(stream, "]}");
}
Exemplo n.º 2
0
char *
ofl_buffer_to_string(uint32_t buffer) {
    char *str;
    size_t str_size;
    FILE *stream = open_memstream(&str, &str_size);

    ofl_buffer_print(stream, buffer);
    fclose(stream);
    return str;
}
static void
ofl_msg_print_packet_in(struct ofl_msg_packet_in *msg, FILE *stream) {
    fprintf(stream, "{buffer=\"");
    ofl_buffer_print(stream, msg->buffer_id);
    fprintf(stream, "\", tlen=\"%u\", reas=\"", msg->total_len);
    ofl_packet_in_reason_print(stream, msg->reason);
    fprintf(stream, "\", table=\"");
    ofl_table_print(stream, msg->table_id);
    fprintf(stream, "\", dlen=\"%zu\"}", msg->data_length);
}
static void
ofl_msg_print_packet_out(struct ofl_msg_packet_out *msg, FILE *stream, struct ofl_exp *exp) {
    size_t i;
    fprintf(stream, "{buffer=\"");
    ofl_buffer_print(stream, msg->buffer_id);
    fprintf(stream, "\", port=\"");
    ofl_port_print(stream, msg->in_port);
    fprintf(stream, "\", actions=[");

    for (i=0; i<msg->actions_num; i++) {
        ofl_action_print(stream, msg->actions[i], exp);
        if (i < msg->actions_num - 1) { fprintf(stream, ", "); }
    }

    fprintf(stream, "]}");
}
Exemplo n.º 5
0
char *
packet_to_string(struct packet *pkt) {
    char *str;
    size_t str_size;
    FILE *stream = open_memstream(&str, &str_size);

    fprintf(stream, "pkt{in=\"");
    ofl_port_print(stream, pkt->in_port);
    fprintf(stream, "\", actset=");
    action_set_print(stream, pkt->action_set);
    fprintf(stream, ", pktout=\"%u\", ogrp=\"", pkt->packet_out);
    ofl_group_print(stream, pkt->out_group);
    fprintf(stream, "\", oprt=\"");
    ofl_port_print(stream, pkt->out_port);
    fprintf(stream, "\", buffer=\"");
    ofl_buffer_print(stream, pkt->buffer_id);
    fprintf(stream, "\", std=");
    //packet_handle_std_print(stream, pkt->handle_std);
    fprintf(stream, "}");

    fclose(stream);
    return str;
}