blob: ad36f3f0c21d2f17d862b07a2928b0849463a331 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk57451852001-09-06 22:25:14 +00002/*
3 * (C) Copyright 2001
4 * Murray Jensen <Murray.Jensen@cmst.csiro.au>
wdenk57451852001-09-06 22:25:14 +00005 */
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <unistd.h>
10#include <time.h>
11
12int
13main(int argc, char *argv[])
14{
15 unsigned long ethaddr_low, ethaddr_high;
16
Josh Wu3e4dad52015-09-16 18:21:04 +080017 srand(time(0) + (getpid() << 8));
wdenk57451852001-09-06 22:25:14 +000018
19 /*
20 * setting the 2nd LSB in the most significant byte of
21 * the address makes it a locally administered ethernet
22 * address
23 */
Peter Tyser2eeb4e92009-03-13 18:54:31 -050024 ethaddr_high = (rand() & 0xfeff) | 0x0200;
25 ethaddr_low = rand();
wdenk57451852001-09-06 22:25:14 +000026
27 printf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx\n",
28 ethaddr_high >> 8, ethaddr_high & 0xff,
29 ethaddr_low >> 24, (ethaddr_low >> 16) & 0xff,
30 (ethaddr_low >> 8) & 0xff, ethaddr_low & 0xff);
31
32 return (0);
33}