Smart Home firewall
Profile-based Smart Home firewall
dns_map.h
Go to the documentation of this file.
1 
10 #ifndef _PROTOCOL_PARSERS_DNS_MAP_
11 #define _PROTOCOL_PARSERS_DNS_MAP_
12 
13 #include <stdlib.h>
14 #include <stdint.h>
15 #include <stdbool.h>
16 #include <string.h>
17 #include "hashmap.h"
18 #include "packet_utils.h"
19 
20 // Initial size of the DNS table
21 // If set to 0, the default size will be 16
22 #define DNS_MAP_INIT_SIZE 0
23 
24 
26 
30 typedef struct ip_list {
31  uint8_t ip_count; // Number of IP addresses
32  ip_addr_t *ip_addresses; // List of IP addresses
34 
39 typedef struct dns_entry {
40  char *domain_name; // Domain name
41  ip_list_t ip_list; // List of IP addresses
43 
47 typedef struct hashmap dns_map_t;
48 
49 
51 
62 
71 
78 
84 void dns_map_free(dns_map_t *table);
85 
94 void dns_map_add(dns_map_t *table, char *domain_name, ip_list_t ip_list);
95 
102 void dns_map_remove(dns_map_t *table, char *domain_name);
103 
112 dns_entry_t* dns_map_get(dns_map_t *table, char *domain_name);
113 
123 dns_entry_t* dns_map_pop(dns_map_t *table, char *domain_name);
124 
131 
132 #endif /* _PROTOCOL_PARSERS_DNS_MAP_ */
struct ip_list ip_list_t
void dns_entry_print(dns_entry_t *dns_entry)
Print a DNS table entry.
Definition: dns_map.c:195
void dns_map_free(dns_map_t *table)
Definition: dns_map.c:122
ip_list_t ip_list_init()
Initialize an ip_list_t structure.
Definition: dns_map.c:66
dns_map_t * dns_map_create()
Definition: dns_map.c:104
void dns_map_remove(dns_map_t *table, char *domain_name)
Definition: dns_map.c:159
dns_entry_t * dns_map_get(dns_map_t *table, char *domain_name)
Definition: dns_map.c:173
void dns_map_add(dns_map_t *table, char *domain_name, ip_list_t ip_list)
Definition: dns_map.c:134
bool dns_entry_contains(dns_entry_t *dns_entry, ip_addr_t ip_address)
Checks if a dns_entry_t structure contains a given IP address.
Definition: dns_map.c:80
struct dns_entry dns_entry_t
dns_entry_t * dns_map_pop(dns_map_t *table, char *domain_name)
Definition: dns_map.c:186
Utilitaries for payload manipulation and display.
Definition: dns_map.h:39
Definition: hashmap.c:37
IP (v4 or v6) address.
Definition: packet_utils.h:37
Definition: dns_map.h:30