Procházet zdrojové kódy

add settings white list

balbekova před 7 roky
rodič
revize
02d47941e6

+ 5 - 0
Makefile

@@ -51,5 +51,10 @@ fullflash_6706:
 	st-flash --reset write output/iap.bin 0x8000000
 	sleep 1
 	st-flash --reset write output/stm32bt6706.bin 0x8020000	
+	
+fullflash_6708:
+	st-flash --reset write output/iap.bin 0x8000000
+	sleep 1
+	st-flash --reset write output/stm32bt6708.bin 0x8020000	
 
 

+ 24 - 0
modules/HTTP_Server/http_server.c

@@ -10,7 +10,11 @@
 #include "parameters.h"
 #include "urlcode.h"
 #include "trap_params.h"
+#ifdef HARDWARE_BT6706
 #include "bt6706_fs/fsdata.c"
+#elif HARDWARE_BT6708
+#include "bt6708_fs/fsdata.c"
+#endif
 #include "settings_api.h"
 #include "netconf.h"
 #include "common_config.h"
@@ -778,6 +782,26 @@ void HTTP_SetSettings(char *buf, uint16_t lenBuf)
   SetManagerIp5(value);
   memset(value, 0, len);
 
+#ifdef HARDWARE_BT6708
+  /* White list */
+  const char *white_list_set[] =
+  {
+		  "wtl_ip1=",
+		  "wtl_ip2=",
+		  "wtl_ip3=",
+		  "wtl_ip4=",
+		  "wtl_ip5=",
+  };
+  for(uint8_t i = 0; i < MAX_WHITE_LIST; i++){
+	  GetParamValue(buf, white_list_set[i], value, &valueLen);
+	  memset(str, 0, len);
+	  url_decode(str, sizeof(str), value);
+	  SetWhiteListSTR(str, i);
+	  memset(value, 0, len);
+  }
+
+#endif
+
   /* Сетевые параметры */
   GetParamValue(buf, "dhcp=", value, &valueLen);
   SetDhcpStateStr(value);

+ 19 - 1
modules/HTTP_Server/web_params_api.c

@@ -241,9 +241,27 @@ void HTTP_GetSettings(char *buf)
   strncat(buf, str, len);
 #endif
 
+#ifdef HARDWARE_BT6708
+  /* White list */
+  const char *white_list_js[] =
+  {
+		  ",\"wtl_ip1\":\"",
+		  "\",\"wtl_ip2\":\"",
+		  "\",\"wtl_ip3\":\"",
+		  "\",\"wtl_ip4\":\"",
+		  "\",\"wtl_ip5\":\"",
+  };
+  for(uint8_t i = 0; i < MAX_WHITE_LIST; i++){
+	  	GetWhiteListSTR(str, &len, i);
+	    strcat(buf, white_list_js[i]);
+	    strncat(buf, str, len);
+  }
+
+#endif
+
   /* Параметры даты и времени */
   GetDateStr(str, &len);
-  strcat(buf, ",\"date\":\"");
+  strcat(buf, "\",\"date\":\"");
   strncat(buf, str, len);
 
   GetTimeStr(str, &len);

+ 1 - 1
modules/Makefile

@@ -178,7 +178,7 @@ ifeq ($(HARDWARE), bt6706)
 endif
 
 ifeq ($(HARDWARE), bt6708)
-	WUI_DIR = ../web_interface/dist/wui-6
+	WUI_DIR = ../web_interface/dist/wui-8
 	FSDATA_DIR = ./HTTP_Server/bt6708_fs
 endif
 

+ 29 - 0
modules/parameters.c

@@ -734,6 +734,21 @@ void GetDhcpStateStrRu(char *str, uint8_t *len)
 	  *len = strlen(str);
 }
 
+#ifdef HARDWARE_BT6708
+// ************************************************************************** //
+//                             Параметры довверительных хостов
+
+/**
+  * @brief  диапазон доверительных хостов
+  */
+void GetWhiteListSTR(char *str, uint8_t *len, uint8_t num)
+{
+	strcpy(str, sSettings.sWhiteList[num].ip_range);
+  *len = strlen(str);
+}
+
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 
@@ -995,6 +1010,20 @@ void SetUDPDhcpStateStr(char *str)
     sSettings.sWebTempParams.dhcpEnable = 0;
 }
 
+#ifdef HARDWARE_BT6708
+// ************************************************************************** //
+//                             Параметры довверительных хостов
+
+/**
+  * @brief  диапазон доверительных хостов
+  */
+void SetWhiteListSTR(char *str, uint8_t num)
+{
+	strcpy(sSettings.sWhiteList[num].ip_range, str);
+}
+
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 

+ 22 - 0
modules/parameters.h

@@ -227,6 +227,17 @@ void GetDhcpStateUDP(char *str, uint8_t *len);
   */
 void GetDhcpStateStrRu(char *str, uint8_t *len);
 
+#ifdef HARDWARE_BT6708
+// ************************************************************************** //
+//                             Параметры довверительных хостов
+
+/**
+  * @brief  диапазон доверительных хостов
+  */
+void GetWhiteListSTR(char *str, uint8_t *len, uint8_t num);
+
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 /**
@@ -417,6 +428,17 @@ void SetDhcpStateStr(char *str);
   */
 void SetUDPDhcpStateStr(char *str);
 
+#ifdef HARDWARE_BT6708
+// ************************************************************************** //
+//                             Параметры довверительных хостов
+
+/**
+  * @brief  диапазон доверительных хостов
+  */
+void SetWhiteListSTR(char *str, uint8_t num);
+
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 

+ 24 - 0
modules/settings_api.c

@@ -240,6 +240,17 @@ void SETTINGS_SetTelnetDef(void){
 
 #endif
 
+#if defined HARDWARE_BT6708
+/**
+  * @brief  Установить параметры списка доверительных хостов
+  */
+void SETTINGS_SetWhiteListDef(void){
+	for(uint8_t i = 0; i < MAX_WHITE_LIST; i++)
+		strcpy(sSettings.sWhiteList[i].ip_range, "");
+}
+
+#endif
+
 /**
   * @brief  Сброс настроек в значения по умолчанию
   */
@@ -258,6 +269,9 @@ void SETTINGS_SetDefault(void)
 #if defined HARDWARE_BT6706 || HARDWARE_BT6708
   SETTINGS_SetTelnetDef();
 #endif
+#if defined HARDWARE_BT6708
+  SETTINGS_SetWhiteListDef();
+#endif
 
   sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
 }
@@ -274,6 +288,9 @@ void SETTINGS_SetPartDefault(void)
   SETTINGS_SetSntpDef();
   SETTINGS_SetINOUTSDef();
  // SETTINGS_SetRADIUSDef();
+#if defined HARDWARE_BT6708
+  SETTINGS_SetWhiteListDef();
+#endif
   
   sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
 
@@ -301,6 +318,10 @@ void SETTINGS_SetAllDefault(void)
 #if defined HARDWARE_BT6706 || HARDWARE_BT6708
   SETTINGS_SetTelnetDef();
 #endif
+
+#ifdef HARDWARE_BT6708
+  SETTINGS_SetWhiteListDef();
+#endif
   
   sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
 
@@ -328,6 +349,9 @@ void SETTINGS_SetDefaultDebug(void)
 #if defined HARDWARE_BT6706 || HARDWARE_BT6708
   SETTINGS_SetTelnetDef();
 #endif
+#if defined HARDWARE_BT6708
+  SETTINGS_SetWhiteListDef();
+#endif
   
   sSettings.CritSecCRC = SETTINGS_GetCritSecCRC();
 

+ 20 - 0
modules/settings_api.h

@@ -32,6 +32,8 @@
  * Others are USER */
 #define MAX_WEB_USERS                 2
 
+#define MAX_WHITE_LIST                5
+
 /**
 * @brief  Параметры обновления ПО
   */
@@ -54,6 +56,14 @@ typedef struct
 	
 } WEB_PARAMS_t;
 
+/**
+  * @brief  Параметры сетевого подключения
+  */
+typedef struct
+{
+  char    ip_range[19];
+} WHITE_LIST_t;
+
 /**
   * @brief  Параметры SNMP
   */
@@ -215,6 +225,9 @@ typedef struct
 #endif
 #if defined HARDWARE_BT6706 || HARDWARE_BT6708
   TELNET_t		sTelnet;
+#endif
+#ifdef HARDWARE_BT6708
+  WHITE_LIST_t sWhiteList[MAX_WHITE_LIST];
 #endif
   uint32_t      controlWorld;  // Слово для контроля целостности структуры настроек
   
@@ -284,6 +297,13 @@ void SETTINGS_SetSSLcrtDef(void);
 void SETTINGS_SetTelnetDef(void);
 #endif
 
+#if defined HARDWARE_BT6708
+/**
+  * @brief  Установить параметры списка доверительных хостов
+  */
+void SETTINGS_SetWhiteListDef(void);
+#endif
+
 /**
   * @brief  Установить значение сервисных настроек по умолчанию
   */