Skip to content

Commit

Permalink
disable nl_debug.c
Browse files Browse the repository at this point in the history
* disable build nl_debug.c
* add NL_DEBUG defines
  • Loading branch information
Andy2244 committed Jun 28, 2021
1 parent a9dd9a1 commit 062a954
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

CFLAGS = -Wall -Wextra -g -O0
LDFLAGS = -g
OBJFILES = wsdd2.o wsd.o llmnr.o nl_debug.o
OBJFILES = wsdd2.o wsd.o llmnr.o
HEADERS = wsdd.h wsd.h

INSTALLPREFIX ?= $(PREFIX)/usr
Expand All @@ -19,7 +19,7 @@ SBININSTALLDIR = $(INSTALLPREFIX)/$(SBINDIR)
MANINSTALLDIR = $(INSTALLPREFIX)/$(MANDIR)
LIBINSTALLDIR = $(LIBDIR)

all: wsdd2 nl_debug
all: wsdd2

nl_debug: CPPFLAGS+=-DMAIN
nl_debug: nl_debug.c; $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
Expand Down
8 changes: 6 additions & 2 deletions llmnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
#define DNS_TYPE_AAAA 0x001C /* rfc 3596 */
#define DNS_CLASS_IN 0x0001 /* rfc 1035 */

#ifdef NL_DEBUG
static void dumphex(const char *label, const void *p, size_t len)
{
if (debug_L >= 5)
dump(p, len, 0, label);
}
#endif

static int llmnr_send_response(struct endpoint *ep, _saddr_t *sa,
const uint8_t *in, size_t inlen)
Expand All @@ -80,9 +82,9 @@ static int llmnr_send_response(struct endpoint *ep, _saddr_t *sa,
int ret;
_saddr_t ci;
socklen_t slen = (sa->ss.ss_family == AF_INET) ? sizeof sa->in : sizeof sa->in6;

#ifdef NL_DEBUG
dumphex("LLMNR INPUT: ", in, inlen);

#endif
if (connected_if(sa, &ci)) {
char buf[_ADDRSTRLEN];
DEBUG(1, L, "llmnr: connected_if: %s: %s",
Expand Down Expand Up @@ -370,7 +372,9 @@ static int llmnr_send_response(struct endpoint *ep, _saddr_t *sa,
memcpy(out + out_name_len, &ci.in6.sin6_addr, len);
}
send:
#ifdef NL_DEBUG
dumphex("LLMNR OUTPUT: ", out, inlen + answer_len);
#endif
ret = sendto(ep->sock, out, inlen + answer_len, 0, (struct sockaddr *)sa, slen);

free(out);
Expand Down
1 change: 1 addition & 0 deletions wsdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <netinet/in.h> // struct sockaddr_in, struct ip_mreq
#include <linux/in.h> // struct ip_mreqn
#include <linux/netlink.h> // struct sockaddr_nl
#include <time.h> // time_t, time()

/* wsdd2.c */
extern char *hostname, *hostaliases, *netbiosname, *netbiosaliases, *workgroup;
Expand Down
4 changes: 2 additions & 2 deletions wsdd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ static int netlink_recv(struct endpoint *ep)
ep->errstr = __FUNCTION__ ": netlink_recv: recv";
return -1;
}

#ifdef NL_DEBUG
nl_debug(buf, msglen);

#endif
for (struct nlmsghdr *nh = (struct nlmsghdr *) buf;
NLMSG_OK(nh, msglen) && nh->nlmsg_type != NLMSG_DONE;
nh = NLMSG_NEXT(nh, msglen)) {
Expand Down

0 comments on commit 062a954

Please sign in to comment.