EVL Anonymization

Table of Contents


Products, services and company names referenced in this document may be either trademarks or registered trademarks of their respective owners.

Copyright © 2017–2020 EVL Tool, s.r.o.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts.

IP Addresses Functions

Typical IPv4 manipulation usage within a mapping:

// convert and assign IPv4 string into unsigned integer
out->ipv4_uint = str_to_ipv4(in->ipv4_string);
// or the other way
out->ipv4_string = ipv4_to_str(in->ipv4_uint);

Typical IPv6 manipulation usage within a mapping:

// suppose in->ipv6_string = "4567::123"
out->ipv6_normalized = ipv6_normalize(in->ipv6_string);
    // return "4567:0000:0000:0000:0000:0000:0000:0123"

// suppose in->ipv6_string = "0000:0000:0000:0004:5678:9098:0000:0654"
out->ipv6_compressed = ipv6_compress(in->ipv6_string);
    // return "::4:5678:9098:0000:654"

Or one can distinguish both IP versions:

if ( is_valid_ipv4(in->ip_string) ) {
  // act on IPv4
}
else if ( is_valid_ipv6(in->ip_string) ) {
  // act on IPv6
}
else {
  // act when neither is valid 
}

There are these two rules in all IP manipulation functions described in this section:

  • When the first argument is a pointer, the function returns also a pointer.
  • When the first argument is ‘nullptr’, the function returns ‘nullptr’ as well.

IPv4 Functions

(since EVL 2.4)

ipv4addr

constructor

str_to_ipv4()

convert string to uint32,

ipv4_to_str()

convert uint32 to ipv4 string,

is_valid_ipv4()

to check whether the string is valid IPv4.

IPv6 Functions

(since EVL 2.4)

str_to_ipv6()

convert string to uint128,

ipv6_to_str()

convert uint128 to ipv6 string,

is_valid_ipv6()

to check whether the string is valid IPv6,

ipv6_normalize()

convert string to normalized IPv6 string,

ipv6_compress()

convert string to compressed IPv6 string,

Examples

To get normalized and compressed IPv6:

// suppose in->ipv6_string = "0000:0000:22::0003:4"
out->ipv6_normalized = ipv6_normalize(in->ipv6_string);
    // "0000:0000:0022:0000:0000:0000:0003:0004"
out->ipv6_compressed = ipv6_compress(in->ipv6_string);
    // "0:0:22::3:4"