On 12 January 2015 at 15:04, Stuart Haslam <[email protected]> wrote:
> On Mon, Jan 12, 2015 at 01:52:26PM +0000, Ola Liljedahl wrote:
>> On 12 January 2015 at 14:42, Stuart Haslam <[email protected]> wrote:
>> > 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".
>> Have you heard of this novel thing called "symbolic constants"?
>>
>
> Yeah, maybe in the next version I will use >> EIGHT, and >> TWENTY_FOUR :)
It would have sufficed with a comment where the 0x0200 constant was used above.

>
> (actually, won't need this code at all)
>
> --
> Stuart.
>

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

Reply via email to