📄 cgi_show.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: cgi_show.c
*
* Purpose:
*
* Author: Jenda Jao
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__STR_H__)
#include "str.h"
#endif
#if !defined(__SWSRAM_H__)
#include "swsram.h"
#endif
#if !defined(__HTTPD_H__)
#include "httpd.h"
#endif
#include "version.h"
#include "weblib.h"
#include "cfgstr.h"
#include "allpages.h"
#include "piportmp.h"
#include "piport.h"
#include "swsys.h"
#include "pidef.h"
#include "pimsg.h"
#include "piipmmod.h"
#include "piipmgrp.h"
#include "pismacgp.h"
#include "pimib.h"
#include "pigmrpgp.h"
#include "pigmrpmd.h"
#include "piacl.h"
#include "piaclgrp.h"
#include "pimacfltmd.h"
#include "pimacfltgp.h"
#include "cgi_show.h"
/*--------------------- Static Definitions ------------------------*/
#define s_apszStrTbl ((char**)&WEBg_SCgiInfo) // share memory buffer in order to save ram
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static char s_szTrColor[] = " bgcolor=skyblue";
#ifdef __PRTCL_REG_TBL_ADD
char s_szPageList[] = "\
<STYLE type=\"text/css\">\n\
BODY {font-family:Arial}\n\
A:link,A:active,A:visited {text-decoration:none;color:blue}\n\
A:hover {text-decoration:underline;color:blue}\n\
</STYLE>\n\
<BASE target=main>\
<IMG src=logo.gif>\
<P>\
<LI><A HREF=ShowPortSts>Port Status</A>\
<LI><A HREF=ShowPortCfg>Port Configuration</A>\
<LI><A HREF=ShowTrkCfg>Trunk Configuration</A>\
<LI><A HREF=ShowVlanCfg>VLAN Configuration</A>\
<LI><A HREF=ShowSnfCfg>Port Monitoring Configuration</A>\
<LI><A HREF=ShowRateCfg>Bandwidth Control</A>\
<LI><A HREF=ShowQosCfg>QoS Configuration</A>\
<LI><A HREF=ShowMibCnt>Port Counters</A>\
<LI><A HREF=ShowACLCfg>Access Control List</A>\
<LI><A HREF=ShowSMACFltCfg>Mac Address Permit / Deny</A>\
<LI><A HREF='javascript:show()' target=_self>Misc Operation</A>\
<UL id=sub style=\"display:none;font-size=80%\">\
<LI><A HREF=ShowMiscCfg>Advanced Switch Configuration</A>\
<LI><A HREF='javascript:show2()' target=_self>Protocol Register&Table Access</A>\
<UL id=sub2 style=\"display:none;font-size=80%\" type=disc>\
<LI><A HREF=ShowSTPCfg>STP Register Access</A>\
<LI><A HREF=ShowIGMPCfg>IGMP Register&Table Access</A>\
<LI><A HREF='javascript:show3()' target=_self>MAC Table Access</A>\
<UL id=sub3 style=\"display:none;font-size=80%\" type=disc>\
<LI><A HREF=ShowSMacCfg>Static MAC Table Access</A>\
<LI><A HREF=ShowGMRPCfg>GMRP Register&Table Access</A>\
</UL>\
<LI><A HREF=Show8021XCfg>802.1X Register Access</A>\
<LI><A HREF=ShowPrvMiscCfg>Misc Register Access</A>\
</UL>\
<LI><A HREF=ShowAdmCfg>Password Setting</A>\
<LI><A HREF=ShowIpCfg>IP Configuration</A>\
<LI><A HREF=ShowFwUpdt>Firmware Update</A>\
<LI><A HREF=WriteDefault onclick=\"return confirm('All user configuration will be reset to default!\\nAnd the system will reboot.')\" target=_top>Restore System Default Setting</A>\
<LI><A HREF=Reboot onclick=\"return confirm('Are you sure?')\" target=_top>Reboot System</A>\
<LI><A HREF=ShowSysInfo>System Information</A>\
</UL>\
<LI><A HREF=Logout target=_top>Logout</A>\
<SCRIPT LANGUAGE=javascript>\n\
x=0\n\
function show()\n\
{\n\
x=!x\n\
obj=document.getElementById(\"sub\")\n\
if (x)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
y=0\n\
function show2()\n\
{\n\
y=!y\n\
obj=document.getElementById(\"sub2\")\n\
if (y)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
z=0\n\
function show3()\n\
{\n\
z=!z\n\
obj=document.getElementById(\"sub3\")\n\
if (z)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
</SCRIPT>";
#else
char s_szPageList[] = "\
<STYLE type=\"text/css\">\n\
BODY {font-family:Arial}\n\
A:link,A:active,A:visited {text-decoration:none;color:blue}\n\
A:hover {text-decoration:underline;color:blue}\n\
</STYLE>\n\
<BASE target=main>\
<IMG src=logo.gif>\
<P>\
<LI><A HREF=ShowPortSts>Port Status</A>\
<LI><A HREF=ShowPortCfg>Port Configuration</A>\
<LI><A HREF=ShowTrkCfg>Trunk Configuration</A>\
<LI><A HREF=ShowVlanCfg>VLAN Configuration</A>\
<LI><A HREF=ShowSnfCfg>Port Monitoring Configuration</A>\
<LI><A HREF=ShowRateCfg>Bandwidth Control</A>\
<LI><A HREF=ShowQosCfg>QoS Configuration</A>\
<LI><A HREF=ShowMibCnt>Port Counters</A>\
<LI><A HREF=ShowACLCfg>Access Control List</A>\
<LI><A HREF=ShowSMACFltCfg>Mac Address Permit / Deny</A>\
<LI><A HREF='javascript:show()' target=_self>Misc Operation</A>\
<UL id=sub style=\"display:none;font-size=80%\">\
<LI><A HREF=ShowMiscCfg>Advanced Switch Configuration</A>\
<LI><A HREF=ShowAdmCfg>Password Setting</A>\
<LI><A HREF=ShowIpCfg>IP Configuration</A>\
<LI><A HREF=ShowFwUpdt>Firmware Update</A>\
<LI><A HREF=WriteDefault onclick=\"return confirm('All user configuration will be reset to default!\\nAnd the system will reboot.')\" target=_top>Restore System Default Setting</A>\
<LI><A HREF=Reboot onclick=\"return confirm('Are you sure?')\" target=_top>Reboot System</A>\
<LI><A HREF=ShowSysInfo>System Information</A>\
</UL>\
<LI><A HREF=Logout target=_top>Logout</A>\
<SCRIPT LANGUAGE=javascript>\n\
x=0\n\
function show()\n\
{\n\
x=!x\n\
obj=document.getElementById(\"sub\")\n\
if (x)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
y=0\n\
function show2()\n\
{\n\
y=!y\n\
obj=document.getElementById(\"sub2\")\n\
if (y)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
z=0\n\
function show3()\n\
{\n\
z=!z\n\
obj=document.getElementById(\"sub3\")\n\
if (z)\n\
obj.style.display=\"BLOCK\"\n\
else\n\
obj.style.display=\"NONE\"\n\
}\n\
</SCRIPT>";
#endif
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
static UINT8 s_byGenHtmlHeader(PSTR pszBuf, PSTR pszTitle)
{
char* psz = pszBuf;
psz += STR_iStrcpy(psz, g_szHtmlOkHeader);
psz += STR_iStrcat(psz, "<BODY><CENTER><H2>");
psz += STR_iStrcat(psz, pszTitle);
psz += STR_iStrcat(psz, "</H2>");
return (UINT8)(psz - pszBuf);
}
static UINT8 s_byAddFormTable(PSTR pszBuf, PSTR szAction, BOOL bBorder)
{
char* psz = pszBuf;
psz += STR_iStrcpy(psz, "<FORM method=GET name=f action=");
psz += STR_iStrcat(psz, szAction);
psz += STR_iStrcat(psz, "><TABLE");
psz += STR_iStrcat(psz, (bBorder) ? " border=1>" : "><TR><TD>");
return (UINT8)(psz - pszBuf);
}
static UINT8 s_byAddFormTableEnd(PSTR pszBuf)
{
return (UINT8)STR_iStrcpy(pszBuf, "</TABLE><P><INPUT type=submit value=Apply></FORM>");
}
UINT16 CGI_wShowMain(void)
{
char* psz = HTTPg_acOutBuf;
psz += STR_iStrcpy(psz, g_szHtmlOkHeader);
psz += STR_iStrcat(psz, "<TITLE>VIA VT6528 Web Smart</TITLE><FRAMESET cols=\"240,*\" frameborder=0><FRAME src=ShowList noresize marginwidth=0><FRAME src=ShowLogin name=main></FRAMESET>");
return (psz - HTTPg_acOutBuf);
}
UINT16 CGI_wShowList(void)
{
char* psz = HTTPg_acOutBuf;
psz += STR_iStrcpy(psz, g_szHtmlOkHeader);
psz += STR_iStrcat(psz, s_szPageList);
return (psz - HTTPg_acOutBuf);
}
char s_szLogin[] = "<FORM method=GET action=/Login><P>Username:<INPUT type=text name=U><P>Password:<INPUT type=password name=P><P><INPUT type=submit value=Login></FORM><SCRIPT language=javascript>if (top.frames.length!=0) top.location=self.location</SCRIPT>";
UINT16 CGI_wShowLogin(void)
{
char* psz = HTTPg_acOutBuf;
psz += STR_iStrcpy(psz, g_szHtmlOkHeader);
psz += STR_iStrcat(psz, "<BODY><CENTER><H2><BR><BR>"STRING_LOGIN_TITLE"<BR><BR></H2>");
psz += STR_iStrcat(psz, (WEBg_bLoginEn && (g_aszWebLoginID[0] == '\0')) ? s_szLogin : "Welcome");
return (psz - HTTPg_acOutBuf);
}
UINT16 CGI_wShowPortSts(void)
{
char* psz = HTTPg_acOutBuf;
UINT8 byPortId;
// Get port status
PIPORT_vGetPortStatus(WEBg_pSPortStatus);
psz += s_byGenHtmlHeader(HTTPg_acOutBuf, g_strPortStatus);
psz += STR_iStrcat(psz, "<TABLE border=1><TR ALIGN=center><TH>Port<TH>Enable<TH>Link Status<TH>Spd/Dpx<TH>Flow Control</TR>");
for (byPortId = 0; byPortId < SWITCH_PORT_NUM; byPortId++) {
// Put begining of a table entry and port name
psz += STR_iStrcat(psz, "<TR");
psz += STR_iStrcat(psz, ((byPortId & 0x01) ? "" : s_szTrColor));
psz += STR_iStrcat(psz, "><TD>");
psz += STR_iStrcat(psz, g_aszPortNameTable[byPortId]);
// Put port enable status
psz += STR_iStrcat(psz, "<TD>");
psz += STR_iStrcat(psz, g_aszEnDisCfg[WEBg_pSPortStatus->aSPortStatus[byPortId].f2Enable]);
// Put port link status
psz += STR_iStrcat(psz, "<TD>");
psz += STR_iStrcat(psz, g_aszPortLinkDownUp[WEBg_pSPortStatus->aSPortStatus[byPortId].f2LinkUp]);
// Put speed & duplex status
psz += STR_iStrcat(psz, "<TD>");
psz += STR_iStrcat(psz, g_aszSpdDpxCfg[WEBg_pSPortStatus->aSPortStatus[byPortId].f4SpdDpx]);
// Put flow control status
psz += STR_iStrcat(psz, "<TD>");
psz += STR_iStrcat(psz, g_aszOnOffCfg[WEBg_pSPortStatus->aSPortStatus[byPortId].f2FlowCtrl]);
}
psz += STR_iStrcat(psz, "</TABLE>");
return (psz - HTTPg_acOutBuf);
}
char s_szPortCfgJS[] = "\
en=new Array(\"Disable\",\"Enable\")\n\
spd=new Array(\"Auto\",\"100F\",\"100H\",\"10F\",\"10H\")\n\
onf=new Array(\"Off\",\"On\")\n\
txt=new Array(en,onf,spd,onf)\n\
function m(i,s){\n\
num=txt[i%4].length\n\
document.f.elements[i].length=num\n\
for (j=0;j<num;j++){\n\
with(document.f.elements[i].options[j]){\n\
text=txt[i%4][j]\n\
value=j\n\
selected=true\n\
}}\n\
document.f.elements[i].selectedIndex=s\n\
}\n\
for (i=0;i<p*4;i++)\n\
m(i,v[i])\n\
</SCRIPT>";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -