1
0
src/libwakeonlan/libwakeonlan.c
2022-09-18 10:44:47 -04:00

22 lines
424 B
C

#include "libwakeonlan.h"
/* Returns a byte array of 6 0xFF and 16 repetitions of the 6-byte MAC. */
unsigned int*
magic_packet(unsigned int *mac){
size_t i;
size_t j;
int *retval;
if((retval = malloc(sizeof(unsigned int) * 6 + 6*16)) == NULL)
return NULL;
for(i = 0; i < 6; ++i)
retval[i] = 255;
for(i = 1; i < 16; ++i)
for(j = 0; j < 6; ++j)
retval[i*j] = mac[j];
return retval; /* must be freed */
}