parse_ipv4()parse_ipv4()
将 IPv4 字符串转换为 long(带符号的 64 位)数字表示形式。Converts IPv4 string to long (signed 64-bit) number representation.
parse_ipv4("127.0.0.1") == 2130706433
parse_ipv4('192.1.168.1') < parse_ipv4('192.1.168.2') == true
语法Syntax
parse_ipv4(
Expr
)
参数Arguments
Expr
:字符串表达式,表示将转换为 long 的 IPv4。Expr
: String expression representing IPv4 that will be converted to long. 字符串可以包含使用 IP 前缀表示法的网络掩码。String may include net-mask using IP-prefix notation.
IP 前缀表示法IP-prefix notation
IP 地址可通过使用斜杠 (/
) 字符的 IP-prefix notation
进行定义。IP addresses can be defined with IP-prefix notation
using a slash (/
) character.
斜杠 (/
) 左边的 IP 地址是基本 IP 地址。The IP address to the LEFT of the slash (/
) is the base IP address. 斜杠 (/) 右边的数字(1 到 32)是网络掩码中连续位的数目。The number (1 to 32) to the RIGHT of the slash (/) is the number of contiguous 1 bit in the netmask.
例如,192.168.2.0/24 将具有关联的网络/子网掩码,其中包含 24 个连续位或点分十进制格式的 255.255.255.0。For example, 192.168.2.0/24 will have an associated net/subnetmask containing 24 contiguous bits or 255.255.255.0 in dotted decimal format.
返回Returns
如果转换成功,则结果将是一个 long 类型的数字。If conversion is successful, the result will be a long number.
如果转换未成功,结果将为 null
。If conversion isn't successful, the result will be null
.
示例Example
datatable(ip_string:string)
[
'192.168.1.1',
'192.168.1.1/24',
'255.255.255.255/31'
]
| extend ip_long = parse_ipv4(ip_string)
ip_stringip_string | ip_longip_long |
---|---|
192.168.1.1192.168.1.1 | 32322357773232235777 |
192.168.1.1/24192.168.1.1/24 | 32322357763232235776 |
255.255.255.255/31255.255.255.255/31 | 42949672944294967294 |