Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

imported freebsd46

  • Loading branch information...
commit 4012957d75fd5cde27e1e109d6159ea8c3516c06 1 parent 18e810d
suz authored
6 freebsd4/etc/mtree/BSD.include.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.include.dist,v 1.32.2.6 2001/08/01 20:37:03 obrien Exp $
+# $FreeBSD: src/etc/mtree/BSD.include.dist,v 1.32.2.8 2002/03/25 21:37:31 gshapiro Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -12,6 +12,8 @@
..
..
dev
+ an
+ ..
ppbus
..
usb
@@ -31,6 +33,8 @@
cd9660
..
..
+ libmilter
+ ..
machine
..
msdosfs
26 freebsd4/etc/mtree/BSD.local.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.55.2.14 2002/01/22 16:46:06 phantom Exp $
+# $FreeBSD: src/etc/mtree/BSD.local.dist,v 1.55.2.18 2002/03/01 15:56:55 phantom Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -236,11 +236,19 @@
..
examples
..
+ java
+ classes
+ ..
+ ..
misc
..
nls
C
..
+ af_ZA.ISO8859-1
+ ..
+ af_ZA.ISO8859-15
+ ..
bg_BG.CP1251
..
cs_CZ.ISO8859-2
@@ -261,6 +269,8 @@
..
de_DE.ISO8859-15
..
+ el_GR.ISO8859-7
+ ..
en_AU.ISO8859-1
..
en_AU.ISO8859-15
@@ -293,6 +303,8 @@
..
es_ES.ISO8859-15
..
+ et_EE.ISO8859-15
+ ..
fi_FI.ISO8859-1
..
fi_FI.ISO8859-15
@@ -329,11 +341,11 @@
..
it_IT.ISO8859-15
..
- ja_JP.EUC
+ ja_JP.eucJP
..
ja_JP.SJIS
..
- ko_KR.EUC
+ ko_KR.eucKR
..
la_LN.ISO8859-1
..
@@ -383,14 +395,20 @@
..
tr_TR.ISO8859-9
..
+ uk_UA.ISO8859-5
+ ..
uk_UA.KOI8-U
..
- zh_CN.EUC
+ zh_CN.eucCN
..
zh_TW.Big5
..
..
+ sgml
+ ..
skel
..
+ xml
+ ..
..
..
6 freebsd4/etc/mtree/BSD.root.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.root.dist,v 1.45.2.2 2001/08/01 20:37:03 obrien Exp $
+# $FreeBSD: src/etc/mtree/BSD.root.dist,v 1.45.2.3.2.1 2002/06/10 15:34:22 obrien Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -16,6 +16,8 @@
..
..
etc
+ X11
+ ..
defaults
..
gnats
@@ -39,6 +41,8 @@
..
monthly
..
+ security
+ ..
weekly
..
..
14 freebsd4/etc/mtree/BSD.sendmail.dist
View
@@ -0,0 +1,14 @@
+# $FreeBSD: src/etc/mtree/BSD.sendmail.dist,v 1.1.2.1 2002/04/28 19:57:43 gshapiro Exp $
+#
+# Please see the file src/etc/mtree/README before making changes to this file.
+#
+
+/set type=dir uname=root gname=wheel mode=0755
+. nochange
+ var nochange
+ spool nochange
+ clientmqueue uname=smmsp gname=smmsp mode=0770
+ ..
+ ..
+ ..
+..
38 freebsd4/etc/mtree/BSD.usr.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.usr.dist,v 1.188.2.30 2002/01/22 16:46:06 phantom Exp $
+# $FreeBSD: src/etc/mtree/BSD.usr.dist,v 1.188.2.37 2002/05/27 12:14:06 dwmalone Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -169,6 +169,8 @@
calendar
de_DE.ISO8859-1
..
+ fr_FR.ISO8859-1
+ ..
hr_HR.ISO8859-2
..
ru_RU.KOI8-R
@@ -311,6 +313,8 @@
..
ibcs2
..
+ ipfilter
+ ..
ipfw
..
isdn
@@ -359,6 +363,8 @@
..
ppp
..
+ pppd
+ ..
printing
..
scsi_target
@@ -393,6 +399,8 @@
sort
..
..
+ tcsh
+ ..
worm
..
..
@@ -443,6 +451,10 @@
libg++
..
locale
+ af_ZA.ISO8859-1
+ ..
+ af_ZA.ISO8859-15
+ ..
bg_BG.CP1251
..
cs_CZ.ISO8859-2
@@ -499,6 +511,8 @@
..
es_ES.ISO8859-15
..
+ et_EE.ISO8859-15
+ ..
fi_FI.ISO8859-1
..
fi_FI.ISO8859-15
@@ -535,11 +549,11 @@
..
it_IT.ISO8859-15
..
- ja_JP.EUC
+ ja_JP.eucJP
..
ja_JP.SJIS
..
- ko_KR.EUC
+ ko_KR.eucKR
..
la_LN.ISO8859-1
..
@@ -589,9 +603,11 @@
..
tr_TR.ISO8859-9
..
+ uk_UA.ISO8859-5
+ ..
uk_UA.KOI8-U
..
- zh_CN.EUC
+ zh_CN.eucCN
..
zh_TW.Big5
..
@@ -753,6 +769,10 @@
nls
C
..
+ af_ZA.ISO8859-1
+ ..
+ af_ZA.ISO8859-15
+ ..
bg_BG.CP1251
..
cs_CZ.ISO8859-2
@@ -807,6 +827,8 @@
..
es_ES.ISO8859-15
..
+ et_EE.ISO8859-15
+ ..
fi_FI.ISO8859-1
..
fi_FI.ISO8859-15
@@ -843,11 +865,11 @@
..
it_IT.ISO8859-15
..
- ja_JP.EUC
+ ja_JP.eucJP
..
ja_JP.SJIS
..
- ko_KR.EUC
+ ko_KR.eucKR
..
la_LN.ISO8859-1
..
@@ -897,9 +919,11 @@
..
tr_TR.ISO8859-9
..
+ uk_UA.ISO8859-5
+ ..
uk_UA.KOI8-U
..
- zh_CN.EUC
+ zh_CN.eucCN
..
zh_TW.Big5
..
2  freebsd4/etc/mtree/BSD.var.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.var.dist,v 1.43.2.6 2002/01/14 11:23:15 ru Exp $
+# $FreeBSD: src/etc/mtree/BSD.var.dist,v 1.43.2.8 2002/04/28 19:57:43 gshapiro Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
4 freebsd4/etc/mtree/BSD.x11-4.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.x11-4.dist,v 1.13.2.5 2001/08/01 20:37:03 obrien Exp $
+# $FreeBSD: src/etc/mtree/BSD.x11-4.dist,v 1.13.2.6 2002/04/15 00:44:15 dougb Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -309,6 +309,8 @@
..
..
..
+ libdata
+ ..
libexec
..
man
4 freebsd4/etc/mtree/BSD.x11.dist
View
@@ -1,4 +1,4 @@
-# $FreeBSD: src/etc/mtree/BSD.x11.dist,v 1.9.2.5 2001/08/01 20:37:03 obrien Exp $
+# $FreeBSD: src/etc/mtree/BSD.x11.dist,v 1.9.2.6 2002/04/15 00:44:15 dougb Exp $
#
# Please see the file src/etc/mtree/README before making changes to this file.
#
@@ -191,6 +191,8 @@
modules
..
..
+ libdata
+ ..
libexec
..
man
20 freebsd4/etc/rc.network6
View
@@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/etc/rc.network6,v 1.5.2.21 2001/12/19 17:52:17 ru Exp $
+# $FreeBSD: src/etc/rc.network6,v 1.5.2.22 2002/04/16 18:43:52 ume Exp $
#
# Note that almost all of the user-configurable behavior is not in this
@@ -96,6 +96,9 @@ network6_pass1() {
#
ipv6_network_interfaces="`ifconfig -l`"
;;
+ [Nn][Oo][Nn][Ee])
+ ipv6_network_interfaces=''
+ ;;
esac
# just to make sure
@@ -120,17 +123,20 @@ network6_pass1() {
;;
*)
# act as endhost - start with manual configuration
+ # Setup of net.inet6.ip6.accept_rtadv is done later by
+ # network6_interface_setup.
sysctl net.inet6.ip6.forwarding=0
- sysctl net.inet6.ip6.accept_rtadv=0
;;
esac
- # setting up interfaces
- network6_interface_setup $ipv6_network_interfaces
+ if [ -n "${ipv6_network_interfaces}" ]; then
+ # setting up interfaces
+ network6_interface_setup $ipv6_network_interfaces
- # wait for DAD's completion (for global addrs)
- sleep `sysctl -n net.inet6.ip6.dad_count`
- sleep 1
+ # wait for DAD's completion (for global addrs)
+ sleep `sysctl -n net.inet6.ip6.dad_count`
+ sleep 1
+ fi
case ${ipv6_gateway_enable} in
[Yy][Ee][Ss])
93 freebsd4/libexec/tftpd/tftpd.c
View
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
- "$FreeBSD: src/libexec/tftpd/tftpd.c,v 1.15.2.2 2001/03/04 09:15:27 kris Exp $";
+ "$FreeBSD: src/libexec/tftpd/tftpd.c,v 1.15.2.4 2002/04/26 17:22:41 ume Exp $";
#endif /* not lint */
/*
@@ -87,10 +87,11 @@ int maxtimeout = 5*TIMEOUT;
#define PKTSIZE SEGSIZE+4
char buf[PKTSIZE];
char ackbuf[PKTSIZE];
-struct sockaddr_in from;
+struct sockaddr_storage from;
int fromlen;
void tftp __P((struct tftphdr *, int));
+static void unmappedaddr __P((struct sockaddr_in6 *));
/*
* Null-terminated directory prefix list for absolute pathname requests and
@@ -119,7 +120,8 @@ main(argc, argv)
register struct tftphdr *tp;
register int n;
int ch, on;
- struct sockaddr_in sin;
+ struct sockaddr_storage me;
+ int len;
char *chroot_dir = NULL;
struct passwd *nobody;
char *chuser = "nobody";
@@ -244,9 +246,15 @@ main(argc, argv)
char *tempchroot;
struct stat sb;
int statret;
-
- tempchroot = inet_ntoa(from.sin_addr);
- asprintf(&tempchroot, "%s/%s", chroot_dir, tempchroot);
+ struct sockaddr_storage ss;
+ char hbuf[NI_MAXHOST];
+
+ memcpy(&ss, &from, from.ss_len);
+ unmappedaddr((struct sockaddr_in6 *)&ss);
+ getnameinfo((struct sockaddr *)&ss, ss.ss_len,
+ hbuf, sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST | NI_WITHSCOPEID);
+ asprintf(&tempchroot, "%s/%s", chroot_dir, hbuf);
statret = stat(tempchroot, &sb);
if ((sb.st_mode & S_IFDIR) &&
(statret == 0 || (statret == -1 && ipchroot == 1)))
@@ -265,22 +273,37 @@ main(argc, argv)
setuid(nobody->pw_uid);
}
- from.sin_family = AF_INET;
+ len = sizeof(me);
+ if (getsockname(0, (struct sockaddr *)&me, &len) == 0) {
+ switch (me.ss_family) {
+ case AF_INET:
+ ((struct sockaddr_in *)&me)->sin_port = 0;
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *)&me)->sin6_port = 0;
+ break;
+ default:
+ /* unsupported */
+ break;
+ }
+ } else {
+ memset(&me, 0, sizeof(me));
+ me.ss_family = from.ss_family;
+ me.ss_len = from.ss_len;
+ }
alarm(0);
close(0);
close(1);
- peer = socket(AF_INET, SOCK_DGRAM, 0);
+ peer = socket(from.ss_family, SOCK_DGRAM, 0);
if (peer < 0) {
syslog(LOG_ERR, "socket: %m");
exit(1);
}
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- if (bind(peer, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
+ if (bind(peer, (struct sockaddr *)&me, me.ss_len) < 0) {
syslog(LOG_ERR, "bind: %m");
exit(1);
}
- if (connect(peer, (struct sockaddr *)&from, sizeof(from)) < 0) {
+ if (connect(peer, (struct sockaddr *)&from, from.ss_len) < 0) {
syslog(LOG_ERR, "connect: %m");
exit(1);
}
@@ -352,11 +375,12 @@ tftp(tp, size)
}
ecode = (*pf->f_validate)(&filename, tp->th_opcode);
if (logging) {
- char host[MAXHOSTNAMELEN];
+ char hbuf[NI_MAXHOST];
- realhostname(host, sizeof(host) - 1, &from.sin_addr);
- host[sizeof(host) - 1] = '\0';
- syslog(LOG_INFO, "%s: %s request for %s: %s", host,
+ getnameinfo((struct sockaddr *)&from, from.ss_len,
+ hbuf, sizeof(hbuf), NULL, 0,
+ NI_WITHSCOPEID);
+ syslog(LOG_INFO, "%s: %s request for %s: %s", hbuf,
tp->th_opcode == WRQ ? "write" : "read",
filename, errtomsg(ecode));
}
@@ -519,9 +543,19 @@ xmitfile(pf)
(void)setjmp(timeoutbuf);
send_data:
- if (send(peer, dp, size + 4, 0) != size + 4) {
- syslog(LOG_ERR, "write: %m");
- goto abort;
+ {
+ int i, t = 1;
+ for (i = 0; ; i++){
+ if (send(peer, dp, size + 4, 0) != size + 4) {
+ sleep(t);
+ t = (t < 32) ? t<< 1 : t;
+ if (i >= 12) {
+ syslog(LOG_ERR, "write: %m");
+ goto abort;
+ }
+ }
+ break;
+ }
}
read_ahead(file, pf->f_convert);
for ( ; ; ) {
@@ -700,3 +734,24 @@ nak(error)
if (send(peer, buf, length, 0) != length)
syslog(LOG_ERR, "nak: %m");
}
+
+/* translate IPv4 mapped IPv6 address to IPv4 address */
+static void
+unmappedaddr(struct sockaddr_in6 *sin6)
+{
+ struct sockaddr_in *sin4;
+ u_int32_t addr;
+ int port;
+
+ if (sin6->sin6_family != AF_INET6 ||
+ !IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+ return;
+ sin4 = (struct sockaddr_in *)sin6;
+ addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12];
+ port = sin6->sin6_port;
+ memset(sin4, 0, sizeof(struct sockaddr_in));
+ sin4->sin_addr.s_addr = addr;
+ sin4->sin_port = port;
+ sin4->sin_family = AF_INET;
+ sin4->sin_len = sizeof(struct sockaddr_in);
+}
4 freebsd4/sbin/ifconfig/Makefile
View
@@ -1,5 +1,5 @@
# From: @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD: src/sbin/ifconfig/Makefile,v 1.14.2.6 2001/12/19 04:49:11 dd Exp $
+# $FreeBSD: src/sbin/ifconfig/Makefile,v 1.14.2.7 2002/02/15 03:58:37 luigi Exp $
PROG= ifconfig
SRCS= ifconfig.c
@@ -8,12 +8,10 @@ SRCS= ifconfig.c
SRCS+= ifmedia.c
CFLAGS+=-DUSE_IF_MEDIA
CFLAGS+=-DINET6
-.if !defined(RELEASE_CRUNCH)
#comment out to exclude SIOC[GS]ETVLAN support
SRCS+= ifvlan.c
CFLAGS+=-DUSE_VLANS
-.endif
#comment out to exclude SIOC[GS]IEEE80211 support
SRCS+= ifieee80211.c
46 freebsd4/sbin/ifconfig/ifconfig.8
View
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
-.\" $FreeBSD: src/sbin/ifconfig/ifconfig.8,v 1.27.2.16 2002/01/09 15:13:43 ru Exp $
+.\" $FreeBSD: src/sbin/ifconfig/ifconfig.8,v 1.27.2.19 2002/05/14 17:42:38 brian Exp $
.\"
.Dd July 2, 2001
.Dt IFCONFIG 8
@@ -131,6 +131,18 @@ parameter below for more information.
.\" However, two consecutive dots imply a zero
.\" byte, and the dots are optional, if the user wishes to (carefully)
.\" count out long strings of digits in network byte order.
+.Pp
+The link-level
+.Pq Dq link
+address
+is specified as a series of colon-separated hex digits.
+This can be used to
+e.g. set a new MAC address on an ethernet interface, though the
+mechanism used is not ethernet-specific.
+If the interface is already
+up when this option is used, it will be briefly brought down and
+then brought back up again in order to ensure that the receive
+filter in the underlying ethernet hardware is properly reprogrammed.
.It Ar address_family
Specify the
address family
@@ -142,12 +154,19 @@ supported are
.Dq inet ,
.Dq inet6 ,
.Dq atalk ,
-.Dq ether ,
+.Dq ipx ,
.\" .Dq iso ,
and
-.Dq ipx .
+.Dq link .
.\" and
.\" .Dq ns .
+The default is
+.Dq inet .
+.Dq ether
+and
+.Dq lladdr
+are synonyms for
+.Dq link .
.It Ar dest_address
Specify the address of the correspondent on the other end
of a point to point link.
@@ -174,9 +193,10 @@ Establish an additional network address for this interface.
This is sometimes useful when changing network numbers, and
one wishes to accept packets addressed to the old interface.
If the address is on the same subnet as the first network address
-for this interface, a netmask of
+for this interface, a non-conflicting netmask must be given.
+Usually
.Li 0xffffffff
-has to be specified.
+is most appropriate.
.It Fl alias
Remove the network address specified.
This would be used if you incorrectly specified an alias, or it
@@ -228,10 +248,6 @@ the system will not attempt to
transmit messages through that interface.
If possible, the interface will be reset to disable reception as well.
This action does not automatically disable routes using the interface.
-.It Cm ether
-Another name for the
-.Cm lladdr
-parameter.
.\" .It Cm ipdst
.\" This is used to specify an Internet host who is willing to receive
.\" ip packets encapsulating NS packets bound for a remote network.
@@ -241,18 +257,6 @@ parameter.
.\" IP encapsulation of
.\" .Tn CLNP
.\" packets is done differently.
-.It Cm lladdr Ar addr
-Set the link-level address on an interface.
-This can be used to
-e.g. set a new MAC address on an ethernet interface, though the
-mechanism used is not ethernet-specific.
-The address
-.Ar addr
-is specified as a series of colon-separated hex digits.
-If the interface is already
-up when this option is used, it will be briefly brought down and
-then brought back up again in order to ensure that the receive
-filter in the underlying ethernet hardware is properly reprogrammed.
.It Cm media Ar type
If the driver supports the media selection system, set the media type
of the interface to
93 freebsd4/sbin/ifconfig/ifconfig.c
View
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#endif
static const char rcsid[] =
- "$FreeBSD: src/sbin/ifconfig/ifconfig.c,v 1.51.2.15 2001/12/14 23:36:23 jlemon Exp $";
+ "$FreeBSD: src/sbin/ifconfig/ifconfig.c,v 1.51.2.16 2002/04/03 11:48:48 ru Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -177,7 +177,7 @@ c_func setip6vltime;
c_func2 setip6lifetime;
#endif
c_func setifipdst;
-c_func setifflags, setifmetric, setifmtu, setiflladdr, setifcap;
+c_func setifflags, setifmetric, setifmtu, setifcap;
c_func clone_destroy;
@@ -282,7 +282,6 @@ struct cmd {
{ "compress", IFF_LINK0, setifflags },
{ "noicmp", IFF_LINK1, setifflags },
{ "mtu", NEXTARG, setifmtu },
- { "lladdr", NEXTARG, setiflladdr },
{ 0, 0, setifaddr },
{ 0, 0, setifdstaddr },
};
@@ -295,8 +294,8 @@ typedef void af_status __P((int, struct rt_addrinfo *));
typedef void af_getaddr __P((const char *, int));
typedef void af_getprefix __P((const char *, int));
-af_status in_status, at_status, ether_status;
-af_getaddr in_getaddr, at_getaddr, ether_getaddr;
+af_status in_status, at_status, link_status;
+af_getaddr in_getaddr, at_getaddr, link_getaddr;
#ifndef NO_IPX
af_status ipx_status;
@@ -344,7 +343,11 @@ struct afswtch {
{ "ns", AF_NS, xns_status, xns_getaddr, NULL,
SIOCDIFADDR, SIOCAIFADDR, C(ridreq), C(addreq) },
#endif
- { "ether", AF_LINK, ether_status, ether_getaddr, NULL,
+ { "link", AF_LINK, link_status, link_getaddr, NULL,
+ 0, SIOCSIFLLADDR, NULL, C(ridreq) },
+ { "ether", AF_LINK, link_status, link_getaddr, NULL,
+ 0, SIOCSIFLLADDR, NULL, C(ridreq) },
+ { "lladdr", AF_LINK, link_status, link_getaddr, NULL,
0, SIOCSIFLLADDR, NULL, C(ridreq) },
#if 0 /* XXX conflicts with the media command */
#ifdef USE_IF_MEDIA
@@ -608,7 +611,7 @@ main(argc, argv)
name[sdl->sdl_nlen] = '\0';
if (namesonly) {
if (afp == NULL ||
- afp->af_status != ether_status ||
+ afp->af_status != link_status ||
sdl->sdl_type == IFT_ETHER) {
if (need_nl)
putchar(' ');
@@ -1086,30 +1089,6 @@ setifmtu(val, dummy, s, afp)
warn("ioctl (set mtu)");
}
-void
-setiflladdr(val, dummy, s, afp)
- const char *val;
- int dummy __unused;
- int s;
- const struct afswtch *afp;
-{
- struct ether_addr *ea;
-
- ea = ether_aton(val);
- if (ea == NULL) {
- warn("malformed link-level address");
- return;
- }
- strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
- ifr.ifr_addr.sa_len = ETHER_ADDR_LEN;
- ifr.ifr_addr.sa_family = AF_LINK;
- bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN);
- if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0)
- warn("ioctl (set lladdr)");
-
- return;
-}
-
#define IFFBITS \
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
@@ -1189,8 +1168,8 @@ status(afp, addrcount, sdl, ifm, ifam)
addrcount--;
ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
}
- if (allfamilies || afp->af_status == ether_status)
- ether_status(s, (struct rt_addrinfo *)sdl);
+ if (allfamilies || afp->af_status == link_status)
+ link_status(s, (struct rt_addrinfo *)sdl);
#ifdef USE_IF_MEDIA
if (allfamilies || afp->af_status == media_status)
media_status(s, NULL);
@@ -1208,7 +1187,7 @@ status(afp, addrcount, sdl, ifm, ifam)
printf("%s", ifs.ascii);
if (!allfamilies && !p && afp->af_status != media_status &&
- afp->af_status != ether_status
+ afp->af_status != link_status
#ifdef USE_VLANS
&& afp->af_status != vlan_status
#endif
@@ -1554,23 +1533,20 @@ xns_status(s, info)
void
-ether_status(s, info)
+link_status(s, info)
int s __unused;
struct rt_addrinfo *info;
{
- char *cp;
int n;
struct sockaddr_dl *sdl = (struct sockaddr_dl *)info;
- cp = (char *)LLADDR(sdl);
if ((n = sdl->sdl_alen) > 0) {
- if (sdl->sdl_type == IFT_ETHER)
- printf ("\tether ");
+ if (sdl->sdl_type == IFT_ETHER &&
+ sdl->sdl_alen == ETHER_ADDR_LEN)
+ printf("\tether %s\n",
+ ether_ntoa((struct ether_addr *)LLADDR(sdl)));
else
- printf ("\tlladdr ");
- while (--n >= 0)
- printf("%02x%c",*cp++ & 0xff, n>0? ':' : ' ');
- putchar('\n');
+ printf("\tlladdr %s\n", link_ntoa(sdl) + n + 1);
}
}
@@ -1784,21 +1760,28 @@ at_getaddr(addr, which)
}
void
-ether_getaddr(addr, which)
+link_getaddr(addr, which)
const char *addr;
int which;
{
- struct ether_addr *ea;
- struct sockaddr *sea = &ridreq.ifr_addr;
-
- ea = ether_aton(addr);
- if (ea == NULL)
- errx(1, "malformed ether address");
- if (which == MASK)
- errx(1, "Ethernet does not use netmasks");
- sea->sa_family = AF_LINK;
- sea->sa_len = ETHER_ADDR_LEN;
- bcopy(ea, sea->sa_data, ETHER_ADDR_LEN);
+ char *temp;
+ struct sockaddr_dl sdl;
+ struct sockaddr *sa = &ridreq.ifr_addr;
+
+ if (which != ADDR)
+ errx(1, "can't set link-level netmask or broadcast");
+ if ((temp = malloc(strlen(addr) + 1)) == NULL)
+ errx(1, "malloc failed");
+ temp[0] = ':';
+ strcpy(temp + 1, addr);
+ sdl.sdl_len = sizeof(sdl);
+ link_addr(temp, &sdl);
+ free(temp);
+ if (sdl.sdl_alen > sizeof(sa->sa_data))
+ errx(1, "malformed link-level address");
+ sa->sa_family = AF_LINK;
+ sa->sa_len = sdl.sdl_alen;
+ bcopy(LLADDR(&sdl), sa->sa_data, sdl.sdl_alen);
}
/* XXX FIXME -- should use strtoul for better parsing. */
19 freebsd4/sbin/ifconfig/ifieee80211.c
View
@@ -22,7 +22,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sbin/ifconfig/ifieee80211.c,v 1.1.2.2 2001/07/27 16:13:44 brooks Exp $
+ * $FreeBSD: src/sbin/ifconfig/ifieee80211.c,v 1.1.2.3 2002/02/07 15:12:37 ambrisko Exp $
*/
/*-
@@ -99,6 +99,11 @@ set80211ssid(const char *val, int d, int s, const struct afswtch *rafp)
u_int8_t data[33];
ssid = 0;
+ len = sizeof(val);
+ if (len > 2 && isdigit(val[0]) && val[1] == ':') {
+ ssid = atoi(val)-1;
+ val += 2;
+ }
bzero(data, sizeof(data));
len = sizeof(data);
@@ -296,6 +301,18 @@ ieee80211_status (s, info)
}
printf("\tssid ");
print_string(data, ireq.i_len);
+ num = 0;
+ ireq.i_type = IEEE80211_IOC_NUMSSIDS;
+ if (ioctl(s, SIOCG80211, &ireq) >= 0) {
+ num = ireq.i_val;
+ }
+ ireq.i_type = IEEE80211_IOC_SSID;
+ for (ireq.i_val = 0; ireq.i_val < num; ireq.i_val++) {
+ if (ioctl(s, SIOCG80211, &ireq) >= 0 && ireq.i_len > 0) {
+ printf(" %d:", ireq.i_val + 1);
+ print_string(data, ireq.i_len);
+ }
+ }
printf("\n");
ireq.i_type = IEEE80211_IOC_STATIONNAME;
8 freebsd4/sbin/route/Makefile
View
@@ -1,12 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD: src/sbin/route/Makefile,v 1.11.2.1 2001/04/25 10:58:49 ru Exp $
+# $FreeBSD: src/sbin/route/Makefile,v 1.11.2.2 2002/04/12 11:13:56 ru Exp $
PROG= route
MAN= route.8
SRCS= route.c keywords.h
CFLAGS+=-I. -Wall -DNS
CFLAGS+=-DINET6
-CLEANFILES+=keywords.h
+CLEANFILES+=keywords.h _keywords.tmp
BINMODE=4555
keywords.h: keywords
@@ -19,8 +19,4 @@ keywords.h: keywords
> ${.TARGET}
rm -f _keywords.tmp
-./keywords.h: keywords.h
-
.include <bsd.prog.mk>
-
-route .depend lint tags: keywords.h
27 freebsd4/sbin/route/route.c
View
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$FreeBSD: src/sbin/route/route.c,v 1.40.2.6 2001/12/20 12:17:36 ru Exp $";
+ "$FreeBSD: src/sbin/route/route.c,v 1.40.2.7 2002/02/01 11:48:00 ru Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -1329,6 +1329,7 @@ char *msgtypes[] = {
"RTM_IFINFO: iface status change",
"RTM_NEWMADDR: new multicast group membership on iface",
"RTM_DELMADDR: multicast group membership removed from iface",
+ "RTM_IFANNOUNCE: interface arrival/departure",
0,
};
@@ -1357,6 +1358,7 @@ print_rtmsg(rtm, msglen)
#ifdef RTM_NEWMADDR
struct ifma_msghdr *ifmam;
#endif
+ struct if_announcemsghdr *ifan;
if (verbose == 0)
return;
@@ -1365,7 +1367,11 @@ print_rtmsg(rtm, msglen)
rtm->rtm_version);
return;
}
- (void)printf("%s: len %d, ", msgtypes[rtm->rtm_type], rtm->rtm_msglen);
+ if (msgtypes[rtm->rtm_type] != NULL)
+ (void)printf("%s: ", msgtypes[rtm->rtm_type]);
+ else
+ (void)printf("#%d: ", rtm->rtm_type);
+ (void)printf("len %d, ", rtm->rtm_msglen);
switch (rtm->rtm_type) {
case RTM_IFINFO:
ifm = (struct if_msghdr *)rtm;
@@ -1387,6 +1393,23 @@ print_rtmsg(rtm, msglen)
pmsg_addrs((char *)(ifmam + 1), ifmam->ifmam_addrs);
break;
#endif
+ case RTM_IFANNOUNCE:
+ ifan = (struct if_announcemsghdr *)rtm;
+ (void) printf("if# %d, what: ", ifan->ifan_index);
+ switch (ifan->ifan_what) {
+ case IFAN_ARRIVAL:
+ printf("arrival");
+ break;
+ case IFAN_DEPARTURE:
+ printf("departure");
+ break;
+ default:
+ printf("#%d", ifan->ifan_what);
+ break;
+ }
+ printf("\n");
+ break;
+
default:
(void) printf("pid: %ld, seq %d, errno %d, flags:",
(long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
21 freebsd4/usr.bin/netstat/route.c
View
@@ -36,7 +36,7 @@
static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$FreeBSD: src/usr.bin/netstat/route.c,v 1.41.2.11 2001/10/18 10:33:25 ru Exp $";
+ "$FreeBSD: src/usr.bin/netstat/route.c,v 1.41.2.12 2002/04/08 08:01:51 ru Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -44,6 +44,7 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
+#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
@@ -513,20 +514,12 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width)
switch (sdl->sdl_type) {
case IFT_ETHER:
- {
- register int i;
- register u_char *lla = (u_char *)sdl->sdl_data +
- sdl->sdl_nlen;
-
- cplim = "";
- for (i = 0; i < sdl->sdl_alen; i++, lla++) {
- cp += sprintf(cp, "%s%x", cplim, *lla);
- cplim = ":";
+ if (sdl->sdl_alen == ETHER_ADDR_LEN) {
+ cp = ether_ntoa((struct ether_addr *)
+ sdl->sdl_data + sdl->sdl_nlen);
+ break;
}
- cp = workbuf;
- break;
- }
-
+ /* FALLTHROUGH */
default:
cp = link_ntoa(sdl);
break;
177 freebsd4/usr.bin/tftp/main.c
View
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$FreeBSD: src/usr.bin/tftp/main.c,v 1.8.2.1 2002/01/07 09:01:53 guido Exp $";
+ "$FreeBSD: src/usr.bin/tftp/main.c,v 1.8.2.3 2002/05/14 22:08:07 bsd Exp $";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -74,9 +74,8 @@ static const char rcsid[] =
#define TIMEOUT 5 /* secs between rexmt's */
-struct sockaddr_in peeraddr;
+struct sockaddr_storage peeraddr;
int f;
-short port;
int trace;
int verbose;
int connected;
@@ -86,8 +85,8 @@ int margc;
char *margv[20];
char *prompt = "tftp";
jmp_buf toplevel;
+volatile int txrx_error;
void intr();
-struct servent *sp;
void get __P((int, char **));
void help __P((int, char **));
@@ -96,6 +95,7 @@ void put __P((int, char **));
void quit __P((int, char **));
void setascii __P((int, char **));
void setbinary __P((int, char **));
+void setpeer0 __P((char *, char *));
void setpeer __P((int, char **));
void setrexmt __P((int, char **));
void settimeout __P((int, char **));
@@ -157,23 +157,12 @@ main(argc, argv)
int argc;
char *argv[];
{
- struct sockaddr_in sin;
-
- sp = getservbyname("tftp", "udp");
- if (sp == 0)
- errx(1, "udp/tftp: unknown service");
- f = socket(AF_INET, SOCK_DGRAM, 0);
- if (f < 0)
- err(3, "socket");
- bzero((char *)&sin, sizeof(sin));
- sin.sin_family = AF_INET;
- if (bind(f, (struct sockaddr *)&sin, sizeof(sin)) < 0)
- err(1, "bind");
+ f = -1;
strcpy(mode, "netascii");
signal(SIGINT, intr);
if (argc > 1) {
if (setjmp(toplevel) != 0)
- exit(0);
+ exit(txrx_error);
setpeer(argc, argv);
}
if (setjmp(toplevel) != 0)
@@ -184,11 +173,78 @@ main(argc, argv)
char hostname[MAXHOSTNAMELEN];
void
+setpeer0(host, port)
+ char *host;
+ char *port;
+{
+ struct addrinfo hints, *res0, *res;
+ int error;
+ struct sockaddr_storage ss;
+ char *cause = "unknown";
+
+ if (connected) {
+ close(f);
+ f = -1;
+ }
+ connected = 0;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_UDP;
+ hints.ai_flags = AI_CANONNAME;
+ if (!port)
+ port = "tftp";
+ error = getaddrinfo(host, port, &hints, &res0);
+ if (error) {
+ warnx("%s", gai_strerror(error));
+ return;
+ }
+
+ for (res = res0; res; res = res->ai_next) {
+ if (res->ai_addrlen > sizeof(peeraddr))
+ continue;
+ f = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (f < 0) {
+ cause = "socket";
+ continue;
+ }
+
+ memset(&ss, 0, sizeof(ss));
+ ss.ss_family = res->ai_family;
+ ss.ss_len = res->ai_addrlen;
+ if (bind(f, (struct sockaddr *)&ss, ss.ss_len) < 0) {
+ cause = "bind";
+ close(f);
+ f = -1;
+ continue;
+ }
+
+ break;
+ }
+
+ if (f < 0)
+ warn("%s", cause);
+ else {
+ /* res->ai_addr <= sizeof(peeraddr) is guaranteed */
+ memcpy(&peeraddr, res->ai_addr, res->ai_addrlen);
+ if (res->ai_canonname) {
+ (void) strncpy(hostname, res->ai_canonname,
+ sizeof(hostname));
+ } else
+ (void) strncpy(hostname, host, sizeof(hostname));
+ hostname[sizeof(hostname)-1] = 0;
+ connected = 1;
+ }
+
+ freeaddrinfo(res0);
+}
+
+void
setpeer(argc, argv)
int argc;
char *argv[];
{
- struct hostent *host;
if (argc < 2) {
strcpy(line, "Connect ");
@@ -202,34 +258,10 @@ setpeer(argc, argv)
printf("usage: %s host-name [port]\n", argv[0]);
return;
}
- host = gethostbyname(argv[1]);
- if (host) {
- peeraddr.sin_family = host->h_addrtype;
- bcopy(host->h_addr, &peeraddr.sin_addr,
- MIN(sizeof(peeraddr.sin_addr), host->h_length));
- strncpy(hostname, host->h_name, sizeof(hostname));
- } else {
- peeraddr.sin_family = AF_INET;
- peeraddr.sin_addr.s_addr = inet_addr(argv[1]);
- if (peeraddr.sin_addr.s_addr == -1) {
- connected = 0;
- printf("%s: unknown host\n", argv[1]);
- return;
- }
- strncpy(hostname, argv[1], sizeof(hostname));
- }
- hostname[sizeof(hostname) - 1] = '\0';
- port = sp->s_port;
- if (argc == 3) {
- port = atoi(argv[2]);
- if (port < 0) {
- printf("%s: bad port number\n", argv[2]);
- connected = 0;
- return;
- }
- port = htons(port);
- }
- connected = 1;
+ if (argc == 3)
+ setpeer0(argv[1], NULL);
+ else
+ setpeer0(argv[1], argv[2]);
}
struct modes {
@@ -333,9 +365,8 @@ put(argc, argv)
return;
}
targ = argv[argc - 1];
- if (index(argv[argc - 1], ':')) {
+ if (rindex(argv[argc - 1], ':')) {
char *cp;
- struct hostent *hp;
for (n = 1; n < argc - 1; n++)
if (index(argv[n], ':')) {
@@ -343,20 +374,13 @@ put(argc, argv)
return;
}
cp = argv[argc - 1];
- targ = index(cp, ':');
+ targ = rindex(cp, ':');
*targ++ = 0;
- hp = gethostbyname(cp);
- if (hp == NULL) {
- fprintf(stderr, "tftp: %s: ", cp);
- herror((char *)NULL);
- return;
+ if (cp[0] == '[' && cp[strlen(cp) - 1] == ']') {
+ cp[strlen(cp) - 1] = '\0';
+ cp++;
}
- bcopy(hp->h_addr, (caddr_t)&peeraddr.sin_addr,
- MIN(sizeof(peeraddr.sin_addr), hp->h_length));
- peeraddr.sin_family = hp->h_addrtype;
- connected = 1;
- strncpy(hostname, hp->h_name, sizeof(hostname));
- hostname[sizeof(hostname) - 1] = '\0';
+ setpeer0(cp, NULL);
}
if (!connected) {
printf("No target machine specified.\n");
@@ -372,7 +396,6 @@ put(argc, argv)
if (verbose)
printf("putting %s to %s:%s [%s]\n",
cp, hostname, targ, mode);
- peeraddr.sin_port = port;
xmitfile(fd, targ, mode);
return;
}
@@ -390,7 +413,6 @@ put(argc, argv)
if (verbose)
printf("putting %s to %s:%s [%s]\n",
argv[n], hostname, targ, mode);
- peeraddr.sin_port = port;
xmitfile(fd, targ, mode);
}
}
@@ -430,31 +452,26 @@ get(argc, argv)
}
if (!connected) {
for (n = 1; n < argc ; n++)
- if (index(argv[n], ':') == 0) {
+ if (rindex(argv[n], ':') == 0) {
getusage(argv[0]);
return;
}
}
for (n = 1; n < argc ; n++) {
- src = index(argv[n], ':');
+ src = rindex(argv[n], ':');
if (src == NULL)
src = argv[n];
else {
- struct hostent *hp;
-
+ char *cp;
*src++ = 0;
- hp = gethostbyname(argv[n]);
- if (hp == NULL) {
- fprintf(stderr, "tftp: %s: ", argv[n]);
- herror((char *)NULL);
- continue;
+ cp = argv[n];
+ if (cp[0] == '[' && cp[strlen(cp) - 1] == ']') {
+ cp[strlen(cp) - 1] = '\0';
+ cp++;
}
- bcopy(hp->h_addr, (caddr_t)&peeraddr.sin_addr,
- MIN(sizeof(peeraddr.sin_addr), hp->h_length));
- peeraddr.sin_family = hp->h_addrtype;
- connected = 1;
- strncpy(hostname, hp->h_name, sizeof(hostname));
- hostname[sizeof(hostname) - 1] = '\0';
+ setpeer0(cp, NULL);
+ if (!connected)
+ continue;
}
if (argc < 4) {
cp = argc == 3 ? argv[2] : tail(src);
@@ -466,7 +483,6 @@ get(argc, argv)
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
hostname, src, cp, mode);
- peeraddr.sin_port = port;
recvfile(fd, src, mode);
break;
}
@@ -479,7 +495,6 @@ get(argc, argv)
if (verbose)
printf("getting from %s:%s to %s [%s]\n",
hostname, src, cp, mode);
- peeraddr.sin_port = port;
recvfile(fd, src, mode);
}
}
@@ -602,7 +617,7 @@ command()
printf("%s> ", prompt);
if (fgets(line, sizeof line , stdin) == 0) {
if (feof(stdin)) {
- exit(0);
+ exit(txrx_error);
} else {
continue;
}
@@ -690,7 +705,7 @@ quit(argc, argv)
char *argv[];
{
- exit(0);
+ exit(txrx_error);
}
/*
7 freebsd4/usr.bin/tftp/tftp.1
View
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)tftp.1 8.2 (Berkeley) 4/18/94
-.\" $FreeBSD: src/usr.bin/tftp/tftp.1,v 1.4.2.5 2001/08/16 13:17:07 ru Exp $
+.\" $FreeBSD: src/usr.bin/tftp/tftp.1,v 1.4.2.6 2002/04/26 17:22:43 ume Exp $
.\"
.Dd April 18, 1994
.Dt TFTP 1
@@ -137,6 +137,11 @@ If the remote-directory form is used, the remote host is
assumed to be a
.Tn UNIX
machine.
+If you need to specify IPv6 numeric address to
+.Ar hosts ,
+wrap them using square bracket like
+.Ar [hosts]:filename
+to disambiguate the colon.
.Pp
.It Cm quit
Exit
79 freebsd4/usr.bin/tftp/tftp.c
View
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)tftp.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$FreeBSD: src/usr.bin/tftp/tftp.c,v 1.5.2.1 2001/03/04 09:12:14 kris Exp $";
+ "$FreeBSD: src/usr.bin/tftp/tftp.c,v 1.5.2.3 2002/05/14 22:08:07 bsd Exp $";
#endif /* not lint */
/* Many bug fixes are from Jim Guyton <guyton@rand-unix> */
@@ -59,16 +59,18 @@ static const char rcsid[] =
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <netdb.h>
#include "extern.h"
#include "tftpsubs.h"
-extern struct sockaddr_in peeraddr; /* filled in by main */
+extern struct sockaddr_storage peeraddr; /* filled in by main */
extern int f; /* the opened socket */
extern int trace;
extern int verbose;
extern int rexmtval;
extern int maxtimeout;
+extern volatile int txrx_error;
#define PKTSIZE SEGSIZE+4
char ackbuf[PKTSIZE];
@@ -76,13 +78,14 @@ int timeout;
jmp_buf toplevel;
jmp_buf timeoutbuf;
-static void nak __P((int));
+static void nak __P((int, struct sockaddr *));
static int makerequest __P((int, const char *, struct tftphdr *, const char *));
static void printstats __P((const char *, unsigned long));
static void startclock __P((void));
static void stopclock __P((void));
static void timer __P((int));
static void tpacket __P((const char *, struct tftphdr *, int));
+static int cmpport __P((struct sockaddr *, struct sockaddr *));
/*
* Send the requested file.
@@ -99,9 +102,11 @@ xmitfile(fd, name, mode)
volatile unsigned short block;
volatile int size, convert;
volatile unsigned long amount;
- struct sockaddr_in from;
+ struct sockaddr_storage from;
int fromlen;
FILE *file;
+ struct sockaddr_storage peer;
+ struct sockaddr_storage serv; /* valid server port number */
startclock(); /* start stat's clock */
dp = r_init(); /* reset fillbuf/read-ahead code */
@@ -110,6 +115,8 @@ xmitfile(fd, name, mode)
convert = !strcmp(mode, "netascii");
block = 0;
amount = 0;
+ memcpy(&peer, &peeraddr, peeraddr.ss_len);
+ memset(&serv, 0, sizeof(serv));
signal(SIGALRM, timer);
do {
@@ -119,7 +126,7 @@ xmitfile(fd, name, mode)
/* size = read(fd, dp->th_data, SEGSIZE); */
size = readit(file, &dp, convert);
if (size < 0) {
- nak(errno + 100);
+ nak(errno + 100, (struct sockaddr *)&peer);
break;
}
dp->th_opcode = htons((u_short)DATA);
@@ -131,7 +138,7 @@ xmitfile(fd, name, mode)
if (trace)
tpacket("sent", dp, size + 4);
n = sendto(f, dp, size + 4, 0,
- (struct sockaddr *)&peeraddr, sizeof(peeraddr));
+ (struct sockaddr *)&peer, peer.ss_len);
if (n != size + 4) {
warn("sendto");
goto abort;
@@ -149,7 +156,14 @@ xmitfile(fd, name, mode)
warn("recvfrom");
goto abort;
}
- peeraddr.sin_port = from.sin_port; /* added */
+ if (!serv.ss_family)
+ serv = from;
+ else if (!cmpport((struct sockaddr *)&serv,
+ (struct sockaddr *)&from)) {
+ warn("server port mismatch");
+ goto abort;
+ }
+ peer = from;
if (trace)
tpacket("received", ap, n);
/* should verify packet came from server */
@@ -158,6 +172,7 @@ xmitfile(fd, name, mode)
if (ap->th_opcode == ERROR) {
printf("Error code %d: %s\n", ap->th_code,
ap->th_msg);
+ txrx_error = 1;
goto abort;
}
if (ap->th_opcode == ACK) {
@@ -205,10 +220,12 @@ recvfile(fd, name, mode)
volatile unsigned short block;
volatile int size, firsttrip;
volatile unsigned long amount;
- struct sockaddr_in from;
+ struct sockaddr_storage from;
int fromlen;
FILE *file;
volatile int convert; /* true if converting crlf -> lf */
+ struct sockaddr_storage peer;
+ struct sockaddr_storage serv; /* valid server port number */
startclock();
dp = w_init();
@@ -218,6 +235,8 @@ recvfile(fd, name, mode)
block = 1;
firsttrip = 1;
amount = 0;
+ memcpy(&peer, &peeraddr, peeraddr.ss_len);
+ memset(&serv, 0, sizeof(serv));
signal(SIGALRM, timer);
do {
@@ -235,8 +254,8 @@ recvfile(fd, name, mode)
send_ack:
if (trace)
tpacket("sent", ap, size);
- if (sendto(f, ackbuf, size, 0, (struct sockaddr *)&peeraddr,
- sizeof(peeraddr)) != size) {
+ if (sendto(f, ackbuf, size, 0, (struct sockaddr *)&peer,
+ peer.ss_len) != size) {
alarm(0);
warn("sendto");
goto abort;
@@ -254,7 +273,14 @@ recvfile(fd, name, mode)
warn("recvfrom");
goto abort;
}
- peeraddr.sin_port = from.sin_port; /* added */
+ if (!serv.ss_family)
+ serv = from;
+ else if (!cmpport((struct sockaddr *)&serv,
+ (struct sockaddr *)&from)) {
+ warn("server port mismatch");
+ goto abort;
+ }
+ peer = from;
if (trace)
tpacket("received", dp, n);
/* should verify client address */
@@ -263,6 +289,7 @@ recvfile(fd, name, mode)
if (dp->th_opcode == ERROR) {
printf("Error code %d: %s\n", dp->th_code,
dp->th_msg);
+ txrx_error = 1;
goto abort;
}
if (dp->th_opcode == DATA) {
@@ -286,7 +313,7 @@ recvfile(fd, name, mode)
/* size = write(fd, dp->th_data, n - 4); */
size = writeit(file, &dp, n - 4, convert);
if (size < 0) {
- nak(errno + 100);
+ nak(errno + 100, (struct sockaddr *)&peer);
break;
}
amount += size;
@@ -294,8 +321,8 @@ recvfile(fd, name, mode)
abort: /* ok to ack, since user */
ap->th_opcode = htons((u_short)ACK); /* has seen err msg */
ap->th_block = htons((u_short)block);
- (void) sendto(f, ackbuf, 4, 0, (struct sockaddr *)&peeraddr,
- sizeof(peeraddr));
+ (void) sendto(f, ackbuf, 4, 0, (struct sockaddr *)&peer,
+ peer.ss_len);
write_behind(file, convert); /* flush last buffer */
fclose(file);
stopclock();
@@ -345,8 +372,9 @@ struct errmsg {
* offset by 100.
*/
static void
-nak(error)
+nak(error, peer)
int error;
+ struct sockaddr *peer;
{
register struct errmsg *pe;
register struct tftphdr *tp;
@@ -367,8 +395,7 @@ nak(error)
length = strlen(pe->e_msg) + 4;
if (trace)
tpacket("sent", tp, length);
- if (sendto(f, ackbuf, length, 0, (struct sockaddr *)&peeraddr,
- sizeof(peeraddr)) != length)
+ if (sendto(f, ackbuf, length, 0, peer, peer->sa_len) != length)
warn("nak");
}
@@ -455,5 +482,23 @@ timer(sig)
printf("Transfer timed out.\n");
longjmp(toplevel, -1);
}
+ txrx_error = 1;
longjmp(timeoutbuf, 1);
}
+
+static int
+cmpport(sa, sb)
+ struct sockaddr *sa;
+ struct sockaddr *sb;
+{
+ char a[NI_MAXSERV], b[NI_MAXSERV];
+
+ if (getnameinfo(sa, sa->sa_len, NULL, 0, a, sizeof(a), NI_NUMERICSERV))
+ return 0;
+ if (getnameinfo(sb, sb->sa_len, NULL, 0, b, sizeof(b), NI_NUMERICSERV))
+ return 0;
+ if (strcmp(a, b) != 0)
+ return 0;
+
+ return 1;
+}
4 freebsd4/usr.bin/tftp/tftpsubs.c
View
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)tftpsubs.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$FreeBSD: src/usr.bin/tftp/tftpsubs.c,v 1.3 1999/08/28 01:06:25 peter Exp $";
+ "$FreeBSD: src/usr.bin/tftp/tftpsubs.c,v 1.3.2.1 2002/04/26 17:22:43 ume Exp $";
#endif /* not lint */
/* Simple minded read-ahead/write-behind subroutines for tftp user and
@@ -260,7 +260,7 @@ synchnet(f)
{
int i, j = 0;
char rbuf[PKTSIZE];
- struct sockaddr_in from;
+ struct sockaddr_storage from;
int fromlen;
while (1) {
Please sign in to comment.
Something went wrong with that request. Please try again.