blob: 5fa3e0cf5651b8595591c837ee518185e93b9290 [file] [log] [blame]
wdenk57451852001-09-06 22:25:14 +00001/*
2 * (C) Copyright 2001
3 * Murray Jensen <Murray.Jensen@cmst.csiro.au>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk57451852001-09-06 22:25:14 +00006 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <unistd.h>
11#include <time.h>
12
13int
14main(int argc, char *argv[])
15{
16 unsigned long ethaddr_low, ethaddr_high;
17
Josh Wue0256b42015-09-16 18:21:04 +080018 srand(time(0) + (getpid() << 8));
wdenk57451852001-09-06 22:25:14 +000019
20 /*
21 * setting the 2nd LSB in the most significant byte of
22 * the address makes it a locally administered ethernet
23 * address
24 */
Peter Tysercecc4072009-03-13 18:54:31 -050025 ethaddr_high = (rand() & 0xfeff) | 0x0200;
26 ethaddr_low = rand();
wdenk57451852001-09-06 22:25:14 +000027
28 printf("%02lx:%02lx:%02lx:%02lx:%02lx:%02lx\n",
29 ethaddr_high >> 8, ethaddr_high & 0xff,
30 ethaddr_low >> 24, (ethaddr_low >> 16) & 0xff,
31 (ethaddr_low >> 8) & 0xff, ethaddr_low & 0xff);
32
33 return (0);
34}