tests for obsdrdr.c and pfpinhole.c

This commit is contained in:
Thomas Bernard 2024-05-26 04:18:45 +02:00
parent 036ae353b0
commit 8f8b89aa1e
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
3 changed files with 21 additions and 6 deletions

View File

@ -1,9 +1,15 @@
# $Id: Makefile,v 1.7 2020/05/21 00:10:56 nanard Exp $
# made for GNU Make (and BSD make)
# only for testing purposes.
# Please follow instructions in INSTALL file for building miniUPnPd
CFLAGS = -Wall -g -DTEST
CFLAGS += -Wextra
CFLAGS += -I..
CFLAGS += -I.. -I../build
EXECUTABLES = testobsdrdr testpfpinhole
# to test libpfctl
CFLAGS += -I/usr/local/include/
LDFLAGS += -L/usr/local/lib
LIBS += -lpfctl
all: $(EXECUTABLES)
@ -11,10 +17,11 @@ clean:
rm -f *.o $(EXECUTABLES)
testobsdrdr: testobsdrdr.o obsdrdr.o getifaddr.o
$(CC) $(CFLAGS) -o $@ $>
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $>
testpfpinhole: testpfpinhole.o obsdrdr.o pfpinhole.o getifaddr.o
$(CC) $(CFLAGS) -o $@ $>
testpfpinhole: testpfpinhole.o obsdrdr.o pfpinhole.o \
getifaddr.o upnputils.o getroute.o
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $>
obsdrdr.o: obsdrdr.c obsdrdr.h
@ -25,3 +32,7 @@ testobsdrdr.o: testobsdrdr.c obsdrdr.h
testpfpinhole.o: testpfpinhole.c pfpinhole.h
getifaddr.o: ../getifaddr.c
upnputils.o: ../upnputils.c
getroute.o: ../bsd/getroute.c

View File

@ -129,7 +129,7 @@ main(int argc, char * * argv)
printf("delete_redirect_rule() failed\n");
*/
if(delete_redirect_and_filter_rules("ep0", 12123, IPPROTO_UDP) < 0)
printf("delete_redirect_rule() failed\n");
printf("delete_redirect_and_filter_rules() failed\n");
if(delete_redirect_rule("ep0", 12123, IPPROTO_UDP) < 0)
printf("delete_redirect_rule() failed\n");

View File

@ -12,11 +12,13 @@
#include <netinet/in.h>
#include <syslog.h>
#include "../config.h"
#include "config.h"
#include "obsdrdr.h"
#include "pfpinhole.h"
#include "../miniupnpdtypes.h"
int runtime_flags = 0;
time_t startup_time = 0;
const char * tag = NULL;
const char * anchor_name = "miniupnpd";
@ -24,6 +26,8 @@ const char * queue = NULL;
const char * use_ext_ip_addr = "42.42.42.42";
struct lan_addr_list lan_addrs;
#ifdef ENABLE_IPV6
static int print_pinhole(int uid)
{