IPv4 Addresses
in_addr_t from String
#include <arpa/inet.h> in_addr_t ipAddr = inet_addr("127.0.0.1");
in_addr_t to String
#include <arpa/inet.h> in_addr_t ipAddr = inet_addr("127.0.0.1"); char buffer[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &ipAddr, buffer, INET_ADDRSTRLEN); printf("IP as String: %s\n", buffer);
IPv4 (AF_INET) From String to Binary Form
#include <arpa/inet.h> uint32_t bits; inet_pton(AF_INET, "127.0.0.1", &bits);
Ethernet Address to String
#include ??? struct ether_addr eth_addr; // find ethernet adress and store it into eth_addr ... printf("MAC: %s\n", ether_ntoa(ð_addr));
String to Ethernet Address
#include ??? struct ether_addr *eth_addr = ether_aton(param_mac); if (eth_addr == NULL) { return; } printf("MAC: %s\n", ether_ntoa(eth_addr)); free(eth_addr); eth_addr = NULL;