aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ndp
diff options
context:
space:
mode:
authorJoseph Mingrone <jrm@FreeBSD.org>2023-06-07 02:21:27 +0000
committerJoseph Mingrone <jrm@FreeBSD.org>2023-06-08 01:57:20 +0000
commit1cdec2832d051ddcb1417f3f2601e6212aff2613 (patch)
treec523b66eac38ed130b3f11f9a0b9df0f98935244 /usr.sbin/ndp
parent1232c7884d4a9bc69d4dd71cd293f92bb1ae6197 (diff)
downloadsrc-1cdec2832d051ddcb1417f3f2601e6212aff2613.tar.gz
src-1cdec2832d051ddcb1417f3f2601e6212aff2613.zip
ndp: Prepare for pending tcpdump update
ndp makes use of gmt2local, however that library has been removed from tcpdump. Add utc_offset() as a substitute. Reviewed by: emaste, jhb, melifaro Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40445
Diffstat (limited to 'usr.sbin/ndp')
-rw-r--r--usr.sbin/ndp/Makefile6
-rw-r--r--usr.sbin/ndp/ndp.c20
-rw-r--r--usr.sbin/ndp/ndp_netlink.c1
3 files changed, 20 insertions, 7 deletions
diff --git a/usr.sbin/ndp/Makefile b/usr.sbin/ndp/Makefile
index 1722f4a5a2ef..f66c4ec846a8 100644
--- a/usr.sbin/ndp/Makefile
+++ b/usr.sbin/ndp/Makefile
@@ -15,15 +15,13 @@
.include <src.opts.mk>
-.PATH: ${SRCTOP}/contrib/tcpdump
-
PROG= ndp
MAN= ndp.8
-SRCS= ndp.c gmt2local.c
+SRCS= ndp.c
LIBADD= xo
-CFLAGS+= -I. -I${.CURDIR} -I${SRCTOP}/contrib/tcpdump
+CFLAGS+= -I. -I${.CURDIR}
CFLAGS+= -D_U_=""
.if ${MK_EXPERIMENTAL} != "no"
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index 23e186466c22..112fd099e3e0 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -98,6 +98,7 @@
#include <arpa/inet.h>
+#include <assert.h>
#include <ctype.h>
#include <netdb.h>
#include <errno.h>
@@ -107,11 +108,12 @@
#include <string.h>
#include <paths.h>
#include <err.h>
+#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <libxo/xo.h>
-#include "gmt2local.h"
+#include <time.h>
#include "ndp.h"
@@ -181,6 +183,20 @@ valid_type(int if_type)
return (false);
}
+static int32_t
+utc_offset(void)
+{
+ time_t t;
+ struct tm *tm;
+
+ t = time(NULL);
+ tm = localtime(&t);
+
+ assert(tm->tm_gmtoff > INT32_MIN && tm->tm_gmtoff < INT32_MAX);
+
+ return (tm->tm_gmtoff);
+}
+
int
main(int argc, char **argv)
{
@@ -188,7 +204,7 @@ main(int argc, char **argv)
char *arg = NULL;
pid = getpid();
- thiszone = gmt2local(0);
+ thiszone = utc_offset();
argc = xo_parse_args(argc, argv);
if (argc < 0)
diff --git a/usr.sbin/ndp/ndp_netlink.c b/usr.sbin/ndp/ndp_netlink.c
index a34359a4343f..ace3e5e5fa11 100644
--- a/usr.sbin/ndp/ndp_netlink.c
+++ b/usr.sbin/ndp/ndp_netlink.c
@@ -33,7 +33,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <libxo/xo.h>
-#include "gmt2local.h"
#include <netlink/netlink.h>