Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <time.h>
  4.  
  5. #define DLK_MAX 17
  6.  
  7. void rand_init()
  8. {
  9.     srand((unsigned int)time(NULL));
  10. }
  11.  
  12. int dlk_gen(char* buffer, size_t max, char* mac)
  13. {
  14.     int rs = 0, mac_hi, mac_lo;
  15.     if (max >= DLK_MAX)
  16.     {
  17.         sscanf(mac, "%04x%08x", &mac_hi, &mac_lo);     
  18.         mac_lo ^= 0xdeadbeef;
  19.         rs = sprintf(buffer, "%08x%08x", mac_lo, (rand() << 16) | rand());
  20.     }
  21.     return rs;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement