pkgsrc/net/wakeup/patches/patch-aa
2004-11-14 13:35:20 +00:00

74 lines
2 KiB
Text

$NetBSD: patch-aa,v 1.4 2004/11/14 13:35:20 hira Exp $
--- hpwake.c.orig 2004-11-14 21:56:25.000000000 +0900
+++ hpwake.c 2004-11-14 21:57:36.000000000 +0900
@@ -16,8 +16,10 @@
email: wann@server7.ik.mb.uni-siegen.de
*/
+#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
@@ -26,6 +28,8 @@
u_char magicpacket[500];
+int get_magicpacket(unsigned char *,char *);
+int main(int,char *[]);
int get_magicpacket(packet,arg)
@@ -41,8 +45,8 @@
char *a;
for (a = arg; *a; a++)
- if (*a != ':' && !isxdigit(*a)) {
- fprintf(stderr, "MAC Adresse muss hexadezimal angegeben werden! [00:11:22:33:44:55]\n");
+ if (*a != ':' && !isxdigit((unsigned char)*a)) {
+ 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)