FreeBSD/sys/dev/rt/if_rt.c
/*
 * ether_request_mac - try to find usable MAC address.
 */
try to find usable MAC address.
try to find usable MAC address .
static int
ether_request_mac(device_t dev, uint8_t *mac)
{
	char *var;
#if defined(RT305X_UBOOT) ||  defined(__REDBOOT__) || defined(__ROUTERBOOT__)
	if ((var = kern_getenv("ethaddr")) != NULL ||
	    (var = kern_getenv("kmac")) != NULL ) {
		if(!macaddr_atoi(var, mac)) {
			printf("%s: use %s macaddr from KENV\n",
			    device_get_nameunit(dev), var);
			freeenv(var);
			return (0);
		}
		freeenv(var);
	}
#endif
	if (!resource_string_value(device_get_name(dev),
	    device_get_unit(dev), "macaddr", (const char **)&var)) {
		if(!macaddr_atoi(var, mac)) {
			printf("%s: use %s macaddr from hints\n",
			    device_get_nameunit(dev), var);
			return (0);
		}
	}
#ifdef USE_GENERATED_MAC_ADDRESS
	generate_mac(mac);
	device_printf(dev, "use generated %02x:%02x:%02x:%02x:%02x:%02x "
	    "macaddr\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#else
	mac[0] = 0x00;
	mac[1] = 0x18;
	mac[2] = 0xe7;
	mac[3] = 0xd5;
	mac[4] = 0x83;
	mac[5] = 0x90;
	device_printf(dev, "use hardcoded 00:18:e7:d5:83:90 macaddr\n");
#endif
	return (0);
}
static int ether_request_mac ( device_t dev , uint8_t * mac ) { char * var ; #if defined ( RT305X_UBOOT ) || defined ( __REDBOOT__ ) || defined ( __ROUTERBOOT__ ) if ( ( var = kern_getenv ( " " ) ) != NULL || ( var = kern_getenv ( " " ) ) != NULL ) { if ( ! macaddr_atoi ( var , mac ) ) { printf ( " \n " , device_get_nameunit ( dev ) , var ) ; freeenv ( var ) ; return ( 0 ) ; } freeenv ( var ) ; } #endif if ( ! resource_string_value ( device_get_name ( dev ) , device_get_unit ( dev ) , " " , ( const char * * ) & var ) ) { if ( ! macaddr_atoi ( var , mac ) ) { printf ( " \n " , device_get_nameunit ( dev ) , var ) ; return ( 0 ) ; } } #ifdef USE_GENERATED_MAC_ADDRESS generate_mac ( mac ) ; device_printf ( dev , " " " \n " , mac [ 0 ] , mac [ 1 ] , mac [ 2 ] , mac [ 3 ] , mac [ 4 ] , mac [ 5 ] ) ; #else mac [ 0 ] = 0x00 ; mac [ 1 ] = 0x18 ; mac [ 2 ] = 0xe7 ; mac [ 3 ] = 0xd5 ; mac [ 4 ] = 0x83 ; mac [ 5 ] = 0x90 ; device_printf ( dev , " \n " ) ; #endif return ( 0 ) ; }
ether_request_mac - try to find usable MAC address.
ether_request_mac - try to find usable MAC address .
/*
	 * "ethaddr" is passed via envp on RedBoot platforms
	 * "kmac" is passed via argv on RouterBOOT platforms
	 */ /*
	 * Try from hints
	 * hint.[dev].[unit].macaddr
	 */ /* Hardcoded */