Ejemplo n.º 1
0
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, "\", port=\"");
    ofl_port_print(stream, msg->in_port);
    fprintf(stream, "\", phy_port=\"");
    ofl_port_print(stream, msg->in_phy_port);
    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_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, "]}");
}
static void
ofl_msg_print_stats_request_queue(struct ofl_msg_multipart_request_queue *msg, FILE *stream) {
    fprintf(stream, ", port=\"");
    ofl_port_print(stream, msg->port_no);
    fprintf(stream, "\", q=\"");
    ofl_queue_print(stream, msg->queue_id);
    fprintf(stream, "\"");
}
static void
ofl_msg_print_port_mod(struct ofl_msg_port_mod *msg, FILE *stream) {

    fprintf(stream, "{port=\"");
    ofl_port_print(stream, msg->port_no);
    fprintf(stream, "\", hwaddr=\""ETH_ADDR_FMT"\", config=\"0x%08"PRIx32"\", "
                          "mask=\"0x%"PRIx32"\", adv=\"0x%"PRIx32"\"}",
                  ETH_ADDR_ARGS(msg->hw_addr), msg->config, msg->mask, msg->advertise);
}
Ejemplo n.º 5
0
char *
ofl_port_to_string(uint32_t port) {
    char *str;
    size_t str_size;
    FILE *stream = open_memstream(&str, &str_size);

    ofl_port_print(stream, port);
    fclose(stream);
    return str;
}
Ejemplo n.º 6
0
void
ofl_structs_queue_stats_print(FILE *stream, struct ofl_queue_stats *s) {

    fprintf(stream, "{port=\"");
    ofl_port_print(stream, s->port_no);
    fprintf(stream, "\", q=\"");
    ofl_queue_print(stream, s->queue_id);
    fprintf(stream, "\", tx_bytes=\"%"PRIu64"\", "
                          "tx_pkt=\"%"PRIu64"\", tx_err=\"%"PRIu64"\"}",
                  s->tx_bytes, s->tx_packets, s->tx_errors);
};
static void
ofl_msg_print_stats_request_flow(struct ofl_msg_multipart_request_flow *msg, FILE *stream, struct ofl_exp *exp) {
    fprintf(stream, ", table=\"");
    ofl_table_print(stream, msg->table_id);
    fprintf(stream, "\", oport=\"");
    ofl_port_print(stream, msg->out_port);
    fprintf(stream, "\", ogrp=\"");
    ofl_group_print(stream, msg->out_group);
    fprintf(stream, "\", cookie=0x%"PRIx64"\", mask=0x%"PRIx64"\", match=",
                  msg->cookie, msg->cookie_mask);
    ofl_structs_match_print(stream, msg->match, exp);
}
Ejemplo n.º 8
0
void
ofl_structs_port_print(FILE *stream, struct ofl_port *port) {
    fprintf(stream, "{no=\"");
    ofl_port_print(stream, port->port_no);
    fprintf(stream, "\", hw_addr=\""ETH_ADDR_FMT"\", name=\"%s\", "
                          "config=\"0x%"PRIx32"\", state=\"0x%"PRIx32"\", curr=\"0x%"PRIx32"\", "
                          "adv=\"0x%"PRIx32"\", supp=\"0x%"PRIx32"\", peer=\"0x%"PRIx32"\", "
                          "curr_spd=\"%ukbps\", max_spd=\"%ukbps\"}",
                  ETH_ADDR_ARGS(port->hw_addr), port->name,
                  port->config, port->state, port->curr,
                  port->advertised, port->supported, port->peer,
                  port->curr_speed, port->max_speed);
}
Ejemplo n.º 9
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;
}
static void
ofl_msg_print_queue_get_config_reply(struct ofl_msg_queue_get_config_reply *msg, FILE *stream) {
    size_t i;

    fprintf(stream, "{port=\"");
    ofl_port_print(stream, msg->port);
    fprintf(stream, "\" queues=[");

    for (i=0; i<msg->queues_num; i++) {
        ofl_structs_queue_print(stream, msg->queues[i]);
        if (i < msg->queues_num - 1) { fprintf(stream, ", "); }
    }

    fprintf(stream, "]}");
}
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, "]}");
}
Ejemplo n.º 12
0
void
ofl_structs_bucket_print(FILE *stream, struct ofl_bucket *b, struct ofl_exp *exp) {
    size_t i;

    fprintf(stream, "{w=\"%u\", wprt=\"", b->weight);
    ofl_port_print(stream, b->watch_port);
    fprintf(stream, "\", wgrp=\"");
    ofl_group_print(stream, b->watch_group);
    fprintf(stream, "\", acts=[");

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

    fprintf(stream, "]}");
}
Ejemplo n.º 13
0
void
ofl_structs_port_stats_print(FILE *stream, struct ofl_port_stats *s) {

    fprintf(stream, "{port=\"");
    ofl_port_print(stream, s->port_no);
    fprintf(stream, "\", rx_pkt=\"%"PRIu64"\", tx_pkt=\"%"PRIu64"\", "
                          "rx_bytes=\"%"PRIu64"\", tx_bytes=\"%"PRIu64"\", "
                          "rx_drops=\"%"PRIu64"\", tx_drops=\"%"PRIu64"\", "
                          "rx_errs=\"%"PRIu64"\", tx_errs=\"%"PRIu64"\", "
                          "rx_frm=\"%"PRIu64"\", rx_over=\"%"PRIu64"\", "
                          "rx_crc=\"%"PRIu64"\", coll=\"%"PRIu64"\"}",
                  s->rx_packets, s->tx_packets,
                  s->rx_bytes, s->tx_bytes,
                  s->rx_dropped, s->tx_dropped,
                  s->rx_errors, s->tx_errors,
                  s->rx_frame_err, s->rx_over_err,
                  s->rx_crc_err, s->collisions);
};
Ejemplo n.º 14
0
char *
ofl_exp_openflow_msg_to_string(struct ofl_msg_experimenter *msg) {
    char *str;
    size_t str_size;
    FILE *stream = open_memstream(&str, &str_size);

    if (msg->experimenter_id == OPENFLOW_VENDOR_ID) {
        struct ofl_exp_openflow_msg_header *exp = (struct ofl_exp_openflow_msg_header *)msg;
        switch (exp->type) {
            case (OFP_EXT_QUEUE_MODIFY):
            case (OFP_EXT_QUEUE_DELETE): {
                struct ofl_exp_openflow_msg_queue *q = (struct ofl_exp_openflow_msg_queue *)exp;
                fprintf(stream, "%squeue{port=\"", exp->type == OFP_EXT_QUEUE_MODIFY ? "mod" : "del");
                ofl_port_print(stream, q->port_id);
                fprintf(stream, "\", queue=");
                ofl_structs_queue_print(stream, q->queue);
                fprintf(stream, "}");
                break;
            }
            case (OFP_EXT_SET_DESC): {
                struct ofl_exp_openflow_msg_set_dp_desc *s = (struct ofl_exp_openflow_msg_set_dp_desc *)exp;
                fprintf(stream, "setdesc{desc=\"%s\"}", s->dp_desc);
                break;
            }
            default: {
                OFL_LOG_WARN(LOG_MODULE, "Trying to print unknown Openflow Experimenter message.");
                fprintf(stream, "ofexp{type=\"%u\"}", exp->type);
            }
        }
    } else {
        OFL_LOG_WARN(LOG_MODULE, "Trying to print non-Openflow Experimenter message.");
        fprintf(stream, "exp{exp_id=\"%u\"}", msg->experimenter_id);
    }

    fclose(stream);
    return str;
}
Ejemplo n.º 15
0
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;
        }
    }
}
static void
ofl_msg_print_queue_get_config_request(struct ofl_msg_queue_get_config_request *msg, FILE *stream) {
    fprintf(stream, "{port=\"");
    ofl_port_print(stream, msg->port);
    fprintf(stream, "\"}");
}
Ejemplo n.º 17
0
static void
ofl_msg_print_stats_request_port(struct ofl_msg_stats_request_port *msg, FILE *stream) {
    fprintf(stream, ", port=\"");
    ofl_port_print(stream, msg->port_no);
    fprintf(stream, "\"");
}