⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iocbk.c

📁 基于网络服务控制芯片TF-320的嵌入式web server源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
            i4 = (atol(vp[3].value)); //str2num(vp[3].value);                        if( (config_g.ipaddr[3] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.ipaddr[3] = (u8_t)i4;                config_g.ipaddr[3] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                            if( i4 <= 0|| i4 >= 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid IP";               httpd_send_file(fs_open("errormsg.htm"));               return OK;            }            /* SubMask config vp[4] ~ vp[7] */            /* SubMask[0] config */                  i4 = (atol(vp[4].value));            if( (config_g.netmask[0] != (u8_t)i4) && (i4>0) && (i4<=255) )            {                //tempconfig_g.netmask[0] = (u8_t)i4;                config_g.netmask[0] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                        if( i4 <= 0 || i4 > 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Subnet Mask";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            /* SubMask[1] config */             i4 = (atol(vp[5].value));            if( i4 < 0 || i4 > 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Subnet Mask";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.netmask[1] != (u8_t)i4) && (i4>=0) && (i4<=255) )            {                //tempconfig_g.netmask[1] = (u8_t)i4 ;                config_g.netmask[1] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }            /* SubMask[2] config */             i4 = (atol(vp[6].value));            if( i4 < 0|| i4 > 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Subnet Mask";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.netmask[2] != (u8_t)i4) && (i4>=0) && (i4<=255) )            {                //tempconfig_g.netmask[2] = (u8_t)i4;                config_g.netmask[2] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                /* SubMask[3] config */             i4 = (atol(vp[7].value));            if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Subnet Mask";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.netmask[3] != (u8_t)i4) && (i4>=0) && (i4<=255) )            {                //tempconfig_g.netmask[3] = (u8_t)i4;                config_g.netmask[3] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                /* GateWay config vp[8] ~ vp[11] */            /* GateWay[0] config */             i4 = (atol(vp[8].value));            if( i4 <= 0 || i4 >= 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Gateway";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.gateway[0] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.netmask[0] = (u8_t)i4;                config_g.gateway[0] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }            /* GateWay[1] config */              i4 = (atol(vp[9].value));            if( i4 < 0 || i4 > 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Gateway";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.gateway[1] != (u8_t)i4) && (i4>=0) && (i4<=255) )            {                //tempconfig_g.netmask[1] = (u8_t)i4 ;                config_g.gateway[1] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }            /* GateWay[2] config */             i4 = (atol(vp[10].value));            if( i4 < 0|| i4 > 255 )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Gateway";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.gateway[2] != (u8_t)i4) && (i4>=0) && (i4<=255) )            {                //tempconfig_g.netmask[2] = (u8_t)i4;                config_g.gateway[2] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                /* GateWay[3] config */             i4 = (atol(vp[11].value));            if( i4 <= 0|| i4 >= 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid Gateway";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.gateway[3] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.netmask[3] = (u8_t)i4;                config_g.gateway[3] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }  	 /* MAC[0] config */ 		strcpy(u8buf,vp[12].value);			i4=sstrtohex(&u8buf);//            i4 = (atol(vp[12].value));           if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }                    if( (config_g.hardmac[0] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[0] = (u8_t)i4;                config_g.hardmac[0] =(u8_t)i4;                ConfigChangeFlag = 1 ;              }	     	 /* MAC[1] config */ 		strcpy(u8buf,vp[13].value);			i4=sstrtohex(&u8buf);          //           i4 = (atol(vp[13].value));          if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }             if( (config_g.hardmac[1] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[1] = (u8_t)i4;                config_g.hardmac[1] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            } 	/* MAC[2] config */ 		strcpy(u8buf,vp[14].value);			i4=sstrtohex(&u8buf);//            i4 = (atol(vp[14].value));           if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.hardmac[2] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[2] = (u8_t)i4;                config_g.hardmac[2] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }   	   /*  MAC[3] config */ 		strcpy(u8buf,vp[15].value);			i4=sstrtohex(&u8buf);//            i4 = (atol(vp[15].value));           if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.hardmac[3] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[3] = (u8_t)i4;                config_g.hardmac[3] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }	/* MAC[4] config */  		strcpy(u8buf,vp[16].value);			i4=sstrtohex(&u8buf);//           i4 = (atol(vp[16].value));            if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.hardmac[4] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[4] = (u8_t)i4;                config_g.hardmac[4] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }     /* MAC[5] config */ 		strcpy(u8buf,vp[17].value);			i4=sstrtohex(&u8buf); //           i4 = (atol(vp[17].value));          if( i4 < 0|| i4 > 255  )            {                errmsgflag = ERRORMSG_SETUP ;                hs->errormsg = "Invalid MAC";                httpd_send_file(fs_open("errormsg.htm"));                return OK;            }            if( (config_g.hardmac[5] != (u8_t)i4) && (i4>0) && (i4<255) )            {                //tempconfig_g.MAC[5] = (u8_t)i4;                config_g.hardmac[5] = (u8_t)i4;                ConfigChangeFlag = 1 ;                            }                //if( ConfigChangeFlag )            //{            //    httpd_send_file(fs_open("reconnect.htm"));            //    return OK;            //}		#ifdef EEPROM_ENABLE        //DEBUGF(DEBUG_UART, ("\r\n EE_FLAG is (%.bx)", EE_FLAG));   	 if (EE_FLAG == EEPROM24C16)        {            /* Save Configuration to EEPROM */            /* MY_IP */            for (i=0; i<4; i++)                _24c16_eeprom_word_write((u16_t)EE_IP12*2+i, config_g.ipaddr[i]);                        /* NETMASK */            for (i=0; i<4; i++)                _24c16_eeprom_word_write((u16_t)EE_NETMASK12*2+i, config_g.netmask[i]);                        /* GATEWAY */            for (i=0; i<4; i++)                _24c16_eeprom_word_write((u16_t)EE_GATEWAY12*2+i, config_g.gateway[i]);	     /* MAC */            for (i=0; i<6; i++)                _24c16_eeprom_word_write((u16_t)EE_MAC12*2+i, config_g.hardmac[i]);						            /* DHCP */                        u8EEData1 = en ? 0x01 : 0x00;            _24c16_eeprom_word_write(EE_DHCPEN*2, u8EEData1);                        /* Write MAGIC Code */            u8EEData1 = (u8_t)((EE_MAGIC_CODE_DATA&0xFF00)>>8);            u8EEData2 = (u8_t)(EE_MAGIC_CODE_DATA&0x00FF);            _24c16_eeprom_word_write((u16_t)EE_MAGIC_CODE*2, u8EEData1);            _24c16_eeprom_word_write((u16_t)EE_MAGIC_CODE*2+1, u8EEData2);                }#endif	 // DEBUGF(DEBUG_SYS, ("\r\n\r\n IN tgiSystem()"));		set_my_uip();    }    httpd_send_file(fs_open("system.htm"));    return OK;}u8_t tgi_password(u8_t varid, variable_t *vp){    	u8_t  i, pwd_len, u8EEData;    char  *oldpasswd ;    // for delete warring     u8_t u8_dwarring ;    u8_dwarring = varid ;    // end of delete warring  	oldpasswd = user_table[0].passwd; //	char  newpasswd1[MAX_PASSWORD_LEN+1], newpasswd2[MAX_PASSWORD_LEN+1];	//    printf("\r\n%s\r\n%s\r\n%s",vp[0].value, vp[1].value, vp[2].value );	if (!strcmp(vp[3].value, "Apply"))	{		if (!strcmp( vp[0].value, oldpasswd))	 	// password is correct!!!		{//			DEBUGF(DEBUG_UART, ("\r\n Password Correct!!"));            pwd_len = (u8_t)(strlen(vp[1].value));            DEBUGF(0, ("\r\n pwd_len is %bu",pwd_len));            if( pwd_len > MAX_PASSWORD_LEN )            { //               printf("\r\n pwd_len > MAX_PASSWORD_LEN") ;                errmsgflag = ERRORMSG_HISTORY_BACK ;               	hs->errormsg = "New password too long!!! Max length is 4.";				httpd_send_file(fs_open("errormsg.htm"));                return OK;                            }			if (!strcmp( vp[1].value, vp[2].value))			{	                errmsgflag = ERRORMSG_NOTE  ;						hs->errormsg = "Password Changed!!!";				httpd_send_file(fs_open("errormsg.htm"));								#ifdef EEPROM_ENABLE//					DEBUGF(DEBUG_UART, ("\r\n Show user_table[0].passwd: Before:(%s)", user_table[0].passwd));					strcpy(user_table[0].passwd, vp[1].value);//					DEBUGF(DEBUG_UART, ("\r\n Show user_table[0].passwd: After:(%s)", user_table[0].passwd));					// Set to EEPROM!!!															for (i=0; i<pwd_len+1; i++)		// 1 NULL Char					{							u8EEData = 0x00;							u8EEData = user_table[0].passwd[i];							_24c16_eeprom_word_write(EE_PASSWRD*2+i, u8EEData);							DEBUGF(DEBUG_UART, ("\r\n EE_OFFSET: (%.bu) Write EE_DATA: (%c)", EE_PASSWRD*2+i, (char)u8EEData));					}									#endif			}		 			else if ( strcmp( vp[1].value, vp[2].value) != 0)			{                errmsgflag = ERRORMSG_HISTORY_BACK ;				hs->errormsg = "New Password not Confirmed";				httpd_send_file(fs_open("errormsg.htm"));			}            		}		else if ( (strcmp( vp[0].value, oldpasswd)) != 0 )		{//			DEBUGF(DEBUG_UART, ("\r\n Incorrect Password!!!"));//			httpd_send_loginError();		            errmsgflag = ERRORMSG_HISTORY_BACK;	            hs->errormsg = "Invalid Password";		    httpd_send_file(fs_open("errormsg.htm"));		}		}    if (!strcmp(vp[3].value, "Reset"))    {                httpd_send_file(fs_open("password.htm"));    }	//httpd_send_file(fs_open("note.htm"));		    return OK;}u8_t ssiPassword(u8_t varid, value_t *vp){	switch (varid)	{		case TGI_OLDPASS:			vp->value.string = "";			vp->type = string;					            break;		case TGI_NEWPASS:			vp->value.string = "";			vp->type = string;							break;		case TGI_CONFIRMPASS:			vp->value.string = "";			vp->type = string;							break;				default:			vp->value.string = "";			vp->type = string;			break;	}	return OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -