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