$NetBSD: patch-aa,v 1.3 2003/09/25 12:08:30 tron Exp $ --- hpwake.c.orig 2003-09-25 14:06:58.000000000 +0200 +++ hpwake.c 2003-09-25 14:07:18.000000000 +0200 @@ -16,8 +16,10 @@ email: wann@server7.ik.mb.uni-siegen.de */ +#include #include #include +#include #include #include #include @@ -26,6 +28,8 @@ u_char magicpacket[500]; +int get_magicpacket(unsigned char *,char *); +int main(int,char *[]); int get_magicpacket(packet,arg) @@ -42,7 +46,7 @@ for (a = arg; *a; a++) if (*a != ':' && !isxdigit(*a)) { - fprintf(stderr, "MAC Adresse muss hexadezimal angegeben werden! [00:11:22:33:44:55]\n"); + fprintf(stderr, "MAC address must be given in hex! [00:11:22:33:44:55]\n"); exit(2); } @@ -50,7 +54,7 @@ &dstaddr[0], &dstaddr[1], &dstaddr[2], &dstaddr[3], &dstaddr[4], &dstaddr[5]); if (k != 6) { - fprintf(stderr, "Ungueltige MAC Adresse! [00:11:22:33:44:55]\n"); + fprintf(stderr, "Invalid MAC address! [00:11:22:33:44:55]\n"); exit(2); } @@ -85,7 +89,7 @@ -main(argc,argv) +int main(argc,argv) int argc; char *argv[]; @@ -98,6 +102,11 @@ int s; int i; + if (argc < 2) { + fprintf(stderr, "Usage: %s xx:xx:xx:xx:xx:xx\n", argv[0]); + exit(1); + } + packetsize = get_magicpacket(magicpacket, argv[1]); if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) @@ -111,7 +120,7 @@ server.sin_addr.s_addr = INADDR_ANY; client.sin_family = AF_INET; - client.sin_port = 7777; + client.sin_port = 32768+666; /* invalid port */ client.sin_addr.s_addr = INADDR_BROADCAST; if (bind(s, (struct sockaddr *)&server, sizeof(server)) < 0)