|
@@ -557,6 +557,40 @@ static const CLI_Command_Definition_t prvSysLogCommandDefinition = {
|
|
|
};
|
|
|
#endif
|
|
|
|
|
|
+#ifdef RADIUS_SERVER_ENABLE
|
|
|
+
|
|
|
+const char *radius_args_list[] = {
|
|
|
+ "info",
|
|
|
+ "ENA",
|
|
|
+ "DIS",
|
|
|
+ "server_ip",
|
|
|
+ "server_port",
|
|
|
+ "secret",
|
|
|
+};
|
|
|
+
|
|
|
+typedef enum{
|
|
|
+ ARG_RADIUS_INFO = 0,
|
|
|
+ ARG_RADIUS_ENABLE,
|
|
|
+ ARG_RADIUS_DISABLE,
|
|
|
+ ARG_RADIUS_IP,
|
|
|
+ ARG_RADIUS_PORT,
|
|
|
+ ARG_RADIUS_SECRET,
|
|
|
+ ARG_RADIUS_ALL
|
|
|
+}radius_args_t;
|
|
|
+
|
|
|
+static portBASE_TYPE prvTaskRADIUSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );
|
|
|
+static const CLI_Command_Definition_t prvRADIUSCommandDefinition = {
|
|
|
+ (const int8_t *const)"radius", /* The command string to type. */
|
|
|
+ (const int8_t *const)"\tradius info: вывод информации о настройках RADIUS\r\n"
|
|
|
+ "\tradius ENA|DIS: вкл./выкл. авторизации через RADIUS\r\n"
|
|
|
+ "\tradius server_ip <ip address>: установка ip-адреса RADIUS-сервера\r\n"
|
|
|
+ "\tradius server_port <port>: установка порта RADIUS-сервера\r\n"
|
|
|
+ "\tradius secret <secret>: установка пароля RADIUS-сервера\r\n",
|
|
|
+ prvTaskRADIUSCommand, /* The function to run. */
|
|
|
+ -1 /* The user can enter any number of commands. */
|
|
|
+};
|
|
|
+#endif
|
|
|
+
|
|
|
/* Structure that defines the "quit" command line command. This
|
|
|
generates a table that shows how much run time each task has */
|
|
|
static const CLI_Command_Definition_t prvQuitCommandDefinition = {
|
|
@@ -597,6 +631,9 @@ void vRegisterCLICommands( void )
|
|
|
#endif
|
|
|
#ifdef SYSLOG_ENABLE
|
|
|
FreeRTOS_CLIRegisterCommand( &prvSysLogCommandDefinition );
|
|
|
+#endif
|
|
|
+#ifdef RADIUS_SERVER_ENABLE
|
|
|
+ FreeRTOS_CLIRegisterCommand( &prvRADIUSCommandDefinition );
|
|
|
#endif
|
|
|
FreeRTOS_CLIRegisterCommand( &prvQuitCommandDefinition );
|
|
|
}
|
|
@@ -2332,6 +2369,11 @@ static portBASE_TYPE prvTaskConfigCommand(cli_state_t *cli_state, int8_t *pcWrit
|
|
|
case PARAM_CONFIG_SYSLOG:
|
|
|
syslog_config_param(pcWriteBuffer);
|
|
|
break;
|
|
|
+#endif
|
|
|
+#ifdef RADIUS_SERVER_ENABLE
|
|
|
+ case PARAM_CONFIG_RADIUS:
|
|
|
+ radius_config_param(pcWriteBuffer);
|
|
|
+ break;
|
|
|
#endif
|
|
|
case PARAM_CONFIG_AKB:
|
|
|
akb_config_param(pcWriteBuffer);
|
|
@@ -3104,6 +3146,153 @@ static portBASE_TYPE prvTaskSysLogCommand(cli_state_t *cli_state, int8_t *pcWri
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+#ifdef RADIUS_SERVER_ENABLE
|
|
|
+static portBASE_TYPE prvTaskRADIUSCommand(cli_state_t *cli_state, int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
|
|
|
+{
|
|
|
+ int8_t *pcParameterString;
|
|
|
+ signed portBASE_TYPE xParameterStringLength, xReturn;
|
|
|
+ portBASE_TYPE xParameterNumber = 1;
|
|
|
+ char str[110];
|
|
|
+ char str_temp[110];
|
|
|
+ uint8_t len;
|
|
|
+ uint8_t i;
|
|
|
+ bool enable_old_radius;
|
|
|
+
|
|
|
+ ( void ) pcCommandString;
|
|
|
+ ( void ) xWriteBufferLen;
|
|
|
+ configASSERT( pcWriteBuffer );
|
|
|
+
|
|
|
+ memset(pcWriteBuffer, 0, configCOMMAND_INT_MAX_OUTPUT_SIZE);
|
|
|
+ /* Obtain the parameter string. */
|
|
|
+ pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter
|
|
|
+ (
|
|
|
+ pcCommandString, /* The command string itself. */
|
|
|
+ xParameterNumber, /* Return the next parameter. */
|
|
|
+ &xParameterStringLength /* Store the parameter string length. */
|
|
|
+ );
|
|
|
+ if (pcParameterString == NULL) {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ return pdFALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i = 0; i < ARG_RADIUS_ALL; i ++) {
|
|
|
+ if ( strncmp( ( const char * ) pcParameterString, radius_args_list[i], strlen(radius_args_list[i]) ) == 0
|
|
|
+ && xParameterStringLength == strlen(radius_args_list[i])) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cli_state->user_id != ADMIN && i != ARG_RADIUS_INFO) {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcPermissionDenied, strlen( ( char * ) pcPermissionDenied ) );
|
|
|
+ return pdFALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ xParameterNumber ++;
|
|
|
+ /* Obtain the parameter string. */
|
|
|
+ pcParameterString = ( int8_t * ) FreeRTOS_CLIGetParameter
|
|
|
+ (
|
|
|
+ pcCommandString, /* The command string itself. */
|
|
|
+ xParameterNumber, /* Return the next parameter. */
|
|
|
+ &xParameterStringLength /* Store the parameter string length. */
|
|
|
+ );
|
|
|
+ if (pcParameterString == NULL) {
|
|
|
+ switch (i) {
|
|
|
+ case ARG_RADIUS_INFO:
|
|
|
+ /* Return the next command help string, before moving the pointer on to
|
|
|
+ the next command in the list. */
|
|
|
+ radius_config_param(pcWriteBuffer);
|
|
|
+ break;
|
|
|
+ case ARG_RADIUS_ENABLE:
|
|
|
+ enable_old_radius = sSettings.sRADIUS.RDSEnable;
|
|
|
+ SetRDSEnableStateStr("on");
|
|
|
+ if (sSettings.sRADIUS.RDSEnable != enable_old_radius) {
|
|
|
+ cli_save_config(cli_state);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ARG_RADIUS_DISABLE:
|
|
|
+ enable_old_radius = sSettings.sRADIUS.RDSEnable;
|
|
|
+ SetRDSEnableStateStr("off");
|
|
|
+ if (sSettings.sRADIUS.RDSEnable != enable_old_radius) {
|
|
|
+ cli_save_config(cli_state);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ memset(str_temp, 0, sizeof(str_temp));
|
|
|
+ if (xParameterStringLength > (int32_t)sizeof(str_temp)) {
|
|
|
+ xParameterStringLength = sizeof(str_temp) - 1;
|
|
|
+ }
|
|
|
+ strncat(str_temp, ( const char * ) pcParameterString, xParameterStringLength);
|
|
|
+ switch (i) {
|
|
|
+ case ARG_RADIUS_IP:
|
|
|
+ if (xParameterStringLength <= 15) {
|
|
|
+ if (ipaddr_addr(str_temp) != IPADDR_NONE) {
|
|
|
+ GetRDSIpStr(str, &len);
|
|
|
+ if (strncmp(str_temp, str, strlen(str_temp)) != 0) {
|
|
|
+ SetRDSIpStr(str_temp);
|
|
|
+ cli_save_config(cli_state);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ARG_RADIUS_PORT:
|
|
|
+ if (xParameterStringLength <= 5) {
|
|
|
+ for (uint8_t j = 0; j < xParameterStringLength; j++) {
|
|
|
+ if (!isdigit_int(str_temp[j])) {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ return pdFALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int temp = atoi(str_temp);
|
|
|
+ if (temp > 0 && temp < 65535) {
|
|
|
+ GetRDSPortStr(str, &len);
|
|
|
+ if (strncmp(str_temp, str, strlen(str_temp)) != 0) {
|
|
|
+ SetRDSPortStr(str_temp);
|
|
|
+ cli_save_config(cli_state);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ARG_RADIUS_SECRET:
|
|
|
+ if (xParameterStringLength <= 17) {
|
|
|
+ for (uint8_t j = 0; j < xParameterStringLength; j++) {
|
|
|
+ if ( str_temp[j] < 33 || str_temp[j] > 127 ) {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ return pdFALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GetRDSPasswordkStr(str, &len);
|
|
|
+ if (strncmp(str_temp, str, strlen(str_temp)) != 0) {
|
|
|
+ SetRDSPasswordkStr(str_temp);
|
|
|
+ cli_save_config(cli_state);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ strncpy( ( char * ) pcWriteBuffer, ( const char * ) pcInvalidCommand, strlen( ( char * ) pcInvalidCommand ) );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ xReturn = pdFALSE;
|
|
|
+
|
|
|
+ return xReturn;
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
#ifdef FTP_ENABLE
|
|
|
#pragma GCC diagnostic error "-Wall"
|
|
|
#pragma GCC diagnostic error "-Wextra"
|