/* =========================================== winwol.c Author: Jakob Klamra, jklamra@csee.usf.edu Will wake up a device in power sleep. Device NIC must be WOL enabled. Device motherboard must support WOL. Device OS must be WOL enabled. Broadcasts UDP packet with Ethernet address of the receiver repeated 16 times. The address is hardcoded. This code is made to be compiled with bcc32 for Windows. The program gives no output if it suceeds. The platform for this program was made by dr. Christensen and can be found at http://www.csee.usf.edu/~christen/tools/server1.c This program was downloaded from http://www.csee.usf.edu/~jklamra/upnp/ and is part of a master thesis about power management in Universal Plug and Play. =========================================== */ #include #include #include #include #include #include #define BUFMAX 256 #define MACLEN 6 #define IP_ADDR "255.255.255.255" #define PORT_NUM 65535 main(argc,argv) int argc; char *argv[]; { WSADATA info; unsigned int my_s; // the socket unsigned char optval; struct sockaddr_in my_addr; // destination addr char out_buf[BUFMAX]; // output buffer for data char *p; int i, j, len; char mac[MACLEN]; if (WSAStartup(MAKEWORD(1,1), &info) != 0) printf(stderr,"Cannot initialize WinSock!"); // >>> Step #1 <<< // Create a socket // - AF_INET is Address Family Internet my_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); // >>> Step #2 <<< // Fill-in my socket's address information and bind the socket // - See winsock.h for a description of struct sockaddr_in my_addr.sin_family = AF_INET; // Address family to use my_addr.sin_port = htons(PORT_NUM); // Port number to use my_addr.sin_addr.s_addr = inet_addr(IP_ADDR); //send to IP_ADDR for(i = 0; i<6; ++i){ out_buf[i] = 0xFF; } mac[0] = 0x00; mac[1] = 0x00; mac[2] = 0x00; mac[3] = 0x00; mac[4] = 0x00; mac[5] = 0x00; for(i = 1; i<17; ++i){ for(j = 0; j