CN103297554B - The method and device of IPv4 and IPv6 compatible processing - Google Patents

The method and device of IPv4 and IPv6 compatible processing Download PDF

Info

Publication number
CN103297554B
CN103297554B CN201210278733.2A CN201210278733A CN103297554B CN 103297554 B CN103297554 B CN 103297554B CN 201210278733 A CN201210278733 A CN 201210278733A CN 103297554 B CN103297554 B CN 103297554B
Authority
CN
China
Prior art keywords
address
ipv6
ipv6 address
type
ipv4
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201210278733.2A
Other languages
Chinese (zh)
Other versions
CN103297554A (en
Inventor
唐兵兵
范书田
黄传冠
丁柏
刘万慧
元绍华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Zhongxing Communication Technology Service Co., Ltd.
Original Assignee
Shenzhen Zhongxing Communication Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Zhongxing Communication Technology Service Co Ltd filed Critical Shenzhen Zhongxing Communication Technology Service Co Ltd
Priority to CN201210278733.2A priority Critical patent/CN103297554B/en
Publication of CN103297554A publication Critical patent/CN103297554A/en
Application granted granted Critical
Publication of CN103297554B publication Critical patent/CN103297554B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention discloses a kind of method of IPv4 and IPv6 compatible processing, and the method comprises the following steps: definition IP address is storage-type and display type, receives IP address byte stream information and judges IP address version;If IPv4, then corresponding long data are used uniquely to identify IPv4 address;If IPv6, then according to preset transformational rule, the representation of IPv6 address is converted to storage-type assignment long data by display type;Set up IP mapping relations table according to the IP mapping relations that preset IP address is corresponding with long data and IP mapping relations table is stored.Invention additionally discloses the device of a kind of IPv4 and IPv6 compatible processing.By the present invention in that the method representing IPv4 and IPv6 with unique long, it is achieved that IPv4 and IPv6 compatible processing, reduction system memory space, the beneficial effect of raising system operating efficiency.

Description

The method and device of IPv4 and IPv6 compatible processing
Technical field
The present invention relates to technical field of the computer network, particularly relate to a kind of IPv4 and IPv6 compatible processing Method and device.
Background technology
At present, the IP(Internet Protocol that we use, Internet protocol) address is most Number is IPv4(Version 4, and version number is 4), IPv4 address uses 32 binary codings , i.e. 4 bytes, every 8 is one group;In routine use, IPv4 address dotted decimal notation Represent, such as address: 10.40.183.7.The demonstration of IPv4 address table is enclosed and is: 0.0.0.0 ~ 255.2 55.255.255。
At most can only use more than 40 hundred million IP addresses due to IPv4 address, can not meet far away and day by day increase The demand of global interconnection network users, so having formulated IPv6(Version 6, version number is 6) agreement.The length of IPv6 address is 4 times of IPv4 address size, and IPv6 address uses 128 Binary coding, i.e. 16 bytes, represent to get up also complicated than IPv4, IPv6 address basic Expression way is X:X:X:X:X:X:X:X, and wherein X is 4 hexadecimal integers, each whole Number comprise 4 numerals, each numeral is represented by 4 bits, each address include 8 whole Number, 128 altogether.
Such as program or data base in the system relating generally to IP address process, for the guarantor of IPv4 address There is two ways, a kind of for character string storage (such as 10.40.183.7), a general bit stealing One byte, at most takies 15 bytes;Another kind is long or integer storage, it is only necessary to 8 Or 4 bytes.And the IPv6 address of 16 bytes is in program or data base, generally use character String represents, such as 2009:ABCD:1234:5678:789F:0123:2010:2012, because common Integer type cannot complete representation IPv6.According to this method for expressing, at most need 39 Byte (for mixing expression formula, at most need 45 bytes).If system needs process relatively Many IP information, this storage mode can take more space undoubtedly, especially grasp data base When making character string type field (such as sort, packet etc.), compare operation integer field, efficiency Also can be much lower;System big for data volume, that efficiency requirements is high, this is the most individual the biggest Bottleneck.Especially in a system needing the storage of compatible IPv4 and IPv6 address, how to realize Its compatible processing, is a very important problem.If an IP, both it was likely to be IPv4 Being likely to be again IPv6, we are by IPv4 and IPv6 classification storage, and such as IPv4 uses integer, And IPv6 uses character string, this can increase Operating Complexity and difficulty, and processes the most inconsistent ;If by unified for IPv4 and IPv6 according to string processing, then storage occupancy can be caused to increase , operating efficiency reduce ill effect.How to realize compatible storage and the inquiry of IPv4 and IPv6 , and the system that can guarantee that reasonably stores occupation rate and efficient treatment effeciency, is that pendulum is in our face A front difficult problem.
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.
Accompanying drawing explanation
Fig. 1 is the method first embodiment schematic flow sheet of IPv4 and IPv6 compatible processing of the present invention;
Fig. 2 is establishment IP mapping relations table T_FCS_IPMap partial schematic diagram in Mysql data base;
Fig. 3 is in the method for IPv4 and IPv6 compatible processing of the present invention, according to preset transformational rule, by I The representation of Pv6 address is converted to storage-type one embodiment schematic flow sheet by display type;
Fig. 4 is method the second embodiment schematic flow sheet of IPv4 and IPv6 compatible processing of the present invention;
Fig. 5 is in the method for IPv4 and IPv6 compatible processing of the present invention, according to preset transformational rule, by I The representation of Pv6 address is converted to display type one embodiment schematic flow sheet by storage-type;
Method the 3rd embodiment schematic flow sheet of Fig. 6 IPv4 and IPv6 of the present invention compatible processing;
The legitimacy one verifying IPv6 address in the method for Fig. 7 IPv4 and IPv6 of the present invention compatible processing is implemented Example schematic flow sheet;
Fig. 8 is the device first embodiment structural representation of IPv4 and IPv6 compatible processing of the present invention;
Fig. 9 be IPv4 and IPv6 compatible processing of the present invention device in IPv6 address module first embodiment knot Structure schematic diagram;
Figure 10 is device the second example structure schematic diagram of IPv4 and IPv6 compatible processing of the present invention;
Figure 11 is device the 3rd example structure schematic diagram of IPv4 and IPv6 compatible processing of the present invention.
The realization of the object of the invention, functional characteristics and advantage will in conjunction with the embodiments, do referring to the drawings into one Step explanation.
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.

Claims (8)

1. the method for an IPv4 and IPv6 compatible processing, it is characterised in that comprise the following steps:
The representation of definition internet protocol address is storage-type and display type, receives the throttling of IP address word 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, the representation of IPv6 address is converted to storage-type by display type, and will turn Storage-type IPv6 address assignment after changing is long IPv6 address;
IP mapping relations are set up according to the IP mapping relations that preset IP address is corresponding with described long data Table, and described IP mapping relations table is stored;
Described according to preset transformational rule, the representation of IPv6 address is converted to storage-type by display type Also include after step:
The legitimacy of verification IPv6 address;
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 pre- Put verification rule;
If there being arbitrary character string to be unsatisfactory for preset verification rule, the most described IPv6 address is illegal, does not enters it Row storage;
Wherein, the IP address of display type specifically includes: comprises null character string or omits non-NULL in every piece of digital The IP address of zero before character;The IP address of storage-type specifically includes: that every piece of digital is filled after zero is complete IP address.
The method of IPv4 and IPv6 compatible processing the most according to claim 1, it is characterised in that described According to preset transformational rule, the step that by display type, the representation of IPv6 address is converted to storage-type is concrete Including:
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 carrys out polishing Character string dimension;
If not null character string, then before nonblank character, fill zero, common nonblank character string array is mended Qi Siwei.
The method of IPv4 and IPv6 compatible processing the most according to claim 1, it is characterised in that also wrap Include step:
Receive the inquiry request to IPv4 or the IPv6 address stored;
According to preset transformational rule, be converted to show by storage-type by the representation of described IPv4 or IPv6 address Show type.
The method of IPv4 and IPv6 compatible processing the most according to claim 3, it is characterised in that described According to preset transformational rule, the step that by storage-type, the representation of IPv6 address is converted to display type is concrete Including:
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 it is continuous that at least two is contained at the stem of the storage-type IPv6 address after zero-suppressing and processing and/or middle part Null string, described null string with colon as cut-point, then by described continuous print null string reduce For double colons, and a double colon can only occur in an IPv6 address.
5. the device of an IPv4 and IPv6 compatible processing, it is characterised in that including:
IP address receiver module, is storage-type and display type for defining the representation of IP address, receives IP Address byte stream information also judges 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, it is right to be used IPv4 address The long data answered uniquely identify;
IPv6 address module, for when the version of the IP address received is IPv6, according to preset transformational rule, The representation of IPv6 address is converted to storage-type by display type, and by the storage-type IPv6 address after conversion It is entered as long IPv6 address;
IPv4 and IPv6 compatible processing module, for corresponding with described long data according to preset IP address IP mapping relations set up IP mapping relations table, and described IP mapping relations table is stored;
It is characterized in that, also include:
IPv6 address check module, for verifying the legitimacy of IPv6 address;
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 pre- Put verification rule;
If there being arbitrary character string to be unsatisfactory for preset verification rule, the most described IPv6 address is illegal, does not enters it Row storage;
Wherein, the IP address of display type specifically includes: comprises null character string or omits non-NULL in every piece of digital The IP address of zero before character;The IP address of storage-type specifically includes: that every piece of digital is filled after zero is complete IP address.
The device of IPv4 and IPv6 compatible processing the most according to claim 5, it is characterised in that described IPv6 address module specifically includes:
IPv6 address storage-type unit, for according to preset transformational rule, by the representation of IPv6 address by Display type is converted to storage-type;
IPv6 address assignment unit, the storage-type IPv6 address assignment after changing is long IPv6 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 carrys out polishing Character string dimension;
If not null character string, then before nonblank character, fill zero, common nonblank character string array is mended Qi Siwei.
The device of IPv4 and IPv6 compatible processing the most according to claim 5, it is characterised in that also wrap Include:
IP enquiry module, for receiving the inquiry request to IPv4 or the IPv6 address stored;According to preset Transformational rule, is converted to display type by the representation of described IPv4 or IPv6 address by storage-type.
The device of IPv4 and IPv6 compatible processing the most according to claim 7, it is characterised in that described According to preset transformational rule, the step that by storage-type, the representation of IPv6 address is converted to display type is concrete Including:
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 it is continuous that at least two is contained at the stem of the storage-type IPv6 address after zero-suppressing and processing and/or middle part Null string, described null string with colon as cut-point, then by described continuous print null string reduce For double colons, and a double colon can only occur in an IPv6 address.
CN201210278733.2A 2012-03-02 2012-08-07 The method and device of IPv4 and IPv6 compatible processing Active CN103297554B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210278733.2A CN103297554B (en) 2012-03-02 2012-08-07 The method and device of IPv4 and IPv6 compatible processing

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201210052718 2012-03-02
CN2012100527186 2012-03-02
CN201210052718.6 2012-03-02
CN201210278733.2A CN103297554B (en) 2012-03-02 2012-08-07 The method and device of IPv4 and IPv6 compatible processing

Publications (2)

Publication Number Publication Date
CN103297554A CN103297554A (en) 2013-09-11
CN103297554B true CN103297554B (en) 2016-09-28

Family

ID=49097856

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210278733.2A Active CN103297554B (en) 2012-03-02 2012-08-07 The method and device of IPv4 and IPv6 compatible processing

Country Status (1)

Country Link
CN (1) CN103297554B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105187568B (en) * 2015-08-12 2018-09-25 广东睿江云计算股份有限公司 A kind of IPV4 address conversion methods and device
CN105827530B (en) * 2016-03-11 2019-04-16 中国互联网络信息中心 A kind of IP binary chop method and device of compatible IPV4/IPV6
CN108011993B (en) * 2017-12-07 2021-07-16 北京百悟科技有限公司 Method and system for storing IP address information and inquiring IPv4 address
CN108093095B (en) * 2017-12-13 2020-01-21 清华大学 Method and device for converting address character string with short name into IPv6 address
CN109348305B (en) * 2018-09-30 2021-04-27 武汉斗鱼网络科技有限公司 Bullet screen data verification method and device, terminal and storage medium
CN109325496B (en) * 2018-09-30 2021-07-23 武汉斗鱼网络科技有限公司 Bullet screen checking method and device based on character removal, terminal and storage medium
CN109299719B (en) * 2018-09-30 2021-07-23 武汉斗鱼网络科技有限公司 Bullet screen checking method and device based on character segmentation, terminal and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102223289A (en) * 2010-04-15 2011-10-19 杭州华三通信技术有限公司 Method and device for storing IPv4 (the Fourth Internet Protocol Version) address and IPv6 (the Sixth Internet Protocol Version) address
CN102340551A (en) * 2010-07-27 2012-02-01 中国电信股份有限公司 Method and system for establishing IPv6 (Internet Protocol Version 6) address pool

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8406232B2 (en) * 2010-06-17 2013-03-26 Microsoft Corporation 4to6 network stack for IPv4 applications

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102223289A (en) * 2010-04-15 2011-10-19 杭州华三通信技术有限公司 Method and device for storing IPv4 (the Fourth Internet Protocol Version) address and IPv6 (the Sixth Internet Protocol Version) address
CN102340551A (en) * 2010-07-27 2012-02-01 中国电信股份有限公司 Method and system for establishing IPv6 (Internet Protocol Version 6) address pool

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种Web服务中IPv4/IPv6兼容的实现方法;张杰等;《微计算机信息》;20061030;第22卷(第30期);第25-27页 *

Also Published As

Publication number Publication date
CN103297554A (en) 2013-09-11

Similar Documents

Publication Publication Date Title
CN103297554B (en) The method and device of IPv4 and IPv6 compatible processing
CN104298680B (en) Data statistical approach and data statistics device
US20170063525A1 (en) Comparison and search operations of encrypted data
US10747538B2 (en) Method and apparatus to re-configure MDIO registers on an ethernet device
US20180089245A1 (en) Bloom filter index for device discovery
CN111191422B (en) File format conversion method, device and computer readable storage medium
CN111095421B (en) Context-aware delta algorithm for gene files
EP2618268A1 (en) Method and device for data storage
CN102333039A (en) Method for forwarding message, and method and device for generating table entry
CN105528345B (en) Terminal, server and character complementing method
CN112035857B (en) Data protection method, device, equipment and medium
CN104657481A (en) Data storage method and device and data query method and device
CN108874987A (en) Entry management method, device and exchange chip
CN105447151A (en) Method for accessing distributed database, data source proxy apparatus and application server
US11409724B2 (en) Hashed balanced tree data structure
CN106802927A (en) A kind of date storage method and querying method
CN104767761A (en) Cloud storage platform access control method and device
CN109698814A (en) Botnet finds that method and Botnet find device
JP2014502756A (en) Apparatus and method for mass data storage based on tree structure
CN103379145A (en) Information processing method, apparatus and system
CN103051480B (en) The storage means of a kind of DN and DN storage device
CN116610731A (en) Big data distributed storage method and device, electronic equipment and storage medium
US20150363510A1 (en) Indexed shaped graph creation
CN109413077B (en) JSON message data receiving and sending method and device and electronic equipment
CN111198880A (en) Data storage method and device based on redis and electronic equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C53 Correction of patent for invention or patent application
CB02 Change of applicant information

Address after: 518057, A building, Zhongxing building, Nanshan District science and Technology Park, Shenzhen, Guangdong, five

Applicant after: ZTE Corporation

Address before: 518057 Nanshan District Guangdong high tech Industrial Park, South Road, science and technology, ZTE building, Ministry of Justice

Applicant before: ZTE Corporation

ASS Succession or assignment of patent right

Owner name: SHENZHEN ZHONGXING TELECOMMUNICATION TECHNOLOGY SE

Free format text: FORMER OWNER: ZTE CORPORATION

Effective date: 20150109

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20150109

Address after: 518057 Nanshan District high tech Industrial Park, Guangdong, ZTE building, A3-01, A3-02,

Applicant after: Shenzhen Zhongxing Communication Technology Service Co., Ltd.

Address before: 518057, A building, Zhongxing building, Nanshan District science and Technology Park, Shenzhen, Guangdong, five

Applicant before: ZTE Corporation

C14 Grant of patent or utility model
GR01 Patent grant