--- libaitio/src/Attic/tools.c 2011/10/14 07:28:16 1.5.4.1 +++ libaitio/src/Attic/tools.c 2011/10/31 13:53:51 1.6 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.5.4.1 2011/10/14 07:28:16 misho Exp $ +* $Id: tools.c,v 1.6 2011/10/31 13:53:51 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -317,4 +317,33 @@ io_ether_ntoa(const struct io_ether_addr *n, char * __ return NULL; return a; +} + +/* + * io_ether_aton() Convert string to ethernet address + * @a = string + * @e = ethernet address structure, like struct ether_addr + * return: NULL error or !=NULL ethernet address structure + */ +inline struct io_ether_addr * +io_ether_aton(const char *a, struct io_ether_addr *e) +{ + int i; + u_int o0, o1, o2, o3, o4, o5; + + if (!a || !e) + return NULL; + + i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5); + if (i != 6) + return NULL; + + e->ether_addr_octet[0] = o0; + e->ether_addr_octet[1] = o1; + e->ether_addr_octet[2] = o2; + e->ether_addr_octet[3] = o3; + e->ether_addr_octet[4] = o4; + e->ether_addr_octet[5] = o5; + + return e; }