unbound: ipset/ipset.c File Reference

unbound 0.1

Macros | Typedefs | Functions | Variables
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.
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_block * | ipset_get_funcblock (void)
| Get the function block with pointers to the ipset functions.

## Variables
static struct module_func_block | ipset_block
| The ipset function block.

## 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()

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

Return an error.

Parameters

  qstate | our query state
  id | module id
  rcode | error 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_rcodes, VERB_QUERY, and verbose().

Referenced by ipset_operate().

## ◆ 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",
&ipset_startup, &ipset_destartup, &ipset_init, &ipset_deinit,
&ipset_operate, &ipset_inform_super, &ipset_clear, &ipset_get_mem
}
ipset_init
int ipset_init(struct module_env *env, int id)
Init the ipset module.
Definition ipset.c:370
ipset_startup
int ipset_startup(struct module_env *env, int id)
Startup the ipset module.
Definition ipset.c:324
ipset_destartup
void ipset_destartup(struct module_env *env, int id)
Destartup the ipset module.
Definition ipset.c:347
ipset_clear
void ipset_clear(struct module_qstate *qstate, int id)
clear the ipset query-specific contents out of qstate
Definition ipset.c:468
ipset_operate
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
ipset_get_mem
size_t ipset_get_mem(struct module_env *env, int id)
return memory estimate for ipset module
Definition ipset.c:481

The ipset function block.

Referenced by ipset_get_funcblock().