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
This commit is contained in:
Joseph Mingrone 2023-06-06 23:21:27 -03:00
parent 1232c7884d
commit 1cdec2832d
No known key found for this signature in database
GPG key ID: 36A40C83B0D6EF9E
3 changed files with 20 additions and 7 deletions

View file

@ -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"

View file

@ -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)

View file

@ -33,7 +33,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <libxo/xo.h>
#include "gmt2local.h"
#include <netlink/netlink.h>