git: 1cdec2832d05 - main - ndp: Prepare for pending tcpdump update
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 08 Jun 2023 01:59:22 UTC
The branch main has been updated by jrm:
URL: https://cgit.FreeBSD.org/src/commit/?id=1cdec2832d051ddcb1417f3f2601e6212aff2613
commit 1cdec2832d051ddcb1417f3f2601e6212aff2613
Author: Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2023-06-07 02:21:27 +0000
Commit: Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2023-06-08 01:57:20 +0000
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
---
usr.sbin/ndp/Makefile | 6 ++----
usr.sbin/ndp/ndp.c | 20 ++++++++++++++++++--
usr.sbin/ndp/ndp_netlink.c | 1 -
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>