Пример #1
0
static void usr_cmd_clear_resource() {
    POF_COMMAND_PRINT_HEAD("clear_resource");
    POF_LOG_LOCK_OFF;
    poflr_clear_resource();
    POF_LOG_LOCK_ON;
    return;
}
Пример #2
0
static void
usr_cmd_enable_color()
{
	POF_COMMAND_PRINT_HEAD("enable_color");
	poflp_color_enable();
    strncpy(g_states.debug_color_on.cont, "ON", POF_STRING_PAIR_MAX_LEN-1);
}
Пример #3
0
static void
usr_cmd_disable_debug()
{
	POF_COMMAND_PRINT_HEAD("disable_debug");
	poflp_debug_disable();
    strncpy(g_states.debug_on.cont, "OFF", POF_STRING_PAIR_MAX_LEN-1);
}
Пример #4
0
void pof_runing_command(char *cmd, size_t cmd_len) {
    uint8_t usr_cmd_type;
    while(1) {
        POF_COMMAND_PRINT_NO_LOGFILE(1,BLUE,"pof_command >>");

        usr_cmd_type = usr_cmd_gets(cmd, cmd_len);
        if(usr_cmd_type == POFUC_quit) {
            return;
        }

        switch(usr_cmd_type) {
#define COMMAND(STRING) \
			case POFUC_##STRING:	\
				POF_LOG_LOCK_ON;	\
				usr_cmd_##STRING(); \
				POF_LOG_LOCK_OFF;	\
				break;

            COMMANDS
#undef COMMAND
        default:
            if(cmd[0] == 0) {
                break;
            }
            POF_COMMAND_PRINT_HEAD("wrong command: %u", usr_cmd_type);
            POF_COMMAND_PRINT(1,RED,"Input 'help' to find commands!\n");
            break;
        }
    }
}
Пример #5
0
static void usr_cmd_help() {
    int i;
    POF_COMMAND_PRINT_HEAD("help");
#define COMMAND(STRING) POF_COMMAND_PRINT(1,PINK,#STRING"\n");
    COMMANDS
#undef COMMAND
    return;
}
Пример #6
0
static void
usr_cmd_disable_promisc()
{
    dp.filter = dp.no_promisc;
	POF_COMMAND_PRINT_HEAD("Disable PROMISC.");
    strncpy(g_states.promisc_on.cont, "OFF", POF_STRING_PAIR_MAX_LEN-1);
	return;
}
Пример #7
0
static void usr_cmd_switch_config() {
    pof_switch_config *pofsc_ptr = NULL;
    poflr_get_switch_config(&pofsc_ptr);

    POF_COMMAND_PRINT_HEAD("switch_config");

    POF_COMMAND_PRINT(1,CYAN,"flags=");
    POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",pofsc_ptr->flags);
    POF_COMMAND_PRINT(1,CYAN,"miss_send_len=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",pofsc_ptr->miss_send_len);
    POF_COMMAND_PRINT(1,WHITE,"\n");
    return;
}
Пример #8
0
static void flow_table() {
    poflr_flow_table *p = NULL;
    uint8_t *table_num = NULL;
    int type, table_id, entry_id;

    POF_COMMAND_PRINT_HEAD("tables");
    poflr_get_table_number(&table_num);

    for(type=0; type<POF_MAX_TABLE_TYPE; type++) {
        for(table_id=0; table_id<table_num[type]; table_id++) {
            poflr_get_flow_table(&p, type, table_id);
            if(p->state == POFLR_STATE_INVALID) {
                continue;
            }
            flow_table_single(*p);
        }
    }
}
Пример #9
0
static void usr_cmd_ports() {
    pof_port *p = NULL;
    uint16_t port_num = 0;
    int i;

    POF_COMMAND_PRINT_HEAD("ports");
    poflr_get_port(&p);
    poflr_get_port_number(&port_num);

    for(i=0; i<port_num; i++) {
        POF_COMMAND_PRINT(1,PINK,"[Port %d] ", i);

        POF_COMMAND_PRINT(1,CYAN,"port_id=");
        POF_COMMAND_PRINT(1,WHITE,"%u ",p->port_id);
        POF_COMMAND_PRINT(1,CYAN,"device_id=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.4x ",p->device_id);
        POF_COMMAND_PRINT(1,CYAN,"hw_addr=");
        POF_COMMAND_PRINT_0X_NO_ENTER(p->hw_addr, POF_ETH_ALEN);
        POF_COMMAND_PRINT(1,CYAN,"name=");
        POF_COMMAND_PRINT(1,WHITE,"%s ",p->name);
        POF_COMMAND_PRINT(1,CYAN,"config=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->config);
        POF_COMMAND_PRINT(1,CYAN,"state=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->state);
        POF_COMMAND_PRINT(1,CYAN,"curr=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->curr);
        POF_COMMAND_PRINT(1,CYAN,"advertised=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->advertised);
        POF_COMMAND_PRINT(1,CYAN,"supported=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->supported);
        POF_COMMAND_PRINT(1,CYAN,"peer=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->peer);
        POF_COMMAND_PRINT(1,CYAN,"curr_speed=");
        POF_COMMAND_PRINT(1,WHITE,"%u ",p->curr_speed);
        POF_COMMAND_PRINT(1,CYAN,"max_speed=");
        POF_COMMAND_PRINT(1,WHITE,"%u ",p->max_speed);
        POF_COMMAND_PRINT(1,CYAN,"of_enable=");
        POF_COMMAND_PRINT(1,WHITE,"0x%.2x ",p->of_enable);
        p++;
        POF_COMMAND_PRINT(1,WHITE,"\n");
    }
    return;
}
Пример #10
0
static void usr_cmd_switch_feature() {
    pof_switch_features *p = NULL;
    poflr_get_switch_feature(&p);
    POF_COMMAND_PRINT_HEAD("switch_feature");

    POF_COMMAND_PRINT(1,CYAN,"dev_id=");
    POF_COMMAND_PRINT(1,WHITE,"0x%.4x ",p->dev_id);
    POF_COMMAND_PRINT(1,CYAN,"port_num=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->port_num);
    POF_COMMAND_PRINT(1,CYAN,"table_num=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->table_num);
    POF_COMMAND_PRINT(1,CYAN,"capabilities=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->capabilities);
    POF_COMMAND_PRINT(1,CYAN,"vendor_id=");
    POF_COMMAND_PRINT(1,WHITE,"%s ",p->vendor_id);
    POF_COMMAND_PRINT(1,CYAN,"dev_fw_id=");
    POF_COMMAND_PRINT(1,WHITE,"%s ",p->dev_fw_id);
    POF_COMMAND_PRINT(1,CYAN,"dev_lkup_id=");
    POF_COMMAND_PRINT(1,WHITE,"%s ",p->dev_lkup_id);
    POF_COMMAND_PRINT(1,WHITE,"\n");
    return;
}
Пример #11
0
static void usr_cmd_table_resource() {
    pof_flow_table_resource *p = NULL;
    int i;
    poflr_get_flow_table_resource(&p);
    POF_COMMAND_PRINT_HEAD("table_resource");

    POF_COMMAND_PRINT(1,CYAN,"resourceType=");
    POF_COMMAND_PRINT(1,WHITE,"%.2x ",p->resourceType);
    POF_COMMAND_PRINT(1,CYAN,"counter_num=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->counter_num);
    POF_COMMAND_PRINT(1,CYAN,"meter_num=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->meter_num);
    POF_COMMAND_PRINT(1,CYAN,"group_num=");
    POF_COMMAND_PRINT(1,WHITE,"%u ",p->group_num);
    POF_COMMAND_PRINT(1,WHITE,"\n");

    for(i=0; i<POF_MAX_TABLE_TYPE; i++) {
        POF_COMMAND_PRINT(1,PINK,"[pof_table_resource_desc %d] ",i);
        table_resource_desc(&p->tbl_rsc_desc[i]);
        POF_COMMAND_PRINT(1,WHITE,"\n");
    }
    return;
}
Пример #12
0
static void usr_cmd_groups() {
    pof_flow_table_resource *flow_table_resource_ptr = NULL;
    poflr_groups *group_ptr = NULL;
    uint32_t i, j, count, num;
    pof_group *p = NULL;

    poflr_get_group(&group_ptr);
    poflr_get_flow_table_resource(&flow_table_resource_ptr);
    num = group_ptr->group_num;

    POF_COMMAND_PRINT_HEAD("groups");
    for(i=0, count=0; i<flow_table_resource_ptr->group_num || count<num; i++) {
        if(group_ptr->state[i] == POFLR_STATE_INVALID) {
            continue;
        }
        p = &group_ptr->group[i];
        POF_COMMAND_PRINT(1,CYAN,"type=");
        POF_COMMAND_PRINT(1,WHITE,"%u ", p->type);
        POF_COMMAND_PRINT(1,CYAN,"action_number=");
        POF_COMMAND_PRINT(1,WHITE,"%u ", p->action_number);
        POF_COMMAND_PRINT(1,CYAN,"group_id=");
        POF_COMMAND_PRINT(1,WHITE,"%u ", p->group_id);
        POF_COMMAND_PRINT(1,CYAN,"counter_id=");
        POF_COMMAND_PRINT(1,WHITE,"%u ", p->counter_id);

        void (*tmp)(char *,char *,char *) = g_log._pDbg;
        poflp_debug_enable();

        for(j=0; j<p->action_number; j++) {
            poflp_action(&p->action[j]);
        }
        g_log._pDbg = tmp;

        POF_COMMAND_PRINT(1,CYAN,"\n");
        count++;
    }
}
Пример #13
0
static void usr_cmd_counters() {
    pof_flow_table_resource *flow_table_resource_ptr = NULL;
    poflr_counters *counter_ptr = NULL;
    uint32_t i, j, count, num;
    pof_counter *p = NULL;

    poflr_get_counter(&counter_ptr);
    poflr_get_flow_table_resource(&flow_table_resource_ptr);
    num = counter_ptr->counter_num;

    POF_COMMAND_PRINT_HEAD("counter");
    for(i=0, count=0; i<flow_table_resource_ptr->counter_num || count<num; i++) {
        if(counter_ptr->state[i] == POFLR_STATE_INVALID) {
            continue;
        }
        p = &counter_ptr->counter[i];
        POF_COMMAND_PRINT(1,CYAN,"counter_id=");
        POF_COMMAND_PRINT(1,WHITE,"%u ", p->counter_id);
        POF_COMMAND_PRINT(1,CYAN,"value=");
        POF_COMMAND_PRINT(1,WHITE,"%llu ", p->value);
        POF_COMMAND_PRINT(1,CYAN,"\n");
        count++;
    }
}
Пример #14
0
static void
usr_cmd_quit()
{
    POF_COMMAND_PRINT_HEAD("quit");
    return;
}
Пример #15
0
static void
usr_cmd_state()
{
	POF_COMMAND_PRINT_HEAD("state");
    pof_states_print();
}
Пример #16
0
static void usr_cmd_version() {
    POF_COMMAND_PRINT_HEAD("version");
    POF_COMMAND_PRINT(1,PINK,"%s\n", POFSWITCH_VERSION);
    return;
}
Пример #17
0
void usr_cmd_tables(){
	POF_COMMAND_PRINT_HEAD("tables");
    flow_table();
}
Пример #18
0
static void
usr_cmd_test()
{
	POF_COMMAND_PRINT_HEAD("test");
	return;
}