conversions.ipv4_conversion¶
Functions¶
|
|
|
Convert a decimal representation of an IP address to its IPv4 format. |
|
Convert an IPv4 address to its decimal representation. |
Module Contents¶
- conversions.ipv4_conversion.alt_ipv4_to_decimal(ipv4_address: str) int ¶
>>> alt_ipv4_to_decimal("192.168.0.1") 3232235521 >>> alt_ipv4_to_decimal("10.0.0.255") 167772415
- conversions.ipv4_conversion.decimal_to_ipv4(decimal_ipv4: int) str ¶
Convert a decimal representation of an IP address to its IPv4 format.
- Args:
decimal_ipv4: An integer representing the decimal IP address.
- Returns:
The IPv4 representation of the decimal IP address.
>>> decimal_to_ipv4(3232235521) '192.168.0.1' >>> decimal_to_ipv4(167772415) '10.0.0.255' >>> decimal_to_ipv4(-1) Traceback (most recent call last): ... ValueError: Invalid decimal IPv4 address
- conversions.ipv4_conversion.ipv4_to_decimal(ipv4_address: str) int ¶
Convert an IPv4 address to its decimal representation.
- Args:
ip_address: A string representing an IPv4 address (e.g., “192.168.0.1”).
- Returns:
int: The decimal representation of the IP address.
>>> ipv4_to_decimal("192.168.0.1") 3232235521 >>> ipv4_to_decimal("10.0.0.255") 167772415 >>> ipv4_to_decimal("10.0.255") Traceback (most recent call last): ... ValueError: Invalid IPv4 address format >>> ipv4_to_decimal("10.0.0.256") Traceback (most recent call last): ... ValueError: Invalid IPv4 octet 256