if test -z "$PROTOC_C"; then
AC_MSG_ERROR([The protoc-c program was not found. Please install protobuf-c!])
fi
- AC_ARG_WITH([protobuf-c], AC_HELP_STRING([--with-protobuf-c=path],
+ AC_ARG_WITH([protobuf-c], AS_HELP_STRING([--with-protobuf-c=path],
[Path where protobuf-c is installed, for dnstap]), [
# workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
if test -f $withval/include/google/protobuf-c/protobuf-c.h; then
}
/** delete the tap structure */
-void tap_data_free(struct tap_data* data)
+static void tap_data_free(struct tap_data* data)
{
ub_event_del(data->ev);
ub_event_free(data->ev);
/** signal handler for user quit */
static RETSIGTYPE main_sigh(int sig)
{
- verbose(VERB_ALGO, "exit on signal %d\n", sig);
+ if(!sig_quit)
+ fprintf(stderr, "exit on signal %d\n", sig);
if(sig_base) {
ub_event_base_loopexit(sig_base);
sig_base = NULL;
struct tube;
struct query_info;
#include "util/data/packed_rrset.h"
+#include "daemon/worker.h"
+#include "daemon/remote.h"
+#include "util/fptr_wlist.h"
+#include "libunbound/context.h"
void worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
uint8_t* ATTR_UNUSED(buffer), size_t ATTR_UNUSED(len),
RFC 4509: SHA256 DS hash.
RFC 4592: wildcards.
RFC 4697: No DNS Resolution Misbehavior.
+RFC 5001: DNS Name Server Identifier (NSID) Option
RFC 5011: update of trust anchors with timers.
RFC 5155: NSEC3, NSEC3PARAM types
RFC 5358: reflectors-are-evil: access control list for recursive
o windows version, auto update feature, a query to check for the version.
o command the server with TSIG inband. get-config, clearcache,
get stats, get memstats, get ..., reload, clear one zone from cache
-o NSID rfc 5001 support.
o timers rfc 5011 support.
o Treat YXDOMAIN from a DNAME properly, in iterator (not throwaway), validator.
o make timeout backoffs randomized (a couple percent random) to spread traffic.
* module actions.
*/
#include "config.h"
+#include "dynlibmod/dynlibmod.h"
#include "util/module.h"
#include "util/config_file.h"
-#include "dynlibmod/dynlibmod.h"
#if HAVE_WINDOWS_H
#include <windows.h>
#define __DYNMOD HMODULE
#define __DYNSYM FARPROC
#define __LOADSYM GetProcAddress
-void log_dlerror() {
+static void log_dlerror() {
DWORD dwLastError = GetLastError();
LPSTR MessageBuffer;
DWORD dwBufferLength;
}
-HMODULE open_library(const char* fname) {
+static HMODULE open_library(const char* fname) {
return LoadLibrary(fname);
}
-void close_library(const char* fname, __DYNMOD handle) {
+static void close_library(const char* fname, __DYNMOD handle) {
(void)fname;
(void)handle;
}
#define __DYNMOD void*
#define __DYNSYM void*
#define __LOADSYM dlsym
-void log_dlerror() {
+static void log_dlerror() {
log_err("dynlibmod: %s", dlerror());
}
-void* open_library(const char* fname) {
+static void* open_library(const char* fname) {
return dlopen(fname, RTLD_LAZY | RTLD_GLOBAL);
}
-void close_library(const char* fname, __DYNMOD handle) {
+static void close_library(const char* fname, __DYNMOD handle) {
if(!handle) return;
if(dlclose(handle) != 0) {
log_err("dlclose %s: %s", fname, strerror(errno));
int dynlib_inplace_cb_reply_generic(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out,
- struct comm_reply* repinfo, struct regional* region, int id,
- void* callback) {
+ struct comm_reply* repinfo, struct regional* region,
+ struct timeval* start_time, int id, void* callback) {
struct cb_pair* cb_pair = (struct cb_pair*) callback;
- return ((inplace_cb_reply_func_type*) cb_pair->cb)(qinfo, qstate, rep, rcode, edns, opt_list_out, repinfo, region, id, cb_pair->cb_arg);
+ return ((inplace_cb_reply_func_type*) cb_pair->cb)(qinfo, qstate, rep, rcode, edns, opt_list_out, repinfo, region, start_time, id, cb_pair->cb_arg);
}
int dynlib_inplace_cb_query_generic(struct query_info* qinfo, uint16_t flags,
int dynlib_inplace_cb_reply_generic(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out,
- struct comm_reply* repinfo, struct regional* region, int id,
- void* callback);
+ struct comm_reply* repinfo, struct regional* region,
+ struct timeval* start_time, int id, void* callback);
int dynlib_inplace_cb_query_generic(struct query_info* qinfo, uint16_t flags,
struct module_qstate* qstate, struct sockaddr_storage* addr,
* And to build for windows, first make unbound with the --with-dynlibmod
* switch, then use this command:
* x86_64-w64-mingw32-gcc -m64 -I../.. -shared -Wall -Werror -fpic
- * -o helloworld.dll helloworld.c -L../.. -l:libunbound.a
- * to cross-compile a 64-bit Windows DLL.
+ * -o helloworld.dll helloworld.c -L../.. -l:libunbound.dll.a
+ * to cross-compile a 64-bit Windows DLL. The libunbound.dll.a is produced
+ * by the compile step that makes unbound.exe and allows the dynlib dll to
+ * access definitions in unbound.exe.
*/
#include "../../config.h"
int reply_callback(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out,
- struct comm_reply* repinfo, struct regional* region, int id,
- void* callback);
+ struct comm_reply* repinfo, struct regional* region,
+ struct timeval* start_time, int id, void* callback);
/* Init is called when the module is first loaded. It should be used to set up
* the environment for this module and do any other initialisation required. */
int reply_callback(struct query_info* qinfo,
struct module_qstate* qstate, struct reply_info* rep, int rcode,
struct edns_data* edns, struct edns_option** opt_list_out,
- struct comm_reply* repinfo, struct regional* region, int id,
- void* callback) {
+ struct comm_reply* repinfo, struct regional* region,
+ struct timeval* start_time, int id, void* callback) {
log_info("dynlib: hello world from callback");
struct dynlibmod_env* env = qstate->env->modinfo[id];
if (env->dyn_env != NULL) {
int only_exact, int wr, int zones_keep_lock)
{
uint8_t* ce;
- size_t ce_len, ce_labs;
+ size_t ce_len;
+ int ce_labs;
uint8_t wc[LDNS_MAX_DOMAINLEN+1];
int exact;
struct local_zone* z = NULL;
for(a = az->rpz_first; a; a = a->rpz_az_next) {
lock_rw_rdlock(&a->lock);
r = a->rpz;
- if(!r->taglist || taglist_intersect(r->taglist,
- r->taglistlen, taglist, taglen)) {
+ if(!r->disabled && (!r->taglist || taglist_intersect(r->taglist,
+ r->taglistlen, taglist, taglen))) {
z = rpz_find_zone(r, qinfo->qname, qinfo->qname_len,
qinfo->qclass, 0, 0, 0);
if(z && r->action_override == RPZ_DISABLED_ACTION) {
return ret;
}
+
+void rpz_enable(struct rpz* r)
+{
+ if(!r)
+ return;
+ r->disabled = 0;
+}
+
+void rpz_disable(struct rpz* r)
+{
+ if(!r)
+ return;
+ r->disabled = 1;
+}
int log;
char* log_name;
struct regional* region;
+ int disabled;
};
/**
enum respip_action
rpz_action_to_respip_action(enum rpz_action a);
+/**
+ * Enable RPZ
+ * @param r: RPZ struct to enable
+ */
+void rpz_enable(struct rpz* r);
+
+/**
+ * Disable RPZ
+ * @param r: RPZ struct to disable
+ */
+void rpz_disable(struct rpz* r);
+
#endif /* SERVICES_RPZ_H */
#include "sldns/sbuffer.h"
#include "sldns/wire2str.h"
#include "sldns/str2wire.h"
+#include "daemon/remote.h"
#include <signal.h>
struct worker;
struct daemon_remote;
edns.bits = 0;
if(dnssec)
edns.bits = EDNS_DO;
+ edns.padding_block_size = 0;
if((client_string_addr = edns_string_addr_lookup(
&env->edns_strings->client_strings,
addr, addrlen))) {
}
int comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
- struct sockaddr* addr, socklen_t addrlen)
+ struct sockaddr* addr, socklen_t addrlen, int ATTR_UNUSED(is_connected))
{
struct fake_commpoint* fc = (struct fake_commpoint*)c;
struct replay_runtime* runtime = fc->runtime;
#ifdef HAVE_TIME_H
# include <time.h>
#endif
+#include <ctype.h>
#include "testcode/testpkts.h"
#include "testcode/replay.h"
#include "testcode/fake_event.h"
#include "daemon/remote.h"
+#include "libunbound/worker.h"
#include "util/config_file.h"
#include "sldns/keyraw.h"
-#include <ctype.h>
+#ifdef UB_ON_WINDOWS
+#include "winrc/win_svc.h"
+#endif
/** signal that this is a testbound compile */
#define unbound_testbound 1
+/** renamed main routine */
+int daemon_main(int argc, char* argv[]);
/**
* include the main program from the unbound daemon.
* rename main to daemon_main to call it
}
/** remove config file at exit */
-void remove_configfile(void)
+static void remove_configfile(void)
{
struct config_strlist* p;
for(p=cfgfiles; p; p=p->next)
log_assert(0);
}
+#ifdef UB_ON_WINDOWS
void wsvc_command_option(const char* ATTR_UNUSED(wopt),
const char* ATTR_UNUSED(cfgfile), int ATTR_UNUSED(v),
int ATTR_UNUSED(c))
{
log_assert(0);
}
+#endif
+#ifdef UB_ON_WINDOWS
void wsvc_setup_worker(struct worker* ATTR_UNUSED(worker))
{
/* do nothing */
}
+#endif
+#ifdef UB_ON_WINDOWS
void wsvc_desetup_worker(struct worker* ATTR_UNUSED(worker))
{
/* do nothing */
}
+#endif
#ifdef UB_ON_WINDOWS
void worker_win_stop_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(ev),
#define yyget_leng ub_c_get_leng
#define yylineno ub_c_lineno
#define yyget_text ub_c_get_text
+#define yyss ub_c_ss
+#define yysslim ub_c_sslim
+#define yyssp ub_c_ssp
+#define yystacksize ub_c_stacksize
+#define yyvs ub_c_vs
+#define yyvsp ub_c_vsp
#endif /* UTIL_CONFIGYYRENAME_H */
!edns_keepalive(edns_out, edns_in, c, region))
return 0;
+ if (cfg->nsid && edns_opt_list_find(edns_in->opt_list, LDNS_EDNS_NSID)
+ && !edns_opt_list_append(&edns_out->opt_list,
+ LDNS_EDNS_NSID, cfg->nsid_len, cfg->nsid, region))
+ return 0;
+
+ if(!cfg->pad_responses || c->type != comm_tcp || !c->ssl
+ || !edns_opt_list_find(edns_in->opt_list, LDNS_EDNS_PADDING)) {
+ ; /* pass */
+ }
+
+ else if(!edns_opt_list_append(&edns_out->opt_list, LDNS_EDNS_PADDING
+ , 0, NULL, region))
+ return 0;
+ else
+ edns_out->padding_block_size = cfg->pad_responses_block_size;
+
return 1;
}