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

📄 piipcfg.c

📁 vt6528芯片交换机API函数和文档运行程序
💻 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:    piipcfg.c
 *
 * Purpose:
 *
 * Author:  Tevin Chen
 *
 * Date:    Jan 08, 2002
 *
 * Functions:
 *
 * Revision History:
 *
 */


#if !defined(__NVRAM_H__)
#include "nvram.h"
#endif
#include "swmsg.h"
#include "piipcfg.h"
#include "pidef.h"
#if !defined(__NETIF_H__)
#include "netif.h"
#endif
#include "weblib.h"




/*---------------------  Static Definitions  ------------------------*/

/*---------------------  Static Types  ------------------------------*/

/*---------------------  Static Macros  -----------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/

/*---------------------  Export Variables  --------------------------*/




void PIIPCONF_vInitPage(SIpConfPageCfg* pSPageCfg_IpConf)
{
    UINT8        si;
    SIpFlshCfg  sCfg;


    PIEEP_vGetCfgFromEep(NVR_ADDR_IPCONF, NVR_SIZE_IPCONF, (PUINT8)&sCfg);
    STR_vCvtIpValtoStr(pSPageCfg_IpConf->szIp, sCfg.u32Ip);
    STR_vCvtIpValtoStr(pSPageCfg_IpConf->szSubnet, sCfg.u32Subnet);
    STR_vCvtIpValtoStr(pSPageCfg_IpConf->szGateway, sCfg.u32Gateway);
    // convert mac address to hex string
    for (si = 0; si < 6; si++) {
        STR_iU32ToStrHexPad(pSPageCfg_IpConf->szMac + si * 3, g_au8MyEthAddr[si], 2);
        STR_iStrcat(pSPageCfg_IpConf->szMac + si * 3, ":");
    }    
    pSPageCfg_IpConf->szMac[MAC_STRING_LEN] = 0;    // remove the last ":"
}


void PIIPCONF_vSetCfgToHW(SIpFlshCfg* psIpCfg)
{
    g_u32MyIpAddr     = psIpCfg->u32Ip;
    g_u32MyNetmask    = psIpCfg->u32Subnet;
    g_u32MyDefGateway = psIpCfg->u32Gateway;
}


void PIIPCONF_vSetHwFromEep(void)
{
    SIpFlshCfg  sCfg;

    PIEEP_vGetCfgFromEep(NVR_ADDR_IPCONF, NVR_SIZE_IPCONF, (PUINT8)&sCfg);    
    PIIPCONF_vSetCfgToHW(&sCfg);
}


void PIIPCONF_vSetEepDefault(BOOL bWriteDefault)
{
    SIpFlshCfg  sCfg;
    
    
    sCfg.u32Ip      = DEFAULT_IP_ADDR;
    sCfg.u32Subnet  = DEFAULT_SUBNET;
    sCfg.u32Gateway = DEFAULT_GATEWAY;
    if (bWriteDefault) {
        // Set value to nvram software cache
        STR_pvMemcpy(g_abyNVRSwCache + (NVR_ADDR_IPCONF - NVR_ADDR_IPCONF), (PUINT8)&sCfg, NVR_SIZE_IPCONF);          
    }        
    else {
        PIEEP_vSetCfgIntoEep((PUINT8)&sCfg, NVR_ADDR_IPCONF, NVR_SIZE_IPCONF);
    }
}


UINT8 PIIPCONF_bySavePage(SIpConfPageCfg* pSPageCfg_IpConf)
{
    SIpFlshCfg sCfg;
    
    
    if (0 == (sCfg.u32Ip = STR_dwCvtIpStrtoVal(pSPageCfg_IpConf->szIp)))
        return IPCONF_OP_INVALID_IP;
    if (0 == (sCfg.u32Subnet = STR_dwCvtIpStrtoVal(pSPageCfg_IpConf->szSubnet)))
        return IPCONF_OP_INVALID_SUBNET;
    if (0 == (sCfg.u32Gateway = STR_dwCvtIpStrtoVal(pSPageCfg_IpConf->szGateway)))
        return IPCONF_OP_INVALID_GATEWAY;

    PIEEP_vSetCfgIntoEep((PUINT8)&sCfg, NVR_ADDR_IPCONF, sizeof(SIpFlshCfg));

    PIIPCONF_vSetCfgToHW(&sCfg);

    // after ip changed, auto logout web page
    g_aszWebLoginID[0] = '\0';

    return OP_OK;
}


⌨️ 快捷键说明

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