Skip to content

Instantly share code, notes, and snippets.

@crossle
Last active December 11, 2015 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crossle/ebcd32a4097257c7290d to your computer and use it in GitHub Desktop.
Save crossle/ebcd32a4097257c7290d to your computer and use it in GitHub Desktop.
#define RANDOM(x) (rand()%x)
#define MAC_ADDR_LENGTH 6
void macGen() {
uint8_t HEXCHAR[256];
uint8_t MACAddr[MAC_ADDR_LENGTH];
for (int j = 0; j < 256; j ++) {
HEXCHAR[j] = j;
}
srand(getpid());
for(int i = 0;i < MAC_ADDR_LENGTH; i++) {
int n = RANDOM(255);
MACAddr[i] = HEXCHAR[n];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment