mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-02-12 15:23:41 -05:00
fake event replaces link signture of event handling.
git-svn-id: file:///svn/unbound/trunk@83 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
05d471c46e
commit
9c8164c633
7 changed files with 201 additions and 22 deletions
12
Makefile.in
12
Makefile.in
|
|
@ -48,11 +48,11 @@ INSTALL=$(srcdir)/install-sh
|
|||
|
||||
COMMON_SRC=$(wildcard services/*.c util/*.c)
|
||||
COMMON_OBJ=$(addprefix $(BUILD),$(COMMON_SRC:.c=.o) $(LIBOBJS))
|
||||
UNITTEST_SRC=testcode/unitmain.c
|
||||
UNITTEST_SRC=testcode/unitmain.c $(COMMON_SRC)
|
||||
UNITTEST_OBJ=$(addprefix $(BUILD),$(UNITTEST_SRC:.c=.o))
|
||||
DAEMON_SRC=$(wildcard daemon/*.c)
|
||||
DAEMON_SRC=$(wildcard daemon/*.c) $(COMMON_SRC)
|
||||
DAEMON_OBJ=$(addprefix $(BUILD),$(DAEMON_SRC:.c=.o))
|
||||
TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c testcode/replay.c testcode/fake_event.c
|
||||
TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c daemon/worker.c testcode/replay.c testcode/fake_event.c $(filter-out util/netevent.c services/listen_dnsport.c services/outside_network.c, $(COMMON_SRC))
|
||||
TESTBOUND_OBJ=$(addprefix $(BUILD),$(TESTBOUND_SRC:.c=.o))
|
||||
ALL_SRC=$(COMMON_SRC) $(UNITTEST_SRC) $(DAEMON_SRC) $(TESTBOUND_SRC)
|
||||
ALL_OBJ=$(addprefix $(BUILD),$(ALL_SRC:.c=.o) $(LIBOBJS))
|
||||
|
|
@ -70,15 +70,15 @@ $(BUILD)%.o: $(srcdir)/%.c
|
|||
|
||||
all: $(COMMON_OBJ) unbound unittest testbound
|
||||
|
||||
unbound: $(COMMON_OBJ) $(DAEMON_OBJ)
|
||||
unbound: $(DAEMON_OBJ)
|
||||
$(INFO) Link $@
|
||||
$Q$(LINK) -o $@ $^ $(LIBS)
|
||||
|
||||
unittest: $(COMMON_OBJ) $(UNITTEST_OBJ)
|
||||
unittest: $(UNITTEST_OBJ)
|
||||
$(INFO) Link $@
|
||||
$Q$(LINK) -o $@ $^ $(LIBS)
|
||||
|
||||
testbound: $(COMMON_OBJ) $(TESTBOUND_OBJ)
|
||||
testbound: $(TESTBOUND_OBJ)
|
||||
$(INFO) Link $@
|
||||
$Q$(LINK) -o $@ $^ $(LIBS)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include "services/outside_network.h"
|
||||
#include "util/netevent.h"
|
||||
#include "util/log.h"
|
||||
#include "util/net_help.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "services/listen_dnsport.h"
|
||||
#include "util/netevent.h"
|
||||
#include "util/log.h"
|
||||
#include "util/net_help.h"
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
|
|
@ -225,15 +226,6 @@ make_udp_range(struct comm_point** coms, const char* ifname,
|
|||
return done;
|
||||
}
|
||||
|
||||
/** returns true is string addr is an ip6 specced address. */
|
||||
int
|
||||
str_is_ip6(const char* str)
|
||||
{
|
||||
if(strchr(str, ':'))
|
||||
return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/** calculate number of ip4 and ip6 interfaces, times multiplier. */
|
||||
static void
|
||||
calc_num46(const char** ifs, int num_ifs, int do_ip4, int do_ip6,
|
||||
|
|
|
|||
|
|
@ -151,11 +151,4 @@ void pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
|
|||
*/
|
||||
void pending_delete(struct outside_network* outnet, struct pending* p);
|
||||
|
||||
/**
|
||||
* See if string is ip4 or ip6.
|
||||
* @param str: IP specification.
|
||||
* @return: true if string addr is an ip6 specced address.
|
||||
*/
|
||||
int str_is_ip6(const char* str);
|
||||
|
||||
#endif /* OUTSIDE_NETWORK_H */
|
||||
|
|
|
|||
|
|
@ -69,4 +69,94 @@ fake_event_cleanup()
|
|||
|
||||
/*********** Dummy routines ***********/
|
||||
|
||||
struct listen_dnsport*
|
||||
listen_create(struct comm_base* ATTR_UNUSED(base),
|
||||
int ATTR_UNUSED(num_ifs), const char* ATTR_UNUSED(ifs[]),
|
||||
const char* ATTR_UNUSED(port),
|
||||
int ATTR_UNUSED(do_ip4), int ATTR_UNUSED(do_ip6),
|
||||
int ATTR_UNUSED(do_udp), int ATTR_UNUSED(do_tcp),
|
||||
size_t ATTR_UNUSED(bufsize), comm_point_callback_t* ATTR_UNUSED(cb),
|
||||
void* ATTR_UNUSED(cb_arg))
|
||||
{
|
||||
return malloc(1);
|
||||
}
|
||||
|
||||
void
|
||||
listen_delete(struct listen_dnsport* listen)
|
||||
{
|
||||
free(listen);
|
||||
}
|
||||
|
||||
struct comm_base* comm_base_create()
|
||||
{
|
||||
return malloc(1);
|
||||
}
|
||||
|
||||
void comm_base_delete(struct comm_base* b)
|
||||
{
|
||||
free(b);
|
||||
}
|
||||
|
||||
void comm_base_dispatch(struct comm_base* b)
|
||||
{
|
||||
/* TODO run the scenario ! */
|
||||
}
|
||||
|
||||
void comm_base_exit(struct comm_base* ATTR_UNUSED(b))
|
||||
{
|
||||
/* some sort of failure */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct comm_signal* comm_signal_create(struct comm_base* ATTR_UNUSED(base),
|
||||
void ATTR_UNUSED((*callback)(int, void*)), void* ATTR_UNUSED(cb_arg))
|
||||
{
|
||||
return malloc(1);
|
||||
}
|
||||
|
||||
int comm_signal_bind(struct comm_signal* ATTR_UNUSED(comsig), int
|
||||
ATTR_UNUSED(sig))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void comm_signal_delete(struct comm_signal* comsig)
|
||||
{
|
||||
free(comsig);
|
||||
}
|
||||
|
||||
void
|
||||
comm_point_send_reply(struct comm_reply* repinfo)
|
||||
{
|
||||
/* TODO see if this is checked */
|
||||
}
|
||||
|
||||
void
|
||||
comm_point_drop_reply(struct comm_reply* repinfo)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
struct outside_network*
|
||||
outside_network_create(struct comm_base* ATTR_UNUSED(base),
|
||||
size_t ATTR_UNUSED(bufsize), size_t ATTR_UNUSED(num_ports),
|
||||
const char** ATTR_UNUSED(ifs), int ATTR_UNUSED(num_ifs),
|
||||
int ATTR_UNUSED(do_ip4), int ATTR_UNUSED(do_ip6),
|
||||
int ATTR_UNUSED(port_base))
|
||||
{
|
||||
return malloc(1);
|
||||
}
|
||||
|
||||
void
|
||||
outside_network_delete(struct outside_network* outnet)
|
||||
{
|
||||
free(outnet);
|
||||
}
|
||||
|
||||
void pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
|
||||
struct sockaddr_storage* addr, socklen_t addrlen, int timeout,
|
||||
comm_point_callback_t* callback, void* callback_arg)
|
||||
{
|
||||
}
|
||||
|
||||
/*********** End of Dummy routines ***********/
|
||||
|
|
|
|||
51
util/net_help.c
Normal file
51
util/net_help.c
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* util/net_help.c - implementation of the network helper code
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* This software is open source.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the NLNET LABS nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
* Implementation of log.h.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "util/net_help.h"
|
||||
|
||||
/** returns true is string addr is an ip6 specced address. */
|
||||
int
|
||||
str_is_ip6(const char* str)
|
||||
{
|
||||
if(strchr(str, ':'))
|
||||
return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
52
util/net_help.h
Normal file
52
util/net_help.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* util/net_help.h - network help functions
|
||||
*
|
||||
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* This software is open source.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the NLNET LABS nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* This file contains functions to perform network related tasks.
|
||||
*/
|
||||
|
||||
#ifndef NET_HELP_H
|
||||
#define NET_HELP_H
|
||||
|
||||
/**
|
||||
* See if string is ip4 or ip6.
|
||||
* @param str: IP specification.
|
||||
* @return: true if string addr is an ip6 specced address.
|
||||
*/
|
||||
int str_is_ip6(const char* str);
|
||||
|
||||
#endif /* NET_HELP_H */
|
||||
Loading…
Reference in a new issue