acl_list.c File Reference
#include "config.h"
#include "daemon/acl_list.h"
#include "util/regional.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "services/localzone.h"
#include "services/listen_dnsport.h"
#include "sldns/str2wire.h"

Functions

struct acl_listacl_list_create (void)
 Create acl structure. More...
 
void acl_list_delete (struct acl_list *acl)
 Delete acl structure. More...
 
static struct acl_addracl_list_insert (struct acl_list *acl, struct sockaddr_storage *addr, socklen_t addrlen, int net, enum acl_access control, int complain_duplicates)
 insert new address into acl_list structure
 
static int parse_acl_access (const char *str, enum acl_access *control)
 parse str to acl_access enum
 
static int acl_list_str_cfg (struct acl_list *acl, const char *str, const char *s2, int complain_duplicates)
 apply acl_list string
 
static struct acl_addracl_find_or_create_str2addr (struct acl_list *acl, const char *str, int is_interface, int port)
 find or create node (NULL on parse or error)
 
static struct acl_addracl_find_or_create (struct acl_list *acl, struct sockaddr_storage *addr, socklen_t addrlen, enum acl_access control)
 find or create node (NULL on error)
 
static int acl_interface_str_cfg (struct acl_list *acl_interface, const char *iface, const char *s2, int port)
 apply acl_interface string
 
struct acl_addracl_interface_insert (struct acl_list *acl_interface, struct sockaddr_storage *addr, socklen_t addrlen, enum acl_access control)
 Insert interface in the acl_list. More...
 
static int acl_list_tags_cfg (struct acl_list *acl, const char *str, uint8_t *bitmap, size_t bitmaplen, int is_interface, int port)
 apply acl_tag string
 
static int acl_list_view_cfg (struct acl_list *acl, const char *str, const char *str2, struct views *vs, int is_interface, int port)
 apply acl_view string
 
static int acl_list_tag_action_cfg (struct acl_list *acl, struct config_file *cfg, const char *str, const char *tag, const char *action, int is_interface, int port)
 apply acl_tag_action string
 
static int check_data (const char *data, const struct config_strlist *head)
 check wire data parse
 
static int acl_list_tag_data_cfg (struct acl_list *acl, struct config_file *cfg, const char *str, const char *tag, const char *data, int is_interface, int port)
 apply acl_tag_data string
 
static int read_acl_list (struct acl_list *acl, struct config_str2list *acls)
 read acl_list config
 
static int read_acl_view (struct acl_list *acl, struct config_str2list **acl_view, struct views *v)
 read acl view config
 
static int read_acl_tags (struct acl_list *acl, struct config_strbytelist **acl_tags)
 read acl tags config
 
static int read_acl_tag_actions (struct acl_list *acl, struct config_file *cfg, struct config_str3list **acl_tag_actions)
 read acl tag actions config
 
static int read_acl_tag_datas (struct acl_list *acl, struct config_file *cfg, struct config_str3list **acl_tag_datas)
 read acl tag datas config
 
int acl_list_apply_cfg (struct acl_list *acl, struct config_file *cfg, struct views *v)
 Process access control config. More...
 
int acl_interface_compare (const void *k1, const void *k2)
 compare ACL interface "addr_tree" nodes (+port)
 
void acl_interface_init (struct acl_list *acl_interface)
 Initialise (also clean) the acl_interface struct. More...
 
static int read_acl_interface_action (struct acl_list *acl_interface, struct config_str2list *acls, int port)
 
static int read_acl_interface_view (struct acl_list *acl_interface, struct config_str2list **acl_view, struct views *v, int port)
 read acl view config for interface
 
static int read_acl_interface_tags (struct acl_list *acl_interface, struct config_strbytelist **acl_tags, int port)
 read acl tags config for interface
 
static int read_acl_interface_tag_actions (struct acl_list *acl_interface, struct config_file *cfg, struct config_str3list **acl_tag_actions, int port)
 read acl tag actions config for interface
 
static int read_acl_interface_tag_datas (struct acl_list *acl_interface, struct config_file *cfg, struct config_str3list **acl_tag_datas, int port)
 read acl tag datas config for interface
 
int acl_interface_apply_cfg (struct acl_list *acl_interface, struct config_file *cfg, struct views *v)
 Process interface control config. More...
 
enum acl_access acl_get_control (struct acl_addr *acl)
 Lookup access control status for acl structure. More...
 
struct acl_addracl_addr_lookup (struct acl_list *acl, struct sockaddr_storage *addr, socklen_t addrlen)
 Lookup address to see its acl structure. More...
 
size_t acl_list_get_mem (struct acl_list *acl)
 Get memory used by acl structure. More...
 
const char * acl_access_to_str (enum acl_access acl)
 
void log_acl_action (const char *action, struct sockaddr_storage *addr, socklen_t addrlen, enum acl_access acl, struct acl_addr *acladdr)
 

Detailed Description

This file helps the server keep out queries from outside sources, that should not be answered.

Function Documentation

◆ acl_list_create()

struct acl_list* acl_list_create ( void  )

Create acl structure.

Returns
new structure or NULL on error.

References acl_list_delete(), acl_list::region, and regional_create().

◆ acl_list_delete()

void acl_list_delete ( struct acl_list acl)

Delete acl structure.

Parameters
aclto delete.

References acl_list::region, and regional_destroy().

Referenced by acl_list_create(), and daemon_delete().

◆ acl_interface_insert()

struct acl_addr* acl_interface_insert ( struct acl_list acl_interface,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
enum acl_access  control 
)

Insert interface in the acl_list.

This should happen when the listening interface is setup.

Parameters
acl_interfaceacl_list to insert to.
addrinterface IP.
addrlenlength of the interface IP.
controlacl_access.
Returns
new structure or NULL on error.

References acl_find_or_create(), and acl_addr::control.

◆ acl_list_apply_cfg()

int acl_list_apply_cfg ( struct acl_list acl,
struct config_file cfg,
struct views v 
)

◆ acl_interface_init()

void acl_interface_init ( struct acl_list acl_interface)

Initialise (also clean) the acl_interface struct.

Parameters
acl_interfacewhere to store.

References addr_tree_addrport_init(), acl_list::region, regional_free_all(), and acl_list::tree.

Referenced by daemon_open_shared_ports().

◆ acl_interface_apply_cfg()

int acl_interface_apply_cfg ( struct acl_list acl_interface,
struct config_file cfg,
struct views v 
)

Process interface control config.

Parameters
acl_interfacewhere to store.
cfgconfig options.
vviews structure
Returns
0 on error.

◆ acl_get_control()

enum acl_access acl_get_control ( struct acl_addr acl)

Lookup access control status for acl structure.

Parameters
aclstructure for acl storage.
Returns
: what to do with message from this address.

References acl_deny, and acl_addr::control.

◆ acl_addr_lookup()

struct acl_addr* acl_addr_lookup ( struct acl_list acl,
struct sockaddr_storage *  addr,
socklen_t  addrlen 
)

Lookup address to see its acl structure.

Parameters
aclstructure for address storage.
addraddress to check
addrlenlength of addr.
Returns
: acl structure from this address.

References addr_tree_lookup(), and acl_list::tree.

◆ acl_list_get_mem()

size_t acl_list_get_mem ( struct acl_list acl)

Get memory used by acl structure.

Parameters
aclstructure for address storage.
Returns
bytes in use.

References acl_list::region, and regional_get_mem().