コード例 #1
0
ファイル: ofl_messages_print.c プロジェクト: TrafficLab/ofss
int
ofl_msg_print(FILE *stream, struct ofl_msg_header *msg, struct ofl_exp *exp, char *errbuf) {
    ofl_message_type_print(stream, msg->type);

    switch (msg->type) {
        case OFPT_HELLO: { return 0; }
        case OFPT_ERROR: { ofl_msg_print_error((struct ofl_msg_error *)msg, stream); return 0; }
        case OFPT_ECHO_REQUEST:
        case OFPT_ECHO_REPLY: { ofl_msg_print_echo((struct ofl_msg_echo *)msg, stream); return 0; }
        case OFPT_EXPERIMENTER: {
            if (exp == NULL || exp->msg == NULL || exp->msg->to_string == NULL) {
                ofl_msg_print_experimenter((struct ofl_msg_experimenter *)msg, stream);
                //TODO error?
                return 0;
            } else {
                //TODO ret value ?
                char *c = exp->msg->to_string((struct ofl_msg_experimenter *)msg);
                fprintf(stream, "%s", c);
                free(c);
                return 0;
            }
        }

        /* Switch configuration messages. */
        case OFPT_FEATURES_REQUEST: { return 0; }
        case OFPT_FEATURES_REPLY: { ofl_msg_print_features_reply((struct ofl_msg_features_reply *)msg, stream); return 0; }
        case OFPT_GET_CONFIG_REQUEST: { return 0; }
        case OFPT_GET_CONFIG_REPLY: { ofl_msg_print_get_config_reply((struct ofl_msg_get_config_reply *)msg, stream); return 0; }
        case OFPT_SET_CONFIG: { ofl_msg_print_set_config((struct ofl_msg_set_config *)msg, stream); return 0; }

        /* Asynchronous messages. */
        case OFPT_PACKET_IN: { ofl_msg_print_packet_in((struct ofl_msg_packet_in *)msg, stream); return 0; }
        case OFPT_FLOW_REMOVED: { ofl_msg_print_flow_removed((struct ofl_msg_flow_removed *)msg, stream, exp); return 0; }
        case OFPT_PORT_STATUS: { ofl_msg_print_port_status((struct ofl_msg_port_status *)msg, stream); return 0; }

        /* Controller command messages. */
        case OFPT_PACKET_OUT: { ofl_msg_print_packet_out((struct ofl_msg_packet_out *)msg, stream, exp); return 0; }
        case OFPT_FLOW_MOD: { ofl_msg_print_flow_mod((struct ofl_msg_flow_mod *)msg, stream, exp); return 0; }
        case OFPT_GROUP_MOD: { ofl_msg_print_group_mod((struct ofl_msg_group_mod *)msg, stream, exp); return 0; }
        case OFPT_PORT_MOD: { ofl_msg_print_port_mod((struct ofl_msg_port_mod *)msg, stream); return 0; }
        case OFPT_TABLE_MOD: { ofl_msg_print_table_mod((struct ofl_msg_table_mod *)msg, stream); return 0; }

        /* Statistics messages. */
        case OFPT_STATS_REQUEST: { return ofl_msg_print_stats_request((struct ofl_msg_stats_request_header *)msg, stream, exp, errbuf); }
        case OFPT_STATS_REPLY: { return ofl_msg_print_stats_reply((struct ofl_msg_stats_reply_header *)msg, stream, exp, errbuf); }

        /* Barrier messages. */
        case OFPT_BARRIER_REQUEST: { return 0; }
        case OFPT_BARRIER_REPLY: { return 0; }

        /* Queue Configuration messages. */
        case OFPT_QUEUE_GET_CONFIG_REQUEST: { ofl_msg_print_queue_get_config_request((struct ofl_msg_queue_get_config_request *)msg, stream); return 0; }
        case OFPT_QUEUE_GET_CONFIG_REPLY: { ofl_msg_print_queue_get_config_reply((struct ofl_msg_queue_get_config_reply *)msg, stream); return 0; }
    }
    return -1;
}
コード例 #2
0
void
ofl_msg_print(FILE *stream, struct ofl_msg_header *msg, struct ofl_exp *exp) {
    ofl_message_type_print(stream, msg->type);

    switch (msg->type) {
        case OFPT_HELLO: { return; }
        case OFPT_ERROR: { ofl_msg_print_error((struct ofl_msg_error *)msg, stream); return; }
        case OFPT_ECHO_REQUEST:
        case OFPT_ECHO_REPLY: { ofl_msg_print_echo((struct ofl_msg_echo *)msg, stream); return; }
        case OFPT_EXPERIMENTER: {
            if (exp == NULL || exp->msg == NULL || exp->msg->to_string == NULL) {
                ofl_msg_print_experimenter((struct ofl_msg_experimenter *)msg, stream);
            } else {
                char *c = exp->msg->to_string((struct ofl_msg_experimenter *)msg);
                fprintf(stream, "%s", c);
                free(c);
            }
            return;
        }

        /* Switch configuration messages. */
        case OFPT_FEATURES_REQUEST: { return; }
        case OFPT_FEATURES_REPLY: { ofl_msg_print_features_reply((struct ofl_msg_features_reply *)msg, stream); return; }
        case OFPT_GET_CONFIG_REQUEST: { return; }
        case OFPT_GET_CONFIG_REPLY: { ofl_msg_print_get_config_reply((struct ofl_msg_get_config_reply *)msg, stream); return; }
        case OFPT_SET_CONFIG: { ofl_msg_print_set_config((struct ofl_msg_set_config *)msg, stream); return; }

        /* Asynchronous messages. */
        case OFPT_PACKET_IN: { ofl_msg_print_packet_in((struct ofl_msg_packet_in *)msg, stream); return; }
        case OFPT_FLOW_REMOVED: { ofl_msg_print_flow_removed((struct ofl_msg_flow_removed *)msg, stream, exp); return; }
        case OFPT_PORT_STATUS: { ofl_msg_print_port_status((struct ofl_msg_port_status *)msg, stream); return; }

        /* Controller command messages. */
        case OFPT_PACKET_OUT: { ofl_msg_print_packet_out((struct ofl_msg_packet_out *)msg, stream, exp); return; }
        case OFPT_FLOW_MOD: { ofl_msg_print_flow_mod((struct ofl_msg_flow_mod *)msg, stream, exp); return; }
        case OFPT_GROUP_MOD: { ofl_msg_print_group_mod((struct ofl_msg_group_mod *)msg, stream, exp); return; }
        case OFPT_PORT_MOD: { ofl_msg_print_port_mod((struct ofl_msg_port_mod *)msg, stream); return; }
        case OFPT_TABLE_MOD: { ofl_msg_print_table_mod((struct ofl_msg_table_mod *)msg, stream); return; }

        /* Statistics messages. */
        case OFPT_MULTIPART_REQUEST: { ofl_msg_print_multipart_request((struct ofl_msg_multipart_request_header *)msg, stream, exp); return; }
        case OFPT_MULTIPART_REPLY: { ofl_msg_print_multipart_reply((struct ofl_msg_multipart_reply_header *)msg, stream, exp); return; }

        /* Barrier messages. */
        case OFPT_BARRIER_REQUEST: { return; }
        case OFPT_BARRIER_REPLY: { return; }

        /*Role messages */
        case OFPT_ROLE_REQUEST:
        case OFPT_ROLE_REPLY:{
            ofl_msg_print_role_msg((struct ofl_msg_role_request*)msg, stream);        
        }
        /* Queue Configuration messages. */
        case OFPT_QUEUE_GET_CONFIG_REQUEST: { ofl_msg_print_queue_get_config_request((struct ofl_msg_queue_get_config_request *)msg, stream); return; }
        case OFPT_QUEUE_GET_CONFIG_REPLY: { ofl_msg_print_queue_get_config_reply((struct ofl_msg_queue_get_config_reply *)msg, stream); return; }
		
		/* Asynchronous message configuration. */
		case OFPT_GET_ASYNC_REQUEST:{return;}
        case OFPT_GET_ASYNC_REPLY:
        case OFPT_SET_ASYNC:{ofl_msg_print_async((struct ofl_msg_async_config*)msg, stream); return;}		
		
		case OFPT_METER_MOD: {ofl_msg_print_meter_mod((struct ofl_msg_meter_mod*)msg, stream); return;}
			    	
        /* Bundle messages. */
        case OFPT_BUNDLE_CONTROL: { ofl_msg_print_bundle_control((struct ofl_msg_bundle_control *)msg, stream); return; }
        case OFPT_BUNDLE_ADD_MESSAGE: { ofl_msg_print_bundle_add_msg((struct ofl_msg_bundle_add_msg *)msg, stream); return; }
    }
}