What is eth_addr_t and friends in libdnet
I am trying to create a wrapper around libdnet for programming D language. The problem that I have encountered, does not know what type to underscore eth_addr_t, ip_addr_t and ip6_addr_t while converting addr.h . The last type of mystery - sockaddr
And I am also interested in why there is a while while loop which is always false.
#define addr_pack(addr, type, bits, data, len) do { \
(addr)->addr_type = type; \
(addr)->addr_bits = bits; \
memmove((addr)->addr_data8, (char *)data, len); \
} while (0)
is it required for C to execute code in a macro?
a source to share
This is the definition macro for the c preprocessor. Those backslashes are at the end because it's all one definition that spans multiple lines. A while loop, like a while loop, except for evaluation, is executed at the end, allowing it to run at least once. In this case, the developer used this loop as a kind of hack so that his code could be placed in his scope.
From eth.h in the same directory:
typedef struct eth_addr {
uint8_t data[ETH_ADDR_LEN];
} eth_addr_t;
ip.h:
typedef uint32_t ip_addr_t;
ip6.h:
typedef struct ip6_addr {
uint8_t data[IP6_ADDR_LEN];
} ip6_addr_t;
Honeyd-1.1.1 / unused / winsock.h:
/*
* Structure used by kernel to store most
* addresses.
*/
struct sockaddr {
u_short sa_family; /* address family */
char sa_data[14]; /* up to 14 bytes of direct address */
};
a source to share