Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src rtadvd: advertise IPv6 prefix info via router advertisement.
details: https://anonhg.NetBSD.org/src/rev/6f555cd380c4
branches: trunk
changeset: 474255:6f555cd380c4
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Jul 02 09:28:16 1999 +0000
description:
rtadvd: advertise IPv6 prefix info via router advertisement.
(to be run on routers)
diffstat:
etc/Makefile | 5 +-
etc/rtadvd.conf | 13 +
usr.sbin/Makefile | 4 +-
usr.sbin/rtadvd/Makefile | 11 +
usr.sbin/rtadvd/advcap.c | 460 +++++++++++++++
usr.sbin/rtadvd/advcap.h | 43 +
usr.sbin/rtadvd/config.c | 623 +++++++++++++++++++++
usr.sbin/rtadvd/config.h | 32 +
usr.sbin/rtadvd/if.c | 587 +++++++++++++++++++
usr.sbin/rtadvd/if.h | 55 +
usr.sbin/rtadvd/pathnames.h | 1 +
usr.sbin/rtadvd/rrenum.c | 407 +++++++++++++
usr.sbin/rtadvd/rrenum.h | 32 +
usr.sbin/rtadvd/rtadvd.8 | 110 +++
usr.sbin/rtadvd/rtadvd.c | 1210 +++++++++++++++++++++++++++++++++++++++++
usr.sbin/rtadvd/rtadvd.conf.5 | 249 ++++++++
usr.sbin/rtadvd/rtadvd.h | 104 +++
usr.sbin/rtadvd/timer.c | 199 ++++++
usr.sbin/rtadvd/timer.h | 61 ++
19 files changed, 4203 insertions(+), 3 deletions(-)
diffs (truncated from 4302 to 300 lines):
diff -r e8703bb8cff2 -r 6f555cd380c4 etc/Makefile
--- a/etc/Makefile Fri Jul 02 08:58:21 1999 +0000
+++ b/etc/Makefile Fri Jul 02 09:28:16 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.119 1999/06/30 18:42:03 ross Exp $
+# $NetBSD: Makefile,v 1.120 1999/07/02 09:28:16 itojun Exp $
# from: @(#)Makefile 8.7 (Berkeley) 5/25/95
# Environment variables without default values:
@@ -93,6 +93,9 @@
BIN1+= ld.so.conf
.endif
+# IPv6
+BIN1+= rtadvd.conf
+
# -rw-rw-r--
BIN2+= motd
diff -r e8703bb8cff2 -r 6f555cd380c4 etc/rtadvd.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rtadvd.conf Fri Jul 02 09:28:16 1999 +0000
@@ -0,0 +1,13 @@
+#
+# common definitions.
+#
+default:\
+ :chlim#64:raflags#0:rltime#1800:rtime#30000:retrans#1000:\
+ :pinfoflags#192:vltime#3600000:pltime#3600000:mtu#1500:
+ether:\
+ :mtu#1500:tc=default:
+#
+# interfaces.
+#
+ef0:\
+ :addrs#1:addr="fec0:0000:0000:0000::":prefixlen#64:tc=ether:
diff -r e8703bb8cff2 -r 6f555cd380c4 usr.sbin/Makefile
--- a/usr.sbin/Makefile Fri Jul 02 08:58:21 1999 +0000
+++ b/usr.sbin/Makefile Fri Jul 02 09:28:16 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.113 1999/07/01 20:55:03 itojun Exp $
+# $NetBSD: Makefile,v 1.114 1999/07/02 09:28:16 itojun Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
# XXX Temporary for NO_SENDMAIL and BUILD_POSTFIX
@@ -22,7 +22,7 @@
zdump zic
# IPv6
-SUBDIR+=gifconfig ifmcstat ndp traceroute6
+SUBDIR+=gifconfig ifmcstat ndp rtadvd traceroute6
.if !defined(NO_SENDMAIL)
SUBDIR+= sendmail
diff -r e8703bb8cff2 -r 6f555cd380c4 usr.sbin/rtadvd/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/rtadvd/Makefile Fri Jul 02 09:28:16 1999 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 1999/07/02 09:28:17 itojun Exp $
+
+PROG= rtadvd
+SRCS= rtadvd.c rrenum.c advcap.c if.c config.c timer.c
+
+CFLAGS+=-DINET6
+MAN= rtadvd.8 rtadvd.conf.5
+LDADD+= -lcompat
+DPADD+= ${LIBCOMPAT}
+
+.include <bsd.prog.mk>
diff -r e8703bb8cff2 -r 6f555cd380c4 usr.sbin/rtadvd/advcap.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/rtadvd/advcap.c Fri Jul 02 09:28:16 1999 +0000
@@ -0,0 +1,460 @@
+/*
+ * Copyright (c) 1983 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)remcap.c 5.5 (Berkeley) 2/2/91";
+#else
+__RCSID("@(#)remcap.c 5.5 (Berkeley) 2/2/91");
+#endif
+#endif /* not lint */
+
+/*
+ * remcap - routines for dealing with the remote host data base
+ *
+ * derived from termcap
+ */
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <errno.h>
+#include <string.h>
+#include "pathnames.h"
+
+#ifndef BUFSIZ
+#define BUFSIZ 1024
+#endif
+#define MAXHOP 32 /* max number of tc= indirections */
+
+#define tgetent agetent
+#define tnchktc anchktc
+#define tnamatch anamatch
+#define tgetnum agetnum
+#define tgetflag agetflag
+#define tgetstr agetstr
+
+#if 0
+#define V_TERMCAP "REMOTE"
+#define V_TERM "HOST"
+#endif
+
+char *RM;
+
+/*
+ * termcap - routines for dealing with the terminal capability data base
+ *
+ * BUG: Should use a "last" pointer in tbuf, so that searching
+ * for capabilities alphabetically would not be a n**2/2
+ * process when large numbers of capabilities are given.
+ * Note: If we add a last pointer now we will screw up the
+ * tc capability. We really should compile termcap.
+ *
+ * Essentially all the work here is scanning and decoding escapes
+ * in string capabilities. We don't use stdio because the editor
+ * doesn't, and because living w/o it is not hard.
+ */
+
+static char *tbuf;
+static int hopcount; /* detect infinite loops in termcap, init 0 */
+
+static char *remotefile;
+
+extern char *conffile;
+
+int tgetent __P((char *, char *));
+int getent __P((char *, char *, char *));
+int tnchktc __P((void));
+int tnamatch __P((char *));
+static char *tskip __P((char *));
+int tgetnum __P((char *));
+int tgetflag __P((char *));
+char *tgetstr __P((char *, char **));
+static char *tdecode __P((char *, char **));
+
+/*
+ * Get an entry for terminal name in buffer bp,
+ * from the termcap file. Parse is very rudimentary;
+ * we just notice escaped newlines.
+ */
+int
+tgetent(bp, name)
+ char *bp, *name;
+{
+ char *cp;
+
+ remotefile = cp = conffile ? conffile : _PATH_RTADVDCONF;
+ return (getent(bp, name, cp));
+}
+
+int
+getent(bp, name, cp)
+ char *bp, *name, *cp;
+{
+ register int c;
+ register int i = 0, cnt = 0;
+ char ibuf[BUFSIZ];
+ int tf;
+
+ tbuf = bp;
+ tf = 0;
+ /*
+ * TERMCAP can have one of two things in it. It can be the
+ * name of a file to use instead of /etc/termcap. In this
+ * case it better start with a "/". Or it can be an entry to
+ * use so we don't have to read the file. In this case it
+ * has to already have the newlines crunched out.
+ */
+ if (cp && *cp) {
+ tf = open(RM = cp, O_RDONLY);
+ }
+ if (tf < 0) {
+ syslog(LOG_WARNING,
+ "<%s> open: %s", __FUNCTION__, strerror(errno));
+ return (-2);
+ }
+ for (;;) {
+ cp = bp;
+ for (;;) {
+ if (i == cnt) {
+ cnt = read(tf, ibuf, BUFSIZ);
+ if (cnt <= 0) {
+ close(tf);
+ return (0);
+ }
+ i = 0;
+ }
+ c = ibuf[i++];
+ if (c == '\n') {
+ if (cp > bp && cp[-1] == '\\') {
+ cp--;
+ continue;
+ }
+ break;
+ }
+ if (cp >= bp+BUFSIZ) {
+ write(2,"Remcap entry too long\n", 23);
+ break;
+ } else
+ *cp++ = c;
+ }
+ *cp = 0;
+
+ /*
+ * The real work for the match.
+ */
+ if (tnamatch(name)) {
+ close(tf);
+ return (tnchktc());
+ }
+ }
+}
+
+/*
+ * tnchktc: check the last entry, see if it's tc=xxx. If so,
+ * recursively find xxx and append that entry (minus the names)
+ * to take the place of the tc=xxx entry. This allows termcap
+ * entries to say "like an HP2621 but doesn't turn on the labels".
+ * Note that this works because of the left to right scan.
+ */
+int
+tnchktc()
+{
+ register char *p, *q;
+ char tcname[16]; /* name of similar terminal */
+ char tcbuf[BUFSIZ];
+ char *holdtbuf = tbuf;
+ int l;
+
+ p = tbuf + strlen(tbuf) - 2; /* before the last colon */
+ while (*--p != ':')
+ if (p<tbuf) {
+ write(2, "Bad remcap entry\n", 18);
+ return (0);
+ }
+ p++;
+ /* p now points to beginning of last field */
+ if (p[0] != 't' || p[1] != 'c')
+ return (1);
+ strcpy(tcname, p+3);
+ q = tcname;
+ while (*q && *q != ':')
+ q++;
+ *q = 0;
+ if (++hopcount > MAXHOP) {
+ write(2, "Infinite tc= loop\n", 18);
+ return (0);
+ }
+ if (getent(tcbuf, tcname, remotefile) != 1) {
+ return (0);
+ }
+ for (q = tcbuf; *q++ != ':'; )
+ ;
Home |
Main Index |
Thread Index |
Old Index