CVS commit: src/usr.sbin/ndp

2023-08-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Aug 18 13:07:38 UTC 2023

Modified Files:
src/usr.sbin/ndp: Makefile ndp.c

Log Message:
ndp: add gmt2local() from external/bsd/tcpdump instead of reachover

It is no longer shipped with the tcpdump distribution.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/ndp/Makefile
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2023-08-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Fri Aug 18 13:07:38 UTC 2023

Modified Files:
src/usr.sbin/ndp: Makefile ndp.c

Log Message:
ndp: add gmt2local() from external/bsd/tcpdump instead of reachover

It is no longer shipped with the tcpdump distribution.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/ndp/Makefile
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/Makefile
diff -u src/usr.sbin/ndp/Makefile:1.13 src/usr.sbin/ndp/Makefile:1.14
--- src/usr.sbin/ndp/Makefile:1.13	Tue Oct 10 19:30:41 2017
+++ src/usr.sbin/ndp/Makefile	Fri Aug 18 13:07:38 2023
@@ -1,18 +1,15 @@
-# $NetBSD: Makefile,v 1.13 2017/10/10 19:30:41 christos Exp $
+# $NetBSD: Makefile,v 1.14 2023/08/18 13:07:38 tnn Exp $
 
 .include 
 
 USE_FORT?=	yes	# network client
 
-TCPDUMP=	${NETBSDSRCDIR}/external/bsd/tcpdump/dist
-.PATH:		${TCPDUMP}
-
 RUMPPRG=	ndp
-SRCS=		ndp.c gmt2local.c
+SRCS=		ndp.c
 MAN=		ndp.8
 
 CPPFLAGS+=	-DINET6
-CPPFLAGS+=	-I. -I${TCPDUMP}
+CPPFLAGS+=	-I.
 
 .if (${MKRUMP} != "no")
 CPPFLAGS+= 	-DRUMP_ACTION

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.59 src/usr.sbin/ndp/ndp.c:1.60
--- src/usr.sbin/ndp/ndp.c:1.59	Sat Nov 27 22:30:25 2021
+++ src/usr.sbin/ndp/ndp.c	Fri Aug 18 13:07:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.59 2021/11/27 22:30:25 rillig Exp $	*/
+/*	$NetBSD: ndp.c,v 1.60 2023/08/18 13:07:38 tnn Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -62,6 +62,27 @@
  */
 
 /*
+ * Copyright (c) 1997
+ *	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: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
  * Based on:
  * "@(#) Copyright (c) 1984, 1993\n\
  *	The Regents of the University of California.  All rights reserved.\n";
@@ -105,7 +126,6 @@
 #include 
 #include 
 
-#include "gmt2local.h"
 #include "prog_ops.h"
 
 static pid_t pid;
@@ -134,6 +154,7 @@ static void ifinfo(char *, int, char **)
 static const char *sec2str(time_t);
 static char *ether_str(struct sockaddr_dl *);
 static void ts_print(const struct timeval *);
+static int32_t gmt2local(time_t t);
 
 #define NDP_F_CLEAR	1
 #define NDP_F_DELETE	2
@@ -953,3 +974,35 @@ ts_print(const struct timeval *tvp)
 	(void)printf("%02d:%02d:%02d.%06u ",
 	s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tvp->tv_usec);
 }
+
+/*
+ * Returns the difference between gmt and local time in seconds.
+ * Use gmtime() and localtime() to keep things simple.
+ */
+static int32_t
+gmt2local(time_t t)
+{
+	int dt, dir;
+	struct tm *gmt, *loc;
+	struct tm sgmt;
+
+	if (t == 0)
+		t = time(NULL);
+	gmt = 
+	*gmt = *gmtime();
+	loc = localtime();
+	dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
+	(loc->tm_min - gmt->tm_min) * 60;
+
+	/*
+	 * If the year or julian day is different, we span 00:00 GMT
+	 * and must add or subtract a day. Check the year first to
+	 * avoid problems when the julian day wraps.
+	 */
+	dir = loc->tm_year - gmt->tm_year;
+	if (dir == 0)
+		dir = loc->tm_yday - gmt->tm_yday;
+	dt += dir * 24 * 60 * 60;
+
+	return (dt);
+}



CVS commit: src/usr.sbin/ndp

2020-09-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Sep 15 10:11:36 UTC 2020

Modified Files:
src/usr.sbin/ndp: ndp.8 ndp.c

Log Message:
ndp: Show U for Unreachable


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/ndp/ndp.8
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2020-09-15 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Sep 15 10:11:36 UTC 2020

Modified Files:
src/usr.sbin/ndp: ndp.8 ndp.c

Log Message:
ndp: Show U for Unreachable


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/ndp/ndp.8
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.8
diff -u src/usr.sbin/ndp/ndp.8:1.31 src/usr.sbin/ndp/ndp.8:1.32
--- src/usr.sbin/ndp/ndp.8:1.31	Fri Jun 12 21:08:02 2020
+++ src/usr.sbin/ndp/ndp.8	Tue Sep 15 10:11:35 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ndp.8,v 1.31 2020/06/12 21:08:02 roy Exp $
+.\"	$NetBSD: ndp.8,v 1.32 2020/09/15 10:11:35 roy Exp $
 .\"	$KAME: ndp.8,v 1.33 2005/10/19 14:57:42 suz Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 19, 2020
+.Dd September 15, 2020
 .Dt NDP 8
 .Os
 .\"
@@ -110,6 +110,8 @@ Probe
 Reachable
 .It S
 Stale
+.It U
+Unreachable
 .It W
 Waitdelete
 .It ?

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.57 src/usr.sbin/ndp/ndp.c:1.58
--- src/usr.sbin/ndp/ndp.c:1.57	Fri Jun 12 21:08:02 2020
+++ src/usr.sbin/ndp/ndp.c	Tue Sep 15 10:11:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.57 2020/06/12 21:08:02 roy Exp $	*/
+/*	$NetBSD: ndp.c,v 1.58 2020/09/15 10:11:35 roy Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -571,29 +571,30 @@ again:;
 (void)printf(" %-9.9s", "expired");
 
 			switch (nbi->state) {
-			case ND6_LLINFO_NOSTATE:
+			case ND_LLINFO_NOSTATE:
  (void)printf(" N");
  break;
-#ifdef ND6_LLINFO_WAITDELETE
-			case ND6_LLINFO_WAITDELETE:
+			case ND_LLINFO_WAITDELETE:
  (void)printf(" W");
  break;
-#endif
-			case ND6_LLINFO_INCOMPLETE:
+			case ND_LLINFO_INCOMPLETE:
  (void)printf(" I");
  break;
-			case ND6_LLINFO_REACHABLE:
+			case ND_LLINFO_REACHABLE:
  (void)printf(" R");
  break;
-			case ND6_LLINFO_STALE:
+			case ND_LLINFO_STALE:
  (void)printf(" S");
  break;
-			case ND6_LLINFO_DELAY:
+			case ND_LLINFO_DELAY:
  (void)printf(" D");
  break;
-			case ND6_LLINFO_PROBE:
+			case ND_LLINFO_PROBE:
  (void)printf(" P");
  break;
+			case ND_LLINFO_UNREACHABLE:
+ (void)printf(" U");
+ break;
 			default:
  (void)printf(" ?");
  break;



CVS commit: src/usr.sbin/ndp

2020-06-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 12 21:08:02 UTC 2020

Modified Files:
src/usr.sbin/ndp: ndp.8 ndp.c

Log Message:
ndp: Sync usage and SYNPOSIS with reality


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/ndp/ndp.8
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.8
diff -u src/usr.sbin/ndp/ndp.8:1.30 src/usr.sbin/ndp/ndp.8:1.31
--- src/usr.sbin/ndp/ndp.8:1.30	Fri Jun 12 11:04:46 2020
+++ src/usr.sbin/ndp/ndp.8	Fri Jun 12 21:08:02 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ndp.8,v 1.30 2020/06/12 11:04:46 roy Exp $
+.\"	$NetBSD: ndp.8,v 1.31 2020/06/12 21:08:02 roy Exp $
 .\"	$KAME: ndp.8,v 1.33 2005/10/19 14:57:42 suz Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -42,7 +42,7 @@
 .Ar hostname
 .Nm ndp
 .Op Fl nt
-.Fl a | Fl c | Fl p
+.Fl a | Fl c
 .Nm ndp
 .Op Fl nt
 .Fl A Ar wait

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.56 src/usr.sbin/ndp/ndp.c:1.57
--- src/usr.sbin/ndp/ndp.c:1.56	Fri Jun 12 11:04:46 2020
+++ src/usr.sbin/ndp/ndp.c	Fri Jun 12 21:08:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.56 2020/06/12 11:04:46 roy Exp $	*/
+/*	$NetBSD: ndp.c,v 1.57 2020/06/12 21:08:02 roy Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -695,7 +695,7 @@ usage(void)
 
 	(void)fprintf(stderr, "Usage: %s [-nt] hostname\n", pn);
 	(void)fprintf(stderr,
-	"   %s [-nt] -a | -c | -p | -r | -H | -P | -R\n", pn);
+	"   %s [-nt] -a | -c\n", pn);
 	(void)fprintf(stderr, "   %s [-nt] -A wait\n", pn);
 	(void)fprintf(stderr, "   %s [-nt] -d hostname\n", pn);
 	(void)fprintf(stderr, "   %s [-nt] -f filename\n", pn);



CVS commit: src/usr.sbin/ndp

2020-06-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Jun 12 21:08:02 UTC 2020

Modified Files:
src/usr.sbin/ndp: ndp.8 ndp.c

Log Message:
ndp: Sync usage and SYNPOSIS with reality


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/ndp/ndp.8
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-12-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Dec 16 08:47:43 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
ndp: SIOCSPFXFLUSH_IN6 and SIOCSRTRFLUSH_IN6 expect struct in6_ifreq

And not just a character string of the interface name.
This only worked before because the interface name is the first member
of the structure.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.54 src/usr.sbin/ndp/ndp.c:1.55
--- src/usr.sbin/ndp/ndp.c:1.54	Thu Jul 12 08:20:49 2018
+++ src/usr.sbin/ndp/ndp.c	Sun Dec 16 08:47:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.54 2018/07/12 08:20:49 nonaka Exp $	*/
+/*	$NetBSD: ndp.c,v 1.55 2018/12/16 08:47:43 roy Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -1400,13 +1400,14 @@ plist(void)
 static void
 pfx_flush(void)
 {
-	char dummyif[IFNAMSIZ+8];
 	int s;
+	struct in6_ifreq ifr;
 
 	if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
 		err(1, "socket");
-	(void)strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
-	if (prog_ioctl(s, SIOCSPFXFLUSH_IN6, (caddr_t)) < 0)
+	memset(, 0, sizeof(ifr));
+	strcpy(ifr.ifr_name, "lo0");
+	if (prog_ioctl(s, SIOCSPFXFLUSH_IN6, ) < 0)
 		err(1, "ioctl(SIOCSPFXFLUSH_IN6)");
 	(void)prog_close(s);
 }
@@ -1414,15 +1415,15 @@ pfx_flush(void)
 static void
 rtr_flush(void)
 {
-	char dummyif[IFNAMSIZ+8];
 	int s;
+	struct in6_ifreq ifr;
 
 	if ((s = prog_socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
 		err(1, "socket");
-	(void)strlcpy(dummyif, "lo0", sizeof(dummyif)); /* dummy */
-	if (prog_ioctl(s, SIOCSRTRFLUSH_IN6, (caddr_t)) < 0)
+	memset(, 0, sizeof(ifr));
+	strcpy(ifr.ifr_name, "lo0");
+	if (prog_ioctl(s, SIOCSRTRFLUSH_IN6, ) < 0)
 		err(1, "ioctl(SIOCSRTRFLUSH_IN6)");
-
 	(void)prog_close(s);
 }
 



CVS commit: src/usr.sbin/ndp

2018-12-16 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Dec 16 08:47:43 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
ndp: SIOCSPFXFLUSH_IN6 and SIOCSRTRFLUSH_IN6 expect struct in6_ifreq

And not just a character string of the interface name.
This only worked before because the interface name is the first member
of the structure.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:20:49 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Use s6, not mysin.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.53 src/usr.sbin/ndp/ndp.c:1.54
--- src/usr.sbin/ndp/ndp.c:1.53	Thu Jul 12 08:16:14 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 08:20:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.53 2018/07/12 08:16:14 nonaka Exp $	*/
+/*	$NetBSD: ndp.c,v 1.54 2018/07/12 08:20:49 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -494,8 +494,8 @@ delete(struct rt_msghdr *rtm, char *host
 	if (rtmsg(RTM_DELETE, rtm) == 0) {
 		struct sockaddr_in6 s6 = *mysin; /* XXX: for safety */
 
-		mysin->sin6_scope_id = 0;
-		inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+		s6.sin6_scope_id = 0;
+		inet6_putscopeid(, INET6_IS_ADDR_LINKLOCAL);
 		(void)getnameinfo((struct sockaddr *)(void *),
 		(socklen_t)s6.sin6_len, delete_host_buf,
 		sizeof(delete_host_buf), NULL, 0,



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:20:49 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Use s6, not mysin.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:16:14 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
ndp(8): host_buf should not be used in delete().

host_buf is passed to the argument host of delete() in do_foreach().


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.52 src/usr.sbin/ndp/ndp.c:1.53
--- src/usr.sbin/ndp/ndp.c:1.52	Thu Jul 12 07:32:35 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 08:16:14 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.52 2018/07/12 07:32:35 nonaka Exp $	*/
+/*	$NetBSD: ndp.c,v 1.53 2018/07/12 08:16:14 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -478,6 +478,7 @@ delete_one(char *host)
 static int
 delete(struct rt_msghdr *rtm, char *host)
 {
+	char delete_host_buf[NI_MAXHOST];
 	struct sockaddr_in6 *mysin = _m;
 	struct sockaddr_dl *sdl;
 
@@ -496,10 +497,10 @@ delete(struct rt_msghdr *rtm, char *host
 		mysin->sin6_scope_id = 0;
 		inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
 		(void)getnameinfo((struct sockaddr *)(void *),
-		(socklen_t)s6.sin6_len, host_buf,
-		sizeof(host_buf), NULL, 0,
+		(socklen_t)s6.sin6_len, delete_host_buf,
+		sizeof(delete_host_buf), NULL, 0,
 		(nflag ? NI_NUMERICHOST : 0));
-		(void)printf("%s (%s) deleted\n", host, host_buf);
+		(void)printf("%s (%s) deleted\n", host, delete_host_buf);
 	}
 
 	return 0;



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 08:16:14 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
ndp(8): host_buf should not be used in delete().

host_buf is passed to the argument host of delete() in do_foreach().


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 07:32:35 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Remove duplicate rtrlist() function prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.51 src/usr.sbin/ndp/ndp.c:1.52
--- src/usr.sbin/ndp/ndp.c:1.51	Sat Jun 16 13:09:41 2018
+++ src/usr.sbin/ndp/ndp.c	Thu Jul 12 07:32:35 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.51 2018/06/16 13:09:41 christos Exp $	*/
+/*	$NetBSD: ndp.c,v 1.52 2018/07/12 07:32:35 nonaka Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -134,7 +134,6 @@ static void ifinfo(char *, int, char **)
 static void rtrlist(void);
 static void plist(void);
 static void pfx_flush(void);
-static void rtrlist(void);
 static void rtr_flush(void);
 static void harmonize_rtr(void);
 #ifdef SIOCSDEFIFACE_IN6	/* XXX: check SIOCGDEFIFACE_IN6 as well? */



CVS commit: src/usr.sbin/ndp

2018-07-12 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Jul 12 07:32:35 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Remove duplicate rtrlist() function prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-06-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 16 13:09:41 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
PR/53371: Thomas Barabosch: Potential memory leak in usr.sbin/ndp/ndp.c


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.50 src/usr.sbin/ndp/ndp.c:1.51
--- src/usr.sbin/ndp/ndp.c:1.50	Wed Jun 28 04:17:50 2017
+++ src/usr.sbin/ndp/ndp.c	Sat Jun 16 09:09:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.50 2017/06/28 08:17:50 ozaki-r Exp $	*/
+/*	$NetBSD: ndp.c,v 1.51 2018/06/16 13:09:41 christos Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -376,6 +376,7 @@ set(int argc, char **argv)
 		return 1;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	ea = (u_char *)LLADDR(_m);
 	if (ndp_ether_aton(eaddr, ea) == 0)
 		sdl_m.sdl_alen = 6;
@@ -441,6 +442,7 @@ get(char *host)
 		return;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	do_foreach(>sin6_addr, host, 0);
 	if (found_entry == 0) {
 		(void)getnameinfo((struct sockaddr *)(void *)mysin,
@@ -467,6 +469,7 @@ delete_one(char *host)
 		return;
 	}
 	makeaddr(mysin, res->ai_addr);
+	freeaddrinfo(res);
 	do_foreach(>sin6_addr, host, NDP_F_DELETE);
 }
 



CVS commit: src/usr.sbin/ndp

2018-06-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun 16 13:09:41 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
PR/53371: Thomas Barabosch: Potential memory leak in usr.sbin/ndp/ndp.c


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-02-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb 14 10:13:26 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.8

Log Message:
Sort some lists. Use EXIT STATUS instead of RETURN VALUES.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/ndp/ndp.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2018-02-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb 14 10:13:26 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.8

Log Message:
Sort some lists. Use EXIT STATUS instead of RETURN VALUES.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/ndp/ndp.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.8
diff -u src/usr.sbin/ndp/ndp.8:1.28 src/usr.sbin/ndp/ndp.8:1.29
--- src/usr.sbin/ndp/ndp.8:1.28	Wed Feb 14 06:52:41 2018
+++ src/usr.sbin/ndp/ndp.8	Wed Feb 14 10:13:25 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ndp.8,v 1.28 2018/02/14 06:52:41 maxv Exp $
+.\"	$NetBSD: ndp.8,v 1.29 2018/02/14 10:13:25 wiz Exp $
 .\"	$KAME: ndp.8,v 1.33 2005/10/19 14:57:42 suz Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -78,6 +78,13 @@ The
 command manipulates the address mapping table
 used by the Neighbor Discovery Protocol (NDP).
 .Bl -tag -width Ds
+.It Fl A Ar wait
+Repeat
+.Fl a
+.Pq dump NDP entries
+every
+.Ar wait
+seconds.
 .It Fl a
 Dump the currently existing NDP entries.
 The following information will be printed:
@@ -100,20 +107,20 @@ in which case it will never expire.
 State of the neighbor cache entry, as a single letter:
 .Pp
 .Bl -tag -width indent -compact
-.It N
-Nostate
-.It W
-Waitdelete
+.It D
+Delay
 .It I
 Incomplete
+.It N
+Nostate
+.It P
+Probe
 .It R
 Reachable
 .It S
 Stale
-.It D
-Delay
-.It P
-Probe
+.It W
+Waitdelete
 .It ?
 Unknown state (should never happen).
 .El
@@ -124,13 +131,6 @@ They are: Router, proxy neighbor adverti
 The field could be followed by a decimal number,
 which means the number of NS probes the node has sent during the current state.
 .El
-.It Fl A Ar wait
-Repeat
-.Fl a
-.Pq dump NDP entries
-every
-.Ar wait
-seconds.
 .It Fl c
 Erase all the NDP entries.
 .It Fl d
@@ -236,14 +236,14 @@ Specify the Cur Hop Limit on the interfa
 .El
 .It Fl n
 Do not try to resolve numeric addresses to hostnames.
-.It Fl p
-Show prefix list.
 .It Fl P
 Flush all the entries in the prefix list.
-.It Fl r
-Show default router list.
+.It Fl p
+Show prefix list.
 .It Fl R
 Flush all the entries in the default router list.
+.It Fl r
+Show default router list.
 .It Fl s
 Register an NDP entry for a node.
 The entry will be permanent unless the word
@@ -263,7 +263,7 @@ Most useful when used with
 .Fl A .
 .El
 .\"
-.Sh RETURN VALUES
+.Sh EXIT STATUS
 The
 .Nm
 command will exit with 0 on success, and non-zero on errors.



CVS commit: src/usr.sbin/ndp

2018-02-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Feb 14 06:52:41 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.8

Log Message:
Use .Cm instead of .Li, same as arp.8.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/ndp/ndp.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.8
diff -u src/usr.sbin/ndp/ndp.8:1.27 src/usr.sbin/ndp/ndp.8:1.28
--- src/usr.sbin/ndp/ndp.8:1.27	Thu Jun  5 16:06:49 2014
+++ src/usr.sbin/ndp/ndp.8	Wed Feb 14 06:52:41 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ndp.8,v 1.27 2014/06/05 16:06:49 roy Exp $
+.\"	$NetBSD: ndp.8,v 1.28 2018/02/14 06:52:41 maxv Exp $
 .\"	$KAME: ndp.8,v 1.33 2005/10/19 14:57:42 suz Exp $
 .\"
 .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -28,7 +28,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 5, 2014
+.Dd February 14, 2018
 .Dt NDP 8
 .Os
 .\"
@@ -247,10 +247,10 @@ Flush all the entries in the default rou
 .It Fl s
 Register an NDP entry for a node.
 The entry will be permanent unless the word
-.Li temp
+.Cm temp
 is given in the command.
 If the word
-.Li proxy
+.Cm proxy
 is given, this system will act as a proxy NDP server,
 responding to requests for
 .Ar hostname



CVS commit: src/usr.sbin/ndp

2018-02-13 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Feb 14 06:52:41 UTC 2018

Modified Files:
src/usr.sbin/ndp: ndp.8

Log Message:
Use .Cm instead of .Li, same as arp.8.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/ndp/ndp.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2016-09-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 19 19:13:14 UTC 2016

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
remove unused ancient code and widen v6 address so that columns are aligned.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.47 src/usr.sbin/ndp/ndp.c:1.48
--- src/usr.sbin/ndp/ndp.c:1.47	Mon Apr  4 03:37:08 2016
+++ src/usr.sbin/ndp/ndp.c	Mon Sep 19 15:13:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.47 2016/04/04 07:37:08 ozaki-r Exp $	*/
+/*	$NetBSD: ndp.c,v 1.48 2016/09/19 19:13:14 christos Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -507,7 +507,7 @@ delete:
 	return 0;
 }
 
-#define W_ADDR	36
+#define W_ADDR	(8 * 4 + 7)
 #define W_LL	17
 #define W_IF	6
 
@@ -528,14 +528,14 @@ dump(struct in6_addr *addr, int cflag)
 	int addrwidth;
 	int llwidth;
 	int ifwidth;
-	char flgbuf[8];
+	char flgbuf[8], *fl;
 	const char *ifname;
 
 	/* Print header */
 	if (!tflag && !cflag)
-		(void)printf("%-*.*s %-*.*s %*.*s %-9.9s %1s %5s\n",
+		(void)printf("%-*.*s %-*.*s %*.*s %-9.9s %1s %2s\n",
 		W_ADDR, W_ADDR, "Neighbor", W_LL, W_LL, "Linklayer Address",
-		W_IF, W_IF, "Netif", "Expire", "S", "Flags");
+		W_IF, W_IF, "Netif", "Expire", "S", "Fl");
 
 again:;
 	mib[0] = CTL_NET;
@@ -676,25 +676,12 @@ again:;
 		/*
 		 * other flags. R: router, P: proxy, W: ??
 		 */
-		if ((rtm->rtm_addrs & RTA_NETMASK) == 0) {
-			(void)snprintf(flgbuf, sizeof(flgbuf), "%s%s",
-			isrouter ? "R" : "",
-			(rtm->rtm_flags & RTF_ANNOUNCE) ? "p" : "");
-		} else {
-			mysin = (struct sockaddr_in6 *)(void *)
-			(sdl->sdl_len + (char *)(void *)sdl);
-#if 0	/* W and P are mystery even for us */
-			(void)snprintf(flgbuf, sizeof(flgbuf), "%s%s%s%s",
-			isrouter ? "R" : "",
-			!IN6_IS_ADDR_UNSPECIFIED(>sin6_addr) ? "P" : "",
-			(sin->sin6_len != sizeof(struct sockaddr_in6)) ? "W" : "",
-			(rtm->rtm_flags & RTF_ANNOUNCE) ? "p" : "");
-#else
-			(void)snprintf(flgbuf, sizeof(flgbuf), "%s%s",
-			isrouter ? "R" : "",
-			(rtm->rtm_flags & RTF_ANNOUNCE) ? "p" : "");
-#endif
-		}
+		fl = flgbuf;
+		if (isrouter)
+			*fl++ = 'R';
+		if (rtm->rtm_flags & RTF_ANNOUNCE)
+			*fl++ = 'p';
+		*fl++ = '\0';
 		(void)printf(" %s", flgbuf);
 
 		if (prbs)



CVS commit: src/usr.sbin/ndp

2016-09-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep 19 19:13:14 UTC 2016

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
remove unused ancient code and widen v6 address so that columns are aligned.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2015-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 14 18:24:06 UTC 2015

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Don't forget to set sin_scope. From Ryota Ozaki


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2015-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 14 18:24:06 UTC 2015

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Don't forget to set sin_scope. From Ryota Ozaki


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.45 src/usr.sbin/ndp/ndp.c:1.46
--- src/usr.sbin/ndp/ndp.c:1.45	Mon Aug  3 05:51:40 2015
+++ src/usr.sbin/ndp/ndp.c	Mon Dec 14 13:24:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.45 2015/08/03 09:51:40 ozaki-r Exp $	*/
+/*	$NetBSD: ndp.c,v 1.46 2015/12/14 18:24:06 christos Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -304,6 +304,15 @@ main(int argc, char **argv)
 }
 
 static void
+makeaddr(struct sockaddr_in6 *mysin, const void *resp)
+{
+	const struct sockaddr_in6 *res = resp;
+	mysin->sin6_addr = res->sin6_addr;
+	mysin->sin6_scope_id = res->sin6_scope_id;
+	inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+}
+
+static void
 getsocket(void)
 {
 	if (my_s < 0) {
@@ -362,8 +371,7 @@ set(int argc, char **argv)
 		warnx("%s: %s", host, gai_strerror(gai_error));
 		return 1;
 	}
-	mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-	inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+	makeaddr(mysin, res->ai_addr);
 	ea = (u_char *)LLADDR(_m);
 	if (ndp_ether_aton(eaddr, ea) == 0)
 		sdl_m.sdl_alen = 6;
@@ -429,8 +437,7 @@ get(char *host)
 		warnx("%s: %s", host, gai_strerror(gai_error));
 		return;
 	}
-	mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-	inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+	makeaddr(mysin, res->ai_addr);
 	dump(>sin6_addr, 0);
 	if (found_entry == 0) {
 		(void)getnameinfo((struct sockaddr *)(void *)mysin,
@@ -463,8 +470,7 @@ delete(char *host)
 		warnx("%s: %s", host, gai_strerror(gai_error));
 		return 1;
 	}
-	mysin->sin6_addr = ((struct sockaddr_in6 *)(void *)res->ai_addr)->sin6_addr;
-	inet6_putscopeid(mysin, INET6_IS_ADDR_LINKLOCAL);
+	makeaddr(mysin, res->ai_addr);
 	if (rtmsg(RTM_GET) < 0)
 		errx(1, "RTM_GET(%s) failed", host);
 	mysin = (struct sockaddr_in6 *)(void *)(rtm + 1);



CVS commit: src/usr.sbin/ndp

2015-12-13 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Dec 14 06:17:05 UTC 2015

Modified Files:
src/usr.sbin/ndp: Makefile

Log Message:
Add getaddrinfo.c to RUMPSRCS for link-local addresses


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/ndp/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2015-12-13 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Dec 14 06:17:05 UTC 2015

Modified Files:
src/usr.sbin/ndp: Makefile

Log Message:
Add getaddrinfo.c to RUMPSRCS for link-local addresses


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/ndp/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/Makefile
diff -u src/usr.sbin/ndp/Makefile:1.11 src/usr.sbin/ndp/Makefile:1.12
--- src/usr.sbin/ndp/Makefile:1.11	Tue Sep  1 09:54:34 2015
+++ src/usr.sbin/ndp/Makefile	Mon Dec 14 06:17:05 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.11 2015/09/01 09:54:34 ozaki-r Exp $
+# $NetBSD: Makefile,v 1.12 2015/12/14 06:17:05 ozaki-r Exp $
 
 .include 
 
@@ -15,7 +15,8 @@ CPPFLAGS+=	-DINET6
 CPPFLAGS+=	-I. -I${TCPDUMP}
 
 .PATH:		${.CURDIR}/../../lib/libc/net
-RUMPSRCS=	getifaddrs.c getnameinfo.c if_indextoname.c if_nametoindex.c
+RUMPSRCS=	getaddrinfo.c getifaddrs.c getnameinfo.c
+RUMPSRCS+=	if_indextoname.c if_nametoindex.c
 .if (${MKRUMP} != "no")
 CPPFLAGS+= 	-DRUMP_ACTION
 .endif



CVS commit: src/usr.sbin/ndp

2013-12-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 17 20:26:46 UTC 2013

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Simplify code to print the router/prefix list: use memcpy and local structs
properly aligned on the stack to decode the binary format passed by the
kernel - instead of (bogusly) assuming the format will obey all local
alignement requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.41 src/usr.sbin/ndp/ndp.c:1.42
--- src/usr.sbin/ndp/ndp.c:1.41	Sat Oct 19 17:16:25 2013
+++ src/usr.sbin/ndp/ndp.c	Tue Dec 17 20:26:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.41 2013/10/19 17:16:25 christos Exp $	*/
+/*	$NetBSD: ndp.c,v 1.42 2013/12/17 20:26:46 martin Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -,9 +,8 @@ plist(void)
 {
 #ifdef ICMPV6CTL_ND6_PRLIST
 	int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
-	char *buf;
-	struct in6_prefix *p, *ep, *n;
-	struct sockaddr_in6 *advrtr;
+	char *buf, *p, *ep;
+	struct in6_prefix pfx;
 	size_t l;
 	struct timeval tim;
 	const int niflags = NI_NUMERICHOST;
@@ -1134,17 +1133,17 @@ plist(void)
 		/*NOTREACHED*/
 	}
 
-	ep = (struct in6_prefix *)(void *)(buf + l);
-	for (p = (struct in6_prefix *)(void *)buf; p  ep; p = n) {
-		advrtr = (struct sockaddr_in6 *)(void *)(p + 1);
-		n = (struct in6_prefix *)(void *)advrtr[p-advrtrs];
+	ep = buf + l;
+	for (p = buf; p  ep; ) {
+		memcpy(pfx, p, sizeof(pfx));
+		p += sizeof(pfx);
 
-		if (getnameinfo((struct sockaddr *)(void *)p-prefix,
-		(socklen_t)p-prefix.sin6_len, namebuf, sizeof(namebuf),
+		if (getnameinfo((struct sockaddr*)pfx.prefix,
+		(socklen_t)pfx.prefix.sin6_len, namebuf, sizeof(namebuf),
 		NULL, 0, niflags) != 0)
 			(void)strlcpy(namebuf, ?, sizeof(namebuf));
-		(void)printf(%s/%d if=%s\n, namebuf, p-prefixlen,
-		if_indextoname((unsigned int)p-if_index, ifix_buf));
+		(void)printf(%s/%d if=%s\n, namebuf, pfx.prefixlen,
+		if_indextoname((unsigned int)pfx.if_index, ifix_buf));
 
 		(void)gettimeofday(tim, 0);
 		/*
@@ -1152,54 +1151,56 @@ plist(void)
 		 * by origin.  notify the difference to the users.
 		 */
 		(void)printf(flags=%s%s%s%s%s,
-		p-raflags.onlink ? L : ,
-		p-raflags.autonomous ? A : ,
-		(p-flags  NDPRF_ONLINK) != 0 ? O : ,
-		(p-flags  NDPRF_DETACHED) != 0 ? D : ,
+		pfx.raflags.onlink ? L : ,
+		pfx.raflags.autonomous ? A : ,
+		(pfx.flags  NDPRF_ONLINK) != 0 ? O : ,
+		(pfx.flags  NDPRF_DETACHED) != 0 ? D : ,
 #ifdef NDPRF_HOME
-		(p-flags  NDPRF_HOME) != 0 ? H : 
+		(pfx.flags  NDPRF_HOME) != 0 ? H : 
 #else
 		
 #endif
 		);
-		if (p-vltime == ND6_INFINITE_LIFETIME)
+		if (pfx.vltime == ND6_INFINITE_LIFETIME)
 			(void)printf( vltime=infinity);
 		else
-			(void)printf( vltime=%lu, (unsigned long)p-vltime);
-		if (p-pltime == ND6_INFINITE_LIFETIME)
+			(void)printf( vltime=%lu, (unsigned long)pfx.vltime);
+		if (pfx.pltime == ND6_INFINITE_LIFETIME)
 			(void)printf(, pltime=infinity);
 		else
-			(void)printf(, pltime=%lu, (unsigned long)p-pltime);
-		if (p-expire == 0)
+			(void)printf(, pltime=%lu, (unsigned long)pfx.pltime);
+		if (pfx.expire == 0)
 			(void)printf(, expire=Never);
-		else if (p-expire = tim.tv_sec)
+		else if (pfx.expire = tim.tv_sec)
 			(void)printf(, expire=%s,
-			sec2str(p-expire - tim.tv_sec));
+			sec2str(pfx.expire - tim.tv_sec));
 		else
 			(void)printf(, expired);
-		(void)printf(, ref=%d, p-refcnt);
+		(void)printf(, ref=%d, pfx.refcnt);
 		(void)printf(\n);
 		/*
 		 * advertising router list is meaningful only if the prefix
 		 * information is from RA.
 		 */
-		if (p-advrtrs) {
+		if (pfx.advrtrs) {
 			int j;
-			struct sockaddr_in6 *sin6;
+			struct sockaddr_in6 sin6;
 
-			sin6 = advrtr;
 			(void)printf(  advertised by\n);
-			for (j = 0; j  p-advrtrs; j++) {
+			for (j = 0; j  pfx.advrtrs  p = ep; j++) {
 struct in6_nbrinfo *nbi;
 
-if (getnameinfo((struct sockaddr *)(void *)sin6,
-(socklen_t)sin6-sin6_len, namebuf,
+memcpy(sin6, p, sizeof(sin6));
+p += sizeof(sin6);
+
+if (getnameinfo((struct sockaddr *)sin6,
+(socklen_t)sin6.sin6_len, namebuf,
 sizeof(namebuf), NULL, 0, ninflags) != 0)
 	(void)strlcpy(namebuf, ?, sizeof(namebuf));
 (void)printf(%s, namebuf);
 
-nbi = getnbrinfo(sin6-sin6_addr,
-(unsigned int)p-if_index, 0);
+nbi = getnbrinfo(sin6.sin6_addr,
+(unsigned int)pfx.if_index, 0);
 if (nbi) {
 	switch (nbi-state) {
 	case ND6_LLINFO_REACHABLE:
@@ -1213,7 +1214,6 @@ plist(void)
 	}
 } else
 	(void)printf( (no neighbor state)\n);
-sin6++;
 			}
 		} else
 			(void)printf(  No advertising router\n);



CVS commit: src/usr.sbin/ndp

2013-12-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 17 20:26:46 UTC 2013

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
Simplify code to print the router/prefix list: use memcpy and local structs
properly aligned on the stack to decode the binary format passed by the
kernel - instead of (bogusly) assuming the format will obey all local
alignement requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2013-06-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jun 21 12:42:56 UTC 2013

Removed Files:
src/usr.sbin/ndp: gnuc.h

Log Message:
Remove this stub that hasn't been necessary in a decade or so.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/usr.sbin/ndp/gnuc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2013-06-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jun 21 12:50:50 UTC 2013

Modified Files:
src/usr.sbin/ndp: Makefile

Log Message:
Don't check MKINET6 - parent makefile doesn't descend to ndp if it's no.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/ndp/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/Makefile
diff -u src/usr.sbin/ndp/Makefile:1.8 src/usr.sbin/ndp/Makefile:1.9
--- src/usr.sbin/ndp/Makefile:1.8	Sun Dec 12 18:50:31 2010
+++ src/usr.sbin/ndp/Makefile	Fri Jun 21 12:50:50 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2010/12/12 18:50:31 christos Exp $
+# $NetBSD: Makefile,v 1.9 2013/06/21 12:50:50 uwe Exp $
 
 .include bsd.own.mk
 
@@ -11,9 +11,7 @@ PROG=	ndp
 SRCS=	ndp.c gmt2local.c
 MAN=	ndp.8
 
-.if ${MKINET6} != no
 CPPFLAGS+=-DINET6
-.endif
 CPPFLAGS+=-I. -I${TCPDUMP}
 
 .include bsd.prog.mk



CVS commit: src/usr.sbin/ndp

2013-06-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jun 21 12:42:56 UTC 2013

Removed Files:
src/usr.sbin/ndp: gnuc.h

Log Message:
Remove this stub that hasn't been necessary in a decade or so.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r0 src/usr.sbin/ndp/gnuc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2013-06-21 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Fri Jun 21 12:50:50 UTC 2013

Modified Files:
src/usr.sbin/ndp: Makefile

Log Message:
Don't check MKINET6 - parent makefile doesn't descend to ndp if it's no.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/ndp/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2011-06-06 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon Jun  6 16:50:46 UTC 2011

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
make this work again after routing socket alignment changes


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/ndp.c
diff -u src/usr.sbin/ndp/ndp.c:1.38 src/usr.sbin/ndp/ndp.c:1.39
--- src/usr.sbin/ndp/ndp.c:1.38	Fri Nov  6 20:51:19 2009
+++ src/usr.sbin/ndp/ndp.c	Mon Jun  6 16:50:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ndp.c,v 1.38 2009/11/06 20:51:19 dyoung Exp $	*/
+/*	$NetBSD: ndp.c,v 1.39 2011/06/06 16:50:46 drochner Exp $	*/
 /*	$KAME: ndp.c,v 1.121 2005/07/13 11:30:13 keiichi Exp $	*/
 
 /*
@@ -106,11 +106,6 @@
 #include unistd.h
 #include gmt2local.h
 
-/* packing rule for routing socket */
-#define ROUNDUP(a) \
-	((a)  0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
-#define ADVANCE(x, n) (x += ROUNDUP((n)-sa_len))
-
 static pid_t pid;
 static int nflag;
 static int tflag;
@@ -387,7 +382,7 @@
 		/* NOTREACHED */
 	}
 	mysin = (struct sockaddr_in6 *)(void *)(rtm + 1);
-	sdl = (struct sockaddr_dl *)(void *)(ROUNDUP(mysin-sin6_len) + (char *)(void *)mysin);
+	sdl = (struct sockaddr_dl *)(void *)(RT_ROUNDUP(mysin-sin6_len) + (char *)(void *)mysin);
 	if (IN6_ARE_ADDR_EQUAL(mysin-sin6_addr, sin_m.sin6_addr)) {
 		if (sdl-sdl_family == AF_LINK 
 		(rtm-rtm_flags  RTF_LLINFO) 
@@ -482,7 +477,7 @@
 	if (rtmsg(RTM_GET)  0)
 		errx(1, RTM_GET(%s) failed, host);
 	mysin = (struct sockaddr_in6 *)(void *)(rtm + 1);
-	sdl = (struct sockaddr_dl *)(void *)(ROUNDUP(mysin-sin6_len) +
+	sdl = (struct sockaddr_dl *)(void *)(RT_ROUNDUP(mysin-sin6_len) +
 	(char *)(void *)mysin);
 	if (IN6_ARE_ADDR_EQUAL(mysin-sin6_addr, sin_m.sin6_addr)) {
 		if (sdl-sdl_family == AF_LINK 
@@ -574,7 +569,7 @@
 
 		rtm = (struct rt_msghdr *)(void *)next;
 		mysin = (struct sockaddr_in6 *)(void *)(rtm + 1);
-		sdl = (struct sockaddr_dl *)(void *)((char *)(void *)mysin + ROUNDUP(mysin-sin6_len));
+		sdl = (struct sockaddr_dl *)(void *)((char *)(void *)mysin + RT_ROUNDUP(mysin-sin6_len));
 
 		/*
 		 * Some OSes can produce a route that has the LINK flag but
@@ -850,7 +845,7 @@
 #define NEXTADDR(w, s) \
 	if (rtm-rtm_addrs  (w)) { \
 		(void)memcpy(cp, s, sizeof(s)); \
-		ADVANCE(cp, (struct sockaddr *)(void *)s); \
+		RT_ADVANCE(cp, (struct sockaddr *)(void *)s); \
 	}
 
 	NEXTADDR(RTA_DST, sin_m);



CVS commit: src/usr.sbin/ndp

2011-06-06 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Mon Jun  6 16:50:46 UTC 2011

Modified Files:
src/usr.sbin/ndp: ndp.c

Log Message:
make this work again after routing socket alignment changes


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/ndp/ndp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.sbin/ndp

2010-12-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 12 18:50:31 UTC 2010

Modified Files:
src/usr.sbin/ndp: Makefile

Log Message:
use new tcpdump.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/ndp/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/ndp/Makefile
diff -u src/usr.sbin/ndp/Makefile:1.7 src/usr.sbin/ndp/Makefile:1.8
--- src/usr.sbin/ndp/Makefile:1.7	Wed Apr 22 11:23:06 2009
+++ src/usr.sbin/ndp/Makefile	Sun Dec 12 13:50:31 2010
@@ -1,16 +1,19 @@
-# $NetBSD: Makefile,v 1.7 2009/04/22 15:23:06 lukem Exp $
+# $NetBSD: Makefile,v 1.8 2010/12/12 18:50:31 christos Exp $
 
 .include bsd.own.mk
 
 USE_FORT?= yes	# network client
 
-.PATH:	${NETBSDSRCDIR}/dist/tcpdump
+TCPDUMP= ${NETBSDSRCDIR}/external/bsd/tcpdump/dist
+.PATH:	${TCPDUMP}
 
 PROG=	ndp
 SRCS=	ndp.c gmt2local.c
 MAN=	ndp.8
 
+.if ${MKINET6} != no
 CPPFLAGS+=-DINET6
-CPPFLAGS+=-I. -I${NETBSDSRCDIR}/dist/tcpdump
+.endif
+CPPFLAGS+=-I. -I${TCPDUMP}
 
 .include bsd.prog.mk