ipset.c File Reference

This file implements the ipset module. More...

#include "config.h"
#include "ipset/ipset.h"
#include "util/regional.h"
#include "util/net_help.h"
#include "util/config_file.h"
#include "services/cache/dns.h"
#include "sldns/sbuffer.h"
#include "sldns/wire2str.h"
#include "sldns/parseutil.h"
#include <libmnl/libmnl.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/ipset/ip_set.h>

Macros

#define BUFF_LEN   256
 

Typedefs

typedef struct mnl_socket * filter_dev
 

Functions

static int error_response (struct module_qstate *qstate, int id, int rcode)
 Return an error. More...
 
static void * open_filter ()
 
static int add_to_ipset (filter_dev dev, const char *setname, const void *ipaddr, int af)
 
static void ipset_add_rrset_data (struct ipset_env *ie, struct packed_rrset_data *d, const char *setname, int af, const char *dname)
 
static int ipset_check_zones_for_rrset (struct module_env *env, struct ipset_env *ie, struct ub_packed_rrset_key *rrset, const char *qname, int qlen, const char *setname, int af)
 
static int ipset_update (struct module_env *env, struct dns_msg *return_msg, struct query_info qinfo, struct ipset_env *ie)
 
int ipset_startup (struct module_env *env, int id)
 Startup the ipset module.
 
void ipset_destartup (struct module_env *env, int id)
 Destartup the ipset module.
 
int ipset_init (struct module_env *env, int id)
 Init the ipset module.
 
void ipset_deinit (struct module_env *ATTR_UNUSED(env), int ATTR_UNUSED(id))
 
static int ipset_new (struct module_qstate *qstate, int id)
 
void ipset_operate (struct module_qstate *qstate, enum module_ev event, int id, struct outbound_entry *outbound)
 Operate on an event on a query (in qstate).
 
void ipset_inform_super (struct module_qstate *ATTR_UNUSED(qstate), int ATTR_UNUSED(id), struct module_qstate *ATTR_UNUSED(super))
 
void ipset_clear (struct module_qstate *qstate, int id)
 clear the ipset query-specific contents out of qstate
 
size_t ipset_get_mem (struct module_env *env, int id)
 return memory estimate for ipset module
 
struct module_func_blockipset_get_funcblock (void)
 Get the function block with pointers to the ipset functions. More...
 

Variables

static struct module_func_block ipset_block
 The ipset function block. More...
 

Detailed Description

This file implements the ipset module.

It can handle packets by putting the A and AAAA addresses that are configured in unbound.conf as type ipset (local-zone statements) into a firewall rule IPSet. For firewall blacklist and whitelist usage.

Function Documentation

◆ error_response()

static int error_response ( struct module_qstate qstate,
int  id,
int  rcode 
)
static

Return an error.

Parameters
qstateour query state
idmodule id
rcodeerror code (DNS errcode).
Returns
: 0 for use by caller, to make notation easy, like: return error_response(..).

References module_qstate::ext_state, module_finished, module_qstate::return_msg, module_qstate::return_rcode, sldns_lookup_by_id(), sldns_rcodes, VERB_QUERY, and verbose().

◆ ipset_get_funcblock()

struct module_func_block* ipset_get_funcblock ( void  )

Get the function block with pointers to the ipset functions.

Returns
the function block for "ipset".

References ipset_block.

Referenced by module_funcs_avail().

Variable Documentation

◆ ipset_block

struct module_func_block ipset_block
static
Initial value:
= {
"ipset",
}
int ipset_init(struct module_env *env, int id)
Init the ipset module.
Definition: ipset.c:370
int ipset_startup(struct module_env *env, int id)
Startup the ipset module.
Definition: ipset.c:324
void ipset_destartup(struct module_env *env, int id)
Destartup the ipset module.
Definition: ipset.c:347
void ipset_clear(struct module_qstate *qstate, int id)
clear the ipset query-specific contents out of qstate
Definition: ipset.c:468
void ipset_operate(struct module_qstate *qstate, enum module_ev event, int id, struct outbound_entry *outbound)
Operate on an event on a query (in qstate).
Definition: ipset.c:406
size_t ipset_get_mem(struct module_env *env, int id)
return memory estimate for ipset module
Definition: ipset.c:481
void ipset_deinit(struct module_env *env, int id)
Deinit the ipset module.
void ipset_inform_super(struct module_qstate *qstate, int id, struct module_qstate *super)
Subordinate query done, inform this super request of its conclusion.

The ipset function block.

Referenced by ipset_get_funcblock().