There are generally two formats for storing IP addresses in the IP address database, one is dotted decimal format (192.168.1.1), and the other is digital format (3232235777). In applications, it is often necessary to convert between these two formats.
To solve this problem, I implemented a quick method for converting between the two in the exnet extension package:
Example of use:
So how do you convert a dotted decimal IP address into a number? An IPv4 address has 4 bytes and looks like this:
Each byte represents the range:
General formula: b4<<24 | b3<<16 | b2<<16 | b1 For example, 222.173.108.86 Conversion method: 222<<24 | 173<<16 | 108<<8 | 86 = 3735907414 For example, 1.0.1.1 Conversion method: 1<<24 | 0<<16 | 1<<8 | 1 = 16777473 The implementation in exnet is as follows:
Just flip the logic of converting a numeric value to a string. This is implemented in exnet as follows:
|
<<: When porting your number to another network, operators should first change their service mindset
[[350382]] At 14:00 on the afternoon of October 3...
At the MWC 2017 conference, which has ended, peop...
Preface The COVID-19 pandemic has had an unpreced...
RackNerd is a foreign hosting company founded in ...
WiFi has now been fully integrated into our lives...
I checked the port modification records in the si...
We have learned about how to deal with traffic pr...
Recently, Bwh81 has opened a second data center i...
The Wireless Broadband Alliance (WBA) announced i...
[Original article from 51CTO.com] After years of ...
[[390013]] 1. HTTP protocol HyperText Transfer Pr...
[Hangzhou, China, October 18, 2017] Today, the 4t...
With the advent of network automation, programmab...
Recently, the three major telecom operators have ...
According to the Ministry of Industry and Informa...