Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of ethernet port control device and method, reduces the hardware cost realizing ethernet port and control, improves autgmentability.
Technical scheme of the present invention is achieved in that
A kind of ethernet port control device, comprising:
Ether drives the ether driver module of layer, for determining the type of this message and source media access control layer MAC Address and receive the port of ether exchange chip of this message after receiving the message from the ether exchange chip of physical link layer, by determined information input terminal mouth control module, determine whether receive this message according to the information that port control modules returns;
Ether drives the port control modules of layer, and the configuration order for the authentication service program module according to application layer arranges message authentication parameter, the MAC Address passed through comprising certification and/or port authentication information, and carry out port controlling according to the input information of described ether driver module and described message authentication parameter, described port controlling comprises: if the type of message that ether driver module receives is message identifying, then notify that ether driver module receives this message and uploads to the authentication service program module on upper strata, if non-authentication message, whether the port of the MAC Address then judging this message or the ether exchange chip that receives this message is the MAC Address passed through of the certification arranged in described message authentication parameter or port, if it is notify that ether driver module receives this message and uploads to corresponding upper level applications, otherwise abandon this message,
The authentication service program module of application layer, carries out certification for the message identifying driving layer to upload according to ether to MAC Address and/or port information, sends the configuration-direct arranging message authentication parameter to port control modules.
Preferably, described port control modules specifically comprises two external interfaces:
The configuration interface of a message authentication parameter called for the described authentication service program module of confession, comprising the data structure for storing described message authentication parameter, described authentication service program module is conducted interviews by this configuration interface to the message authentication parameter in this data structure and revises;
Another verification function interface for calling for ether driver module, for carrying out described port controlling according to the input information of described ether driver module and described message authentication parameter.
Preferably, the described data structure for storing described message authentication parameter is: Proc node tree.
Preferably, the certification control protocol that described ethernet port control device uses is IEEE802.1x agreement.
A kind of ethernet port control method, comprising:
The message received is uploaded to ether and drives layer by ether exchange chip;
Ether drives layer to determine type from the described message of ether exchange chip and source MAC, and receives the port of ether exchange chip of this message; If described type of message is message identifying, then receives and upload to the authentication service program on upper strata;
The authentication service program on described upper strata carries out certification according to message identifying to MAC Address and/or port information, drives layer to send the configuration-direct arranging message authentication parameter to ether;
Described ether drives layer to arrange message authentication parameter according to the configuration order of described authentication service program, and set message authentication parameter comprises the MAC Address and/or port authentication information that certification passes through;
If the type of the message from ether exchange chip that described ether drives layer to receive is non-message identifying, whether the port of the MAC Address then judging this message or the ether exchange chip that receives this message is the MAC Address passed through of the certification arranged in described message authentication parameter or port, if it is receive this message and upload to corresponding upper level applications, otherwise abandoning this message.
Preferably, comprise further:
Set message authentication parameter comprises the mac address table that acquiescence accepts, described ether drives layer after determining the source MAC from the message of ether exchange chip, judge whether the source MAC of this message is given tacit consent in the mac address table accepted described, if it is receives this message and uploads to corresponding upper level applications;
And/or, set message authentication parameter comprises the mac address table of acquiescence refusal, described ether drives layer after determining the source MAC from the message of ether exchange chip, judge whether the source MAC of this message is given tacit consent in the mac address table of refusal described, if it is abandons this message.
Preferably, arrange further in described message authentication parameter and start mark, for representing that whether enabling ethernet port controls; After the message from ether exchange chip that described ether drives layer to receive, first whether enable ethernet port by this startup marker for judgment and control, if so, then perform follow-up described ethernet port control flow; Otherwise receive this message and upload to corresponding upper level applications.
Preferably, arranging certification mode mark in described message authentication parameter further, is MAC certification mode or port authentication pattern for representing;
After the message from ether exchange chip that described ether drives layer to receive, be MAC certification mode or port authentication pattern by this certification mode marker for judgment;
If MAC certification mode then judges whether the MAC Address of this message is the MAC Address that the certification arranged in described message authentication parameter is passed through, and if it is receives this message and uploads to corresponding upper level applications, otherwise abandoning this message;
If port authentication pattern then judges whether the port receiving this message is the port that the certification arranged in described message authentication parameter is passed through, and if it is receives this message and uploads to corresponding upper level applications, otherwise abandoning this message.
Preferably, the concrete mode that described ether drives layer to arrange message authentication parameter is:
Ether drives layer create in operating system nucleus and safeguard the data structure of the Proc node tree for storing described message authentication parameter, and described authentication service program is directly conducted interviews and revises the message authentication parameter in this Proc node tree by configuration order.
Preferably, described ethernet port control method is use IEEE802.1x agreement to carry out the method controlled.
Compared with prior art, described ether exchange chip of the present invention all can send to ether to drive layer after receiving all messages, layer is driven to add a port control modules at ether, belong to the software module in ether driving layer, for arranging message authentication parameter according to the configuration order of described authentication service program, determine that ether drives layer whether receive and upload the message from ether exchange chip to upper strata according to the message authentication parameter arranged, thus disobey too exchange chip of relying just can realize ethernet port control, reduce the hardware cost realizing ethernet port and control, only the software program in layer need be driven to modify to ether when upgrading to port control mode or revise, improve autgmentability.
The present invention solves the dependence of IEEE802.1x authentication protocol to hardware well, the ethernet port adopting Ethernet switching chip with low cost just can realize IEEE802.1x agreement controls, reduce the hardware cost of the ethernet port control realizing IEEE802.1x agreement, simultaneously, only the software program in layer need be driven to modify to ether when upgrading to port control mode or revise, improve the autgmentability of the ethernet port control realizing IEEE802.1x agreement.So after application the present invention, supporting the equipment of IEEE802.1x authentication protocol, can more go when selecting hardware consider other favourable factors such as cost and ignore this factor of port controlling whether supporting IEEE802.1x certification.
Embodiment
Below in conjunction with drawings and the specific embodiments, the present invention is further described in more detail.
Fig. 2 is the hierarchical chart of ethernet port control device of the present invention.See Fig. 2, ethernet port control device of the present invention comprises:
The ether exchange chip of physical link layer, what distinguish with prior art is that this ether exchange chip does not carry out ethernet port control, but all messages received all are passed to ether drives layer.
Ether drives the ether driver module of layer, for determining the type of this message and source media access control layer (MAC) address and receive the port of ether exchange chip of this message after receiving the message from ether exchange chip, by determined information input terminal mouth control module, determine whether receive this message according to the information that port control modules returns;
Ether drives the port control modules of layer, and the configuration order for the authentication service program module according to application layer arranges message authentication parameter, the MAC Address passed through comprising certification and/or port information, and carry out port controlling according to the input information of described ether driver module and described message authentication parameter, described port controlling comprises: if the type of message that ether driver module receives is message identifying, then notify that ether driver module receives this message and uploads to the authentication service program module on upper strata, if non-authentication message, whether the port of the MAC Address then judging this message or the ether exchange chip that receives this message is the MAC Address passed through of the certification arranged in described message authentication parameter or port, if it is notify that ether driver module receives this message and uploads to corresponding upper level applications, otherwise abandon this message,
The authentication service program module of application layer, carries out certification for the message identifying driving layer to upload according to ether to MAC Address and/or port information, sends the configuration-direct arranging message authentication parameter to port control modules.
Described kernel protocol stack is the general name that application layer and ether drive each agreement between layer, for transmitting the interactive information between application layer and ether driving layer, identical with existing kernel protocol stack, therefore repeats no more herein.
In embodiment of the present invention, the certification control protocol that described ethernet port control device uses is IEEE802.1x agreement.Described port control modules is a port control modules for IEEE802.1x agreement specifically.
The interface diagram that Fig. 3 externally provides for port control modules of the present invention.See Fig. 3, described ether drives the port control modules of layer specifically to comprise two external interfaces:
The configuration interface 301 of a message authentication parameter called for the described authentication service program module of confession, comprising the data structure for storing described message authentication parameter, described authentication service program module is conducted interviews by this configuration interface 301 to the message authentication parameter in this data structure and revises; In the embodiment shown in fig. 3, the described data structure for storing described message authentication parameter is specially and creates and the data structure of the Proc node tree safeguarded in operating system nucleus, described authentication service program module is conducted interviews by configuration order to the message authentication parameter in this Proc node tree and revises, thus the state information of parameters for authentication and collection certification can be configured, such as can by realizing the configuration of parameters for authentication to the write operation of corresponding Proc node, by realizing the collection of authentication information to the read operation of corresponding Proc node.
Another verification function interface 302 called for supplying ether driver module, for carrying out described port controlling according to the input information of described ether driver module and described message authentication parameter, namely, when ether driver module receives the message from ether exchange chip, call this verification function interface 302 and judge whether to receive this message.The type (usually identify with Ether frame agreement, mainly comprise message identifying type and non-authentication type of message) that the information being input to verification function interface 302 of described ether driver module is current the received message of ether driver module and source media access control layer (i.e. MAC) address and receive the port of ether exchange chip of this message.
Fig. 4 is a kind of flow chart of ethernet port control method of the present invention.Ethernet port control method of the present invention is use IEEE802.1x agreement to carry out the method controlled.See Fig. 4, the method mainly comprises:
The message received is uploaded to ether and drives layer by step 401, ether exchange chip;
Step 402, ether drive layer to determine type from the described message of ether exchange chip and source MAC, and receive the port of ether exchange chip of this message;
Step 403, judge whether described type of message is message identifying, if it is perform step 404, otherwise perform step 406;
Step 404, receive this message and upload to the authentication service program on upper strata, the authentication service program on described upper strata carries out certification according to message identifying to MAC Address and/or port information, drives layer to send the configuration-direct arranging message authentication parameter to ether;
Step 405, described ether drive layer to arrange message authentication parameter according to the configuration order of described authentication service program, and set message authentication parameter comprises the MAC Address and/or port information that certification passes through;
If the type of the message from ether exchange chip that the described ether of step 406 drives layer to receive is non-message identifying, whether the port of the MAC Address then judging this message or the ether exchange chip that receives this message is the MAC Address passed through of the certification arranged in described message authentication parameter or port, if it is receive this message and upload to corresponding upper level applications, otherwise abandoning this message.
In a kind of specific embodiment, described message authentication parameter set by the configuration order of authentication service program comprises the mac address table that acquiescence accepts, described ether drives layer after determining the source MAC from the message of ether exchange chip, need the source MAC judging this message whether to give tacit consent in the mac address table accepted described, if it is receive this message and upload to corresponding upper level applications;
And/or, the mac address table of acquiescence refusal also can be comprised in described message authentication parameter set by the configuration order of authentication service program, described ether drives layer after determining the source MAC from the message of ether exchange chip, need the source MAC judging this message whether to give tacit consent in the mac address table of refusal described, if it is abandon this message.
In a kind of specific embodiment, can also arrange further in described message authentication parameter and start mark, for representing that whether enabling ethernet port controls; After the message from ether exchange chip that described ether drives layer to receive, first whether enable ethernet port by this startup marker for judgment to control, if, then perform follow-up described ethernet port control flow, that is: if described type of message is message identifying, then receives and upload to the authentication service program on upper strata; If non-authentication message, whether the port of the MAC Address then judging this message or the ether exchange chip that receives this message is the MAC Address passed through of the certification arranged in described message authentication parameter or port, if it is receive this message and upload to corresponding upper level applications, otherwise abandoning this message; If judge that not needing to enable ethernet port controls, then receive described message and upload to corresponding upper level applications by described startup mark.
In another kind of specific embodiment, can also arrange certification mode mark in described message authentication parameter further, be MAC certification mode or port authentication pattern for representing; After the message from ether exchange chip that described ether drives layer to receive, be MAC certification mode or port authentication pattern by this certification mode marker for judgment:
If MAC certification mode then judges whether the MAC Address of this message is the MAC Address that the certification arranged in described message authentication parameter is passed through, and if it is receives this message and uploads to corresponding upper level applications, otherwise abandoning this message;
If port authentication pattern then judges whether the port receiving this message is the port that the certification arranged in described message authentication parameter is passed through, and if it is receives this message and uploads to corresponding upper level applications, otherwise abandoning this message.
In method of the present invention, the concrete mode of one that described ether drives layer to arrange message authentication parameter is: ether drives layer create in operating system nucleus and safeguard the data structure of the Proc node tree for storing described message authentication parameter, and described authentication service program is directly conducted interviews and revises the message authentication parameter in this Proc node tree by configuration order.
The Proc node tree of the described configuration interface for upper strata authentication service routine call is a kind of bibliographic structure of Proc file system of correspondence.This Proc node tree is created by described port control modules, and this Proc node tree is configured by the authentication service software on upper strata, realizes the configuration to message authentication parameter particular by the node writing correspondence.Described authentication service software arranges interface, and keeper can be arranged as required.
Fig. 5 is the structure chart of a kind of Proc node tree in a kind of specific embodiment.See Fig. 5, wherein the value of each node is introduced with effect is following:
Enable: whether enable the startup mark that 802.1x agreement ethernet port controls, can control to this node write 1 or 0 the ethernet port control whether starting 802.1x.Being wherein the ethernet port control that 1 expression starts 802.1x, is that 0 expression does not start.Such as in a particular application: when upper strata authentication service software startup, to this node write 1, represent that opening ethernet port controls.Representing to this node write 0 when upper layer software (applications) exits stops ethernet port controlling, and when after stopping ether port controlling, just receives all messages.
The mark of Mode:802.1x protocol authentication pattern, can to the certification mode of this node write 0 or 1 control 802.1x agreement.1 is expressed as port authentication pattern, and 0 represents it is MAC certification mode.This certification mode is configured according to concrete business need by keeper.
AcceptMAC: for storing the mac address table that acquiescence accepts, can give tacit consent to receiving portion MAC Address to this node write mac address table.The MAC Address accepted for acquiescence can not by certification directly by this port.The value of this node is also configured by keeper.
DenyMAC: for storing the mac address table of acquiescence refusal, can give tacit consent to refusal Section MAC address to this node write mac address table.MAC Address for acquiescence refusal cannot pass through certification, and data also cannot pass through this port.The value of this node is also configured by keeper.
AuthMAC: for storing the authenticated MAC Address passed through, when certification mode is based on MAC pattern, each MAC Address by certification can exist in this node.After the message identifying of a client transmission have passed the certification of upper strata authentication service software, the MAC Address of this client (i.e. the source MAC of the message of this client transmission) can write in this node by upper strata authentication service software.
Ports: deposit the Proc node that each existing port is corresponding under this catalogue.Often open ether exchange chip and have multiple port, hypothesis has n port herein, is P0 ~ Pn respectively, the port mark whether certification is passed through of what the node of described P0 ~ Pn was deposited is each ether exchange chip of correspondence.The value of such as, node P1 in Fig. 5 is the port one mark whether certification is passed through.1 represents that this port is authenticated passes through, and 0 this port of expression not certification passes through.After the port of an ether exchange chip have passed the certification of upper strata authentication service software, upper strata authentication service software can in Proc node corresponding for the write of this mark.
In addition, in the present embodiment, why partial node deposits the port of certification, and first is because the port number of an ether exchange chip is limited, generally needs the port controlled to be 4.Second is because of for convenience of expansion, conveniently can store the privately owned attribute of each port.3rd is because more meet programmed logic.
Described verification function interface 302 calls for ether driver, the concrete opportunity of calling is: ether exchange chip often receives a message all can report the ether driver that ether drives layer by this message, after ether driver receives a message from ether exchange chip, determine type (whether being namely message identifying) and the source MAC (namely sending the MAC Address of the client of this message) of this message, and receive the port of ether exchange chip of this message, then described verification function interface is called, aforementioned determined information is input in verification function interface, verification function interface performs concrete handling process, the result whether receiving this message is returned to ether driver, the return value of such as verification function is 1 or 0.Wherein 1 represents this message of reception, and 0 expression abandons this message.
Described Fig. 6 is the concrete handling process schematic diagram after described verification function interface is called.See Fig. 6, this flow process comprises:
Step 601, first inquire about the value of Enable node that described Proc sets, judge whether that the ethernet port starting 802.1x controls, if it is perform step 602, otherwise verification function interface returns 1, namely notify that ether driver receives current message and is reported to corresponding upper level applications.
Step 602, inquire about the value of AcceptMAC node that described Proc sets, judge, in the mac address table that the acquiescence whether source MAC that inputs records at this AcceptMAC node accepts, if it is to return 1, otherwise execution step 603.
Step 603, inquire about the value of DenyMAC node that described Proc sets, judge, in the mac address table of the acquiescence the refusal whether source MAC that inputs records at this DenyMAC node, if it is to return 0, otherwise execution step 604.
Step 604, judge input type of message (i.e. Ether frame protocol-identifier) whether be EAPOL message authentication authorization and accounting message, if so, then perform step 605, otherwise execution step 606.
Step 605, determine whether EAPOL-Start message (the beginning message of authentication authorization and accounting message), if it is the port information of the ether exchange chip receiving this message is hidden in the afterbody of this message, then returns 1; Otherwise directly return 1.
The effect of this step is: for message identifying, the authentication service program on upper strata does not know the port accepts of this message by which ether exchange chip usually, therefore in the beginning message of message identifying, need the port information increasing the ether exchange chip receiving this message, authentication service program for upper strata carries out authentication processing, pass through if this port is certified, then the value of node corresponding for this port of the Ports catalogue set by described Proc by configuration order is written as 1 by authentication service program.
Step 606, inquire about the value of Mode node that described Proc sets, judge that current 802.1x protocol authentication pattern is port authentication pattern or MAC certification mode, if port authentication pattern, then inquire about the nodal value (namely 0 or 1) corresponding with the port source information of input under described Ports catalogue, and return this nodal value; If MAC certification mode, then perform step 607.
Step 607, inquire about the value of AuthMAC node that described Proc sets, judge, in the mac address table that the certification whether source MAC of input records at this AuthMAC node is passed through, if it is to return 1, otherwise return 0.
By above-mentioned process, described verification function interface returns to 0 or 1 to ether driver.If what return is 0, then represent and receive this message, ether driver then receives this message and uploads to corresponding program corresponding to this message of upper strata; If what return is 1, then represent and abandon this message, then ether driver abandons received corresponding message.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.