1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
$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 <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)
@@ -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)
|