]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Use exposed bits from configuration
authorYuri Schaeffer <yuri@nlnetlabs.nl>
Thu, 30 Aug 2012 12:23:48 +0000 (12:23 +0000)
committerYuri Schaeffer <yuri@nlnetlabs.nl>
Thu, 30 Aug 2012 12:23:48 +0000 (12:23 +0000)
git-svn-id: file:///svn/unbound/branches/edns-subnet@2755 be551aaa-1e26-0410-a405-d3ace91eadb9

services/outside_network.c
util/config_file.c
util/net_help.c
util/net_help.h

index 431917935061d1a47b4588ebf0fef6fd7cf5566e..e1f51108f06e91b3fc91899f1731eb9b21a268db 100644 (file)
@@ -1342,14 +1342,14 @@ serviced_encode(struct serviced_query* sq, ldns_buffer* buff, int with_edns)
                                /* YBS TODO: source mask must come from original query if
                                 * any. Some default otherwise. But not more than 
                                 * configured maximum */
-                               edns.subnet_source_mask = 26;
+                               edns.subnet_source_mask = MAX_CLIENT_SUBNET_IP4;
                        } 
 #ifdef INET6
                        else {
                                edns.subnet_addr_fam = IANA_ADDRFAM_IP6;
                                sinaddr = &((struct sockaddr_in6*)ss)->sin6_addr;
                                memcpy(edns.subnet_addr, (uint8_t *)sinaddr, INET6_SIZE);
-                               edns.subnet_source_mask = 100;
+                               edns.subnet_source_mask = MAX_CLIENT_SUBNET_IP6;
                        }
 #endif
                        edns.subnet_scope_mask = 0;
index 7d6a8e8e030f34b2111af9544062f3819c1f931f..cf95092581a638fdca95eb1ad018d209b5da1950 100644 (file)
@@ -1101,6 +1101,8 @@ config_apply(struct config_file* config)
        MIN_TTL = (uint32_t)config->min_ttl;
        EDNS_ADVERTISED_SIZE = (uint16_t)config->edns_buffer_size;
        EDNS_SUBNET_OPC = (uint16_t)config->client_subnet_opc;
+       MAX_CLIENT_SUBNET_IP4 = (uint8_t)config->max_client_subnet_ipv4;
+       MAX_CLIENT_SUBNET_IP6 = (uint8_t)config->max_client_subnet_ipv6;
        MINIMAL_RESPONSES = config->minimal_responses;
        RRSET_ROUNDROBIN = config->rrset_roundrobin;
        log_set_time_asc(config->log_time_ascii);
index 151b34fcc25b8ca0a8b444992ea6b88e3ac1f8e3..948c241c4506cc3167209719e99b5099bc171cc1 100644 (file)
@@ -54,6 +54,8 @@
 uint16_t EDNS_ADVERTISED_SIZE = 4096;
 /** Opcode for edns subnet option, is TBD. */
 uint16_t EDNS_SUBNET_OPC = 0x50fa;
+uint8_t MAX_CLIENT_SUBNET_IP4 = 24;
+uint8_t MAX_CLIENT_SUBNET_IP6 = 64;
 
 /** minimal responses when positive answer: default is no */
 int MINIMAL_RESPONSES = 0;
index e8f44b3b07fc37d398f2924d5ca57c4b6d0eaf01..f8cad67a4b5ac5b20061dfc7e706492af0475996 100644 (file)
@@ -83,6 +83,9 @@ struct regional;
 extern uint16_t EDNS_ADVERTISED_SIZE;
 /** Opcode for edns subnet option, is TBD. */
 extern uint16_t EDNS_SUBNET_OPC;
+/** Maximum number of bits we are willing to expose */
+extern uint8_t MAX_CLIENT_SUBNET_IP4;
+extern uint8_t MAX_CLIENT_SUBNET_IP6;
 /** bits for EDNS bitfield */
 #define EDNS_DO 0x8000 /* Dnssec Ok */
 /** byte size of ip4 address */