龙源期刊网 http://www.qikan.com.cn
GoAhead WebServer在以太网交换机中的应用
作者:王向群 渠毅 徐沛平
来源:《现代电子技术》2011年第22期
摘要:为了实现对以太网交换机进行Web配置管理,在简要介绍了GoAhead嵌入式Web服务器的特点后,阐述了其创建动态页面的功能,详细说明了Ejscript和GoForm创建动态数据和进行功能配置的方法。随后介绍了GoAhead WebServer在交换机中的应用结构和开发过程,并通过对地址表老化时间的管理来具体分析了整个动态数据的建立与交互过程,在动态页面的设计中,与JavaScript的灵活结合,更加有效地实现了B/S架构下对交换机的管理。 关键词:以太网交换机; 嵌入式Web服务器; GoAhead WebServer; 动态; Ejscript; GoForm
中图分类号:
文献标识码:A文章编号:
Application of GoAhead WebServer in Ethernet Switch
(1. State Grid Electric Power Research Institute, Nanjing 210003, China; 2. Xuzhou Power Supply Company, Xuzhou 221000, China)
Abstract: In order to realize the Web configuration management of Ethernet switch, the
function of dynamic Web page creation is elaborated after presenting the characteristics of GoAhead embedded Web server. The methods of daynamic data creation and function setting by Ejscript and GoForm are introduced. The application structure and development process of GoAhead WebServer in Ethernet switch are discussed. The whole dynamic data establishment and the interactive process are concretely analyzed through the management of the aging time of MAC address table. And in the design of dynamic pages, the management of the switch is realized effectively on B/S architecture combined with JavaScript flexibly.
Keywords:Ethernet switch; embedded Web server; GoAhead WebServer; dynamic page; Ejscript; GoForm 收稿日期:
引言
随着智能电网的发展,工业以太网交换机在变电站中的使用越来越普及,从而对以太网交换机的配置管理的快捷性和有效性提出了更高的要求。目前,IP技术的日渐成熟使得越来越多的嵌入式设备引入了基于Web的管理功能[
],用户可以远程使用浏览器方便地访问设
龙源期刊网 http://www.qikan.com.cn
备,实现与设备的数据交互,从而简便有效地对设备进行监测与配置。为了实现上述B/S架构的管理,需要在嵌入式设备中运行一个WebServer。常用的嵌入式WebServer有GoAhead,Boa,Lighttpd等,下面介绍GoAhead WebServer应用开发技术。 1GoAhead WebServer开发技术
GoAhead WebServer是一款开放源代码的嵌入式Web服务器程序,小巧精致,功能较强。 支持ASP、嵌入式的JavaScript,CGI执行,支持内存中的 CGI处理GoForm;如果不包含 SSI,仅要求60 KB的内存;Web 页面可以存在ROM或文件系统中; 支持多种操作系统,并且移植非常方便;软件架构清晰明了,只需稍作配置便可进行开发[
]。
为了方便地创建具有高度交互性的动态网页,GoAhead提供了嵌入式JavaScript和GoForms过程2种方法。它们实际上都与定义在服务器端的某个C函数绑定在一起,嵌入式JavaScript用来在ASP中创建动态数据,而GoForms过程则用来处理用户输入和修改设置,它们一起构成了GoAhead WebServer的核心。 1.1嵌入式JavaScript
GoAhead开发了一种嵌入式的脚本语言Ejscript。JavaScript[占用资源较多,因此不适用于嵌入式设备中。GoAhead设计的嵌入式便地应用在ASP中创建动态数据。
在使用Ejscript创建ASP页面时,脚本通过分隔符来界定,基本格式为: <% function(arguments,...); %>
JavaScript 程序通过WebsAspDefine API 进行注册,这样声明了C程序作为JavaScript的全局变量[4]。例如:
extern int asp_ getlinkstatus (int ejid,Webs_t wp,int argc,char_t **argv); WebsAspDefine(“getlinkstatus”,asp_ getlinkstatus);
WebsAspDefine声明了JavaScript命令,并把此命令和C程序“asp_ getlinkstatus”关联起来,当一个ASP页面被浏览器请求时,此页面中所有使用“getlinkstatus”脚本的地方都将调用“asp_ getlinkstatus”函数。 1.2GoForm
]是一种庞大的语言,
解决
了这个问题。Ejscript是JavaScript的一个严格子集,实现了其基本语言要素。Ejscript可以方