- net-plug-1.2.9 - no changes, upstream included Red Hat patches
- ether-wake-1.08 - few changes in implementation (#145718)
This commit is contained in:
parent
3e6663adc0
commit
ebeb31b32e
@ -1,2 +1,3 @@
|
||||
net-tools-1.60.tar.bz2
|
||||
netplug-1.2.7.tar.bz2
|
||||
netplug-1.2.9.tar.bz2
|
||||
|
202
ether-wake.c
202
ether-wake.c
@ -1,33 +1,34 @@
|
||||
/* ether-wake.c: Send a magic packet to wake up sleeping machines. */
|
||||
|
||||
static char version_msg[] =
|
||||
"ether-wake.c: v1.05 12/28/2000 Donald Becker, http://www.scyld.com/";
|
||||
"ether-wake.c: v1.08 3/31/2003 Donald Becker, http://www.scyld.com/";
|
||||
static char brief_usage_msg[] =
|
||||
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n\
|
||||
Use '-u' to see the complete set of options.\n";
|
||||
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
|
||||
" Use '-u' to see the complete set of options.\n";
|
||||
static char usage_msg[] =
|
||||
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n\
|
||||
\n\
|
||||
This program generates and transmits a Wake-On-LAN (WOL) \"Magic Packet\",\n\
|
||||
used for restarting machines that have been soft-powered-down\n\
|
||||
(ACPI D3-warm state). It currently generates the standard AMD Magic Packet\n\
|
||||
format, with an optional password appended.\n\
|
||||
\n\
|
||||
The single required parameter is the Ethernet MAC (station) address\n\
|
||||
of the machine to wake. This is typically retrieved with the 'arp'\n\
|
||||
program while the target machine is awake.\n\
|
||||
\n\
|
||||
Options:\n\
|
||||
-b Send wake-up packet to the broadcast address.\n\
|
||||
-D Increase the debug level.\n\
|
||||
-i ifname Use interface IFNAME instead of the default 'eth0'.\n\
|
||||
-p <pw> Append the four or six byte password PW to the packet.\n\
|
||||
A password is only required for a few adapter types.\n\
|
||||
The password may be specified in ethernet hex format\n\
|
||||
or dotted decimal (Internet address)\n\
|
||||
-p 00:22:44:66:88:aa\n\
|
||||
-p 192.168.1.1\n\
|
||||
";
|
||||
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
|
||||
"\n"
|
||||
" This program generates and transmits a Wake-On-LAN (WOL)\n"
|
||||
" \"Magic Packet\", used for restarting machines that have been\n"
|
||||
" soft-powered-down (ACPI D3-warm state).\n"
|
||||
" It currently generates the standard AMD Magic Packet format, with\n"
|
||||
" an optional password appended.\n"
|
||||
"\n"
|
||||
" The single required parameter is the Ethernet MAC (station) address\n"
|
||||
" of the machine to wake or a host ID with known NSS 'ethers' entry.\n"
|
||||
" The MAC address may be found with the 'arp' program while the target\n"
|
||||
" machine is awake.\n"
|
||||
"\n"
|
||||
" Options:\n"
|
||||
" -b Send wake-up packet to the broadcast address.\n"
|
||||
" -D Increase the debug level.\n"
|
||||
" -i ifname Use interface IFNAME instead of the default 'eth0'.\n"
|
||||
" -p <pw> Append the four or six byte password PW to the packet.\n"
|
||||
" A password is only required for a few adapter types.\n"
|
||||
" The password may be specified in ethernet hex format\n"
|
||||
" or dotted decimal (Internet address)\n"
|
||||
" -p 00:22:44:66:88:aa\n"
|
||||
" -p 192.168.1.1\n";
|
||||
|
||||
/*
|
||||
This program generates and transmits a Wake-On-LAN (WOL) "Magic Packet",
|
||||
@ -39,7 +40,9 @@ Options:\n\
|
||||
of the GNU Public License, incorporated herein by reference.
|
||||
Contact the author for use under other terms.
|
||||
|
||||
This source file is part of the network tricks package.
|
||||
This source file was originally part of the network tricks package, and
|
||||
is now distributed to support the Scyld Beowulf system.
|
||||
Copyright 1999-2003 Donald Becker and Scyld Computing Corporation.
|
||||
|
||||
The author may be reached as becker@scyld, or C/O
|
||||
Scyld Computing Corporation
|
||||
@ -61,13 +64,17 @@ Options:\n\
|
||||
-p 00:22:44:66:88:aa
|
||||
-p 192.168.1.1
|
||||
|
||||
Note: On some systems dropping root capability allows the process to be
|
||||
Notes:
|
||||
On some systems dropping root capability allows the process to be
|
||||
dumped, traced or debugged.
|
||||
If someone traces this program, they get control of a raw socket.
|
||||
Linux handles this safely, but beware when porting this program.
|
||||
|
||||
An alternative to needing 'root' is using a UDP broadcast socket, however
|
||||
doing so only works with adapters configured for unicast+broadcast Rx
|
||||
filter. That configuration consumes more power.
|
||||
*/
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -85,9 +92,23 @@ Options:\n\
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#ifdef UIO_MAXIOV
|
||||
/*extern int setsockopt __P ((int __fd, int __level, int __optname,
|
||||
__ptr_t __optval, int __optlen));*/
|
||||
#include <features.h>
|
||||
#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
|
||||
#include <netpacket/packet.h>
|
||||
#include <net/ethernet.h>
|
||||
#else
|
||||
#include <asm/types.h>
|
||||
#include <linux/if_packet.h>
|
||||
#include <linux/if_ether.h>
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <netinet/ether.h>
|
||||
|
||||
/* Grrr, no consistency between include versions.
|
||||
Enable this if setsockopt() isn't declared with your library. */
|
||||
#if 0
|
||||
extern int setsockopt __P ((int __fd, int __level, int __optname,
|
||||
__ptr_t __optval, int __optlen));
|
||||
#else /* New, correct head files. */
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
@ -103,17 +124,24 @@ int wol_passwd_sz = 0;
|
||||
|
||||
static int opt_no_src_addr = 0, opt_broadcast = 0;
|
||||
|
||||
static int get_fill(unsigned char *pkt, char *arg);
|
||||
static int get_dest_addr(const char *arg, struct ether_addr *eaddr);
|
||||
static int get_fill(unsigned char *pkt, struct ether_addr *eaddr);
|
||||
static int get_wol_pw(const char *optarg);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct sockaddr whereto; /* who to wake up */
|
||||
char *ifname = "eth0";
|
||||
int one = 1; /* True, for socket options. */
|
||||
int s; /* Raw socket */
|
||||
int errflag = 0, verbose = 0, do_version = 0;
|
||||
int perm_failure = 0;
|
||||
int i, c, pktsize;
|
||||
#if defined(PF_PACKET)
|
||||
struct sockaddr_ll whereto;
|
||||
#else
|
||||
struct sockaddr whereto; /* who to wake up */
|
||||
#endif
|
||||
struct ether_addr eaddr;
|
||||
|
||||
while ((c = getopt(argc, argv, "bDi:p:uvV")) != -1)
|
||||
switch (c) {
|
||||
@ -142,22 +170,34 @@ int main(int argc, char *argv[])
|
||||
/* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to
|
||||
work as non-root, but we need SOCK_PACKET to specify the Ethernet
|
||||
destination address. */
|
||||
if ((s = socket(AF_INET, SOCK_PACKET, SOCK_PACKET)) < 0) {
|
||||
#if defined(PF_PACKET)
|
||||
s = socket(PF_PACKET, SOCK_RAW, 0);
|
||||
#else
|
||||
s = socket(AF_INET, SOCK_PACKET, SOCK_PACKET);
|
||||
#endif
|
||||
if (s < 0) {
|
||||
if (errno == EPERM)
|
||||
fprintf(stderr, "ether-wake must run as root\n");
|
||||
fprintf(stderr, "etherwake: This program must be run as root.\n");
|
||||
else
|
||||
perror("ether-wake: socket");
|
||||
if (! debug)
|
||||
return 2;
|
||||
perm_failure++;
|
||||
}
|
||||
/* Don't revert if debugging allows a normal user to get the raw socket. */
|
||||
setuid(getuid());
|
||||
|
||||
pktsize = get_fill(outpack, argv[optind]);
|
||||
/* We look up the station address before reporting failure so that
|
||||
errors may be reported even when run as a normal user.
|
||||
*/
|
||||
if (get_dest_addr(argv[optind], &eaddr) != 0)
|
||||
return 3;
|
||||
if (perm_failure && ! debug)
|
||||
return 2;
|
||||
|
||||
pktsize = get_fill(outpack, &eaddr);
|
||||
|
||||
/* Fill in the source address, if possible.
|
||||
The code to retrieve the local station address is Linux specific. */
|
||||
if (! opt_no_src_addr){
|
||||
if (! opt_no_src_addr) {
|
||||
struct ifreq if_hwaddr;
|
||||
unsigned char *hwaddr = if_hwaddr.ifr_hwaddr.sa_data;
|
||||
|
||||
@ -165,6 +205,8 @@ int main(int argc, char *argv[])
|
||||
if (ioctl(s, SIOCGIFHWADDR, &if_hwaddr) < 0) {
|
||||
fprintf(stderr, "SIOCGIFHWADDR on %s failed: %s\n", ifname,
|
||||
strerror(errno));
|
||||
/* Magic packets still work if our source address is bogus, but
|
||||
we fail just to be anal. */
|
||||
return 1;
|
||||
}
|
||||
memcpy(outpack+6, if_hwaddr.ifr_hwaddr.sa_data, 6);
|
||||
@ -193,10 +235,31 @@ int main(int argc, char *argv[])
|
||||
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&one, sizeof(one)) < 0)
|
||||
perror("setsockopt: SO_BROADCAST");
|
||||
|
||||
#if defined(PF_PACKET)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCGIFINDEX, &ifr) == -1) {
|
||||
fprintf(stderr, "SIOCGIFINDEX on %s failed: %s\n", ifname,
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
memset(&whereto, 0, sizeof(whereto));
|
||||
whereto.sll_family = AF_PACKET;
|
||||
whereto.sll_ifindex = ifr.ifr_ifindex;
|
||||
/* The manual page incorrectly claims the address must be filled.
|
||||
We do so because the code may change to match the docs. */
|
||||
whereto.sll_halen = ETH_ALEN;
|
||||
memcpy(whereto.sll_addr, outpack, ETH_ALEN);
|
||||
|
||||
}
|
||||
#else
|
||||
whereto.sa_family = 0;
|
||||
strcpy(whereto.sa_data, ifname);
|
||||
#endif
|
||||
|
||||
if ((i = sendto(s, outpack, pktsize, 0, &whereto, sizeof(whereto))) < 0)
|
||||
if ((i = sendto(s, outpack, pktsize, 0, (struct sockaddr *)&whereto,
|
||||
sizeof(whereto))) < 0)
|
||||
perror("sendto");
|
||||
else if (debug)
|
||||
printf("Sendto worked ! %d.\n", i);
|
||||
@ -227,36 +290,43 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_fill(unsigned char *pkt, char *arg)
|
||||
/* Convert the host ID string to a MAC address.
|
||||
The string may be a
|
||||
Host name
|
||||
IP address string
|
||||
MAC address string
|
||||
*/
|
||||
|
||||
static int get_dest_addr(const char *hostid, struct ether_addr *eaddr)
|
||||
{
|
||||
int sa[6];
|
||||
unsigned char station_addr[6];
|
||||
int byte_cnt;
|
||||
int offset, i;
|
||||
char *cp;
|
||||
struct ether_addr *eap;
|
||||
|
||||
for (cp = arg; *cp; cp++)
|
||||
if (*cp != ':' && !isxdigit(*cp)) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: patterns must be specified as hex digits.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
byte_cnt = sscanf(arg, "%2x:%2x:%2x:%2x:%2x:%2x",
|
||||
&sa[0], &sa[1], &sa[2], &sa[3], &sa[4], &sa[5]);
|
||||
for (i = 0; i < 6; i++)
|
||||
station_addr[i] = sa[i];
|
||||
if (debug)
|
||||
fprintf(stderr, "Command line stations address is "
|
||||
"%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x.\n",
|
||||
sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]);
|
||||
|
||||
if (byte_cnt != 6) {
|
||||
eap = ether_aton(hostid);
|
||||
if (eap) {
|
||||
*eaddr = *eap;
|
||||
if (debug)
|
||||
fprintf(stderr, "The target station address is %s.\n",
|
||||
ether_ntoa(eaddr));
|
||||
} else if (ether_hostton(hostid, eaddr) == 0) {
|
||||
if (debug)
|
||||
fprintf(stderr, "Station address for hostname %s is %s.\n",
|
||||
hostid, ether_ntoa(eaddr));
|
||||
} else {
|
||||
(void)fprintf(stderr,
|
||||
"ping: The Magic Packet address must be specified as "
|
||||
"00:11:22:33:44:55.\n");
|
||||
exit(2);
|
||||
"ether-wake: The Magic Packet host address must be "
|
||||
"specified as\n"
|
||||
" - a station address, 00:11:22:33:44:55, or\n"
|
||||
" - a hostname with a known 'ethers' entry.\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int get_fill(unsigned char *pkt, struct ether_addr *eaddr)
|
||||
{
|
||||
int offset, i;
|
||||
unsigned char *station_addr = eaddr->ether_addr_octet;
|
||||
|
||||
if (opt_broadcast)
|
||||
memset(pkt+0, 0xff, 6);
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- net-tools-1.60/netplug-1.2.7/Makefile.kill_bitkeeper 2005-01-10 11:36:32.000000000 +0100
|
||||
+++ net-tools-1.60/netplug-1.2.7/Makefile 2005-01-10 11:38:01.796744224 +0100
|
||||
--- net-tools-1.60/netplug-1.2.9/Makefile.kill_bitkeeper 2005-01-10 11:36:32.000000000 +0100
|
||||
+++ net-tools-1.60/netplug-1.2.9/Makefile 2005-01-10 11:38:01.796744224 +0100
|
||||
@@ -24,10 +24,12 @@
|
||||
install $(install_opts) -m 755 scripts/rc.netplugd $(initdir)/netplugd
|
||||
install -C $(install_opts) -m 444 man/man8/netplugd.8 $(mandir)/man8
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- net-tools-1.60/netplug-1.2.7/main.c 2004-02-22 06:52:14.000000000 +0100
|
||||
+++ net-tools-1.60.new/netplug-1.2.7/main.c 2004-05-06 18:28:22.845977718 +0200
|
||||
--- net-tools-1.60/netplug-1.2.9/main.c 2004-02-22 06:52:14.000000000 +0100
|
||||
+++ net-tools-1.60.new/netplug-1.2.9/main.c 2004-05-06 18:28:22.845977718 +0200
|
||||
@@ -149,10 +149,10 @@
|
||||
|
||||
/* Poll the existing interface state, so we can catch any state
|
||||
|
@ -1,9 +1,9 @@
|
||||
%define npversion 1.2.7
|
||||
%define npversion 1.2.9
|
||||
|
||||
Summary: Basic networking tools.
|
||||
Name: net-tools
|
||||
Version: 1.60
|
||||
Release: 43
|
||||
Release: 44
|
||||
License: GPL
|
||||
Group: System Environment/Base
|
||||
Source0: http://www.tazenda.demon.co.uk/phil/net-tools/net-tools-%{version}.tar.bz2
|
||||
@ -23,12 +23,9 @@ Patch9: net-tools-1.60-man.patch
|
||||
Patch10: net-tools-1.60-gcc33.patch
|
||||
Patch11: net-tools-1.60-trailingblank.patch
|
||||
Patch12: net-tools-1.60-interface.patch
|
||||
Patch13: netplug-1.2.1-init.patch
|
||||
Patch14: net-tools-1.60-gcc34.patch
|
||||
Patch15: net-tools-1.60-overflow.patch
|
||||
Patch16: net-tools-1.60-execshield.patch
|
||||
Patch17: netplug-1.2.7-compiler.patch
|
||||
Patch18: netplug-1.2.7-installopts.patch
|
||||
Patch19: net-tools-1.60-siunits.patch
|
||||
Patch20: net-tools-1.60-trunc.patch
|
||||
Patch21: net-tools-1.60-return.patch
|
||||
@ -66,12 +63,9 @@ ifconfig, netstat, route, and others.
|
||||
%patch10 -p1 -b .gcc33
|
||||
%patch11 -p1 -b .trailingblank
|
||||
%patch12 -p1 -b .interface
|
||||
%patch13 -p1 -b .init
|
||||
%patch14 -p1 -b .gcc34
|
||||
%patch15 -p1 -b .overflow
|
||||
%patch16 -p1 -b .execshield
|
||||
%patch17 -p1 -b .compiler
|
||||
%patch18 -p1 -b .installopts
|
||||
%patch19 -p1 -b .siunits
|
||||
%patch20 -p1 -b .trunc
|
||||
%patch21 -p1 -b .return
|
||||
@ -188,6 +182,10 @@ exit 0
|
||||
%{_sysconfdir}/rc.d/init.d/netplugd
|
||||
|
||||
%changelog
|
||||
* Mon Feb 07 2005 Radek Vokal <rvokal@redhat.com> 1.60-44
|
||||
- net-plug-1.2.9 - no changes, upstream included Red Hat patches
|
||||
- ether-wake-1.08 - few changes in implementation (#145718)
|
||||
|
||||
* Mon Jan 10 2005 Radek Vokal <rvokal@redhat.com> 1.60-43
|
||||
- don't report statistics for virtual devices (#143981) <kzak@redhat.com>
|
||||
- fixing translation headers - content type format
|
||||
|
Loading…
Reference in New Issue
Block a user