- 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:
Radek Vokál 2005-02-07 10:46:11 +00:00
parent 3e6663adc0
commit ebeb31b32e
6 changed files with 148 additions and 79 deletions

View File

@ -1,2 +1,3 @@
net-tools-1.60.tar.bz2 net-tools-1.60.tar.bz2
netplug-1.2.7.tar.bz2 netplug-1.2.7.tar.bz2
netplug-1.2.9.tar.bz2

View File

@ -1,33 +1,34 @@
/* ether-wake.c: Send a magic packet to wake up sleeping machines. */ /* ether-wake.c: Send a magic packet to wake up sleeping machines. */
static char version_msg[] = 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[] = static char brief_usage_msg[] =
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\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"; " Use '-u' to see the complete set of options.\n";
static char usage_msg[] = static char usage_msg[] =
"usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n\ "usage: ether-wake [-i <ifname>] [-p aa:bb:cc:dd[:ee:ff]] 00:11:22:33:44:55\n"
\n\ "\n"
This program generates and transmits a Wake-On-LAN (WOL) \"Magic Packet\",\n\ " This program generates and transmits a Wake-On-LAN (WOL)\n"
used for restarting machines that have been soft-powered-down\n\ " \"Magic Packet\", used for restarting machines that have been\n"
(ACPI D3-warm state). It currently generates the standard AMD Magic Packet\n\ " soft-powered-down (ACPI D3-warm state).\n"
format, with an optional password appended.\n\ " It currently generates the standard AMD Magic Packet format, with\n"
\n\ " an optional password appended.\n"
The single required parameter is the Ethernet MAC (station) address\n\ "\n"
of the machine to wake. This is typically retrieved with the 'arp'\n\ " The single required parameter is the Ethernet MAC (station) address\n"
program while the target machine is awake.\n\ " of the machine to wake or a host ID with known NSS 'ethers' entry.\n"
\n\ " The MAC address may be found with the 'arp' program while the target\n"
Options:\n\ " machine is awake.\n"
-b Send wake-up packet to the broadcast address.\n\ "\n"
-D Increase the debug level.\n\ " Options:\n"
-i ifname Use interface IFNAME instead of the default 'eth0'.\n\ " -b Send wake-up packet to the broadcast address.\n"
-p <pw> Append the four or six byte password PW to the packet.\n\ " -D Increase the debug level.\n"
A password is only required for a few adapter types.\n\ " -i ifname Use interface IFNAME instead of the default 'eth0'.\n"
The password may be specified in ethernet hex format\n\ " -p <pw> Append the four or six byte password PW to the packet.\n"
or dotted decimal (Internet address)\n\ " A password is only required for a few adapter types.\n"
-p 00:22:44:66:88:aa\n\ " The password may be specified in ethernet hex format\n"
-p 192.168.1.1\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", 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. of the GNU Public License, incorporated herein by reference.
Contact the author for use under other terms. 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 The author may be reached as becker@scyld, or C/O
Scyld Computing Corporation Scyld Computing Corporation
@ -61,13 +64,17 @@ Options:\n\
-p 00:22:44:66:88:aa -p 00:22:44:66:88:aa
-p 192.168.1.1 -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. dumped, traced or debugged.
If someone traces this program, they get control of a raw socket. If someone traces this program, they get control of a raw socket.
Linux handles this safely, but beware when porting this program. 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 <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -85,9 +92,23 @@ Options:\n\
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/if.h> #include <linux/if.h>
#ifdef UIO_MAXIOV #include <features.h>
/*extern int setsockopt __P ((int __fd, int __level, int __optname, #if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
__ptr_t __optval, int __optlen));*/ #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. */ #else /* New, correct head files. */
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
@ -103,17 +124,24 @@ int wol_passwd_sz = 0;
static int opt_no_src_addr = 0, opt_broadcast = 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); static int get_wol_pw(const char *optarg);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct sockaddr whereto; /* who to wake up */
char *ifname = "eth0"; char *ifname = "eth0";
int one = 1; /* True, for socket options. */ int one = 1; /* True, for socket options. */
int s; /* Raw socket */ int s; /* Raw socket */
int errflag = 0, verbose = 0, do_version = 0; int errflag = 0, verbose = 0, do_version = 0;
int perm_failure = 0;
int i, c, pktsize; 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) while ((c = getopt(argc, argv, "bDi:p:uvV")) != -1)
switch (c) { switch (c) {
@ -142,22 +170,34 @@ int main(int argc, char *argv[])
/* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to /* Note: PF_INET, SOCK_DGRAM, IPPROTO_UDP would allow SIOCGIFHWADDR to
work as non-root, but we need SOCK_PACKET to specify the Ethernet work as non-root, but we need SOCK_PACKET to specify the Ethernet
destination address. */ 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) if (errno == EPERM)
fprintf(stderr, "ether-wake must run as root\n"); fprintf(stderr, "etherwake: This program must be run as root.\n");
else else
perror("ether-wake: socket"); perror("ether-wake: socket");
if (! debug) perm_failure++;
return 2;
} }
/* Don't revert if debugging allows a normal user to get the raw socket. */ /* Don't revert if debugging allows a normal user to get the raw socket. */
setuid(getuid()); 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. /* Fill in the source address, if possible.
The code to retrieve the local station address is Linux specific. */ 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; struct ifreq if_hwaddr;
unsigned char *hwaddr = if_hwaddr.ifr_hwaddr.sa_data; 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) { if (ioctl(s, SIOCGIFHWADDR, &if_hwaddr) < 0) {
fprintf(stderr, "SIOCGIFHWADDR on %s failed: %s\n", ifname, fprintf(stderr, "SIOCGIFHWADDR on %s failed: %s\n", ifname,
strerror(errno)); strerror(errno));
/* Magic packets still work if our source address is bogus, but
we fail just to be anal. */
return 1; return 1;
} }
memcpy(outpack+6, if_hwaddr.ifr_hwaddr.sa_data, 6); 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) if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&one, sizeof(one)) < 0)
perror("setsockopt: SO_BROADCAST"); 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; whereto.sa_family = 0;
strcpy(whereto.sa_data, ifname); 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"); perror("sendto");
else if (debug) else if (debug)
printf("Sendto worked ! %d.\n", i); printf("Sendto worked ! %d.\n", i);
@ -227,36 +290,43 @@ int main(int argc, char *argv[])
return 0; 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]; struct ether_addr *eap;
unsigned char station_addr[6];
int byte_cnt;
int offset, i;
char *cp;
for (cp = arg; *cp; cp++) eap = ether_aton(hostid);
if (*cp != ':' && !isxdigit(*cp)) { if (eap) {
(void)fprintf(stderr, *eaddr = *eap;
"ping: patterns must be specified as hex digits.\n"); if (debug)
exit(2); fprintf(stderr, "The target station address is %s.\n",
} ether_ntoa(eaddr));
} else if (ether_hostton(hostid, eaddr) == 0) {
byte_cnt = sscanf(arg, "%2x:%2x:%2x:%2x:%2x:%2x", if (debug)
&sa[0], &sa[1], &sa[2], &sa[3], &sa[4], &sa[5]); fprintf(stderr, "Station address for hostname %s is %s.\n",
for (i = 0; i < 6; i++) hostid, ether_ntoa(eaddr));
station_addr[i] = sa[i]; } else {
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) {
(void)fprintf(stderr, (void)fprintf(stderr,
"ping: The Magic Packet address must be specified as " "ether-wake: The Magic Packet host address must be "
"00:11:22:33:44:55.\n"); "specified as\n"
exit(2); " - 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) if (opt_broadcast)
memset(pkt+0, 0xff, 6); memset(pkt+0, 0xff, 6);

View File

@ -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.9/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 2005-01-10 11:38:01.796744224 +0100
@@ -24,10 +24,12 @@ @@ -24,10 +24,12 @@
install $(install_opts) -m 755 scripts/rc.netplugd $(initdir)/netplugd install $(install_opts) -m 755 scripts/rc.netplugd $(initdir)/netplugd
install -C $(install_opts) -m 444 man/man8/netplugd.8 $(mandir)/man8 install -C $(install_opts) -m 444 man/man8/netplugd.8 $(mandir)/man8

View File

@ -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/netplug-1.2.9/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.new/netplug-1.2.9/main.c 2004-05-06 18:28:22.845977718 +0200
@@ -149,10 +149,10 @@ @@ -149,10 +149,10 @@
/* Poll the existing interface state, so we can catch any state /* Poll the existing interface state, so we can catch any state

View File

@ -1,9 +1,9 @@
%define npversion 1.2.7 %define npversion 1.2.9
Summary: Basic networking tools. Summary: Basic networking tools.
Name: net-tools Name: net-tools
Version: 1.60 Version: 1.60
Release: 43 Release: 44
License: GPL License: GPL
Group: System Environment/Base Group: System Environment/Base
Source0: http://www.tazenda.demon.co.uk/phil/net-tools/net-tools-%{version}.tar.bz2 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 Patch10: net-tools-1.60-gcc33.patch
Patch11: net-tools-1.60-trailingblank.patch Patch11: net-tools-1.60-trailingblank.patch
Patch12: net-tools-1.60-interface.patch Patch12: net-tools-1.60-interface.patch
Patch13: netplug-1.2.1-init.patch
Patch14: net-tools-1.60-gcc34.patch Patch14: net-tools-1.60-gcc34.patch
Patch15: net-tools-1.60-overflow.patch Patch15: net-tools-1.60-overflow.patch
Patch16: net-tools-1.60-execshield.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 Patch19: net-tools-1.60-siunits.patch
Patch20: net-tools-1.60-trunc.patch Patch20: net-tools-1.60-trunc.patch
Patch21: net-tools-1.60-return.patch Patch21: net-tools-1.60-return.patch
@ -66,12 +63,9 @@ ifconfig, netstat, route, and others.
%patch10 -p1 -b .gcc33 %patch10 -p1 -b .gcc33
%patch11 -p1 -b .trailingblank %patch11 -p1 -b .trailingblank
%patch12 -p1 -b .interface %patch12 -p1 -b .interface
%patch13 -p1 -b .init
%patch14 -p1 -b .gcc34 %patch14 -p1 -b .gcc34
%patch15 -p1 -b .overflow %patch15 -p1 -b .overflow
%patch16 -p1 -b .execshield %patch16 -p1 -b .execshield
%patch17 -p1 -b .compiler
%patch18 -p1 -b .installopts
%patch19 -p1 -b .siunits %patch19 -p1 -b .siunits
%patch20 -p1 -b .trunc %patch20 -p1 -b .trunc
%patch21 -p1 -b .return %patch21 -p1 -b .return
@ -188,6 +182,10 @@ exit 0
%{_sysconfdir}/rc.d/init.d/netplugd %{_sysconfdir}/rc.d/init.d/netplugd
%changelog %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 * Mon Jan 10 2005 Radek Vokal <rvokal@redhat.com> 1.60-43
- don't report statistics for virtual devices (#143981) <kzak@redhat.com> - don't report statistics for virtual devices (#143981) <kzak@redhat.com>
- fixing translation headers - content type format - fixing translation headers - content type format

View File

@ -1,2 +1,2 @@
888774accab40217dde927e21979c165 net-tools-1.60.tar.bz2 888774accab40217dde927e21979c165 net-tools-1.60.tar.bz2
611e0e1957c18dd3d3909137ce4094c6 netplug-1.2.7.tar.bz2 3bc8062d8033e3f897b015f2889ce5a9 netplug-1.2.9.tar.bz2