Merge with 4.4-Lite version.
This commit is contained in:
parent
7322d6fb41
commit
3c78ef3311
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.6 (Berkeley) 6/23/90
|
||||
# $Id: Makefile,v 1.4 1993/08/01 05:38:00 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:38:45 mycroft Exp $
|
||||
|
||||
MAN8= fastboot.0
|
||||
MLINKS= fastboot.8 fasthalt.8
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1983, 1991 Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)fastboot.8 6.3 (Berkeley) 3/16/91
|
||||
.\" $Id: fastboot.8,v 1.4 1993/08/01 07:39:16 mycroft Exp $
|
||||
.\" from: @(#)fastboot.8 8.1 (Berkeley) 6/5/93
|
||||
.\" $Id: fastboot.8,v 1.5 1994/09/23 01:38:46 mycroft Exp $
|
||||
.\"
|
||||
.Dd March 16, 1991
|
||||
.Dd June 5, 1993
|
||||
.Dt FASTBOOT 8
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# Copyright (c) 1985 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 1985, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@ -31,9 +31,8 @@
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# @(#)fastboot.sh 5.6 (Berkeley) 4/16/91
|
||||
#
|
||||
# $Header: /cvsroot/src/sbin/fastboot/fastboot.sh,v 1.3 1993/03/23 00:27:39 cgd Exp $
|
||||
# from: @(#)fastboot.sh 8.1 (Berkeley) 6/5/93
|
||||
# $Id: fastboot.sh,v 1.4 1994/09/23 01:38:47 mycroft Exp $
|
||||
#
|
||||
|
||||
cp /dev/null /fastboot
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh -
|
||||
#
|
||||
# Copyright (c) 1988 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 1988, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@ -31,9 +31,8 @@
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# @(#)fasthalt.sh 5.4 (Berkeley) 4/16/91
|
||||
#
|
||||
# $Header: /cvsroot/src/sbin/fastboot/fasthalt.sh,v 1.3 1993/03/23 00:27:41 cgd Exp $
|
||||
# from: @(#)fasthalt.sh 8.1 (Berkeley) 6/5/93
|
||||
# $Id: fasthalt.sh,v 1.4 1994/09/23 01:38:48 mycroft Exp $
|
||||
#
|
||||
|
||||
cp /dev/null /fastboot
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.4 1993/08/01 05:37:44 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:38:50 mycroft Exp $
|
||||
|
||||
PROG= ifconfig
|
||||
MAN8= ifconfig.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)ifconfig.8 6.13 (Berkeley) 3/16/91
|
||||
.\" $Id: ifconfig.8,v 1.8 1994/01/22 00:29:20 cgd Exp $
|
||||
.\" from: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
|
||||
.\" $Id: ifconfig.8,v 1.9 1994/09/23 01:38:51 mycroft Exp $
|
||||
.\"
|
||||
.Dd March 16, 1991
|
||||
.Dd January 5, 1994
|
||||
.Dt IFCONFIG 8
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
@ -176,7 +176,7 @@ Higher metrics have the effect of making a route
|
||||
less favorable; metrics are counted as addition hops
|
||||
to the destination network or host.
|
||||
.It Cm netmask Ar mask
|
||||
(Inet and Iso)
|
||||
(Inet and ISO)
|
||||
Specify how much of the address to reserve for subdividing
|
||||
networks into sub-networks.
|
||||
The mask includes the network part of the local address
|
||||
@ -204,7 +204,7 @@ taken to be the
|
||||
(Network Entity Title).
|
||||
The default value is 1, which is conformant to US
|
||||
.Tn GOSIP .
|
||||
When an iso address is set in an ifconfig command,
|
||||
When an ISO address is set in an ifconfig command,
|
||||
it is really the
|
||||
.Tn NSAP
|
||||
which is being specified.
|
||||
@ -214,7 +214,7 @@ For example, in
|
||||
specified in the
|
||||
.Tn ISO NSAP
|
||||
to be assigned to the interface.
|
||||
There is some evidence that a number different 1 may be useful
|
||||
There is some evidence that a number different from 1 may be useful
|
||||
for
|
||||
.Tn AFI
|
||||
37 type addresses.
|
||||
@ -238,15 +238,13 @@ Currently used by Internet protocols only.
|
||||
Disable the use of a ``trailer'' link level encapsulation.
|
||||
.It Cm link[0-2]
|
||||
Enable special processing of the link level of the interface.
|
||||
These three options are interface specific in actual effect,
|
||||
however, they are in general used to select special modes
|
||||
of operation. An example of this is to enable SLIP
|
||||
compression or to select BNC (thin-net) or the
|
||||
AUI port on certain ethernet cards. Refer to the man
|
||||
page for the specific driver for more information.
|
||||
These three options are interface specific in actual effect, however,
|
||||
they are in general used to select special modes of operation. An example
|
||||
of this is to enable SLIP compression, or to select the connector type
|
||||
for some ethernet cards. Refer to the man page for the specific driver
|
||||
for more information.
|
||||
.It Fl link[0-2]
|
||||
Disables special processing at the link level with the
|
||||
specified interface.
|
||||
Disable special processing at the link level with the specified interface.
|
||||
.It Cm up
|
||||
Mark an interface ``up''.
|
||||
This may be used to enable an interface after an ``ifconfig down.''
|
||||
@ -264,7 +262,7 @@ Ifconfig will report only the details specific to that protocol family.
|
||||
.Pp
|
||||
The interface name
|
||||
.Ar -a
|
||||
is reserved, and causes information on all interfaces to be printed.
|
||||
is reserved, and causes information on all interfaces to be displayed.
|
||||
The protocol family may be specified as well.
|
||||
.Pp
|
||||
Only the super-user may modify the configuration of a network interface.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -32,14 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1983, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)ifconfig.c 5.1 (Berkeley) 2/28/91";*/
|
||||
static char rcsid[] = "$Id: ifconfig.c,v 1.12 1994/01/22 02:04:35 cgd Exp $";
|
||||
/*static char sccsid[] = "from: @(#)ifconfig.c 8.2 (Berkeley) 2/16/94";*/
|
||||
static char *rcsid = "$Id: ifconfig.c,v 1.13 1994/09/23 01:38:52 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -53,28 +53,25 @@ static char rcsid[] = "$Id: ifconfig.c,v 1.12 1994/01/22 02:04:35 cgd Exp $";
|
||||
#define NSIP
|
||||
#include <netns/ns.h>
|
||||
#include <netns/ns_if.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#define EON
|
||||
#include <netiso/iso.h>
|
||||
#include <netiso/iso_var.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <sys/protosw.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct ifreq ifr, ridreq;
|
||||
struct ifaliasreq addreq;
|
||||
#ifdef EON
|
||||
struct iso_ifreq iso_ridreq;
|
||||
struct iso_aliasreq iso_addreq;
|
||||
#endif
|
||||
struct sockaddr_in netmask;
|
||||
|
||||
char name[30];
|
||||
@ -87,11 +84,14 @@ int doalias;
|
||||
int clearaddr;
|
||||
int newaddr = 1;
|
||||
int s;
|
||||
extern int errno;
|
||||
int af = AF_INET;
|
||||
|
||||
int setifflags(), setifaddr(), setifdstaddr(), setifnetmask();
|
||||
int setifmetric(), setifbroadaddr(), setifipdst();
|
||||
int notealias(), setsnpaoffset(), setnsellength();
|
||||
int notealias(), setsnpaoffset(), setnsellength(), notrailers();
|
||||
int getinfo __P((struct ifreq *));
|
||||
void getsock __P((int));
|
||||
void printall __P((void));
|
||||
|
||||
#define NEXTARG 0xffffff
|
||||
|
||||
@ -102,18 +102,12 @@ struct cmd {
|
||||
} cmds[] = {
|
||||
{ "up", IFF_UP, setifflags } ,
|
||||
{ "down", -IFF_UP, setifflags },
|
||||
{ "trailers", -IFF_NOTRAILERS,setifflags },
|
||||
{ "-trailers", IFF_NOTRAILERS, setifflags },
|
||||
{ "trailers", -1, notrailers },
|
||||
{ "-trailers", 1, notrailers },
|
||||
{ "arp", -IFF_NOARP, setifflags },
|
||||
{ "-arp", IFF_NOARP, setifflags },
|
||||
{ "debug", IFF_DEBUG, setifflags },
|
||||
{ "-debug", -IFF_DEBUG, setifflags },
|
||||
{ "link0", IFF_LINK0, setifflags },
|
||||
{ "-link0", -IFF_LINK0, setifflags },
|
||||
{ "link1", IFF_LINK1, setifflags },
|
||||
{ "-link1", -IFF_LINK1, setifflags },
|
||||
{ "link2", IFF_LINK2, setifflags },
|
||||
{ "-link2", -IFF_LINK2, setifflags },
|
||||
{ "alias", IFF_UP, notealias },
|
||||
{ "-alias", -IFF_UP, notealias },
|
||||
{ "delete", -IFF_UP, notealias },
|
||||
@ -128,26 +122,23 @@ struct cmd {
|
||||
{ "ipdst", NEXTARG, setifipdst },
|
||||
{ "snpaoffset", NEXTARG, setsnpaoffset },
|
||||
{ "nsellength", NEXTARG, setnsellength },
|
||||
{ "link0", IFF_LINK0, setifflags } ,
|
||||
{ "-link0", -IFF_LINK0, setifflags } ,
|
||||
{ "link1", IFF_LINK1, setifflags } ,
|
||||
{ "-link1", -IFF_LINK1, setifflags } ,
|
||||
{ "link2", IFF_LINK2, setifflags } ,
|
||||
{ "-link2", -IFF_LINK2, setifflags } ,
|
||||
{ 0, 0, setifaddr },
|
||||
{ 0, 0, setifdstaddr },
|
||||
};
|
||||
|
||||
/*
|
||||
* XNS support liberally adapted from
|
||||
* code written at the University of Maryland
|
||||
* principally by James O'Toole and Chris Torek.
|
||||
* XNS support liberally adapted from code written at the University of
|
||||
* Maryland principally by James O'Toole and Chris Torek.
|
||||
*/
|
||||
int in_status(), in_getaddr();
|
||||
int in_s = -1;
|
||||
|
||||
#ifdef NSIP
|
||||
int xns_status(), xns_getaddr();
|
||||
int xns_s = -1;
|
||||
#endif
|
||||
#ifdef EON
|
||||
int iso_status(), iso_getaddr();
|
||||
int iso_s = -1;
|
||||
#endif
|
||||
|
||||
/* Known address families */
|
||||
struct afswtch {
|
||||
@ -163,14 +154,10 @@ struct afswtch {
|
||||
#define C(x) ((caddr_t) &x)
|
||||
{ "inet", AF_INET, in_status, in_getaddr,
|
||||
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
|
||||
#ifdef NSIP
|
||||
{ "ns", AF_NS, xns_status, xns_getaddr,
|
||||
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
|
||||
#endif
|
||||
#ifdef EON
|
||||
{ "iso", AF_ISO, iso_status, iso_getaddr,
|
||||
SIOCDIFADDR_ISO, SIOCAIFADDR_ISO, C(iso_ridreq), C(iso_addreq) },
|
||||
#endif
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@ -180,27 +167,23 @@ main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int af = AF_INET;
|
||||
register struct afswtch *rafp;
|
||||
int all = 0;
|
||||
int aflag = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s%s",
|
||||
fprintf(stderr, "usage: ifconfig interface\n%s%s%s%s%s",
|
||||
"\t[ af [ address [ dest_addr ] ] [ up ] [ down ] ",
|
||||
"[ netmask mask ] ]\n",
|
||||
"\t[ metric n ]\n",
|
||||
"\t[ arp | -arp ]\n",
|
||||
"\t[ link0 | -link0 ] [ link1 | -link1 ] ",
|
||||
"[ link2 | -link2 ]\n");
|
||||
"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n");
|
||||
exit(1);
|
||||
}
|
||||
argc--, argv++;
|
||||
if(strcmp(*argv, "-a")==0)
|
||||
all = 1;
|
||||
else {
|
||||
if (!strcmp(*argv, "-a"))
|
||||
aflag = 1;
|
||||
else
|
||||
strncpy(name, *argv, sizeof(name));
|
||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
}
|
||||
argc--, argv++;
|
||||
if (argc > 0) {
|
||||
for (afp = rafp = afs; rafp->af_name; rafp++)
|
||||
@ -211,48 +194,17 @@ main(argc, argv)
|
||||
rafp = afp;
|
||||
af = ifr.ifr_addr.sa_family = rafp->af_af;
|
||||
}
|
||||
in_s = s = socket(af, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
perror("ifconfig: socket");
|
||||
exit(1);
|
||||
}
|
||||
#ifdef NSIP
|
||||
xns_s = socket(AF_NS, SOCK_DGRAM, 0);
|
||||
if(xns_s < 0) {
|
||||
if (errno != EPROTONOSUPPORT) {
|
||||
perror("ifconfig: xns: socket");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef EON
|
||||
iso_s = socket(AF_ISO, SOCK_DGRAM, 0);
|
||||
if (iso_s < 0) {
|
||||
if (errno != EPROTONOSUPPORT) {
|
||||
perror("ifconfig: iso: socket");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(all) {
|
||||
printall(af);
|
||||
if (aflag) {
|
||||
printall();
|
||||
exit(0);
|
||||
}
|
||||
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
|
||||
Perror("ioctl (SIOCGIFFLAGS)");
|
||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (getinfo(&ifr) < 0)
|
||||
exit(1);
|
||||
}
|
||||
if(argc==0) {
|
||||
handle_ifreq(&ifr);
|
||||
if (argc == 0) {
|
||||
status();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||
flags = ifr.ifr_flags;
|
||||
if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0)
|
||||
perror("ioctl (SIOCGIFMETRIC)");
|
||||
else
|
||||
metric = ifr.ifr_metric;
|
||||
|
||||
while (argc > 0) {
|
||||
register struct cmd *p;
|
||||
|
||||
@ -275,7 +227,6 @@ main(argc, argv)
|
||||
}
|
||||
if (af == AF_ISO)
|
||||
adjust_nsellength();
|
||||
#ifdef NSIP
|
||||
if (setipdst && af==AF_NS) {
|
||||
struct nsip_req rq;
|
||||
int size = sizeof(rq);
|
||||
@ -284,9 +235,8 @@ main(argc, argv)
|
||||
rq.rq_ip = addreq.ifra_dstaddr;
|
||||
|
||||
if (setsockopt(s, 0, SO_NSIP_ROUTE, &rq, size) < 0)
|
||||
Perror("Encapsulation Routing");
|
||||
warn("encapsulation routing");
|
||||
}
|
||||
#endif
|
||||
if (clearaddr) {
|
||||
int ret;
|
||||
strncpy(rafp->af_ridreq, name, sizeof ifr.ifr_name);
|
||||
@ -294,75 +244,86 @@ main(argc, argv)
|
||||
if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
|
||||
/* means no previous address for interface */
|
||||
} else
|
||||
Perror("ioctl (SIOCDIFADDR)");
|
||||
warn("SIOCDIFADDR");
|
||||
}
|
||||
}
|
||||
if (newaddr) {
|
||||
strncpy(rafp->af_addreq, name, sizeof ifr.ifr_name);
|
||||
if (ioctl(s, rafp->af_aifaddr, rafp->af_addreq) < 0)
|
||||
Perror("ioctl (SIOCAIFADDR)");
|
||||
warn("SIOCAIFADDR");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
getsock(naf)
|
||||
int naf;
|
||||
{
|
||||
static int oaf = -1;
|
||||
|
||||
if (oaf == naf)
|
||||
return;
|
||||
if (oaf != -1)
|
||||
close(s);
|
||||
s = socket(naf, SOCK_DGRAM, 0);
|
||||
if (s < 0)
|
||||
oaf = -1;
|
||||
else
|
||||
oaf = naf;
|
||||
}
|
||||
|
||||
int
|
||||
getinfo(ifr)
|
||||
struct ifreq *ifr;
|
||||
{
|
||||
|
||||
getsock(af);
|
||||
if (s < 0)
|
||||
err(1, "socket");
|
||||
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) < 0) {
|
||||
warn("SIOCGIFFLAGS");
|
||||
return (-1);
|
||||
}
|
||||
flags = ifr->ifr_flags;
|
||||
if (ioctl(s, SIOCGIFMETRIC, (caddr_t)ifr) < 0) {
|
||||
warn("SIOCGIFMETRIC");
|
||||
metric = 0;
|
||||
} else
|
||||
metric = ifr->ifr_metric;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
printall()
|
||||
{
|
||||
char inbuf[8192];
|
||||
struct ifconf ifc;
|
||||
struct ifreq ifreq, *ifr;
|
||||
struct in_addr in;
|
||||
int i, len;
|
||||
int i;
|
||||
|
||||
ifc.ifc_len = sizeof inbuf;
|
||||
ifc.ifc_len = sizeof(inbuf);
|
||||
ifc.ifc_buf = inbuf;
|
||||
if( ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||
perror("ioctl(SIOCGIFCONF)");
|
||||
return -1;
|
||||
}
|
||||
getsock(af);
|
||||
if (s < 0)
|
||||
err(1, "socket");
|
||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
|
||||
err(1, "SIOCGIFCONF");
|
||||
ifr = ifc.ifc_req;
|
||||
ifreq.ifr_name[0] = '\0';
|
||||
for(i=0; i<ifc.ifc_len; i+=len, ifr=(struct ifreq *)((caddr_t)ifr+len)) {
|
||||
len = sizeof ifr->ifr_name + ifr->ifr_addr.sa_len;
|
||||
ifreq = *ifr;
|
||||
if( ioctl(s, SIOCGIFFLAGS, &ifreq) < 0) {
|
||||
perror("ioctl(SIOCGIFFLAGS)");
|
||||
for (i = 0; i < ifc.ifc_len; ) {
|
||||
ifr = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
|
||||
i += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
|
||||
if (!strncmp(ifreq.ifr_name, ifr->ifr_name,
|
||||
sizeof(ifr->ifr_name)))
|
||||
continue;
|
||||
}
|
||||
handle_ifreq(&ifreq);
|
||||
strncpy(name, ifr->ifr_name, sizeof(ifr->ifr_name));
|
||||
ifreq = *ifr;
|
||||
if (getinfo(&ifreq) < 0)
|
||||
continue;
|
||||
status();
|
||||
}
|
||||
}
|
||||
|
||||
struct ifseen {
|
||||
struct ifseen *next;
|
||||
char *name;
|
||||
} *ifshead;
|
||||
|
||||
handle_ifreq(ifr)
|
||||
struct ifreq *ifr;
|
||||
{
|
||||
struct ifseen *ifs;
|
||||
|
||||
for(ifs=ifshead; ifs; ifs=ifs->next)
|
||||
if(strcmp(ifs->name, ifr->ifr_name)==0)
|
||||
return;
|
||||
|
||||
strncpy(name, ifr->ifr_name, sizeof ifr->ifr_name);
|
||||
flags = ifr->ifr_flags;
|
||||
|
||||
if (ioctl(s, SIOCGIFMETRIC, (caddr_t)ifr) < 0) {
|
||||
perror("ioctl (SIOCGIFMETRIC)");
|
||||
metric = 0;
|
||||
} else
|
||||
metric = ifr->ifr_metric;
|
||||
status();
|
||||
|
||||
ifs = (struct ifseen *)malloc(sizeof *ifs);
|
||||
ifs->name = strdup(ifr->ifr_name);
|
||||
ifs->next = ifshead;
|
||||
ifshead = ifs;
|
||||
}
|
||||
|
||||
#define RIDADDR 0
|
||||
#define ADDR 1
|
||||
#define MASK 2
|
||||
@ -421,6 +382,14 @@ notealias(addr, param)
|
||||
clearaddr = 0;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
notrailers(vname, value)
|
||||
char *vname;
|
||||
int value;
|
||||
{
|
||||
printf("Note: trailers are no longer sent, but always received\n");
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
setifdstaddr(addr, param)
|
||||
char *addr;
|
||||
@ -433,10 +402,8 @@ setifflags(vname, value)
|
||||
char *vname;
|
||||
short value;
|
||||
{
|
||||
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
|
||||
Perror("ioctl (SIOCGIFFLAGS)");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0)
|
||||
err(1, "SIOCGIFFLAGS");
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
flags = ifr.ifr_flags;
|
||||
|
||||
@ -447,7 +414,7 @@ setifflags(vname, value)
|
||||
flags |= value;
|
||||
ifr.ifr_flags = flags;
|
||||
if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&ifr) < 0)
|
||||
Perror(vname);
|
||||
err(1, "SIOCSIFFLAGS");
|
||||
}
|
||||
|
||||
setifmetric(val)
|
||||
@ -456,19 +423,18 @@ setifmetric(val)
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
ifr.ifr_metric = atoi(val);
|
||||
if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
|
||||
perror("ioctl (set metric)");
|
||||
warn("SIOCSIFMETRIC");
|
||||
}
|
||||
|
||||
setsnpaoffset(val)
|
||||
char *val;
|
||||
{
|
||||
#ifdef EON
|
||||
iso_addreq.ifra_snpaoffset = atoi(val);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define IFFBITS \
|
||||
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST"
|
||||
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\
|
||||
\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST"
|
||||
|
||||
/*
|
||||
* Print the status of the interface. If an address family was
|
||||
@ -498,31 +464,39 @@ in_status(force)
|
||||
struct sockaddr_in *sin;
|
||||
char *inet_ntoa();
|
||||
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
if (ioctl(in_s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
|
||||
getsock(AF_INET);
|
||||
if (s < 0) {
|
||||
if (errno == EPROTONOSUPPORT)
|
||||
return;
|
||||
err(1, "socket");
|
||||
}
|
||||
bzero((caddr_t)&ifr, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
|
||||
if (!force)
|
||||
return;
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
} else
|
||||
perror("ioctl (SIOCGIFADDR)");
|
||||
warn("SIOCGIFADDR");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
sin = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
printf("\tinet %s ", inet_ntoa(sin->sin_addr));
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
if (ioctl(in_s, SIOCGIFNETMASK, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFNETMASK, (caddr_t)&ifr) < 0) {
|
||||
if (errno != EADDRNOTAVAIL)
|
||||
perror("ioctl (SIOCGIFNETMASK)");
|
||||
warn("SIOCGIFNETMASK");
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
} else
|
||||
netmask.sin_addr =
|
||||
((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
|
||||
if (flags & IFF_POINTOPOINT) {
|
||||
if (ioctl(in_s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL)
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
else
|
||||
perror("ioctl (SIOCGIFDSTADDR)");
|
||||
warn("SIOCGIFDSTADDR");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
sin = (struct sockaddr_in *)&ifr.ifr_dstaddr;
|
||||
@ -530,11 +504,11 @@ in_status(force)
|
||||
}
|
||||
printf("netmask 0x%x ", ntohl(netmask.sin_addr.s_addr));
|
||||
if (flags & IFF_BROADCAST) {
|
||||
if (ioctl(in_s, SIOCGIFBRDADDR, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFBRDADDR, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL)
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
else
|
||||
perror("ioctl (SIOCGIFADDR)");
|
||||
warn("SIOCGIFBRDADDR");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
sin = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
@ -544,33 +518,36 @@ in_status(force)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
#ifdef NSIP
|
||||
|
||||
xns_status(force)
|
||||
int force;
|
||||
{
|
||||
struct sockaddr_ns *sns;
|
||||
|
||||
if (xns_s < 0)
|
||||
getsock(AF_NS);
|
||||
if (s < 0) {
|
||||
if (errno == EPROTONOSUPPORT)
|
||||
return;
|
||||
|
||||
if (ioctl(xns_s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
|
||||
err(1, "socket");
|
||||
}
|
||||
bzero((caddr_t)&ifr, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (ioctl(s, SIOCGIFADDR, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
|
||||
if (!force)
|
||||
return;
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
} else
|
||||
perror("ioctl (SIOCGIFADDR)");
|
||||
warn("SIOCGIFADDR");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||
sns = (struct sockaddr_ns *)&ifr.ifr_addr;
|
||||
printf("\tns %s ", ns_ntoa(sns->sns_addr));
|
||||
if (flags & IFF_POINTOPOINT) { /* by W. Nesheim@Cornell */
|
||||
if (ioctl(xns_s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL)
|
||||
bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
|
||||
else
|
||||
Perror("ioctl (SIOCGIFDSTADDR)");
|
||||
warn("SIOCGIFDSTADDR");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
sns = (struct sockaddr_ns *)&ifr.ifr_dstaddr;
|
||||
@ -579,43 +556,45 @@ xns_status(force)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef EON
|
||||
iso_status(force)
|
||||
int force;
|
||||
{
|
||||
struct sockaddr_iso *siso;
|
||||
struct iso_ifreq ifr;
|
||||
|
||||
if (iso_s < 0)
|
||||
getsock(AF_ISO);
|
||||
if (s < 0) {
|
||||
if (errno == EPROTONOSUPPORT)
|
||||
return;
|
||||
err(1, "socket");
|
||||
}
|
||||
bzero((caddr_t)&ifr, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (ioctl(iso_s, SIOCGIFADDR_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFADDR_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
|
||||
if (!force)
|
||||
return;
|
||||
bzero((char *)&ifr.ifr_Addr, sizeof(ifr.ifr_Addr));
|
||||
} else {
|
||||
perror("ioctl (SIOCGIFADDR_ISO)");
|
||||
exit(1);
|
||||
}
|
||||
} else
|
||||
warn("SIOCGIFADDR_ISO");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||
siso = &ifr.ifr_Addr;
|
||||
printf("\tiso %s ", iso_ntoa(&siso->siso_addr));
|
||||
if (ioctl(iso_s, SIOCGIFNETMASK_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (errno != EADDRNOTAVAIL)
|
||||
perror("ioctl (SIOCGIFNETMASK_ISO)");
|
||||
if (ioctl(s, SIOCGIFNETMASK_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL)
|
||||
bzero((char *)&ifr.ifr_Addr, sizeof(ifr.ifr_Addr));
|
||||
else
|
||||
warn("SIOCGIFNETMASK_ISO");
|
||||
} else {
|
||||
printf(" netmask %s ", iso_ntoa(&siso->siso_addr));
|
||||
}
|
||||
if (flags & IFF_POINTOPOINT) {
|
||||
if (ioctl(iso_s, SIOCGIFDSTADDR_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (ioctl(s, SIOCGIFDSTADDR_ISO, (caddr_t)&ifr) < 0) {
|
||||
if (errno == EADDRNOTAVAIL)
|
||||
bzero((char *)&ifr.ifr_Addr, sizeof(ifr.ifr_Addr));
|
||||
else
|
||||
Perror("ioctl (SIOCGIFDSTADDR_ISO)");
|
||||
warn("SIOCGIFDSTADDR_ISO");
|
||||
}
|
||||
strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
|
||||
siso = &ifr.ifr_Addr;
|
||||
@ -623,27 +602,6 @@ iso_status(force)
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
#endif
|
||||
|
||||
Perror(cmd)
|
||||
char *cmd;
|
||||
{
|
||||
extern int errno;
|
||||
|
||||
switch (errno) {
|
||||
|
||||
case ENXIO:
|
||||
errx(1, "%s: no such interface", cmd);
|
||||
break;
|
||||
|
||||
case EPERM:
|
||||
errx(1, "%s: permission denied", cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
err(1, "%s", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
struct in_addr inet_makeaddr();
|
||||
|
||||
@ -706,7 +664,6 @@ printb(s, v, bits)
|
||||
putchar('>');
|
||||
}
|
||||
}
|
||||
#ifdef NSIP
|
||||
|
||||
#define SNS(x) ((struct sockaddr_ns *) &(x))
|
||||
struct sockaddr_ns *snstab[] = {
|
||||
@ -726,8 +683,6 @@ char *addr;
|
||||
printf("Attempt to set XNS netmask will be ineffectual\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef EON
|
||||
#define SISO(x) ((struct sockaddr_iso *) &(x))
|
||||
struct sockaddr_iso *sisotab[] = {
|
||||
SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr),
|
||||
@ -748,7 +703,6 @@ char *addr;
|
||||
siso->siso_family = AF_ISO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
setnsellength(val)
|
||||
char *val;
|
||||
@ -760,7 +714,6 @@ setnsellength(val)
|
||||
errx(1, "Setting NSEL length valid only for iso");
|
||||
}
|
||||
|
||||
#ifdef EON
|
||||
fixnsel(s)
|
||||
register struct sockaddr_iso *s;
|
||||
{
|
||||
@ -768,13 +721,10 @@ register struct sockaddr_iso *s;
|
||||
return;
|
||||
s->siso_tlen = nsellength;
|
||||
}
|
||||
#endif
|
||||
|
||||
adjust_nsellength()
|
||||
{
|
||||
#ifdef EON
|
||||
fixnsel(sisotab[RIDADDR]);
|
||||
fixnsel(sisotab[ADDR]);
|
||||
fixnsel(sisotab[DSTADDR]);
|
||||
#endif
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.4 1993/08/01 05:37:37 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:38:54 mycroft Exp $
|
||||
|
||||
PROG= mknod
|
||||
MAN8= mknod.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1980, 1991 Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)mknod.8 6.4 (Berkeley) 3/16/91
|
||||
.\" $Id: mknod.8,v 1.6 1994/01/14 02:06:08 jtc Exp $
|
||||
.\" from: @(#)mknod.8 8.2 (Berkeley) 12/11/93
|
||||
.\" $Id: mknod.8,v 1.7 1994/09/23 01:38:55 mycroft Exp $
|
||||
.\"
|
||||
.Dd March 16, 1991
|
||||
.Dd December 11, 1993
|
||||
.Dt MKNOD 8
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
@ -97,5 +97,5 @@ or a tty line.
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Nm
|
||||
command appeared in
|
||||
command appeared in
|
||||
.At v6 .
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Kevin Fall.
|
||||
@ -35,14 +35,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1989, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)mknod.c 4.4 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: mknod.c,v 1.4 1993/08/01 18:26:34 mycroft Exp $";
|
||||
/*static char sccsid[] = "from: @(#)mknod.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: mknod.c,v 1.5 1994/09/23 01:38:56 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.4 1993/08/01 05:27:07 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:38:58 mycroft Exp $
|
||||
|
||||
PROG= ping
|
||||
MAN8= ping.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1985, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1985, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)ping.8 6.7 (Berkeley) 3/16/91
|
||||
.\" $Id: ping.8,v 1.4 1993/08/01 07:38:34 mycroft Exp $
|
||||
.\" from: @(#)ping.8 8.2 (Berkeley) 12/11/93
|
||||
.\" $Id: ping.8,v 1.5 1994/09/23 01:38:59 mycroft Exp $
|
||||
.\"
|
||||
.Dd March 16, 1991
|
||||
.Dd December 11, 1993
|
||||
.Dt PING 8
|
||||
.Os BSD 4.3
|
||||
.Sh NAME
|
||||
@ -42,12 +42,14 @@
|
||||
packets to network hosts
|
||||
.Sh SYNOPSIS
|
||||
.Nm ping
|
||||
.Op Fl dfnqrvR
|
||||
.Op Fl dfLnqRrv
|
||||
.Op Fl c Ar count
|
||||
.Op Fl I Ar ifaddr
|
||||
.Op Fl i Ar wait
|
||||
.Op Fl l Ar preload
|
||||
.Op Fl p Ar pattern
|
||||
.Op Fl s Ar packetsize
|
||||
.Op Fl t Ar ttl
|
||||
.Sh DESCRIPTION
|
||||
.Nm Ping
|
||||
uses the
|
||||
@ -66,7 +68,6 @@ followed by a
|
||||
and then an arbitrary number of ``pad'' bytes used to fill out the
|
||||
packet.
|
||||
The options are as follows:
|
||||
Other options are:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl c Ar count
|
||||
Stop after sending (and receiving)
|
||||
@ -83,7 +84,7 @@ Outputs packets as fast as they come back or one hundred times per second,
|
||||
whichever is more.
|
||||
For every
|
||||
.Tn ECHO_REQUEST
|
||||
sent a period ``.'' is printed, while for ever
|
||||
sent a period ``.'' is printed, while for every
|
||||
.Tn ECHO_REPLY
|
||||
received a backspace is printed.
|
||||
This provides a rapid display of how many packets are being dropped.
|
||||
@ -154,6 +155,17 @@ packets other than
|
||||
that are received are listed.
|
||||
.El
|
||||
.Pp
|
||||
In addition, the following options may be used for multicast pings:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl I Ar ifaddr
|
||||
Transmit using the specified interface address.
|
||||
.It Fl L
|
||||
Disable the loopback, so the transmitting host doesn't see the ICMP
|
||||
requests.
|
||||
.It Fl t Ar ttl
|
||||
Use the specified time-to-live.
|
||||
.El
|
||||
.Pp
|
||||
When using
|
||||
.Nm ping
|
||||
for fault isolation, it should first be run on the local host, to verify
|
||||
|
227
sbin/ping/ping.c
227
sbin/ping/ping.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Mike Muuss.
|
||||
@ -35,14 +35,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1989, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)ping.c 5.9 (Berkeley) 5/12/91";*/
|
||||
static char rcsid[] = "$Id: ping.c,v 1.7 1993/12/15 04:46:13 hpeyerl Exp $";
|
||||
/*static char sccsid[] = "from: @(#)ping.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: ping.c,v 1.8 1994/09/23 01:39:00 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -108,9 +108,9 @@ int options;
|
||||
|
||||
/* multicast options */
|
||||
int moptions;
|
||||
#define MULTICAST_NOLOOP 0x001
|
||||
#define MULTICAST_TTL 0x002
|
||||
#define MULTICAST_IF 0x004
|
||||
#define MULTICAST_NOLOOP 0x001
|
||||
#define MULTICAST_TTL 0x002
|
||||
#define MULTICAST_IF 0x004
|
||||
|
||||
/*
|
||||
* MAX_DUP_CHK is the number of bits in received table, i.e. the maximum
|
||||
@ -139,9 +139,9 @@ int interval = 1; /* interval between packets */
|
||||
|
||||
/* timing */
|
||||
int timing; /* flag to do timing */
|
||||
double tmin = 100.0*(double)LONG_MAX; /* minimum round trip time */
|
||||
double tmax; /* maximum round trip time */
|
||||
double tsum; /* sum of all times, for doing average */
|
||||
double tmin = 999999999.0; /* minimum round trip time */
|
||||
double tmax = 0.0; /* maximum round trip time */
|
||||
double tsum = 0.0; /* sum of all times, for doing average */
|
||||
|
||||
char *pr_addr();
|
||||
void catcher(), finish();
|
||||
@ -157,11 +157,11 @@ main(argc, argv)
|
||||
struct sockaddr_in *to;
|
||||
struct protoent *proto;
|
||||
struct in_addr ifaddr;
|
||||
int i;
|
||||
register int i;
|
||||
int ch, fdmask, hold, packlen, preload;
|
||||
u_char *datap, *packet;
|
||||
char *target, hnamebuf[MAXHOSTNAMELEN], *malloc();
|
||||
u_char ttl, loop;
|
||||
u_char ttl, loop = 1;
|
||||
#ifdef IP_OPTIONS
|
||||
char rspace[3 + 4 * NROUTES + 1]; /* record route space */
|
||||
#endif
|
||||
@ -172,40 +172,38 @@ main(argc, argv)
|
||||
switch(ch) {
|
||||
case 'c':
|
||||
npackets = atoi(optarg);
|
||||
if (npackets <= 0) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: bad number of packets to transmit.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (npackets <= 0)
|
||||
errx(1, "bad number of packets to transmit: %s",
|
||||
optarg);
|
||||
break;
|
||||
case 'd':
|
||||
options |= F_SO_DEBUG;
|
||||
break;
|
||||
case 'f':
|
||||
if (getuid()) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: %s\n", strerror(EPERM));
|
||||
exit(1);
|
||||
}
|
||||
if (getuid())
|
||||
errx(1, "%s", strerror(EPERM));
|
||||
options |= F_FLOOD;
|
||||
setbuf(stdout, (char *)NULL);
|
||||
break;
|
||||
case 'I':
|
||||
if (inet_aton(optarg, &ifaddr) == 0)
|
||||
errx(1, "bad interface address: %s", optarg);
|
||||
moptions |= MULTICAST_IF;
|
||||
break;
|
||||
case 'i': /* wait between sending packets */
|
||||
interval = atoi(optarg);
|
||||
if (interval <= 0) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: bad timing interval.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (interval <= 0)
|
||||
errx(1, "bad timing interval: %s", optarg);
|
||||
options |= F_INTERVAL;
|
||||
break;
|
||||
case 'L':
|
||||
moptions |= MULTICAST_NOLOOP;
|
||||
loop = 0;
|
||||
break;
|
||||
case 'l':
|
||||
preload = atoi(optarg);
|
||||
if (preload < 0) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: bad preload value.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (preload < 0)
|
||||
errx(1, "bad preload value: %s", optarg);
|
||||
break;
|
||||
case 'n':
|
||||
options |= F_NUMERIC;
|
||||
@ -225,54 +223,27 @@ main(argc, argv)
|
||||
break;
|
||||
case 's': /* size of packet to send */
|
||||
datalen = atoi(optarg);
|
||||
if (datalen > MAXPACKET) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: packet size too large.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (datalen <= 0) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: illegal packet size.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (datalen <= 0)
|
||||
errx(1, "bad packet size: %s", optarg);
|
||||
if (datalen > MAXPACKET)
|
||||
errx(1, "packet size too large: %s", optarg);
|
||||
break;
|
||||
case 't':
|
||||
ttl = atoi(optarg);
|
||||
if (ttl <= 0)
|
||||
errx(1, "bad ttl value: %s", optarg);
|
||||
if (ttl > 255)
|
||||
errx(1, "ttl value too large: %s", optarg);
|
||||
break;
|
||||
case 'v':
|
||||
options |= F_VERBOSE;
|
||||
break;
|
||||
case 'L':
|
||||
moptions |= MULTICAST_NOLOOP;
|
||||
loop = 0;
|
||||
break;
|
||||
case 't':
|
||||
moptions |= MULTICAST_TTL;
|
||||
i = atoi(optarg);
|
||||
if (i < 0 || i > 255) {
|
||||
printf("ttl %u out of range\n", i);
|
||||
exit(1);
|
||||
}
|
||||
ttl = i;
|
||||
break;
|
||||
case 'I':
|
||||
moptions |= MULTICAST_IF;
|
||||
{
|
||||
int i1, i2, i3, i4;
|
||||
|
||||
if (sscanf(optarg, "%u.%u.%u.%u%c",
|
||||
&i1, &i2, &i3, &i4, &i) != 4) {
|
||||
printf("bad interface address '%s'\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
ifaddr.s_addr = (i1<<24)|(i2<<16)|(i3<<8)|i4;
|
||||
ifaddr.s_addr = htonl(ifaddr.s_addr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
|
||||
if (argc != 1)
|
||||
usage();
|
||||
target = *argv;
|
||||
@ -285,44 +256,32 @@ main(argc, argv)
|
||||
hostname = target;
|
||||
else {
|
||||
hp = gethostbyname(target);
|
||||
if (!hp) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: unknown host %s\n", target);
|
||||
exit(1);
|
||||
}
|
||||
if (!hp)
|
||||
errx(1, "unknown host: %s", target);
|
||||
to->sin_family = hp->h_addrtype;
|
||||
bcopy(hp->h_addr, (caddr_t)&to->sin_addr, hp->h_length);
|
||||
(void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
|
||||
hostname = hnamebuf;
|
||||
}
|
||||
|
||||
if (options & F_FLOOD && options & F_INTERVAL) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: -f and -i incompatible options.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (options & F_FLOOD && options & F_INTERVAL)
|
||||
errx(1, "-f and -i options are incompatible");
|
||||
|
||||
if (datalen >= sizeof(struct timeval)) /* can we time transfer */
|
||||
timing = 1;
|
||||
packlen = datalen + MAXIPLEN + MAXICMPLEN;
|
||||
if (!(packet = (u_char *)malloc((u_int)packlen))) {
|
||||
(void)fprintf(stderr, "ping: out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!(packet = (u_char *)malloc((u_int)packlen)))
|
||||
err(1, "malloc");
|
||||
if (!(options & F_PINGFILLED))
|
||||
for (i = 8; i < datalen; ++i)
|
||||
*datap++ = i;
|
||||
|
||||
ident = getpid() & 0xFFFF;
|
||||
|
||||
if (!(proto = getprotobyname("icmp"))) {
|
||||
(void)fprintf(stderr, "ping: unknown protocol icmp.\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
|
||||
perror("ping: socket");
|
||||
exit(1);
|
||||
}
|
||||
if (!(proto = getprotobyname("icmp")))
|
||||
errx(1, "unknown protocol icmp");
|
||||
if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0)
|
||||
err(1, "socket");
|
||||
hold = 1;
|
||||
if (options & F_SO_DEBUG)
|
||||
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold,
|
||||
@ -343,12 +302,23 @@ main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
(void)fprintf(stderr,
|
||||
"ping: record route not available in this implementation.\n");
|
||||
exit(1);
|
||||
errx(1, "record route not available in this implementation");
|
||||
#endif /* IP_OPTIONS */
|
||||
}
|
||||
|
||||
if ((moptions & MULTICAST_NOLOOP) &&
|
||||
setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &loop,
|
||||
sizeof(loop)) < 0)
|
||||
err(1, "setsockopt IP_MULTICAST_LOOP");
|
||||
if ((moptions & MULTICAST_TTL) &&
|
||||
setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
|
||||
sizeof(ttl)) < 0)
|
||||
err(1, "setsockopt IP_MULTICAST_TTL");
|
||||
if ((moptions & MULTICAST_IF) &&
|
||||
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &ifaddr,
|
||||
sizeof(ifaddr)) < 0)
|
||||
err(1, "setsockopt IP_MULTICAST_IF");
|
||||
|
||||
/*
|
||||
* When pinging the broadcast address, you can get a lot of answers.
|
||||
* Doing something so evil is useful if you are trying to stress the
|
||||
@ -359,28 +329,6 @@ main(argc, argv)
|
||||
(void)setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&hold,
|
||||
sizeof(hold));
|
||||
|
||||
if (moptions & MULTICAST_NOLOOP) {
|
||||
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP,
|
||||
&loop, 1) == -1) {
|
||||
perror ("can't disable multicast loopback");
|
||||
exit(92);
|
||||
}
|
||||
}
|
||||
if (moptions & MULTICAST_TTL) {
|
||||
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL,
|
||||
&ttl, 1) == -1) {
|
||||
perror ("can't set multicast time-to-live");
|
||||
exit(93);
|
||||
}
|
||||
}
|
||||
if (moptions & MULTICAST_IF) {
|
||||
if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF,
|
||||
&ifaddr, sizeof(ifaddr)) == -1) {
|
||||
perror ("can't set multicast source interface");
|
||||
exit(94);
|
||||
}
|
||||
}
|
||||
|
||||
if (to->sin_family == AF_INET)
|
||||
(void)printf("PING %s (%s): %d data bytes\n", hostname,
|
||||
inet_ntoa(*(struct in_addr *)&to->sin_addr.s_addr),
|
||||
@ -431,7 +379,7 @@ main(argc, argv)
|
||||
* catcher --
|
||||
* This routine causes another PING to be transmitted, and then
|
||||
* schedules another SIGALRM for 1 second from now.
|
||||
*
|
||||
*
|
||||
* bug --
|
||||
* Our sense of time will slowly skew (i.e., packets will not be
|
||||
* launched exactly at 1-second intervals). This does not affect the
|
||||
@ -448,7 +396,7 @@ catcher()
|
||||
alarm((u_int)interval);
|
||||
else {
|
||||
if (nreceived) {
|
||||
waittime = 2 * tmax / 1000000.0;
|
||||
waittime = 2 * tmax / 1000;
|
||||
if (!waittime)
|
||||
waittime = 1;
|
||||
} else
|
||||
@ -460,7 +408,7 @@ catcher()
|
||||
|
||||
/*
|
||||
* pinger --
|
||||
* Compose and transmit an ICMP ECHO REQUEST packet. The IP packet
|
||||
* Compose and transmit an ICMP ECHO REQUEST packet. The IP packet
|
||||
* will be added on by the kernel. The ID field is our UNIX process ID,
|
||||
* and the sequence number is an ascending integer. The first 8 bytes
|
||||
* of the data portion are used to hold a UNIX "timeval" struct in VAX
|
||||
@ -533,8 +481,7 @@ pr_pack(buf, cc, from)
|
||||
hlen = ip->ip_hl << 2;
|
||||
if (cc < hlen + ICMP_MINLEN) {
|
||||
if (options & F_VERBOSE)
|
||||
(void)fprintf(stderr,
|
||||
"ping: packet too short (%d bytes) from %s\n", cc,
|
||||
warnx("packet too short (%d bytes) from %s", cc,
|
||||
inet_ntoa(*(struct in_addr *)&from->sin_addr.s_addr));
|
||||
return;
|
||||
}
|
||||
@ -553,7 +500,8 @@ pr_pack(buf, cc, from)
|
||||
tp = (struct timeval *)icp->icmp_data;
|
||||
#endif
|
||||
tvsub(&tv, tp);
|
||||
triptime = tv.tv_sec * 1000000.0 + tv.tv_usec;
|
||||
triptime = ((double)tv.tv_sec) * 1000.0 +
|
||||
((double)tv.tv_usec) / 1000.0;
|
||||
tsum += triptime;
|
||||
if (triptime < tmin)
|
||||
tmin = triptime;
|
||||
@ -581,7 +529,7 @@ pr_pack(buf, cc, from)
|
||||
icp->icmp_seq);
|
||||
(void)printf(" ttl=%d", ip->ip_ttl);
|
||||
if (timing)
|
||||
(void)printf(" time=%.3f ms", triptime/1000.0);
|
||||
(void)printf(" time=%.3f ms", triptime);
|
||||
if (dupflag)
|
||||
(void)printf(" (DUP!)");
|
||||
/* check the data */
|
||||
@ -749,6 +697,8 @@ tvsub(out, in)
|
||||
void
|
||||
finish()
|
||||
{
|
||||
register int i;
|
||||
|
||||
(void)signal(SIGINT, SIG_IGN);
|
||||
(void)putchar('\n');
|
||||
(void)fflush(stdout);
|
||||
@ -765,10 +715,12 @@ finish()
|
||||
(int) (((ntransmitted - nreceived) * 100) /
|
||||
ntransmitted));
|
||||
(void)putchar('\n');
|
||||
if (nreceived && timing)
|
||||
if (nreceived && timing) {
|
||||
/* Only display average to microseconds */
|
||||
i = 1000.0 * tsum / (nreceived + nrepeats);
|
||||
(void)printf("round-trip min/avg/max = %.3f/%.3f/%.3f ms\n",
|
||||
tmin / 1000.0, tsum / 1000.0 / (nreceived + nrepeats),
|
||||
tmax / 1000.0);
|
||||
tmin, ((double)i) / 1000.0, tmax);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -1007,11 +959,8 @@ fill(bp, patp)
|
||||
char *cp;
|
||||
|
||||
for (cp = patp; *cp; cp++)
|
||||
if (!isxdigit(*cp)) {
|
||||
(void)fprintf(stderr,
|
||||
"ping: patterns must be specified as hex digits.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!isxdigit(*cp))
|
||||
errx(1, "patterns must be specified as hex digits");
|
||||
ii = sscanf(patp,
|
||||
"%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
|
||||
&pat[0], &pat[1], &pat[2], &pat[3], &pat[4], &pat[5], &pat[6],
|
||||
@ -1019,7 +968,9 @@ fill(bp, patp)
|
||||
&pat[13], &pat[14], &pat[15]);
|
||||
|
||||
if (ii > 0)
|
||||
for (kk = 0; kk <= MAXPACKET - (8 + ii); kk += ii)
|
||||
for (kk = 0;
|
||||
kk <= MAXPACKET - (8 + sizeof(struct timeval) + ii);
|
||||
kk += ii)
|
||||
for (jj = 0; jj < ii; ++jj)
|
||||
bp[jj + kk] = pat[jj];
|
||||
if (!(options & F_QUIET)) {
|
||||
@ -1033,6 +984,6 @@ fill(bp, patp)
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: ping [-LRdfnqrv] [-c count] [-i wait] [-l preload]\n\t[-p pattern] [-s packetsize] [-t ttl] [-I interface address] host\n");
|
||||
"usage: ping [-dfLnqRrv] [-c count] [-I ifaddr] [-i wait] [-l preload]\n\t[-p pattern] [-s packetsize] [-t ttl] host\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.4 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.4 1993/07/31 15:34:41 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:39:02 mycroft Exp $
|
||||
|
||||
PROG= slattach
|
||||
MAN8= slattach.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1986, 1991 The Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1986, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)slattach.8 6.4 (Berkeley) 3/16/91
|
||||
.\" $Id: slattach.8,v 1.10 1994/08/13 09:03:07 mycroft Exp $
|
||||
.\" from: @(#)slattach.8 8.2 (Berkeley) 4/1/94
|
||||
.\" $Id: slattach.8,v 1.11 1994/09/23 01:39:03 mycroft Exp $
|
||||
.\"
|
||||
.Dd April 4, 1993
|
||||
.Dd April 1, 1994
|
||||
.Dt SLATTACH 8
|
||||
.Os BSD 4.3
|
||||
.Sh NAME
|
||||
@ -40,10 +40,9 @@
|
||||
.Nd attach serial lines as network interfaces
|
||||
.Sh SYNOPSIS
|
||||
.Nm slattach
|
||||
.Op \-h
|
||||
.Op \-m
|
||||
.Op \-s baudrate
|
||||
.Ar ttyname
|
||||
.Op Fl hm
|
||||
.Op Fl s Ar baudrate
|
||||
.Ar ttyname
|
||||
.Sh DESCRIPTION
|
||||
.Nm Slattach
|
||||
is used to assign a tty line to a network interface,
|
||||
@ -51,15 +50,13 @@ and to define the network source and destination addresses.
|
||||
The following operands are supported by
|
||||
.Nm slattach :
|
||||
.Bl -tag -width Ar
|
||||
.It Ar \-h
|
||||
Turn on CTS/RTS style flow control on the slip port, by default no flow
|
||||
control is done.
|
||||
.It Ar \-m
|
||||
Maintain modem control signals after closing the tty. If not specified,
|
||||
HUPCL is set, causing DTR to be dropped on the last close of the tty
|
||||
device.
|
||||
.It Ar \-s baudrate
|
||||
Specifies the speed of the connection. If not specified, the
|
||||
.It Fl h
|
||||
Turn on RTS/CTS flow control. By default, no flow control is done.
|
||||
.It Fl m
|
||||
Maintain modem control signals after closing the line. Specifically,
|
||||
this disables HUPCL.
|
||||
.It Fl s Ar baudrate
|
||||
Specifies the speed of the connection. If not specified, the
|
||||
default of 9600 is used.
|
||||
.It Ar ttyname
|
||||
Specifies the name of the tty device.
|
||||
@ -77,14 +74,14 @@ control various properties of the link:
|
||||
.It Ar link0
|
||||
Turn on Van Jacobsen header compression.
|
||||
.It Ar -link0
|
||||
Turn off Van Jacobsen header compression.
|
||||
Turn off header compression.
|
||||
.It Ar link1
|
||||
Don't pass through ICMP packets.
|
||||
.It Ar -link1
|
||||
Do pass through ICMP packets.
|
||||
.It Ar link2
|
||||
If a packet with a compressed header is received, automatically enable
|
||||
compression of transmitted packets.
|
||||
compression of outgoing packets.
|
||||
.It Ar -link2
|
||||
Don't auto-enable compression.
|
||||
.El
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1988 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Rick Adams.
|
||||
@ -34,126 +34,105 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hacked to change from sgtty to POSIX termio style serial line control
|
||||
* and added flag to enable cts/rts style flow control.
|
||||
*
|
||||
* blymn@awadi.com.au (Brett Lymn) 93.04.04
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1988 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1988, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)slattach.c 4.6 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: slattach.c,v 1.11 1994/02/10 18:03:23 cgd Exp $";
|
||||
/*static char sccsid[] = "from: @(#)slattach.c 8.2 (Berkeley) 1/7/94";*/
|
||||
static char *rcsid = "$Id: slattach.c,v 1.12 1994/09/23 01:39:04 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
|
||||
#define DEFAULT_BAUD 9600
|
||||
int speed = 9600;
|
||||
int slipdisc = SLIPDISC;
|
||||
|
||||
static char usage_str[] = "\
|
||||
usage: %s [-h] [-m] [-s <speed>] <device>\n\
|
||||
-h -- turn on CTS/RTS style flow control\n\
|
||||
-m -- maintain DTR after last close (no HUPCL)\n\
|
||||
-s -- baud rate (default 9600)\n";
|
||||
char devicename[32];
|
||||
|
||||
int main(int argc, char **argv)
|
||||
void usage __P((void));
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
register int fd;
|
||||
register char *dev = argv[1];
|
||||
struct termios tty;
|
||||
int option;
|
||||
int fd;
|
||||
char devname[32];
|
||||
char *dev = (char *)0;
|
||||
int slipdisc = SLIPDISC;
|
||||
int speed = DEFAULT_BAUD;
|
||||
int cflags = HUPCL;
|
||||
tcflag_t cflag = HUPCL;
|
||||
int ch;
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
while ((option = getopt(argc, argv, "achmns:")) != EOF) {
|
||||
switch (option) {
|
||||
while ((ch = getopt(argc, argv, "hms:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
cflags |= CRTSCTS;
|
||||
cflag |= CRTSCTS;
|
||||
break;
|
||||
case 'm':
|
||||
cflags &= ~HUPCL;
|
||||
cflag &= ~HUPCL;
|
||||
break;
|
||||
case 's':
|
||||
speed = atoi(optarg);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
fprintf(stderr, usage_str, argv[0]);
|
||||
exit(1);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (optind == argc - 1)
|
||||
dev = argv[optind];
|
||||
|
||||
if (dev == (char *)0) {
|
||||
fprintf(stderr, usage_str, argv[0]);
|
||||
exit(2);
|
||||
}
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
dev = *argv;
|
||||
if (strncmp(_PATH_DEV, dev, sizeof(_PATH_DEV) - 1)) {
|
||||
strcpy(devname, _PATH_DEV);
|
||||
strcat(devname, "/");
|
||||
strncat(devname, dev, 10);
|
||||
dev = devname;
|
||||
(void)snprintf(devicename, sizeof(devicename),
|
||||
"%s%s", _PATH_DEV, dev);
|
||||
dev = devicename;
|
||||
}
|
||||
|
||||
if ((fd = open(dev, O_RDWR | O_NDELAY)) < 0) {
|
||||
perror(dev);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (tcgetattr(fd, &tty) < 0) {
|
||||
perror("tcgetattr");
|
||||
close(fd);
|
||||
exit(1);
|
||||
}
|
||||
tty.c_cflag = CREAD | CS8 | cflag;
|
||||
tty.c_iflag = 0;
|
||||
tty.c_oflag = 0;
|
||||
tty.c_cflag = CREAD | CS8 | cflags;
|
||||
tty.c_lflag = 0;
|
||||
tty.c_cc[VMIN] = 1; /* wait for one char */
|
||||
tty.c_cc[VTIME] = 0; /* wait forever for a char */
|
||||
cfsetispeed(&tty, speed);
|
||||
cfsetospeed(&tty, speed);
|
||||
if (tcsetattr(fd, TCSADRAIN, &tty) < 0) {
|
||||
perror("tcsetattr");
|
||||
close(fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ioctl(fd, TIOCSDTR) < 0) {
|
||||
perror("ioctl(TIOCSDTR)");
|
||||
close(fd);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ioctl(fd, TIOCSETD, &slipdisc) < 0) {
|
||||
perror("ioctl(TIOCSETD)");
|
||||
close(fd);
|
||||
exit(1);
|
||||
}
|
||||
tty.c_oflag = 0;
|
||||
tty.c_cc[VMIN] = 1;
|
||||
tty.c_cc[VTIME] = 0;
|
||||
cfsetspeed(&tty, speed);
|
||||
if (tcsetattr(fd, TCSADRAIN, &tty) < 0)
|
||||
err(1, "tcsetattr");
|
||||
if (ioctl(fd, TIOCSDTR, 0) < 0)
|
||||
err(1, "TIOCSDTR");
|
||||
if (ioctl(fd, TIOCSETD, &slipdisc) < 0)
|
||||
err(1, "TIOCSETD");
|
||||
|
||||
if (fork() > 0)
|
||||
exit(0);
|
||||
|
||||
for (;;)
|
||||
sigpause(0L);
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: slattach [-hm] [-s baudrate] ttyname\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
||||
# $Id: Makefile,v 1.4 1993/07/31 15:34:35 mycroft Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/5/93
|
||||
# $Id: Makefile,v 1.5 1994/09/23 01:39:06 mycroft Exp $
|
||||
|
||||
PROG= swapon
|
||||
MAN8= swapon.0
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" Copyright (c) 1980, 1991 Regents of the University of California.
|
||||
.\" All rights reserved.
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -29,10 +29,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" from: @(#)swapon.8 6.3 (Berkeley) 3/16/91
|
||||
.\" $Id: swapon.8,v 1.4 1993/08/01 07:38:03 mycroft Exp $
|
||||
.\" from: @(#)swapon.8 8.1 (Berkeley) 6/5/93
|
||||
.\" $Id: swapon.8,v 1.5 1994/09/23 01:39:08 mycroft Exp $
|
||||
.\"
|
||||
.Dd March 16, 1991
|
||||
.Dd June 5, 1993
|
||||
.Dt SWAPON 8
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 1980 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 1980, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -32,14 +32,14 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
static char copyright[] =
|
||||
"@(#) Copyright (c) 1980, 1993\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)swapon.c 5.5 (Berkeley) 2/27/91";*/
|
||||
static char rcsid[] = "$Id: swapon.c,v 1.4 1993/08/01 18:23:52 mycroft Exp $";
|
||||
/*static char sccsid[] = "from: @(#)swapon.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: swapon.c,v 1.5 1994/09/23 01:39:09 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <fstab.h>
|
||||
|
Loading…
Reference in New Issue
Block a user