| 
					
				 | 
			
			
				@@ -2102,155 +2102,543 @@ static int my_set_session(ssl_context *ssl) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void ssl_server(void *pvParameters)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  int ret, len;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  int listen_fd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  int client_fd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  char buf[1024];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  struct fs_file file = {0, 0};
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int ret, len;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int listen_fd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    int client_fd;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char buf[1024];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char CookieBuf[50];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char *CookiePtr = NULL;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char name[MAX_WEB_COOKIE_LEN];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    char id[MAX_WEB_COOKIE_LEN];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    uint8_t nameLen = 0, idLen = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    struct fs_file file = {0, 0};
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  memset(&srvcert, 0, sizeof(x509_cert));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    memset(&srvcert, 0, sizeof(x509_cert));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* 1. Load the certificates and private RSA key */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //printf("\n\r Loading the server certificates and key...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 1. Load the certificates and private RSA key 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //printf("\n\r Loading the server certificates and key...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /*
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * This demonstration program uses embedded test certificates.
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * Instead, you may want to use x509parse_crtfile() to read the
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * server and CA certificates, as well as x509parse_keyfile().
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ret = x509parse_crt(&srvcert, (unsigned char *) test_srv_crt, strlen(test_srv_crt));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    printf(" failed\n  !  x509parse_crt returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ret = x509parse_crt(&srvcert, (unsigned char *) test_ca_crt, strlen(test_ca_crt));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    printf(" failed\n  !  x509parse_crt returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  rsa_init( &rsa, RSA_PKCS_V15, 0 );
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ret =  x509parse_key(&rsa, (unsigned char *) test_srv_key, strlen(test_srv_key), NULL, 0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if( ret != 0 )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    printf(" failed\n  !  x509parse_key returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //printf(" ok\n\r");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* 2. Setup the listening TCP socket */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //printf("\n\r Bind to https port ...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* Bind the connection to https port : 443 */ 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ret = net_bind(&listen_fd, NULL, 443); 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    printf(" failed\n  ! net_bind returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  //printf(" ok\n\r");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /* 3. Wait until a client connects */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  for(;;)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf("\n\r Waiting for a remote connection ...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ret = net_accept(listen_fd, &client_fd, NULL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // This demonstration program uses embedded test certificates.
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Instead, you may want to use x509parse_crtfile() to read the
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // server and CA certificates, as well as x509parse_keyfile().
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ret = x509parse_crt(&srvcert, (unsigned char *) test_srv_crt, strlen(test_srv_crt));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      //printf(" failed\n  ! net_accept returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" failed\n  !  x509parse_crt returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 4. Initialize the session data 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf("\n\r Setting up the RNG and SSL data....");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /* Initialize the SSL context */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ret = ssl_init(&ssl);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ret = x509parse_crt(&srvcert, (unsigned char *) test_ca_crt, strlen(test_ca_crt));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      // SSL initialization failed 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      printf(" failed\n  ! ssl_init returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      goto accept;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" failed\n  !  x509parse_crt returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the current session as SSL server 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_endpoint(&ssl, SSL_IS_SERVER);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // No certificate verification 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_authmode(&ssl, SSL_VERIFY_NONE);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the random number generator callback function 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_rng(&ssl, RandVal, &rngs); 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the debug callback function 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_dbg(&ssl, my_debug, stdout);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set read and write callback functions 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_bio(&ssl, net_recv, &client_fd, net_send, &client_fd);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the session callback functions 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_scb(&ssl, my_get_session, my_set_session);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // The list of ciphersuites to be used in this session 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_ciphersuites(&ssl, my_ciphersuites);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the session resuming flag, timeout and session context 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_session(&ssl, 1, 0, &ssn);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    memset(&ssn, 0, sizeof(ssl_session));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the data required to verify peer certificate 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_ca_chain(&ssl, srvcert.next, NULL, NULL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set own certificate and private key 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_own_cert(&ssl, &srvcert, &rsa);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Set the Diffie-Hellman public P and G values 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_set_dh_param(&ssl, my_dhm_P, my_dhm_G);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // 5. Handshake protocol 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf("\n\r Performing the SSL/TLS handshake...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // Perform the SSL handshake protocol 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    while((ret = ssl_handshake(&ssl)) != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    rsa_init( &rsa, RSA_PKCS_V15, 0 );
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ret =  x509parse_key(&rsa, (unsigned char *) test_srv_key, strlen(test_srv_key), NULL, 0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if( ret != 0 )
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if(ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        //printf(" failed\n  ! ssl_handshake returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        goto accept;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" failed\n  !  x509parse_key returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /* 6. Read the HTTP Request */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    //printf("\n\r <= Read from client :");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 2. Setup the listening TCP socket 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //printf("\n\r Bind to https port ...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Bind the connection to https port : 443 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ret = net_bind(&listen_fd, NULL, 443); 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      len = sizeof(buf) - 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      memset(buf, 0, sizeof(buf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      /* Read decrypted application data */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ret = ssl_read(&ssl, (unsigned char*)buf, len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" failed\n  ! net_bind returned %d\n\r", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //printf(" ok\n\r");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 3. Wait until a client connects 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for(;;)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("\n\r Waiting for a remote connection ...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ret = net_accept(listen_fd, &client_fd, NULL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //printf(" failed\n  ! net_accept returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            goto exit;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if(ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        continue;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 4. Initialize the session data 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("\n\r Setting up the RNG and SSL data....");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Initialize the SSL context 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ret = ssl_init(&ssl);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(ret != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //printf(" failed\n  ! ssl_init returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            goto accept;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the current session as SSL server 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_endpoint(&ssl, SSL_IS_SERVER);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // No certificate verification 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_authmode(&ssl, SSL_VERIFY_NONE);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the random number generator callback function 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_rng(&ssl, RandVal, &rngs); 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the debug callback function 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //ssl_set_dbg(&ssl, my_debug, stdout);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set read and write callback functions 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_bio(&ssl, net_recv, &client_fd, net_send, &client_fd);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the session callback functions 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_scb(&ssl, my_get_session, my_set_session);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // The list of ciphersuites to be used in this session 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_ciphersuites(&ssl, my_ciphersuites);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the session resuming flag, timeout and session context 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_session(&ssl, 1, 0, &ssn);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        memset(&ssn, 0, sizeof(ssl_session));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the data required to verify peer certificate 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_ca_chain(&ssl, srvcert.next, NULL, NULL);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set own certificate and private key 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_own_cert(&ssl, &srvcert, &rsa);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Set the Diffie-Hellman public P and G values 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ssl_set_dh_param(&ssl, my_dhm_P, my_dhm_G);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 5. Handshake protocol 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("\n\r Performing the SSL/TLS handshake...");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Perform the SSL handshake protocol 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        while((ret = ssl_handshake(&ssl)) != 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //printf(" failed\n  ! ssl_handshake returned %d\n\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                goto accept;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf(" ok\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      if(ret <= 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        switch(ret)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 6. Read the HTTP Request 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("\n\r <= Read from client :");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        do
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          printf("\n\r connection was closed \n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            len = sizeof(buf) - 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            memset(receiveBuf, 0, RECIVE_BUF_MAX_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          case POLARSSL_ERR_NET_CONN_RESET:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          printf("\n\r connection was reset by peer\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Read decrypted application data 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ret = ssl_read(&ssl, (unsigned char*)receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          default:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-          printf("\n\r ssl_read returned %d\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      len = ret;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      // Display the length of read data 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      //printf("\n\r Successfully read %d bytes from client \n\r",len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }while(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                continue;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(ret <= 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                switch(ret)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    printf("\n\r connection was closed \n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                case POLARSSL_ERR_NET_CONN_RESET:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    printf("\n\r connection was reset by peer\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                default:
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    printf("\n\r ssl_read returned %d\n", ret);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            len = ret;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // Display the length of read data 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //printf("\n\r Successfully read %d bytes from client \n\r",len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }while(0);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // -------------------------------------------------------------------------
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //receivedBufLen = p->tot_len;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //memcpy(receiveBuf, p->payload , receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        receiveBuf[receivedBufLen] = '\0';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // printf("receive %s \r\n", receiveBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Get cookie "uname" value 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CookiePtr = strstr(receiveBuf, "uname=");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strncpy(CookieBuf, CookiePtr, 50);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********CookieBuf1= %s\r\n", CookieBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        memset(name, 0, MAX_WEB_COOKIE_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GetCookieValue(CookieBuf, "uname=", name, &nameLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********CookieBuf2= %s\r\n", CookieBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********uname= %s\r\n", name);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Get cookie "id" value 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CookiePtr = strstr(receiveBuf, "id=");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strncpy(CookieBuf, CookiePtr, 50);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********CookieBuf1= %s\r\n", CookieBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        memset(id, 0, MAX_WEB_COOKIE_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        GetCookieValue(CookieBuf, "id=", id, &idLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********CookieBuf2= %s\r\n", CookieBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //printf("********id= %s\r\n", id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Id of currently logged-in user 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        uint8_t user_id;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Level of currently logged-in user 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        seclevel = 0xFF;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HTTP_GetUserCookie(user_id, CookieBuf, &idLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (strncmp(id, CookieBuf, idLen) == 0 ) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                GetUserLevelInt(user_id, &seclevel);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Authenticated = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Authenticated = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            seclevel = 0xFF;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ( Authenticated == false && sSettings.sRADIUS.Auth_enable == false)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HTTP_LOGIN(sendBuf, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else if ( Authenticated == false )//&& sSettings.sRADIUS.Auth_enable == true
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (strncmp(receiveBuf, "GET /main.css", 13) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/main.css", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /rotek.png", 14) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/rotek.png", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /favicon.ico", 16) == 0) // ?
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/favicon.ico", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /role.js", 12) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/role.js", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if ((strncmp(receiveBuf, "POST /login.cgi", 15) == 0) || (log_post_reqn > 0))
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                uint32_t i, offset = 0, req_data_received = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                post_data_count = Parse_Content_Length(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (post_data_count < MAX_POST_REQ_LEN) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    memset(post_req_data, 0, MAX_POST_REQ_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for (i = 0; i < receivedBufLen; i++)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if (strncmp ((char*)(receiveBuf+i), "\r\n\r\n", 4) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							offset = i+4;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							break;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					req_data_received = receivedBufLen - offset;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (offset != 0) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (req_data_received < post_data_count) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            snprintf(post_req_data, req_data_received, "%s", receiveBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            post_data_count -= req_data_received;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            strncat(post_req_data, (char *)(receiveBuf + offset), post_data_count);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (HTTP_ConfirmWebPwd(post_req_data, sendBuf, strlen(post_req_data), &sendBufLoadLen) == SEND_REQUIRED_YES) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                fs_open("/login.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            post_data_count = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            log_post_reqn = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					/* request was fragmented before "\r\n\r\n" */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						log_post_reqn++;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						/* wait max 2 requests */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if (log_post_reqn > 1) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							/* Redirect to login page */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							fs_open("/login.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							/* End reqest */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							post_data_count = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							log_post_reqn = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    printf("Too long POST request!\r\n");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    /* Ignore request */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    post_data_count = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    log_post_reqn = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    /* Redirect to login page */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    fs_open("/login.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			else if (post_data_count > 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			{
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                strncat(post_req_data, receiveBuf, post_data_count);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (HTTP_ConfirmWebPwd(post_req_data, sendBuf, strlen(post_req_data), &sendBufLoadLen) == SEND_REQUIRED_YES) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					fs_open("/login.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                post_data_count = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				log_post_reqn = 0;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/login.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else if ( Authenticated == true ) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (strncmp(receiveBuf, "GET /main.css", 13) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/main.css", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /rotek.png", 14) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/rotek.png", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /favicon.ico", 16) == 0) // ?                 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {                                                                     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/favicon.ico", &file);                                     
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /main.js", 12) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/main.js", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /role.js", 12) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/role.js", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /settings.html", 18) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UpdateUserLoginTime(user_id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (seclevel == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    fs_open("/settings.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    fs_open("/index.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /info.html", 14) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UpdateUserLoginTime(user_id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/info.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /history.html", 17) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UpdateUserLoginTime(user_id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/history.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /ups_history.html", 21) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UpdateUserLoginTime(user_id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/ups_history.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /getJson.cgi", 16) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_GetParamsPage1(sendBuf);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, sendBuf, strlen(sendBuf));
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }	  
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /settings.cgi", 17) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                SET_PAGE = SET_PAGE_PAGE2;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (seclevel == 0) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (HTTP_SettingsPage(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen) == SEND_REQUIRED_YES)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "POST /settings.cgi", 18) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                strncat(receiveBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_SetSettings(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                memset(sendBuf, 0, SEND_BUF_MAX_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /info.cgi", 13) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (HTTP_InfoPage(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen) == SEND_REQUIRED_YES)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "POST /info.cgi", 14) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                strncat(receiveBuf,  " ", 1);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_SetInfo(receiveBuf, receivedBufLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                memset(sendBuf, 0, SEND_BUF_MAX_LEN);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                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);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /history.cgi", 16) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                int res;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                res = HTTP_HistoryPage(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (res == SEND_REQUIRED_FILE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->file = sendBuf;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->left = sendBufLoadLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    send_data(pcb, hs);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_sent(pcb, http_sent_history);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_err(pcb, http_sent_log_err);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else if (res == SEND_REQUIRED_YES) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->file = sendBuf;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->left = sendBufLoadLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    send_data(pcb, hs);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_sent(pcb, http_sent);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /ups_history.cgi", 19) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                int res;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                res = HTTP_UpsHistoryPage(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (res == SEND_REQUIRED_FILE)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->file = sendBuf;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->left = sendBufLoadLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    send_data(pcb, hs);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_sent(pcb, http_sent_log);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_err(pcb, http_sent_log_err);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else if (res == SEND_REQUIRED_YES) 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->file = sendBuf;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    hs->left = sendBufLoadLen;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    send_data(pcb, hs);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tcp_sent(pcb, http_sent);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Тест  АКБ ИБП */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "POST /bat_test.cgi", 18) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UPSTest(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Выключение ИБП */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "POST /ups_power.cgi", 19) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UPSshutdown(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Сброс настроек и сохранине */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /reset.cgi", 14) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_ResetSettings();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_SaveSettings();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/settings.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Перезагрузка контроллера */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /reboot.cgi", 15) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_Reboot();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Подтверждение новых сетевых настроек */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /confirm.cgi", 16) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                SetWebReinitFlag(false);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                SetConfirmWebParamsFlag();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/index.html", &file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Проверка пароля, переход в bootloader */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /fw_update.cgi", 18) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_ConfirmBootPwd(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            /* Смена пароля пользователя */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "POST /changepwd.cgi", 19) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_ChangeUserPwd(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // На производстве
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else if (strncmp(receiveBuf, "GET /setProdate.cgi", 19) == 0)
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_Prodate(receiveBuf, sendBuf, receivedBufLen, &sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HTTP_UpdateUserLoginTime(user_id);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                fs_open("/index.html", &file); // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ssl_sendframes(&ssl, file.data, file.len);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //}
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /*
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (strncmp(buf, "GET /main.css", 13) == 0) // +
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         {
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2374,7 +2762,7 @@ void ssl_server(void *pvParameters) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     //printf("\n\r => Write to client :\n\r");
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Send the dynamic html page 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ssl_DynPage(&ssl);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //ssl_DynPage(&ssl);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Close the connection 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ssl_close_notify(&ssl);
 
			 |