|
@@ -115,6 +115,7 @@ const char *notification_args_list[] = {
|
|
|
const char *whitelist_args_list[] = {
|
|
|
"info",
|
|
|
"range",
|
|
|
+ "reset",
|
|
|
};
|
|
|
|
|
|
const char *ntp_args_list[] = {
|
|
@@ -376,7 +377,8 @@ generates a table that shows how much run time each task has */
|
|
|
static const CLI_Command_Definition_t prvWhiteListCommandDefinition = {
|
|
|
( const int8_t *const ) "whitelist", /* The command string to type. */
|
|
|
( const int8_t *const ) "\twhitelist info: вывод информации о текущем белом списке IP адресов контроллера\r\n"
|
|
|
- "\twhitelist range <NUM> <A.B.C.D/E>: установка диапазона IP адресов\r\n",
|
|
|
+ "\twhitelist range <NUM> <A.B.C.D/E>: установка диапазона IP адресов\r\n"
|
|
|
+ "\twhitelist reset <NUM>: сброс диапазона IP адресов\r\n",
|
|
|
prvTaskWhiteListCommand, /* The function to run. */
|
|
|
-1 /* The user can enter any number of commands. */
|
|
|
};
|
|
@@ -1917,6 +1919,7 @@ static portBASE_TYPE prvTaskWhiteListCommand( int8_t *pcWriteBuffer, size_t xWri
|
|
|
uint8_t i;
|
|
|
char *beginValue;
|
|
|
uint8_t len;
|
|
|
+ int32_t temp;
|
|
|
|
|
|
( void ) pcCommandString;
|
|
|
( void ) xWriteBufferLen;
|
|
@@ -1971,7 +1974,7 @@ static portBASE_TYPE prvTaskWhiteListCommand( int8_t *pcWriteBuffer, size_t xWri
|
|
|
switch (i) {
|
|
|
case ARG_WHITELIST_RANGE:
|
|
|
if (xParameterStringLength == 1 && isdigit_int(str[0])) {
|
|
|
- int32_t temp = atoi(str);
|
|
|
+ temp = atoi(str);
|
|
|
if (temp > 0 && temp < 6) {
|
|
|
pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter
|
|
|
(
|
|
@@ -1992,6 +1995,7 @@ static portBASE_TYPE prvTaskWhiteListCommand( int8_t *pcWriteBuffer, size_t xWri
|
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
return pdFALSE;
|
|
|
}
|
|
|
+ int32_t mask = atoi(&beginValue[1]);
|
|
|
len = beginValue - str;
|
|
|
memset(temp_str, 0, sizeof(temp_str));
|
|
|
strncpy(temp_str, str, len);
|
|
@@ -2001,7 +2005,7 @@ static portBASE_TYPE prvTaskWhiteListCommand( int8_t *pcWriteBuffer, size_t xWri
|
|
|
return pdFALSE;
|
|
|
}
|
|
|
}
|
|
|
- if (ipaddr_addr(temp_str) != IPADDR_NONE) {
|
|
|
+ if (ipaddr_addr(temp_str) != IPADDR_NONE && (mask <= 32 && mask >= 0)) {
|
|
|
SetWhiteListSTR(str, (temp - 1));
|
|
|
strcpy( ( char * ) pcWriteBuffer,
|
|
|
"\t\tСохраните конфигурацию сетевых настроек\r\n" );
|
|
@@ -2021,6 +2025,21 @@ static portBASE_TYPE prvTaskWhiteListCommand( int8_t *pcWriteBuffer, size_t xWri
|
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
}
|
|
|
break;
|
|
|
+ case ARG_WHITELIST_RESET:
|
|
|
+ if (xParameterStringLength == 1 && isdigit_int(str[0])) {
|
|
|
+ temp = atoi(str);
|
|
|
+ if (temp > 0 && temp < 6) {
|
|
|
+ memset(str, 0, sizeof(str));
|
|
|
+ SetWhiteListSTR(str, (temp - 1));
|
|
|
+ strcpy( ( char * ) pcWriteBuffer,
|
|
|
+ "\t\tСохраните конфигурацию сетевых настроек\r\n" );
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
break;
|