|
Electroneum
|
#include "util/rbtree.h"#include "util/locks.h"#include "util/storage/dnstree.h"#include "util/module.h"#include "services/view.h"

Go to the source code of this file.
Classes | |
| struct | local_zones |
| struct | local_zone |
| struct | local_data |
| struct | local_rrset |
| struct | local_zone_override |
Enumerations | |
| enum | localzone_type { local_zone_unset = 0, local_zone_deny, local_zone_refuse, local_zone_static, local_zone_transparent, local_zone_typetransparent, local_zone_redirect, local_zone_nodefault, local_zone_inform, local_zone_inform_deny, local_zone_always_transparent, local_zone_always_refuse, local_zone_always_nxdomain, local_zone_noview } |
| enum | respip_action { respip_none = local_zone_unset, respip_deny = local_zone_deny, respip_redirect = local_zone_redirect, respip_inform = local_zone_inform, respip_inform_deny = local_zone_inform_deny, respip_always_transparent = local_zone_always_transparent, respip_always_refuse = local_zone_always_refuse, respip_always_nxdomain = local_zone_always_nxdomain, respip_refuse = local_zone_refuse, respip_static = local_zone_static, respip_transparent = local_zone_transparent, respip_typetransparent = local_zone_typetransparent } |
Functions | |
| struct local_zones * | local_zones_create (void) |
| void | local_zones_delete (struct local_zones *zones) |
| int | local_zones_apply_cfg (struct local_zones *zones, struct config_file *cfg) |
| int | local_zone_cmp (const void *z1, const void *z2) |
| int | local_data_cmp (const void *d1, const void *d2) |
| void | local_zone_delete (struct local_zone *z) |
| struct local_zone * | local_zones_tags_lookup (struct local_zones *zones, uint8_t *name, size_t len, int labs, uint16_t dclass, uint16_t dtype, uint8_t *taglist, size_t taglen, int ignoretags) |
| struct local_zone * | local_zones_lookup (struct local_zones *zones, uint8_t *name, size_t len, int labs, uint16_t dclass, uint16_t dtype) |
| void | local_zones_print (struct local_zones *zones) |
| int | local_zones_answer (struct local_zones *zones, struct module_env *env, struct query_info *qinfo, struct edns_data *edns, struct sldns_buffer *buf, struct regional *temp, struct comm_reply *repinfo, uint8_t *taglist, size_t taglen, uint8_t *tagactions, size_t tagactionssize, struct config_strlist **tag_datas, size_t tag_datas_size, char **tagname, int num_tags, struct view *view) |
| int | local_zone_str2type (const char *str, enum localzone_type *t) |
| const char * | local_zone_type2str (enum localzone_type t) |
| struct local_zone * | local_zones_find (struct local_zones *zones, uint8_t *name, size_t len, int labs, uint16_t dclass) |
| struct local_zone * | local_zones_add_zone (struct local_zones *zones, uint8_t *name, size_t len, int labs, uint16_t dclass, enum localzone_type tp) |
| void | local_zones_del_zone (struct local_zones *zones, struct local_zone *zone) |
| int | local_zones_add_RR (struct local_zones *zones, const char *rr) |
| void | local_zones_del_data (struct local_zones *zones, uint8_t *name, size_t len, int labs, uint16_t dclass) |
| int | parse_dname (const char *str, uint8_t **res, size_t *len, int *labs) |
| int | local_data_find_tag_datas (const struct query_info *qinfo, struct config_strlist *list, struct ub_packed_rrset_key *r, struct regional *temp) |
| enum localzone_type | local_data_find_tag_action (const uint8_t *taglist, size_t taglen, const uint8_t *taglist2, size_t taglen2, const uint8_t *tagactions, size_t tagactionssize, enum localzone_type lzt, int *tag, char *const *tagname, int num_tags) |
| int | local_zone_enter_defaults (struct local_zones *zones, struct config_file *cfg) |
| int | rrstr_get_rr_content (const char *str, uint8_t **nm, uint16_t *type, uint16_t *dclass, time_t *ttl, uint8_t *rr, size_t len, uint8_t **rdata, size_t *rdata_len) |
| int | rrset_insert_rr (struct regional *region, struct packed_rrset_data *pd, uint8_t *rdata, size_t rdata_len, time_t ttl, const char *rrstr) |
This file contains functions to enable local zone authority service.
Definition in file localzone.h.
| enum localzone_type |
Local zone type This type determines processing for queries that did not match local-data directly.
Definition at line 64 of file localzone.h.
| enum respip_action |
Valid response ip actions for the IP-response-driven-action feature; defined here instead of in the respip module to enable sharing of enum values with the localzone_type enum. Note that these values except 'none' are the same as localzone types of the 'same semantics'. It's intentional as we use these values via access-control-tags, which can be shared for both response ip actions and local zones.
Definition at line 483 of file localzone.h.
| int local_data_cmp | ( | const void * | d1, |
| const void * | d2 | ||
| ) |
Compare two local_data entries in rbtree. Sort canonical.
| d1 | data 1 |
| d2 | data 2 |
| enum localzone_type local_data_find_tag_action | ( | const uint8_t * | taglist, |
| size_t | taglen, | ||
| const uint8_t * | taglist2, | ||
| size_t | taglen2, | ||
| const uint8_t * | tagactions, | ||
| size_t | tagactionssize, | ||
| enum localzone_type | lzt, | ||
| int * | tag, | ||
| char *const * | tagname, | ||
| int | num_tags | ||
| ) |
See if two sets of tag lists (in the form of bitmap) have the same tag that has an action. If so, '*tag' will be set to the found tag index, and the corresponding action will be returned in the form of local zone type. Otherwise the passed type (lzt) will be returned as the default action. Pointers except tagactions must not be NULL.
| taglist | 1st list of tags |
| taglen | size of taglist in bytes |
| taglist2 | 2nd list of tags |
| taglen2 | size of taglist2 in bytes |
| tagactions | local data actions for tags. May be NULL. |
| tagactionssize | length of the tagactions. |
| lzt | default action (local zone type) if no tag action is found. |
| tag | see above. |
| tagname | array of tag name strings (for debug output). |
| num_tags | number of items in tagname array. |
| int local_data_find_tag_datas | ( | const struct query_info * | qinfo, |
| struct config_strlist * | list, | ||
| struct ub_packed_rrset_key * | r, | ||
| struct regional * | temp | ||
| ) |
Find local data tag string match for the given type (in qinfo) in the list. If found, 'r' will be filled with corresponding rrset information.
| qinfo | contains name, type, and class for the data |
| list | stores local tag data to be searched |
| r | rrset key to be filled for matched data |
| temp | region to allocate rrset in 'r' |
| int local_zone_cmp | ( | const void * | z1, |
| const void * | z2 | ||
| ) |
Compare two local_zone entries in rbtree. Sort hierarchical but not canonical
| z1 | zone 1 |
| z2 | zone 2 |
| void local_zone_delete | ( | struct local_zone * | z | ) |
Delete one zone
| z | to delete. |
| int local_zone_enter_defaults | ( | struct local_zones * | zones, |
| struct config_file * | cfg | ||
| ) |
Enter defaults to local zone.
| zones | to add defaults to |
| cfg | containing list of zones to exclude from default set. |
| int local_zone_str2type | ( | const char * | str, |
| enum localzone_type * | t | ||
| ) |
Parse the string into localzone type.
| str | string to parse |
| t | local zone type returned here. |
| const char* local_zone_type2str | ( | enum localzone_type | t | ) |
Print localzone type to a string. Pointer to a constant string.
| t | local zone type. |
| int local_zones_add_RR | ( | struct local_zones * | zones, |
| const char * | rr | ||
| ) |
Add RR data into the localzone data. Looks up the zone, if no covering zone, a transparent zone with the name of the RR is created.
| zones | the zones tree. Not locked by caller. |
| rr | string with on RR. |
| struct local_zone* local_zones_add_zone | ( | struct local_zones * | zones, |
| uint8_t * | name, | ||
| size_t | len, | ||
| int | labs, | ||
| uint16_t | dclass, | ||
| enum localzone_type | tp | ||
| ) |
Add a new zone. Caller must hold the zones lock. Adjusts the other zones as well (parent pointers) after insertion. The zone must NOT exist (returns NULL and logs error).
| zones | the zones tree |
| name | dname to add |
| len | length of name. |
| labs | labelcount of name. |
| dclass | class to add. |
| tp | type. |
| int local_zones_answer | ( | struct local_zones * | zones, |
| struct module_env * | env, | ||
| struct query_info * | qinfo, | ||
| struct edns_data * | edns, | ||
| struct sldns_buffer * | buf, | ||
| struct regional * | temp, | ||
| struct comm_reply * | repinfo, | ||
| uint8_t * | taglist, | ||
| size_t | taglen, | ||
| uint8_t * | tagactions, | ||
| size_t | tagactionssize, | ||
| struct config_strlist ** | tag_datas, | ||
| size_t | tag_datas_size, | ||
| char ** | tagname, | ||
| int | num_tags, | ||
| struct view * | view | ||
| ) |
Answer authoritatively for local zones. Takes care of locking.
| zones | the stored zones (shared, read only). |
| env | the module environment. |
| qinfo | query info (parsed). |
| edns | edns info (parsed). |
| buf | buffer with query ID and flags, also for reply. |
| temp | temporary storage region. |
| repinfo | source address for checks. may be NULL. |
| taglist | taglist for checks. May be NULL. |
| taglen | length of the taglist. |
| tagactions | local zone actions for tags. May be NULL. |
| tagactionssize | length of the tagactions. |
| tag_datas | array per tag of strlist with rdata strings. or NULL. |
| tag_datas_size | size of tag_datas array. |
| tagname | array of tag name strings (for debug output). |
| num_tags | number of items in tagname array. |
| view | answer using this view. May be NULL. |
| int local_zones_apply_cfg | ( | struct local_zones * | zones, |
| struct config_file * | cfg | ||
| ) |
Apply config settings; setup the local authoritative data. Takes care of locking.
| zones | is set up. |
| cfg | config data. |
| struct local_zones* local_zones_create | ( | void | ) |
Create local zones storage
| void local_zones_del_data | ( | struct local_zones * | zones, |
| uint8_t * | name, | ||
| size_t | len, | ||
| int | labs, | ||
| uint16_t | dclass | ||
| ) |
Remove data from domain name in the tree. All types are removed. No effect if zone or name does not exist.
| zones | zones tree. |
| name | dname to remove |
| len | length of name. |
| labs | labelcount of name. |
| dclass | class to remove. |
| void local_zones_del_zone | ( | struct local_zones * | zones, |
| struct local_zone * | zone | ||
| ) |
Delete a zone. Caller must hold the zones lock. Adjusts the other zones as well (parent pointers) after insertion.
| zones | the zones tree |
| zone | the zone to delete from tree. Also deletes zone from memory. |
| void local_zones_delete | ( | struct local_zones * | zones | ) |
Delete local zones storage
| zones | to delete. |
| struct local_zone* local_zones_find | ( | struct local_zones * | zones, |
| uint8_t * | name, | ||
| size_t | len, | ||
| int | labs, | ||
| uint16_t | dclass | ||
| ) |
Find zone that with exactly given name, class. User must lock the tree or result zone.
| zones | the zones tree |
| name | dname to lookup |
| len | length of name. |
| labs | labelcount of name. |
| dclass | class to lookup. |
| struct local_zone* local_zones_lookup | ( | struct local_zones * | zones, |
| uint8_t * | name, | ||
| size_t | len, | ||
| int | labs, | ||
| uint16_t | dclass, | ||
| uint16_t | dtype | ||
| ) |
Lookup zone that contains the given name, class. User must lock the tree or result zone.
| zones | the zones tree |
| name | dname to lookup |
| len | length of name. |
| labs | labelcount of name. |
| dclass | class to lookup. |
| dtype | type of the record, if type DS then a zone higher up is found pass 0 to just plain find a zone for a name. |
| void local_zones_print | ( | struct local_zones * | zones | ) |
Debug helper. Print all zones Takes care of locking.
| zones | the zones tree |
| struct local_zone* local_zones_tags_lookup | ( | struct local_zones * | zones, |
| uint8_t * | name, | ||
| size_t | len, | ||
| int | labs, | ||
| uint16_t | dclass, | ||
| uint16_t | dtype, | ||
| uint8_t * | taglist, | ||
| size_t | taglen, | ||
| int | ignoretags | ||
| ) |
Lookup zone that contains the given name, class and taglist. User must lock the tree or result zone.
| zones | the zones tree |
| name | dname to lookup |
| len | length of name. |
| labs | labelcount of name. |
| dclass | class to lookup. |
| dtype | type to lookup, if type DS a zone higher is used for zonecuts. |
| taglist | taglist to lookup. |
| taglen | lenth of taglist. |
| ignoretags | lookup zone by name and class, regardless the local-zone's tags. |
| int parse_dname | ( | const char * | str, |
| uint8_t ** | res, | ||
| size_t * | len, | ||
| int * | labs | ||
| ) |
Form wireformat from text format domain name.
| str | the domain name in text "www.example.com" |
| res | resulting wireformat is stored here with malloc. |
| len | length of resulting wireformat. |
| labs | number of labels in resulting wireformat. |
| int rrset_insert_rr | ( | struct regional * | region, |
| struct packed_rrset_data * | pd, | ||
| uint8_t * | rdata, | ||
| size_t | rdata_len, | ||
| time_t | ttl, | ||
| const char * | rrstr | ||
| ) |
Insert specified rdata into the specified resource record.
| region | allocator |
| pd | data portion of the destination resource record |
| rdata | source rdata |
| rdata_len | source rdata length |
| ttl | time to live |
| rrstr | resource record in text form (for logging) |
| int rrstr_get_rr_content | ( | const char * | str, |
| uint8_t ** | nm, | ||
| uint16_t * | type, | ||
| uint16_t * | dclass, | ||
| time_t * | ttl, | ||
| uint8_t * | rr, | ||
| size_t | len, | ||
| uint8_t ** | rdata, | ||
| size_t * | rdata_len | ||
| ) |
Parses resource record string into wire format, also returning its field values.
| str | input resource record |
| nm | domain name field |
| type | record type field |
| dclass | record class field |
| ttl | ttl field |
| rr | buffer for the parsed rr in wire format |
| len | buffer length |
| rdata | rdata field |
| rdata_len | rdata field length |