| 
					
				 | 
			
			
				@@ -589,10 +589,10 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p, err_t er 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 //DBG printf("State: Received %d bytes\r\n", (int)TotalReceived);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 //ВBG printf("receive %s /r/n", sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 HTTP_SetSettings(sendBuf, strlen(&sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 HTTP_SetSettings(sendBuf, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 DataFlag2=0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 BrowserFlag = 0;
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -618,7 +618,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p, err_t er 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   if(receivedBufLen)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 //memcpy(receiveBufTemp, ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 }
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -719,9 +719,9 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p, err_t er 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 if (TotalReceived == size)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 HTTP_SetInfo(sendBuf, strlen(&sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 HTTP_SetInfo(sendBuf, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 DataFlag=0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 BrowserFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 memset(sendBuf, 0, size);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -746,7 +746,7 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb,  struct pbuf *p, err_t er 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   if(receivedBufLen)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				 strncat(&sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				 //memcpy(receiveBufTemp, ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			   }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			 }
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2295,14 +2295,16 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     int client_fd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     char buf[1024];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char *ptr;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     char CookieBuf[50];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     char *CookiePtr = NULL;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     char name[MAX_WEB_COOKIE_LEN];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     char id[MAX_WEB_COOKIE_LEN];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     uint8_t nameLen = 0, idLen = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    uint32_t DataOffset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     struct fs_file file = {0, 0};
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    uint32_t i;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     memset(&srvcert, 0, sizeof(x509_cert));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 1. Load the certificates and private RSA key 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2471,7 +2473,8 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // Id of currently logged-in user 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         uint8_t user_id;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if( DataFlag == 0 && DataFlag2 == 0 ) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // Level of currently logged-in user 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         seclevel = 0xFF;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2484,7 +2487,12 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Authenticated = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             seclevel = 0xFF;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (DataFlag >= 1)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Authenticated = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else if(DataFlag2 >= 1)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Authenticated = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ( Authenticated == false && sSettings.sRADIUS.Auth_enable == false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HTTP_LOGIN(sendBuf, &sendBufLoadLen);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2673,10 +2681,8 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }	  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else if (strncmp(receiveBuf, "GET /settings.cgi", 17) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                SET_PAGE = SET_PAGE_PAGE2;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (seclevel == 0) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (seclevel == 0) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    SET_PAGE = SET_PAGE_PAGE2;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (HTTP_SettingsPage(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen) == SEND_REQUIRED_YES)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2685,17 +2691,110 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else if (strncmp(receiveBuf, "POST /settings.cgi", 18) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strncat(receiveBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                HTTP_SetSettings(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                memset(sendBuf, 0, SEND_BUF_MAX_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (seclevel == 0) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    DataOffset = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcpy(sendBuf, "HTTP/1.1 200 OK\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcat(sendBuf, "\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcat(sendBuf,"<!DOCTYPE html><html lang=""><head><meta http-equiv=\"refresh\" content=\"0;url=/settings.html\"/></head></html>\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // POST Packet received 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (DataFlag2 == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BrowserFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalReceived = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        memset(sendBuf, 0, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                sendBufLoadLen = strlen(sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // parse packet for Content-length field 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        size = Parse_Content_Length(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // parse packet for the octet-stream field 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (i = 0; i < receivedBufLen; i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (strncmp ((char*)(receiveBuf+i), "managerIP", 8)==0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                DataOffset = i;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        /* case of MSIE8 : we do not receive data in the POST packet*/
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (DataOffset == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag2++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            BrowserFlag = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //pbuf_free(p);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            return;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // case of Mozilla Firefox v3.6 : we receive data in the POST packet
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //TotalReceived = receivedBufLen - (ContentLengthOffset + 4);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            TotalReceived = receivedBufLen - DataOffset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (((DataFlag2 ==1)&&(BrowserFlag==1)) || ((DataFlag2 ==0)&&(BrowserFlag==0)))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if ((DataFlag2 ==0)&&(BrowserFlag==0))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag2++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        else if ((DataFlag2 ==1)&&(BrowserFlag==1))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // parse packet for the octet-stream field */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            for (i = 0; i < receivedBufLen; i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (strncmp ((char*)(receiveBuf+i), "managerIP", 8)==0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    DataOffset = i;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            TotalReceived += receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag2++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalData = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // DataFlag >1 => the packet is data only  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalReceived +=receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ptr = (char*)(receiveBuf + DataOffset);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    receivedBufLen-= DataOffset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // update Total data received counter 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    TotalData +=receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // check if last data packet 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (TotalReceived == size)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //DBG printf("State: Received %d bytes\r\n", (int)TotalReceived);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strncat(sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //ВBG printf("receive %s /r/n", sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        HTTP_SetSettings(sendBuf, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        DataFlag2=0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BrowserFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        memset(sendBuf, 0, size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcpy(sendBuf, "HTTP/1.1 200 OK\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcat(sendBuf, "\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcat(sendBuf,"<!DOCTYPE html><html lang=""><head><meta http-equiv=\"refresh\" content=\"0;url=/settings.html\"/></head></html>\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        sendBufLoadLen = strlen(sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // not last data packet 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // write data in flash 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(receivedBufLen)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //memcpy(receiveBufTemp, ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else if (strncmp(receiveBuf, "GET /info.cgi", 13) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2706,17 +2805,106 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else if (strncmp(receiveBuf, "POST /info.cgi", 14) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strncat(receiveBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                HTTP_SetInfo(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                memset(sendBuf, 0, SEND_BUF_MAX_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (seclevel == 0) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    DataOffset = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcpy(sendBuf, "HTTP/1.1 200 OK\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcat(sendBuf, "\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                strcat(sendBuf,"<!DOCTYPE html><html lang=""><head><meta http-equiv=\"refresh\" content=\"0;url=/info.html\"/></head></html>\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // POST Packet received 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (DataFlag == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BrowserFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalReceived = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        memset(sendBuf, 0, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                sendBufLoadLen = strlen(sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // parse packet for Content-length field 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        size = Parse_Content_Length(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // parse packet for the octet-stream field 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (i = 0; i < receivedBufLen; i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (strncmp ((char*)(receiveBuf+i), "owner", 5)==0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                DataOffset = i;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // case of MSIE8 : we do not receive data in the POST packet
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (DataOffset == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            BrowserFlag = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //pbuf_free(p);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            return;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // case of Mozilla Firefox v3.6 : we receive data in the POST packet*/
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //TotalReceived = receivedBufLen - (ContentLengthOffset + 4);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            TotalReceived = receivedBufLen - DataOffset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (((DataFlag ==1)&&(BrowserFlag==1)) || ((DataFlag ==0)&&(BrowserFlag==0)))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if ((DataFlag ==0)&&(BrowserFlag==0))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        else if ((DataFlag ==1)&&(BrowserFlag==1))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            // parse packet for the octet-stream field */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            for (i = 0; i < receivedBufLen; i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (strncmp ((char*)(receiveBuf+i), "owner", 5)==0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    DataOffset = i;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            TotalReceived += receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DataFlag++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalData =0 ;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // DataFlag >1 => the packet is data only  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        TotalReceived +=receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ptr = (char*)(receiveBuf + DataOffset);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    receivedBufLen-= DataOffset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // update Total data received counter 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    TotalData +=receivedBufLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // check if last data packet 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (TotalReceived == size)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strncat(sendBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        HTTP_SetInfo(sendBuf, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        DataFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BrowserFlag = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        memset(sendBuf, 0, size);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcpy(sendBuf, "HTTP/1.1 200 OK\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcat(sendBuf, "\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        strcat(sendBuf,"<!DOCTYPE html><html lang=""><head><meta http-equiv=\"refresh\" content=\"0;url=/info.html\"/></head></html>\r\n\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        sendBufLoadLen = strlen(sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // not last data packet 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // write data in flash 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(receivedBufLen)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            strncat(sendBuf,  ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //memcpy(receiveBufTemp, ptr, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else if (strncmp(receiveBuf, "GET /history.cgi", 16) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             {
 
			 |