]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
5745185e WD |
2 | /* |
3 | * (C) Copyright 2001 | |
4 | * Murray Jensen <[email protected]> | |
5745185e WD |
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 | ||
3e4dad50 | 17 | srand(time(0) + (getpid() << 8)); |
5745185e WD |
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 | */ | |
2eeb4e95 PT |
24 | ethaddr_high = (rand() & 0xfeff) | 0x0200; |
25 | ethaddr_low = rand(); | |
5745185e WD |
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 | } |