Browse Source

开启dhcp

guohui 2 years ago
parent
commit
b9770bdc22
2 changed files with 11 additions and 3 deletions
  1. 1 1
      pro/src/appweb_handle.c
  2. 10 2
      pro/src/sys.c

+ 1 - 1
pro/src/appweb_handle.c

@@ -3665,7 +3665,7 @@ static void communicationManagement(void *conn)
         int ipv=(strstr(reqInfo.type, "WkIPV4Save")?IP_V4:IP_V6);
         int ipv=(strstr(reqInfo.type, "WkIPV4Save")?IP_V4:IP_V6);
         
         
         int mode = atoi(info2->mode);
         int mode = atoi(info2->mode);
-        if(mode==IP_STATIC) {
+        if(ipv==IP_V4 || (ipv==IP_V6 && mode==IP_DHCP)) {
             info->mode = mode;
             info->mode = mode;
             
             
             if(info2->ipaddr)   strcpy(info->ip_address, info2->ipaddr);
             if(info2->ipaddr)   strcpy(info->ip_address, info2->ipaddr);

+ 10 - 2
pro/src/sys.c

@@ -103,6 +103,12 @@ static int exe_cmd(char *cmd, node_t *nd)
     
     
 	return 0;
 	return 0;
 }
 }
+static void nic_restart(char *nic)
+{
+    char tmp[100];
+    sprintf(tmp, "ifdown %s;ifup %s;", nic, nic);
+    system(tmp);
+}
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 int sys_reboot(void)
 int sys_reboot(void)
@@ -829,8 +835,9 @@ int sys_set_net(NetworkInfo_t *para, int ipVersion)
             //system("ip addr flush dev eth0");
             //system("ip addr flush dev eth0");
             //sprintf(eth0, "ip link set dev eth0 %s/%d && ip link set eth0 up && ip link set eth0 down", info->ip_address, info->netmask);
             //sprintf(eth0, "ip link set dev eth0 %s/%d && ip link set eth0 up && ip link set eth0 down", info->ip_address, info->netmask);
             //system(eth0);
             //system(eth0);
-            system("ifdown eth0; ifup eth0");
-            exit(0);
+
+            sys_reboot();
+            //nic_restart(DFLT_NIC); exit(0);
         }
         }
     }
     }
     else {
     else {
@@ -1207,6 +1214,7 @@ int sys_init(void)
     lock_s_init();
     lock_s_init();
     paras_init();
     paras_init();
     
     
+    nic_restart(DFLT_NIC);
     thread_start(THREAD_ID_POLLING, NULL);
     thread_start(THREAD_ID_POLLING, NULL);
 
 
     return 0;
     return 0;