FreeBSD/sys/dev/rt/if_rt.c
/*
 * macaddr_atoi - translate string MAC address to uint8_t array
 */
translate string MAC address to uint8_t array
translate string MAC address to uint8_t array
static int
macaddr_atoi(const char *str, uint8_t *mac)
{
	int count, i;
	unsigned int amac[ETHER_ADDR_LEN];	
	count = sscanf(str, "%x%*c%x%*c%x%*c%x%*c%x%*c%x",
	    &amac[0], &amac[1], &amac[2],
	    &amac[3], &amac[4], &amac[5]);
	if (count < ETHER_ADDR_LEN) {
		memset(mac, 0, ETHER_ADDR_LEN);
		return (1);
	}
	for (i = 0; i < ETHER_ADDR_LEN; i ++)
		mac[i] = (amac[i] & 0xff);
	return (0);
}
static int macaddr_atoi ( const char * str , uint8_t * mac ) { int count , i ; unsigned int amac [ ETHER_ADDR_LEN ] ; count = sscanf ( str , " " , & amac [ 0 ] , & amac [ 1 ] , & amac [ 2 ] , & amac [ 3 ] , & amac [ 4 ] , & amac [ 5 ] ) ; if ( count < ETHER_ADDR_LEN ) { memset ( mac , 0 , ETHER_ADDR_LEN ) ; return ( 1 ) ; } for ( i = 0 ; i < ETHER_ADDR_LEN ; i ++ ) mac [ i ] = ( amac [ i ] & 0xff ) ; return ( 0 ) ; }
macaddr_atoi - translate string MAC address to uint8_t array
macaddr_atoi - translate string MAC address to uint8_t array
/* Aligned version */ /* Copy aligned to result */