Detailed Description
Types and methods to parse IP address strings.
Introduction
IP v4 and v6 addresses can be parsed using the fiftyoneDegreesIpAddressParse and #fiftyoneDegreesIpAddressesParse methods.
Collaboration diagram for IP:
Structs | |
| struct | fiftyoneDegreesIpAddress |
| The structure to hold a IP Address in byte array format. More... | |
Macros | |
| #define | FIFTYONE_DEGREES_IPV4_LENGTH 4 |
| The number of bytes in an Ipv4 Address. | |
| #define | FIFTYONE_DEGREES_IPV6_LENGTH 16 |
| The number of bytes in an Ipv6 Address. | |
Enumerations | |
| enum | fiftyoneDegreesIpType { FIFTYONE_DEGREES_IP_TYPE_INVALID = 0 , FIFTYONE_DEGREES_IP_TYPE_IPV4 = 4 , FIFTYONE_DEGREES_IP_TYPE_IPV6 = 6 } |
| Enum indicating the type of IP address. More... | |
Functions | |
| bool | fiftyoneDegreesIpAddressParse (const char *start, const char *end, fiftyoneDegreesIpAddress *address) |
| Parse a single IP address string. | |
| int | fiftyoneDegreesIpAddressesCompare (const unsigned char *ipAddress1, const unsigned char *ipAddress2, fiftyoneDegreesIpType type) |
| Compare two IP addresses in its binary form. | |
Enumeration Type Documentation
◆ fiftyoneDegreesIpType
Function Documentation
◆ fiftyoneDegreesIpAddressesCompare()
| int fiftyoneDegreesIpAddressesCompare | ( | const unsigned char * | ipAddress1, |
| const unsigned char * | ipAddress2, | ||
| fiftyoneDegreesIpType | type ) |
Compare two IP addresses in its binary form.
- Parameters
-
ipAddress1 the first IP address ipAddress2 the second IP address type the type of IP address. This determine the number of bytes to compare. IPv4 require 4 bytes and IPv6 require 16 bytes
- Returns
- a value indicate the result: 0 for equals
0 for ipAddress1 comes after ipAddress2 < 0 for ipAddress1 comes before ipAddress2
◆ fiftyoneDegreesIpAddressParse()
| bool fiftyoneDegreesIpAddressParse | ( | const char * | start, |
| const char * | end, | ||
| fiftyoneDegreesIpAddress * | address ) |
Parse a single IP address string.
Does not modify the last 12 (out of 16) bytes when parsing IPv4.
- Parameters
-
start of the string containing the IP address to parse end the last character of the string (with IP address) to be considered for parsing address memory to write parsed IP address into.
- Returns
trueif address was parsed correctly,falseotherwise
