Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add RDNSS and DNSSL support, RFC6106.



details:   https://anonhg.NetBSD.org/src/rev/d9d869d1c455
branches:  trunk
changeset: 771946:d9d869d1c455
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Dec 10 19:14:29 2011 +0000

description:
Add RDNSS and DNSSL support, RFC6106.
Replace custom lists with TAILQ lists.
Clean up plently of signed vs unsigned warnings and set WARNS=4.

Adapted from FreeBSD.

diffstat:

 sys/netinet/icmp6.h           |   21 +-
 usr.sbin/rtadvd/Makefile      |    6 +-
 usr.sbin/rtadvd/advcap.c      |   53 ++----
 usr.sbin/rtadvd/advcap.h      |   10 +-
 usr.sbin/rtadvd/config.c      |  323 +++++++++++++++++++++++++++++------------
 usr.sbin/rtadvd/config.h      |   21 +-
 usr.sbin/rtadvd/dump.c        |   82 +++++++---
 usr.sbin/rtadvd/dump.h        |    4 +-
 usr.sbin/rtadvd/if.c          |   22 +-
 usr.sbin/rtadvd/if.h          |   38 ++--
 usr.sbin/rtadvd/rrenum.c      |   31 ++-
 usr.sbin/rtadvd/rrenum.h      |    6 +-
 usr.sbin/rtadvd/rtadvd.c      |  289 ++++++++++++++++++------------------
 usr.sbin/rtadvd/rtadvd.conf.5 |   81 ++++++++++-
 usr.sbin/rtadvd/rtadvd.h      |  120 +++++++++-----
 usr.sbin/rtadvd/timer.c       |   49 +++---
 usr.sbin/rtadvd/timer.h       |   30 +-
 17 files changed, 722 insertions(+), 464 deletions(-)

diffs (truncated from 2492 to 300 lines):

diff -r 4ee5186ffa9f -r d9d869d1c455 sys/netinet/icmp6.h
--- a/sys/netinet/icmp6.h       Sat Dec 10 17:50:19 2011 +0000
+++ b/sys/netinet/icmp6.h       Sat Dec 10 19:14:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.h,v 1.43 2011/11/11 15:09:32 gdt Exp $   */
+/*     $NetBSD: icmp6.h,v 1.44 2011/12/10 19:14:29 roy Exp $   */
 /*     $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $  */
 
 
@@ -300,11 +300,10 @@
 #define ND_OPT_HOMEAGENT_INFO          8
 #define ND_OPT_SOURCE_ADDRLIST         9
 #define ND_OPT_TARGET_ADDRLIST         10
-/* RFC5380 */
-#define ND_OPT_MAP                     23
-/* RFC4191 */
-#define ND_OPT_ROUTE_INFO              24
-#define ND_OPT_RDNSS                   25
+#define ND_OPT_MAP                     23      /* RFC 5380 */
+#define ND_OPT_ROUTE_INFO              24      /* RFC 4191 */
+#define ND_OPT_RDNSS                   25      /* RFC 6016 */
+#define ND_OPT_DNSSL                   31      /* RFC 6016 */
 
 struct nd_opt_route_info {     /* route info */
        u_int8_t        nd_opt_rti_type;
@@ -344,7 +343,7 @@
        u_int32_t       nd_opt_mtu_mtu;
 } __packed;
 
-struct nd_opt_rdnss {          /* RDNSS option RFC 5006 */
+struct nd_opt_rdnss {          /* RDNSS option RFC 6106 */
        u_int8_t        nd_opt_rdnss_type;
        u_int8_t        nd_opt_rdnss_len;
        u_int16_t       nd_opt_rdnss_reserved;
@@ -352,6 +351,14 @@
        /* followed by list of IP prefixes */
 } __packed;
 
+struct nd_opt_dnssl {          /* DNSSL option RFC 6106 */
+       u_int8_t        nd_opt_dnssl_type;
+       u_int8_t        nd_opt_dnssl_len;
+       u_int16_t       nd_opt_dnssl_reserved;
+       u_int32_t       nd_opt_dnssl_lifetime;
+       /* followed by list of IP prefixes */
+} __packed;
+
 /*
  * icmp6 namelookup
  */
diff -r 4ee5186ffa9f -r d9d869d1c455 usr.sbin/rtadvd/Makefile
--- a/usr.sbin/rtadvd/Makefile  Sat Dec 10 17:50:19 2011 +0000
+++ b/usr.sbin/rtadvd/Makefile  Sat Dec 10 19:14:29 2011 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.15 2011/06/20 07:44:04 mrg Exp $
+# $NetBSD: Makefile,v 1.16 2011/12/10 19:14:29 roy Exp $
 
-WARNS?=        2       # XXX -Wcast-qual -Wsign-compare
+WARNS?=        4
 
 .include <bsd.own.mk>
 
@@ -9,7 +9,7 @@
 PROG=  rtadvd
 SRCS=  rtadvd.c rrenum.c advcap.c if.c config.c timer.c dump.c
 
-CPPFLAGS+=-DINET6 -DROUTEINFO
+CPPFLAGS+=-DINET6
 MAN=   rtadvd.8 rtadvd.conf.5
 LDADD+=        -lutil
 DPADD+=        ${LIBUTIL}
diff -r 4ee5186ffa9f -r d9d869d1c455 usr.sbin/rtadvd/advcap.c
--- a/usr.sbin/rtadvd/advcap.c  Sat Dec 10 17:50:19 2011 +0000
+++ b/usr.sbin/rtadvd/advcap.c  Sat Dec 10 19:14:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advcap.c,v 1.12 2006/03/18 22:07:15 dan Exp $  */
+/*     $NetBSD: advcap.c,v 1.13 2011/12/10 19:14:29 roy Exp $  */
 /*     $KAME: advcap.c,v 1.11 2003/05/19 09:46:50 keiichi Exp $        */
 
 /*
@@ -87,15 +87,15 @@
 
 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 *));
-int64_t tgetnum __P((char *));
-int tgetflag __P((char *));
-char *tgetstr __P((char *, char **));
-static char *tdecode __P((char *, char **));
+int tgetent(char *, char *);
+int getent(char *, char *, char *);
+int tnchktc(void);
+int tnamatch(char *);
+static char *tskip(char *);
+int64_t tgetnum(char *);
+int tgetflag(char *);
+char *tgetstr(char *, char **);
+static char *tdecode(char *, char **);
 
 /*
  * Get an entry for terminal name in buffer bp,
@@ -103,18 +103,16 @@
  * we just notice escaped newlines.
  */
 int
-tgetent(bp, name)
-       char *bp, *name;
+tgetent(char *bp, char *name)
 {
        char *cp;
 
-       remotefile = cp = conffile ? conffile : _PATH_RTADVDCONF;
+       remotefile = cp = conffile ? conffile : __UNCONST(_PATH_RTADVDCONF);
        return (getent(bp, name, cp));
 }
 
 int
-getent(bp, name, cp)
-       char *bp, *name, *cp;
+getent(char *bp, char *name, char *cp)
 {
        int c;
        int i = 0, cnt = 0;
@@ -183,7 +181,7 @@
  * Note that this works because of the left to right scan.
  */
 int
-tnchktc()
+tnchktc(void)
 {
        char *p, *q;
        char tcname[16];        /* name of similar terminal */
@@ -232,8 +230,7 @@
  * name (before the first field) stops us.
  */
 int
-tnamatch(np)
-       char *np;
+tnamatch(char *np)
 {
        char *Np, *Bp;
 
@@ -259,8 +256,7 @@
  * into the termcap file in octal.
  */
 static char *
-tskip(bp)
-       char *bp;
+tskip(char *bp)
 {
        int dquote;
 
@@ -304,8 +300,7 @@
  * Note that we handle octal numbers beginning with 0.
  */
 int64_t
-tgetnum(id)
-       char *id;
+tgetnum(char *id)
 {
        int64_t i;
        int base;
@@ -340,8 +335,7 @@
  * not given.
  */
 int
-tgetflag(id)
-       char *id;
+tgetflag(char *id)
 {
        char *bp = tbuf;
 
@@ -368,8 +362,7 @@
  * No checking on area overflow.
  */
 char *
-tgetstr(id, area)
-       char *id, **area;
+tgetstr(char *id, char **area)
 {
        char *bp = tbuf;
 
@@ -394,13 +387,11 @@
  * string capability escapes.
  */
 static char *
-tdecode(str, area)
-       char *str;
-       char **area;
+tdecode(char *str, char **area)
 {
        char *cp;
        int c;
-       char *dp;
+       const char *dps = "E\033^^\\\\::n\nr\rt\tb\bf\f\"\"", *dp;
        int i;
        char term;
 
@@ -419,7 +410,7 @@
                        break;
 
                case '\\':
-                       dp = "E\033^^\\\\::n\nr\rt\tb\bf\f\"\"";
+                       dp = dps; 
                        c = *str++;
 nextc:
                        if (*dp++ == c) {
diff -r 4ee5186ffa9f -r d9d869d1c455 usr.sbin/rtadvd/advcap.h
--- a/usr.sbin/rtadvd/advcap.h  Sat Dec 10 17:50:19 2011 +0000
+++ b/usr.sbin/rtadvd/advcap.h  Sat Dec 10 19:14:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advcap.h,v 1.6 2006/03/05 23:47:08 rpaulo Exp $        */
+/*     $NetBSD: advcap.h,v 1.7 2011/12/10 19:14:29 roy Exp $   */
 /*     $KAME: advcap.h,v 1.5 2003/06/09 05:40:54 t-momose Exp $        */
 
 /*
@@ -36,10 +36,10 @@
 
 __BEGIN_DECLS
 
-extern int agetent __P((char *, const char *));
-extern int agetflag __P((const char *));
-extern int64_t agetnum __P((const char *));
-extern char *agetstr __P((const char *, char **));
+extern int agetent(char *, const char *);
+extern int agetflag(const char *);
+extern int64_t agetnum(const char *);
+extern char *agetstr(const char *, char **);
 
 __END_DECLS
 
diff -r 4ee5186ffa9f -r d9d869d1c455 usr.sbin/rtadvd/config.c
--- a/usr.sbin/rtadvd/config.c  Sat Dec 10 17:50:19 2011 +0000
+++ b/usr.sbin/rtadvd/config.c  Sat Dec 10 19:14:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.c,v 1.25 2006/05/11 08:35:47 mrg Exp $  */
+/*     $NetBSD: config.c,v 1.26 2011/12/10 19:14:29 roy Exp $  */
 /*     $KAME: config.c,v 1.93 2005/10/17 14:40:02 suz Exp $    */
 
 /*
@@ -66,25 +66,45 @@
 
 static time_t prefix_timo = (60 * 120);        /* 2 hours.
                                         * XXX: should be configurable. */
-extern struct rainfo *ralist;
+static struct rtadvd_timer *prefix_timeout(void *);
+static void makeentry(char *, size_t, int, const char *);
+static int getinet6sysctl(int);
+
+static size_t
+encode_domain(char *dst, const char *src)
+{
+       ssize_t len;
+       char *odst, *p;
 
-static struct rtadvd_timer *prefix_timeout __P((void *));
-static void makeentry __P((char *, size_t, int, char *));
-static int getinet6sysctl __P((int));
+       odst = dst;
+       while (src && (len = strlen(src)) != 0) {
+               p = strchr(src, '.');
+               *dst++ = len = MIN(63, p == NULL ? len : p - src);
+               memcpy(dst, src, len);
+               dst += len;
+               if (p == NULL)
+                       break;
+               src = p + 1;
+       }
+       *dst++ = '\0';
+       
+       return dst - odst;
+}
 
 void
 getconfig(intface)
        char *intface;
 {
-       int stat, i;
+       int stat, c, i;
        char tbuf[BUFSIZ];
        struct rainfo *tmp;
-       long val;
+       int32_t val;
        int64_t val64;
        char buf[BUFSIZ];
        char *bp = buf;
-       char *addr, *flagstr;
+       char *addr, *flagstr, *ap;
        static int forwarding = -1;
+       char entbuf[256], abuf[256];
 
 #define MUSTHAVE(var, cap)     \
     do {                                                               \
@@ -101,6 +121,17 @@
        if ((var = agetnum(cap)) < 0)                                   \
                var = def;                                              \
      } while (0)



Home | Main Index | Thread Index | Old Index