18bool isCommandAsDeviceName(
char* name)
21 for (i = 0; i < NETWORK->nDeviceCount; i++)
23 if (!_stricmp(name, NETWORK->ppstruDeviceList[i]->szDeviceName))
29bool validate_command(ptrCLIENTINFO info, ptrCOMMANDARRAY command)
32 if (!info->promptString)
34 if (isCommandAsDeviceName(command->commands[0]))
37 if (!_stricmp(command->commands[index],
"route"))
38 return validate_route_command(info, command, index);
40 if (!_stricmp(command->commands[index],
"acl"))
41 return validate_acl_command(info, command, index);
43 if (!_stricmp(command->commands[index], CMD_ACLCONFIG))
46 if (!_stricmp(command->commands[index],
"ping"))
47 return validate_ping_command(info, command, index);
51 if (strstr(info->promptString, CMD_ACLCONFIG))
52 return validate_aclconfig_command(info, command, index);
55 send_message(info,
"%s command is not a valid command.\n",
56 command->commands[index]);
60void execute_command(ptrCLIENTINFO info, ptrCOMMANDARRAY command, NETSIM_ID d)
63 if (info->promptString)
65 if (strstr(info->promptString, CMD_ACLCONFIG))
66 execute_prompt_aclconfig_command(info, command, index, d);
70 if (isCommandAsDeviceName(command->commands[0]))
72 d = fn_NetSim_Stack_GetDeviceId_asName(command->commands[0]);
76 if (!_stricmp(command->commands[index],
"route"))
77 execute_route_command(info, command, index, d);
78 else if (!_stricmp(command->commands[index],
"ACL"))
79 execute_acl_command(info, command, index, d);
80 else if (!_stricmp(command->commands[index],
"ACLCONFIG"))
81 execute_aclconfig_command(info, command, index, d);
82 else if (!_stricmp(command->commands[index],
"ping"))
83 execute_ping_command(info, command, index, d);
88void pass_to_SDNModule(ptrCLIENTINFO info, ptrCOMMANDARRAY command)
90 NetSim_EVENTDETAILS pevent;
91 memset(&pevent, 0,
sizeof pevent);
92 pevent.dEventTime = ldEventTime+MILLISECOND;
93 pevent.nDeviceId = info->deviceId;
94 pevent.nDeviceType = DEVICE_TYPE(info->deviceId);
95 pevent.nEventType = TIMER_EVENT;
96 pevent.nProtocolId = APP_PROTOCOL_OPENFLOW;
97 pevent.szOtherDetails = FORM_CLI_HANDLE(command, info);
99 if (info->clientType == CLIENTTYPE_SOCKET)
101 info->CLIENT.sockClient.iswait =
true;
102 WaitOnAddress(&info->CLIENT.sockClient.iswait,
103 &info->CLIENT.sockClient.dontUseMe,
104 sizeof info->CLIENT.sockClient.iswait,