📄 piadmin.c
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: piadmin.c
*
* Purpose: Password setting module UI callback functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__UART_H__)
#include "uart.h"
#endif
#include "str.h"
#include "piadmin.h"
#include "pieeprom.h"
#include "pidef.h"
#include "swmsg.h"
#include "pimisc.h"
#include "engine.h"
#include "allpages.h"
#include "soc.h"
#include "pigencfg.h"
#ifdef __MODULE_WEB_SMART
#include "weblib.h"
#endif
/*--------------------- Static Definitions -------------------------*/
#define EEP_ADDR_USERNAME (EEP_ADDR_ADM_CFG+1)
#define EEP_ADDR_PASSWORD (EEP_ADDR_ADM_CFG+1+USERNAME_STR_LEN)
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Macros -----------------------------*/
/*--------------------- Export Functions --------------------------*/
void PIADM_vInitPage(SAdmPageCfg* pSPageCfg_Admin)
{
STR_pvMemset(pSPageCfg_Admin, 0, sizeof(SAdmPageCfg));
PIEEP_vGetCfgFromEep(EEP_ADDR_ADM_CFG, 1, &(pSPageCfg_Admin->byLoginEn));
PIEEP_vGetCfgFromEep(EEP_ADDR_USERNAME, USERNAME_STR_LEN, (PUINT8)pSPageCfg_Admin->strEepromUsername);
PIEEP_vGetCfgFromEep(EEP_ADDR_PASSWORD, USERNAME_STR_LEN, (PUINT8)pSPageCfg_Admin->strEepromPasswd);
STR_pszStrcpy(pSPageCfg_Admin->strNewUsername, pSPageCfg_Admin->strEepromUsername);
STR_pszStrcpy(pSPageCfg_Admin->strNewPasswd, pSPageCfg_Admin->strEepromPasswd);
STR_pszStrcpy(pSPageCfg_Admin->strAgainPasswd, pSPageCfg_Admin->strEepromPasswd);
#ifdef __MODULE_WEB_SMART
WEBg_bLoginEn = pSPageCfg_Admin->byLoginEn;
#endif
}
void PIADM_vSetEepDefault(BOOL bWriteDefault)
{
UINT8 byValue = DEFAULT_LOGIN_ENABLE;
if (bWriteDefault) {
// Set value to nvram software cache
STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_ADM_CFG - NVR_ADDR_DATA_AREA_START), &byValue, 1);
STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_USERNAME - NVR_ADDR_DATA_AREA_START), (PUINT8)DEFAULT_ADM_USERNAME, USERNAME_STR_LEN);
STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_PASSWORD - NVR_ADDR_DATA_AREA_START), (PUINT8)DEFAULT_ADM_PASSWORD, USERNAME_STR_LEN);
}
else {
PIEEP_vSetCfgIntoEep(&byValue, EEP_ADDR_ADM_CFG, 1);
PIEEP_vSetCfgIntoEep((PUINT8)DEFAULT_ADM_USERNAME, EEP_ADDR_USERNAME, USERNAME_STR_LEN);
PIEEP_vSetCfgIntoEep((PUINT8)DEFAULT_ADM_PASSWORD, EEP_ADDR_PASSWORD, USERNAME_STR_LEN);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
}
UINT8 PIbyADM_SavePage(SAdmPageCfg* pSPageCfg_Admin)
{
PIEEP_vSetCfgIntoEep(&(pSPageCfg_Admin->byLoginEn), EEP_ADDR_ADM_CFG, 1);
if (pSPageCfg_Admin->byLoginEn)
{
if (STR_iStrcmp(pSPageCfg_Admin->strNewPasswd, pSPageCfg_Admin->strAgainPasswd))
return ADMIN_OP_DIFF_AGAIN_PASSWORD;
PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_Admin->strNewUsername, EEP_ADDR_USERNAME, USERNAME_STR_LEN);
PIEEP_vSetCfgIntoEep((PUINT8)pSPageCfg_Admin->strNewPasswd, EEP_ADDR_PASSWORD, USERNAME_STR_LEN);
}
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
// after change password protection mode, the root page and auto logout should be modified.
if (pSPageCfg_Admin->byLoginEn) {
g_byRootPageID = PAGE_MAIN_MENU;
//henry, we need to do s_vSetCfgToHw().
//in s_vSetCfgToHw() do re-init auto-logout time.
PIMISC_vSetHwFromEep(g_pSMiscPageCfg);
}
else {
g_byRootPageID = PAGE_MAIN_MENU_NOLOGOUT;
g_wAutoLogoutTime = 0;
g_u16AutoLogoutCntr = 0;
#ifdef __MODULE_WEB_SMART
g_wWebAutoLogoutTime = 0;
g_wWebAutoLogoutCntr = 0;
#endif
}
#ifdef __MODULE_WEB_SMART
//change <Password Setting>, user should re-login.
g_aszWebLoginID[0] = '\0';
#endif
PIADM_vInitPage(pSPageCfg_Admin); // re-init buffer to input again
return OP_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -