FreeBSD/sys/dev/xen/netfront/netfront.c
/**
 * Read the 'mac' node at the given device's node in the store, and parse that
 * as colon-separated octets, placing result the given mac array.  mac must be
 * a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
 * Return 0 on success, or errno on error.
 */
Read the 'mac' node at the given device's node in the store, and parse that
as colon-separated octets, placing result the given mac array.  mac must be
a preallocated array of length ETH_ALEN (as declared in linux/if_ether.h).
Return 0 on success, or errno on error.
Read the ' mac ' node at the given device ' s node in the store and parse that as colon - separated octets placing result the given mac array . mac must be a preallocated array of length ETH_ALEN ( as declared in linux / if_ether . h ) . Return 0 on success or errno on error .
static int
xen_net_read_mac(device_t dev, uint8_t mac[])
{
	int error, i;
	char *s, *e, *macstr;
	const char *path;
	path = xenbus_get_node(dev);
	error = xs_read(XST_NIL, path, "mac", NULL, (void **) &macstr);
	if (error == ENOENT) {
		path = xenbus_get_otherend_path(dev);
		error = xs_read(XST_NIL, path, "mac", NULL, (void **) &macstr);
	}
	if (error != 0) {
		xenbus_dev_fatal(dev, error, "parsing %s/mac", path);
		return (error);
	}
	s = macstr;
	for (i = 0; i < ETHER_ADDR_LEN; i++) {
		mac[i] = strtoul(s, &e, 16);
		if (s == e || (e[0] != ':' && e[0] != 0)) {
			free(macstr, M_XENBUS);
			return (ENOENT);
		}
		s = &e[1];
	}
	free(macstr, M_XENBUS);
	return (0);
}
static int xen_net_read_mac ( device_t dev , uint8_t mac [ ] ) { int error , i ; char * s , * e , * macstr ; const char * path ; path = xenbus_get_node ( dev ) ; error = xs_read ( XST_NIL , path , " " , NULL , ( void * * ) & macstr ) ; if ( error == ENOENT ) { path = xenbus_get_otherend_path ( dev ) ; error = xs_read ( XST_NIL , path , " " , NULL , ( void * * ) & macstr ) ; } if ( error != 0 ) { xenbus_dev_fatal ( dev , error , " " , path ) ; return ( error ) ; } s = macstr ; for ( i = 0 ; i < ETHER_ADDR_LEN ; i ++ ) { mac [ i ] = strtoul ( s , & e , 16 ) ; if ( s == e || ( e [ 0 ] != ' ' && e [ 0 ] != 0 ) ) { free ( macstr , M_XENBUS ) ; return ( ENOENT ) ; } s = & e [ 1 ] ; } free ( macstr , M_XENBUS ) ; return ( 0 ) ; }
Read the 'mac' node at the given device's node in the store, and parse that
 as colon-separated octets, placing result the given mac array.
Read the ' mac ' node at the given device ' s node in the store and parse that as colon - separated octets placing result the given mac array .
/*
		 * Deal with missing mac XenStore nodes on devices with
		 * HVM emulation (the 'ioemu' configuration attribute)
		 * enabled.
		 *
		 * The HVM emulator may execute in a stub device model
		 * domain which lacks the permission, only given to Dom0,
		 * to update the guest's XenStore tree.  For this reason,
		 * the HVM emulator doesn't even attempt to write the
		 * front-side mac node, even when operating in Dom0.
		 * However, there should always be a mac listed in the
		 * backend tree.  Fallback to this version if our query
		 * of the front side XenStore location doesn't find
		 * anything.
		 */