--- libaitio/src/Attic/tools.c 2011/06/07 11:49:39 1.5 +++ libaitio/src/Attic/tools.c 2011/10/14 07:28:16 1.5.4.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.5 2011/06/07 11:49:39 misho Exp $ +* $Id: tools.c,v 1.5.4.1 2011/10/14 07:28:16 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -294,4 +294,27 @@ io_FreeNullTerm(char *** __restrict arr) free(*arr); *arr = NULL; } +} + +/* + * io_ether_ntoa() Convert ethernet address to string + * @n = ethernet address structure, like struct ether_addr + * @a = string + * @len = string length + * return: NULL error or !=NULL string a + */ +inline char * +io_ether_ntoa(const struct io_ether_addr *n, char * __restrict a, int len) +{ + if (!n || !a) + return NULL; + + memset(a, 0, len); + if (snprintf(a, len, "%02x:%02x:%02x:%02x:%02x:%02x", + n->ether_addr_octet[0], n->ether_addr_octet[1], + n->ether_addr_octet[2], n->ether_addr_octet[3], + n->ether_addr_octet[4], n->ether_addr_octet[5]) < 17) + return NULL; + + return a; }