A device detection library that is used natively or by 51Degrees products

IP

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

Enum indicating the type of IP address.

Enumerator

FIFTYONE_DEGREES_IP_TYPE_INVALID 

Invalid IP address.

FIFTYONE_DEGREES_IP_TYPE_IPV4 

An IPv4 address.

FIFTYONE_DEGREES_IP_TYPE_IPV6 

An IPv6 address.

Function Documentation

◆ fiftyoneDegreesIpAddressesCompare()

int fiftyoneDegreesIpAddressesCompare ( const unsigned char * ipAddress1,
const unsigned char * ipAddress2,
fiftyoneDegreesIpType type )

Compare two IP addresses in its binary form.

Parameters
ipAddress1the first IP address
ipAddress2the second IP address
typethe 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
startof the string containing the IP address to parse
endthe last character of the string (with IP address) to be considered for parsing
addressmemory to write parsed IP address into.
Returns
true if address was parsed correctly, false otherwise