Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 5745185 | 2001-09-06 22:25:14 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2001 |
| 4 | * Murray Jensen <Murray.Jensen@cmst.csiro.au> |
wdenk | 5745185 | 2001-09-06 22:25:14 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <stdio.h> |
| 8 | #include <stdlib.h> |
| 9 | #include <unistd.h> |
| 10 | #include <time.h> |
| 11 | |
| 12 | int |
| 13 | main(int argc, char *argv[]) |
| 14 | { |
| 15 | unsigned long ethaddr_low, ethaddr_high; |
| 16 | |
Josh Wu | e0256b4 | 2015-09-16 18:21:04 +0800 | [diff] [blame] | 17 | srand(time(0) + (getpid() << 8)); |
wdenk | 5745185 | 2001-09-06 22:25:14 +0000 | [diff] [blame] | 18 | |
| 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 Tyser | cecc407 | 2009-03-13 18:54:31 -0500 | [diff] [blame] | 24 | ethaddr_high = (rand() & 0xfeff) | 0x0200; |
| 25 | ethaddr_low = rand(); |
wdenk | 5745185 | 2001-09-06 22:25:14 +0000 | [diff] [blame] | 26 | |
| 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 | } |