On Mon, Jan 12, 2015 at 11:40:54AM +0000, Savolainen, Petri (NSN - FI/Espoo) 
wrote:
> > 
> > +static int random_mac(void *mac_addr, size_t addr_size)
> > +{
> > +   uint32_t ethaddr_l, ethaddr_h;
> > +
> > +   srand(odp_time_cycles());
> > +   ethaddr_h = (rand() & 0xfeff) | 0x0200;
> > +   ethaddr_l = rand();
> > +
> > +   snprintf(mac_addr, addr_size, "%02x:%02x:%02x:%02x:%02x:%02x",
> > +            ethaddr_h >> 8, ethaddr_h & 0xff,
> > +            ethaddr_l >> 24, (ethaddr_l >> 16) & 0xff,
> > +            (ethaddr_l >> 8) & 0xff, ethaddr_l & 0xff);
> > +
> > +   return 0;
> > +}
> > +
> 
> 
> Maybe it's better to use constant mac address(es), so that it's easier to 
> spot configuration errors, reproduce problems and test results.

Makes sense, I'll make that change.


>Also the "locally administered" MAC address bit should be set (to avoid 
>collision with globally unique addresses in the case it would leak into 
>network).
>

Will do, this version already does that with the "| 0x0200".

-- 
Stuart.


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to