FreeBSD/sys/mips/atheros/ar71xx_macaddr.c
/*
 * Initialise a MAC address 'dst' from a MAC address 'src'.
 *
 * 'offset' is added to the low three bytes to allow for sequential
 * MAC addresses to be derived from a single one.
 *
 * 'is_local' is whether this 'dst' should be made a local MAC address.
 *
 * Returns 0 if it was successfully initialised, -1 on error.
 */
Initialise a MAC address 'dst' from a MAC address 'src'.
'offset' is added to the low three bytes to allow for sequential
MAC addresses to be derived from a single one.

'is_local' is whether this 'dst' should be made a local MAC address.

Returns 0 if it was successfully initialised, -1 on error.
Initialise a MAC address ' dst ' from a MAC address ' src ' . ' offset ' is added to the low three bytes to allow for sequential MAC addresses to be derived from a single one . ' is_local ' is whether this ' dst ' should be made a local MAC address . Returns 0 if it was successfully initialised - 1 on error .
int
ar71xx_mac_addr_init(unsigned char *dst, const unsigned char *src,
    int offset, int is_local)
{
	int t;
	if (dst == NULL || src == NULL)
		return (-1);
	t = (((uint32_t) src[3]) << 16)
	    + (((uint32_t) src[4]) << 8)
	    + ((uint32_t) src[5]);
	t += offset;
	dst[0] = src[0];
	dst[1] = src[1];
	dst[2] = src[2];
	dst[3] = (t >> 16) & 0xff;
	dst[4] = (t >> 8) & 0xff;
	dst[5] = t & 0xff;
	if (is_local)
		dst[0] |= 0x02;
	return (0);
}
int ar71xx_mac_addr_init ( unsigned char * dst , const unsigned char * src , int offset , int is_local ) { int t ; if ( dst == NULL || src == NULL ) return ( -1 ) ; t = ( ( ( uint32_t ) src [ 3 ] ) << 16 ) + ( ( ( uint32_t ) src [ 4 ] ) << 8 ) + ( ( uint32_t ) src [ 5 ] ) ; t += offset ; dst [ 0 ] = src [ 0 ] ; dst [ 1 ] = src [ 1 ] ; dst [ 2 ] = src [ 2 ] ; dst [ 3 ] = ( t >> 16 ) & 0xff ; dst [ 4 ] = ( t >> 8 ) & 0xff ; dst [ 5 ] = t & 0xff ; if ( is_local ) dst [ 0 ] |= 0x02 ; return ( 0 ) ; }
Initialise a MAC address 'dst' from a MAC address 'src'.
Initialise a MAC address ' dst ' from a MAC address ' src ' .
/* XXX TODO: validate 'src' is a valid MAC address */ /* Note: this is handles both positive and negative offsets */ /* Everything's okay */