PGEN-Address gives users easy interface for IP address and MAC address. These are implemented as pgen_ipaddr and pgen_macaddr.
These are sample codes with PGEN-Address.
/* pgen_ipaddr */
pgen_ipaddr iaddr = "192.168.10.1";
printf("ip addr is %s n", iaddr.c_str());
/* pgen_macaddr */
pgen_macaddr maddr = "00:11:22:33:44:55";
printf("mac addr is %s n", maddr.c_str());
They has many utility member functions and operators.
Member Function and Operator
Address class has many operators that helps address operation.
Available operators is ==, !=, <, >, <=, >=. For example 192.168.100.1 <= 192.168.120.1 is true. 192.168.1.3 > 192.168.1.4 is false. 192.168.111.1 != 192.168.111.1 is false.
If you want to print address with printf(), you use member function, c_str(), like std::string class. See sample code above. More Information, please see libpgen on GihHub.