Background technology
Home gateway is the nucleus equipment of intelligent domestic system, by the household internal network is connected with external network (INTERNET, PSTN, GPRS), realizes the information mutual communication between the networks such as system information collection, logical process, information output, interlock control.Make the user can pass through the Long-distance Control of communicating terminals realizations such as computer, PDA, mobile phone, landline telephone to home automation device, the user can also pass through modes such as browser, mail, multimedia message, phone, receives the multimedia messagess such as audio-visual picture, language and characters of the real-time or historical domestic safety monitoring of inquiry.
Embedded web server in the home gateway plays the effect that receives client-requested, analysis request, response request, returns request results to client.Yet existing embedded web server for each connects independent establishment process, comes multichain to connect the request of processing by duplicating self process when connection request arrives; Its generation to the dynamic network page is by using server script, as JSP, and ASP etc., it needs the webserver to have the operation support module of these scripts.Yet be subjected to the resource limit of embedded system, above-mentioned data handling procedure can influence the processing speed and the efficient of whole embedded web server.
The utility model content
The purpose of this utility model provides a kind of embedded web server, can provide home gateway and external network friendly mutual Webpage, can fast and effeciently receive the solicited message of processing from client, and return request results.
In order to achieve the above object, the technical solution of the utility model provides a kind of embedded web server, it is characterized in that, comprising that circulation connects with lower module:
With the two-way page interface module that is connected of external client;
Be used to intercept and accept the circulation monitoring module of client-requested;
Be used to resolve the data resolution module of client-requested.
Above-mentioned embedded web server also by being arranged in the home gateway, is connected with the business logic modules of home gateway.
Above-mentioned data resolution module also is connected to it with business logic modules in the above-mentioned home gateway and transmits the client-requested order, and sends the request results data returned to page interface module.
Above-mentioned data resolution module sends different http header data by page interface module to client also according to client-requested that parses and the data type difference of being returned by business logic modules.
Above-mentioned business logic modules also is connected with the database module of above-mentioned home gateway, above-mentioned database module is carried out retrieval, the accessing operation of data record.
Above-mentioned business logic modules also is connected with the control logic module of above-mentioned home gateway, is used to drive corresponding apparatus and reaches the state that client requires.
Above-mentioned page interface module comprises the list receiver module, program is returned module, is used for carrying out two-way transfer of data with client; Above-mentioned list receiver module is monitored module with above-mentioned circulation and is connected; Said procedure returns module and is connected with above-mentioned data resolution module.
Above-mentioned page interface module also comprises the input checking module, and it is connected with above-mentioned list receiver module, above-mentioned circulation monitoring module respectively, is used to check that client is submitted to the request msg of list receiver module.
The embedded web server that the utility model provides, compared with prior art, its advantage is: the utility model is monitored module, data resolution module owing to be provided with page interface module, the circulation that connects that circulate, and is used to intercept and accept client-requested and parsing successively; Data resolution module also is connected to its transfer request command with business logic modules in the home gateway, and the protocol header information that sends the request results data return is to page interface module, the Webpage that is exported to client by page interface module shows, realize handling solicited message effectively, and return request results from client;
The utility model is owing to use the Boa server of single task at embedded web server, handle multichannel HTTP connection request by setting up the HTTP request list, only create new process for cgi script, saved system resource to the full extent, it makes this embedded web server have very high HTTP request processing speed and efficient also by generating catalogue, automatic decompressing files automatically simultaneously.
Embodiment
Below in conjunction with description of drawings embodiment of the present utility model.
See also shown in Figure 1ly, the embedded web server 10 that the utility model provides is arranged in the home gateway, is connected with business logic modules 20.This business logic modules 20 also is connected with control logic module 40 with database module 30 respectively.
Wherein the webserver 10 is used for resolving http request and the order that client is sent, and submits to business logic modules 20; By the configuration detection data in 20 pairs of data library modules 30 of business logic modules, log record etc. retrieve, operation such as access, and execution command sent to control assembly; Control assembly is responsible for driving the state of corresponding apparatus to customer requirement; The data of business logic modules 20 being returned via the webserver 10 are submitted to the user with the form of XML again.
See also shown in Figure 2ly, embedded web server 10 comprises page interface module 11, the circulation that circulation connects and monitors module 12, data resolution module 13, is used to intercept and accept client-requested successively and resolves; Data resolution module 13 also is connected to its transfer request command with business logic modules 20 in the home gateway, and the protocol header information that sends the request results data of returning is exported to the Webpage demonstration of client to page interface module 11 by page interface module 11.
The embedded web server 10 that uses in the utility model is Boa servers, it is the http server of a single task, handle multichannel HTTP connection request by setting up the HTTP request list, it is the new process of CGI (CGI) program creation only simultaneously, saved system resource to the full extent, it also has functions such as automatic generation catalogue, automatic decompressing files simultaneously, makes this embedded web server 10 have very high HTTP request processing speed and efficient.
The initial work that module 12 is used for the webserver is monitored in circulation, comprises Boa is configured, and promptly by set up a Boa server directory under/etc catalogue, the main configuration file of Boa is put in the inside, makes it can support the execution of cgi script; When the cgi script request, it is its establishment process that module 12 is monitored in circulation, and will ask output.The groundwork process that module 12 is monitored in circulation is as follows: the creation environment variable, TCP stream mode SOCKET descriptor is intercepted in foundation, be converted into clog-free socket, and bind 80 ports and monitor connection request, enter circulation afterwards and intercept the client-requested of wait from page interface module 11.
Data resolution module 13 is used to analyze client-requested, is about to solicited message and resolves to method, URL target, optional Query Information and form information etc.Data resolution module 13 cooperates with business logic modules 20, according to the difference of the requesting method that parses, makes different responses: if requesting method is HEAD, then directly return response header to page interface module 11; If requesting method is GET, then when returning response header, the URL file destination of client-requested is read from server directory, and sent to page interface module 11; If requesting method is POST, then the form information that the client is sended over sends corresponding C GI program to, carries out cgi script as the parameter of CGI, and execution result is sent to page interface module 11.
Data resolution module 13 also according to the client-requested that parses and the data type difference returned by business logic modules 20 (under HTML type, plain text, JPG image, GIF image, the server directory All Files list information etc.), sends different http header data (filename, size, date etc.) by page interface module 11 to client.
Page interface module 11 is one section program that operate on the webserver 10, and the cgi script with Html page interface on the client browser is provided.Because in HTML, list is the means of topmost transmission information, is applicable to any browser, so the work of cgi script comprises the reception form data, carries out data processing, generates the new page according to result at last and returns to client browser.
Page interface module 11 comprises list receiver module, input checking module, program and returns module.Form data generally is to submit to server with the POST method, is obtained by the cgi script of list receiver module, and interface data and internal data correspondence are carried out next step processing.Cgi script obtains data from the page and just distinguishes according to the element name element name/value.The application and development of the webserver 10 generally all can be come interface and programmed logic disengaging, allows page interface module 11 to a certain degree changing the interface down, as changing the attribute of interface text, sets up multi-language version etc., and need not to change programmed logic.A lot of elements are arranged in the list, comprise the input text frame, radio box, the multiselect frame, button, or the like, the mutual of information can be provided.
The data that the input checking module is just submitted to the user on user interface are checked.It at present generally is the mode that adopts the javascript script.When submitting data to, the onSubmit method of form object will be called, and just can import in this method and check.Inspection commonly used whether have must, maximum/little length, whether character, whether numeral, email address, IP address whether correctly, whether mate a regular expression etc.
Program return module be adopt note among the HTML<!-xxx--〉come mark.Need be in html template being each list element and other any places that needs routine processes, according to certain rule, is exactly that the list element is capable as the next line of note, sets up its comment token.Cgi script just can be judged the table unit prime information and handles according to comment token.Program reads template file line by line, checks to have or not comment token, if any, then next line need be handled, and composes for the list element and goes up data, just can return the page of band data at last and give the browser of client.
Although content of the present utility model has been done detailed introduction by above preferred embodiment, will be appreciated that above-mentioned description should not be considered to restriction of the present utility model.After those skilled in the art have read foregoing, for multiple modification of the present utility model with to substitute all will be conspicuous.Therefore, protection range of the present utility model should be limited to the appended claims.