blob: bf9d935efdca205328de190f911d70c6ac594df2 [file] [log] [blame]
wdenk57451852001-09-06 22:25:14 +00001/*
2 * (C) Copyright 2001
3 * Murray Jensen <Murray.Jensen@cmst.csiro.au>
4 *
Wolfgang Denk1a459662013-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
Peter Tyser2eeb4e92009-03-13 18:54:31 -050018 srand(time(0) | getpid());
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 Tyser2eeb4e92009-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}