Summary of the invention
The main object of the present invention is to provide a kind of method of IPv4 and IPv6 compatible processing, it is intended to realize
IP address that the compatible processing of IPv4 and IPv6, quick search have stored and simply and quickly school
Test the legitimacy of IPv6 address, reduce system memory space simultaneously, improve system operating efficiency.
A kind of method that the invention provides IPv4 and IPv6 compatible processing, comprises the following steps:
The representation of definition internet protocol address is storage-type and display type, receives IP address word
Throttling information also judges that the version of described IP address is IPv4 or IPv6;
If IPv4, then corresponding long data are used uniquely to identify IPv4 address;If
IPv6, then according to preset transformational rule, be converted to the representation of IPv6 address by display type
Storage-type, and the storage-type IPv6 address assignment after changing is long IPv6 address;
Set up IP according to the IP mapping relations that preset IP address is corresponding with described long data and map pass
It is table, and described IP mapping relations table is stored.
Preferably, described according to preset transformational rule, the representation of IPv6 address is turned by display type
The step being changed to storage-type specifically includes:
With colon as cut-point, IPv6 address is divided into character string dimension;
Judge whether each character string dimension after segmentation contains four characters;
If it is not, then judge whether the character string dimension of discontented four is null character string;
If null character string, then the figure place by calculating fill needed for double colons representatives zero is mended
Neat character string dimension;
If not null character string, then before nonblank character, fill zero, by common nonblank character string array
Polishing four.
Preferably, the method for described IPv4 and IPv6 compatible processing further comprises the steps of:
Receive the inquiry request to IPv4 or the IPv6 address stored;
According to preset transformational rule, the representation of described IPv4 or IPv6 address is changed by storage-type
It is aobvious
Show type.
Preferably, described according to preset transformational rule, the representation of IPv6 address is turned by storage-type
The step being changed to display type specifically includes:
If IPv6 address is the storage-type without colon, then supplement colon;
The storage-type IPv6 address of band colon carries out redundancy zero-suppress process;
If at least two is contained even in the stem of the storage-type IPv6 address after zero-suppressing and processing and/or middle part
Continuous null string, described null string is with colon as cut-point, then by described continuous print zero word
Symbol string is reduced to double colon, and can only occur a double colon in an IPv6 address.
Preferably, described according to preset transformational rule, the representation of IPv6 address is turned by display type
Also include after being changed to the step of storage-type:
The legitimacy of verification IPv6 address.
Preferably, the step of the legitimacy of described verification IPv6 address specifically includes:
With colon as cut-point, the storage-type IPv6 address of band colon is divided into character string dimension;
Whether the length judging described character string dimension is 8;
If it is not, the most described IPv6 address is illegal, it is not stored;
The each character string in the most described character string dimension is verified, it may be judged whether meet
Preset verification rule;
If there being arbitrary character string to be unsatisfactory for preset verification rule, the most described IPv6 address is illegal, the most right
It stores.
Present invention also offers the device of a kind of IPv4 and IPv6 compatible processing, including:
IP address receiver module, is storage-type and display type for defining the representation of IP address, connects
Receive IP address byte stream information and judge that the version of described IP address is IPv4 or IPv6;
IPv4 address module, for when the version of the IP address received is IPv4, making IPv4 address
Uniquely identify by corresponding long data;
IPv6 address module, for when the version of the IP address received is IPv6, according to preset conversion
Rule, is converted to storage-type by the representation of IPv6 address by display type, and by after conversion
Storage-type IPv6 address assignment is long IPv6 address;
IPv4 and IPv6 compatible processing module, for according to preset IP address and described long data
Corresponding IP mapping relations set up IP mapping relations table, and are stored by described IP mapping relations table.
Preferably, described IPv6 address module specifically includes:
IPv6 address storage-type unit, for according to preset transformational rule, by the expression shape of IPv6 address
Formula is converted to storage-type by display type;
IPv6 address assignment unit, the storage-type IPv6 address assignment after changing is long IP
V6 address;
Wherein, described IPv6 address storage-type unit specifically for:
With colon as cut-point, IPv6 address is divided into character string dimension;
Judge whether each character string dimension after segmentation contains four characters;
If it is not, then judge whether the character string dimension of discontented four is null character string;
If null character string, then the figure place by calculating fill needed for double colons representatives zero is mended
Neat character string dimension;
If not null character string, then before nonblank character, fill zero, by common nonblank character string array
Polishing four.
Preferably, the device of described IPv4 and IPv6 compatible processing also includes:
IP enquiry module, for receiving the inquiry request to IPv4 or the IPv6 address stored;According to
Preset transformational rule, is converted to show by storage-type by the representation of described IPv4 or IPv6 address
Show type.
Preferably, described according to preset transformational rule, the representation of IPv6 address is turned by storage-type
The step being changed to display type specifically includes:
If IPv6 address is the storage-type without colon, then supplement colon;
The storage-type IPv6 address of band colon carries out redundancy zero-suppress process;
If at least two is contained even in the stem of the storage-type IPv6 address after zero-suppressing and processing and/or middle part
Continuous null string, described null string is with colon as cut-point, then by described continuous print zero word
Symbol string is reduced to double colon, and can only occur a double colon in an IPv6 address.
Preferably, the device of described IPv4 and IPv6 compatible processing also includes:
IPv6 address check module, for verifying the legitimacy of IPv6 address.
Preferably, described IPv6 address check module specifically for:
With colon as cut-point, the storage-type IPv6 address of band colon is divided into character string dimension;
Whether the length judging described character string dimension is 8;
If it is not, the most described IPv6 address is illegal, it is not stored;
The each character string in the most described character string dimension is verified, it may be judged whether meet
In advance
Put verification rule;
If there being arbitrary character string to be unsatisfactory for preset verification rule, the most described IPv6 address is illegal, the most right
It stores.
The present invention by two kinds of representations of definition IP address be display type and storage-type, to IPv4 ground
Location carries out long mark, IPv6 address carries out assignment long, IPv6 address display type and depositing
The method mutually changed and verify IPv6 address legitimacy accurately and efficiently between storage type, it is achieved
The compatible processing of IPv4 and IPv6, reduce system memory space, improve system operating efficiency
Beneficial effect.
Detailed description of the invention
Technical scheme is further illustrated below in conjunction with Figure of description and specific embodiment.Should
Working as understanding, specific embodiment described herein, only in order to explain the present invention, is not used to limit
Determine the present invention.
Show with reference to the method first embodiment flow process that Fig. 1, Fig. 1 are IPv4 and IPv6 compatible processing of the present invention
It is intended to.As it is shown in figure 1, the method for IPv4 and IPv6 compatible processing of the present invention includes:
Step S01, the representation of definition IP address are storage-type and display type;
In daily use, IPv6 address generally uses character string to represent;In follow-up operation,
Because relate to IPv6 address compare, the operation such as IPv6 address realm selection, so to IPv6 address
Storage format have certain requirement.In a preferred embodiment, IPv6 address is " 2009
:: 2010 ", for convenience of subsequent operation, it is expressed as " 2009:0000:0000:0000:00
00:0000:0000:2010 " form, or remove " the 2009000000000000000 of colon
0000000002010 " form, just can carry out the conjunction of IP size according to described complete presentation format
Reason compares the correct selection with IP scope.The IP address of definition " 2009::2010 " this classification
Representation is expression type or display type IP address, defines " 2009:0000:0000:0000:00
00:0000:0000:2010 " storage-type that IP address representation is band colon of this classification
Or complete type IP address, definition " 20090000000000000000000000002010 " this
The IP address representation of classification is the storage-type without colon or complete type IP address.
Similar, for IPv4 address, in a preferred embodiment, when IPv4 address display type
During for " 10.46.36.29 ", the storage-type of its band colon is " 010:046:036:029 ",
Storage-type without colon is " 010046036029 ".
Step S02, receive IP address byte stream information and judge the version of described IP address be IPv4 or
IPv6;If IPv4, then perform step S03;If IPv6, then perform step S04;
Receive IP address byte stream information, distinguish that the version of received IP address is IPv6 or IPv4
.In a preferred embodiment, described IP byte stream information is a string byte stream, described byte
Stream there is the special field representing IP version can be used to identify the version of IP.Therefore, it is very easy to
The version distinguishing received IP address is IPv6 or IPv4.
Step S03, IPv4 address use corresponding long data uniquely identify;
If being IPv4 address through judging the IP address word received throttling, owing to IPv4 address uses
32 binary codings also use 4 byte representations, and IPv4 address is typically directly by long table
Show or by string representation, the long of correspondence therefore can be used uniquely to identify, to IP
The process of v4 address is the most fairly simple.If IPv4 address is directly represented by long, the most directly use
Described long uniquely identifies;
If IPv4 address is by string representation, then described IPv4 address is used corresponding long data
Uniquely identify.So purpose of operation is easy for the follow-up compatible storage with IPv6 address.
Step S04, the representation of IPv6 address is converted to storage-type by display type, and will be after conversion
Storage-type IPv6 address assignment be long IPv6 address;
Because in follow-up operation, relate to IPv6 address compare, the operation such as IPv6 address realm selection
, for the ease of operation, described IPv6 address table is shown as storage-type;Owing to IPv6 address uses
16 byte representations, therefore directly cannot represent by an integer or long.8 table of bytes
The maximum of the tape symbol long shown is 9223372036854775807, at user's routine use
Actual environment under, such as Metropolitan Area Network (MAN) or the network user of campus network, the use number of IPv6 address
Mesh is not over the biggest value, if defining a unique length therefore to each IPv6 address
Integer goes to represent, then can realize being uniformly processed of IPv6 address and IPv4 address;Preferred one
In embodiment, the long value of IPv6 address is by systematic unity assignment.
Step S05, set up according to preset IP address IP mapping relations corresponding with described long data
IP mapping relations table, and described IP mapping relations table is stored.
The uniqueness corresponding with described long numerical value for ensureing IPv4 with IPv6 address, according to preset
IP address IP mapping relations corresponding with described long data set up IP mapping relations table, and will
Described IP mapping relations table stores.System often receives an IPv6 address, just carries out an assignment
。
In a preferred embodiment, by definition IPID(Identity, identification code) realize by
IPv4 address uses corresponding long data uniquely to identify, simultaneously by IPv6 address assignment
Long.Owing to the expression scope of IPv4 address is: 0.0.0.0 ~ 255.255.255.255,
Big IPv4 address is 255.255.255.255, and the integer representation of its correspondence is 4294967295,
Long data corresponding to IPv4 address are maximum not over ten one-bit digitals, therefore by 1010With
On numeral in order to represent IPv6 address.For ensureing IPv4 address, IPv6 address and long number
According to one_to_one corresponding, numeric representation corresponding to IPv6 address is by systematic unity assignment.
In a preferred embodiment, internal memory increases a Hash mapping table, increases in data base
Add the mapping table T_FCS_IPMap of an IP address character string and IP long.With reference to Fig. 2, figure
2 is establishment IP mapping relations table T_FCS_IPMap partial schematic diagram in Mysql data base.Such as Fig. 2
Shown in, according to the IP mapping relations table T_FCS_IPMap created in Mysql data base, it is easy to
Draw IPv6 address and corresponding IPID value.Described Mysql is a kind of associated data library management
System, linked database saves the data in different tables of data rather than by all data
It is placed in a big warehouse.The speed of service the system that improves which adds system are run
Time motility.The Mysql of Fig. 2
The IP mapping relations table created in data base, is by from the side increased by IPv6 address assignment IPID
Formula realizes;In a preferred embodiment, hash algorithm can be used long for IPv6 address assignment
Integer.Described IP mapping relations are stored concurrently in internal memory and data base.It is stored in internal memory
Being fast calling and calculating for the ease of system, system is by periodic cleaning internal memory, and is stored in
Data base then will permanent preserve.
The method of IPv4 and IPv6 compatible processing of the present invention by two kinds of representations of definition IP address is
Display type and storage-type, IPv4 address is carried out long mark, that IPv6 address carries out assignment is long
Integer, mutually changing and verifying IP accurately and efficiently between IPv6 address display type and storage-type
The method of v6 address legitimacy, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system
Memory space, the beneficial effect of raising system operating efficiency.
It is according to preset conversion rule with reference to Fig. 3, Fig. 3 in the method for IPv4 and IPv6 compatible processing of the present invention
Then, the representation of IPv6 address is converted to the signal of storage-type one embodiment flow process by display type
Figure.As it is shown on figure 3, in the method for IPv4 and IPv6 compatible processing of the present invention, according to preset conversion
Rule, includes the step that the representation of IPv6 address is converted to storage-type by display type:
Step S11, with colon as cut-point, IPv6 address is divided into character string dimension;
IPv6 address table is shown as storage-type first have to carry out cutting operation, by colon by IPv6 address
String segmentation.In a preferred embodiment, described IPv6 address is " 123::321 ",
Then it is divided into character string dimension { " 123 ", " ", " 321 " };
Step S12, judge segmentation after each character string dimension in whether contain four characters;If so,
Then represent that described IPv6 address is storage-type;If it is not, then perform step S13;
Judge whether each string data group after segmentation contains four characters, this is because IPv6
Address use 128 binary codings, storage-type representation IPv6 address segmentation after every
Individual string data group comprises 4 characters, if each character string dimension after Fen Ge all contains
Four characters, then it represents that described IPv6 address is storage-type;
Whether step S13, the character string dimension of discontented four of judgement are null character string;If null character string
, then step S14 is performed;If not null character string, then perform step S15;
After the segmentation of IPv6 address, the string data group of discontented four is done the operation filling cover, will
Discontented four character strings fill neat four of spot patch.The character string dimension of described discontented four has two kinds
Situation: null character string and common nonblank character string;
Step S14, by calculate double colons represent required fill zero figure place carry out polishing character string
Array;
If the character string dimension of described discontented four has null character string, then it represents that encounter double colon "
:: ", at this time, it may be necessary to represent several zero-bit by the double colons of calculating one, double colons are reduced
Become " 0000: " combination of length-specific.In a preferred embodiment, described display type IPv
6 addresses are " 123::321 ", the character string dimension after segmentation be " 123 ", " ", " 3
21 " }, the character string dimension a length of 3 after described segmentation;And a display without double colons
Type IPv6 address such as " 1:2:3:4:5:6:7:8 ", the character string dimension a length of 8 after segmentation;
Therefore, a colon in described IPv6 address " 123::321 " represents the number of null character and is
: (8+1-3=6), therefore, the null character string in described IPv6 address " 123::321 " this
Null character string " " can be reduced into " 0000:0000:0000:0000:0000:0000: ";
Step S15, filling zero before nonblank character, by common nonblank character string array polishing four.
If the character string of described discontented four is common nonblank character string, then only need to be before nonblank character
Fill zero, by common nonblank character string array polishing four.In a preferred embodiment
, described display type IPv6 address " 123::321 " give after string data group { " 123 "
, " ", " 321 " } in common nonblank character string " 123 " and " 321 ", polishing four
After, it is " 0123 " and " 0321 ";Thus the most described display type IPv6 address " 12
3::321 " the storage-type IPv6 address that is converted into band colon is: " 0123:0000:0000:000
0:0000:0000:0000:0321”。
The method of IPv4 and IPv6 compatible processing of the present invention is by being expressed as depositing by display type by IPv6 address
The method of storage type, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system memory space
, improve system operating efficiency beneficial effect.
Show with reference to method the second embodiment flow process that Fig. 4, Fig. 4 are IPv4 and IPv6 compatible processing of the present invention
It is intended to.As shown in Figure 4, the method for IPv4 and IPv6 compatible processing of the present invention also includes:
Step S06, the reception inquiry request to IPv4 or the IPv6 address stored;According to preset conversion
Rule, is converted to display type by the representation of described IPv4 or IPv6 address by storage-type.
Because IPv4 and the IPv6 address stored has done following process the most respectively: by IPv4
Address uses corresponding long data uniquely to identify, by IPv6 address assignment long,
And storage time, it is ensured that IPv4 and IPv6 address compatibility storage while, in order to save byte and
Memory space all uses the storage-type IPv4 without colon and IPv6 address;And when user uses,
Ordinary practice use display type IP address, because display type IP address is easy, therefore, in order to
User is facilitated to need, IPv4 and IPv6 that inquiry has stored
During address, the representation of described IPv4 and IPv6 address is converted to display type by storage-type again
。
The method of IPv4 and IPv6 compatible processing of the present invention is by receiving IPv4 or IPv6 stored
The inquiry request of address, according to preset transformational rule
The method that the representation of described IPv4 or IPv6 address is converted to display type by storage-type, real
Show the compatible processing of IPv4 and IPv6 address, reduce system memory space, the operation of raising system
The beneficial effect of efficiency.
It is in the method for IPv4 and IPv6 compatible processing of the present invention with reference to Fig. 5, Fig. 5, according to preset conversion
Rule, is converted to display type one embodiment flow process by the representation of IPv6 address by storage-type and shows
It is intended to.As it is shown in figure 5, in the method for IPv4 and IPv6 compatible processing of the present invention, according to preset turn
Change rule, the step that the representation of IPv6 address is converted to display type by storage-type is specifically wrapped
Include:
Step S31, judge that whether described IPv6 address is the storage-type of band colon;If it is not, then perform step
Rapid S32;The most then perform step S33;
Step S32, supplementary colon, be shown as the storage-type of band colon by described IPv6 address table;
If IPv6 address is the storage-type without colon, then require supplementation with colon, will emit according to 4 segmentations
Number supplementing into, this is for the follow-up needs that IPv6 is converted to display type by storage-type;
Step S33, the redundancy that carried out the storage-type IPv6 address of band colon are zero-suppressed process;
Because the representation of display type IPv6 address is more succinct, it is therefore desirable to by storage-type IPv6 ground
In the character string of location, the zero of redundancy removes.In described IPv6 address character string, the zero of redundancy has two classes,
One class is: be all the null character string of zero in IPv6 address character string;Another kind of: IPv6 address
Nonblank character string common in character string is positioned at the zero of character string front end.Preferably implement one
In example, the storage-type IPv6 address of described band colon is " 0123:0000:0000:0000:0000
: 0000:0000:0321 ", it is reduced to after removing in described IPv6 address character string the zero of redundancy
“123:0:0:0:0:0:0:321”;
Step S34, judge to zero-suppress the stem of storage-type IPv6 address after processing and/or whether middle part contains
There is at least two continuous print null string;If containing at least two continuous print null string, then holding
Row step S35;
Step S35, described continuous print null string is reduced to double colon, and in an IPv6 address
One double colon can only occur.
Judge whether stem and/or the middle part of described IPv6 address character string contain at least two continuous print zero
Character string, described continuous print null string is with colon as cut-point;If described IPv6 address character
At least two continuous print null string, or the head of described IPv6 address character string are contained in the middle part of string
Portion contains at least two
Individual continuous print null string, or the stem of described IPv6 address character string and middle part all contain two
Continuous print null string, then be reduced to double colon by described continuous print null string, but double colon
Same IPv6 address character string can only occur once.
In a preferred embodiment, the IPv6 address character string after zero-suppressing for " 123:0:0:0:0:0:
0:321 ", 6 continuous print null strings in the middle part of described IPv6 address character string are reduced to double
Colon ":: ", obtain display type IPv6 address character string " 123::321 ".
In a preferred embodiment, the IPv6 address character string after zero-suppressing for " 0:0:0:0:0:0:0:
1 ", 7 continuous print null strings of described IPv6 address character string stem are reduced to double colon
":: ", obtains display type IPv6 address character string ":: 1 ".
In a preferred embodiment, the IPv6 address character string after zero-suppressing for " 0:0:0:1:0:0:0:
1 ", by described IPv6 address character string stem or 3 continuous with number null strings at middle part
Be reduced to double colon ":: ", obtain display type IPv6 address character string ":: 1:0:0:0:1 " or
“0:0:0:1::1”.But described IPv6 address character string stem and middle part can not be removed simultaneously
3 continuous print null strings, because double colon can only occur once in IPv6 address.
The method of IPv4 and IPv6 compatible processing of the present invention by by the representation of IPv6 address by storing
Type is converted to the method for display type, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system
System memory space, the beneficial effect of raising system operating efficiency.
Method the 3rd embodiment flow process signal with reference to Fig. 6, Fig. 6 IPv4 and IPv6 of the present invention compatible processing
Figure.As shown in Figure 6, the method for IPv4 and IPv6 compatible processing of the present invention also includes:
Step S07, the legitimacy of verification IPv6 address.
The IPv6 address of user's input may be illegal IPv6 address composition, and only on IPv6 ground
In the case of location is legal, IPv6 is carried out follow-up operation and storage is just of practical significance, therefore
The legitimacy of IPv6 address is verified.
The method of IPv4 and IPv6 compatible processing of the present invention by the method for verification IPv6 address legitimacy,
Achieve the compatible processing of IPv4 and IPv6 address, reduce system memory space, raising system behaviour
Make the beneficial effect of efficiency
With reference to the conjunction verifying IPv6 address in the method for Fig. 7, Fig. 7 IPv4 and IPv6 of the present invention compatible processing
Method one embodiment schematic flow sheet.As it is shown in fig. 7, IPv4 and IPv6 compatible processing of the present invention
Side
In method, the legitimacy of verification IPv6 address specifically includes following steps:
Step S21, with colon as cut-point, the storage-type IPv6 address of band colon is divided into character string
Array;
Before judging that IPv6 address is the most legal, first described IPv6 address table should be shown as band colon
Storage-type;With colon as cut-point, the storage-type IPv6 address of band colon is split,
To character string dimension;
Whether step S22, the length judging described character string dimension are 8;If it is not, then perform step S2
3;The most then perform step S24;
Step S23, described IPv6 address are illegal, do not store it;
Because IPv6 address uses 128 binary systems to encode, each address can be split according to colon
Become 8 integers;So, if the character string obtained after the storage-type IPv6 address of band colon is split
The length of array should be 8;If the character string dimension length obtained behind segmentation storage-type IPv6 address
Not being 8, the most described IPv6 address is the most illegal;To illegal IPv6 address, do not deposit
Storage;
Step S24, each character string in described character string dimension is verified, it may be judged whether meet
Preset verification rule;If there being arbitrary character string to be unsatisfactory for preset verification rule, then perform step S2
3: described IPv6 address is illegal, does not stores it;If all character strings are satisfied by preset
Verification rule, then perform step S25;
Step S25, described IPv6 address are legal;
If the character string dimension length that obtains is 8 behind segmentation storage-type IPv6 address, then every to after segmentation
Individual character string dimension verifies, it may be judged whether meet preset verification rule.The most real one
Executing in example, described preset verification rule is: define a simple regular expression: " ([0-9
A-Fa-f] { Isosorbide-5-Nitrae }) ", the numeral of coupling 0 to 9 and the letter of a ~ f, length is up to 4;Only
Each item of each character string dimension after segmentation meets verification rule, the IPv6 address of input
It it is just legal IPv6 address format.
The method of IPv4 and IPv6 compatible processing of the present invention by the method for verification IPv6 address legitimacy,
Achieve the compatible processing of IPv4 and IPv6 address, reduce system memory space, raising system behaviour
Make the beneficial effect of efficiency.
Show with reference to the device first embodiment structure that Fig. 8, Fig. 8 are IPv4 and IPv6 compatible processing of the present invention
It is intended to.As shown in Figure 8, the device of IPv4 and IPv6 compatible processing of the present invention includes:
IP address receiver module 01, is storage-type and display type for defining the representation of IP address,
Receive IP address byte stream information and judge that the version of described IP address is IPv4 or IPv6;
IPv4 address module 02, for when the version of the IP address received is IPv4, by IPv4 address
The long data using correspondence uniquely identify;
IPv6 address module 03, for when the version of the IP address received is IPv6, according to preset turn
Change rule, the representation of IPv6 address is converted to storage-type by display type, and by after conversion
Storage-type IPv6 address assignment be long IPv6 address;
IPv4 and IPv6 compatible processing module 04, for according to preset IP address and described long number
Set up IP mapping relations table according to corresponding IP mapping relations and described IP mapping relations table is stored.
The device of IPv4 and IPv6 compatible processing of the present invention by two kinds of representations of definition IP address is
Legitimacy and the IPv6 address of display type and storage-type, accurately and efficiently verification IPv6 address show
Mutually conversion between type and storage-type, IPv4 address is carried out long mark, IPv6 address
The method carrying out assignment long, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system
System memory space, the beneficial effect of raising system operating efficiency.
It it is IPv6 address module one in the device of IPv4 and IPv6 compatible processing of the present invention with reference to Fig. 9, Fig. 9
Example structure schematic diagram.As it is shown in figure 9, in the device of IPv4 and IPv6 compatible processing of the present invention
, IPv6 address module 03 specifically includes:
IPv6 address storage-type unit 031, for according to preset transformational rule, by the expression of IPv6 address
Form is converted to storage-type by display type;
IPv6 address assignment unit 022, the storage-type IPv6 address assignment after changing is long
IPv6 address;
Described IPv6 address storage-type unit 031 specifically for:
With colon as cut-point, IPv6 address is divided into character string dimension;
Judge whether each character string dimension after segmentation contains four characters;
If it is not, then judge whether the character string dimension of discontented four is null character string;
If null character string, then the figure place by calculating fill needed for double colons representatives zero is mended
Neat character string dimension;
If not null character string, then before nonblank character, fill zero, by common nonblank character string array
Polishing four.
The device of IPv4 and IPv6 compatible processing of the present invention is by according to preset transformational rule, by IPv6 ground
The representation of location is converted to storage-type by display type, and by the storage-type IPv6 address after conversion
It is entered as long
The method of IPv6 address, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system storage
Space, the beneficial effect of raising system operating efficiency.
It is device second example structure of IPv4 and IPv6 compatible processing of the present invention with reference to Figure 10, Figure 10
Schematic diagram.As shown in Figure 10, the device of IPv4 and IPv6 compatible processing of the present invention also includes:
IP enquiry module 05, for receiving the inquiry request to IPv4 or the IPv6 address stored;Root
According to preset transformational rule, the representation of described IPv4 or IPv6 address is converted to by storage-type
Display type.
The representation of described IPv6 address is converted to display type by storage-type by described IP enquiry module 05
Step specifically include:
If IPv6 address is the storage-type without colon, then supplement colon;
The storage-type IPv6 address of band colon carries out redundancy zero-suppress process;
If at least two is contained at the stem of the storage-type IPv6 address character string after zero-suppressing and/or middle part
Continuous print null string, described null string is with colon as cut-point, then by described continuous print zero
Character string is reduced to double colon, and can only occur a double colon in an IPv6 address.
The device of IPv4 and IPv6 compatible processing of the present invention by by the representation of IPv4 and IPv6 by depositing
Storage type is converted to the method for display type, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction
System memory space, the beneficial effect of raising system operating efficiency.
It is device the 3rd example structure of IPv4 and IPv6 compatible processing of the present invention with reference to Figure 11, Figure 11
Schematic diagram.As shown in figure 11, the device of IPv4 and IPv6 compatible processing of the present invention also includes:
IPv6 address check module 06, for verifying the legitimacy of IPv6 address.
Described IPv6 address check module 06 specifically for:
With colon as cut-point, the storage-type IPv6 address of band colon is divided into character string dimension;
Whether the length judging described character string dimension is 8;
If it is not, the most described IPv6 address is illegal, it is not stored;
The each character string in the most described character string dimension is verified, it may be judged whether meet
Preset verification rule;
If there being arbitrary character string to be unsatisfactory for preset verification rule, the most described IPv6 address is illegal, the most right
It stores.
The device of IPv4 and IPv6 compatible processing of the present invention by the method for verification IPv6 address legitimacy,
Realize
The compatible processing of IPv4 and IPv6 address, reduce system memory space, improve system operation effect
The beneficial effect of rate.
The present invention is display type and storage-type, precise and high efficiency by two kinds of representations of definition IP address
Mutual conversion between legitimacy and IPv6 address display type and the storage-type of verification IPv6 address, ground
, IPv4 address is carried out long mark, IPv6 address carries out assignment long and to IP address
The method carrying out inquiring about, it is achieved that the compatible processing of IPv4 and IPv6 address, reduction system storage
Space, the beneficial effect of raising system operating efficiency.
The foregoing is only the preferred embodiments of the present invention, not thereby limit its scope of the claims, every
Utilize equivalent structure or equivalence flow process conversion that description of the invention and accompanying drawing content made, directly
Or indirectly it is used in other relevant technical fields, the most in like manner it is included in the patent protection of the present invention
In the range of.