Home | History | Annotate | Download | only in edns-subnet

Lines Matching refs:ecs

90 /** new query for ecs module */
105 /** Add ecs struct to edns list, after parsing it to wire format. */
107 subnet_ecs_opt_list_append(struct ecs_data* ecs, struct edns_option** list,
113 if(ecs->subnet_validdata) {
114 log_assert(ecs->subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP4 ||
115 ecs->subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP6);
116 log_assert(ecs->subnet_addr_fam != EDNSSUBNET_ADDRFAM_IP4 ||
117 ecs->subnet_source_mask <= INET_SIZE*8);
118 log_assert(ecs->subnet_addr_fam != EDNSSUBNET_ADDRFAM_IP6 ||
119 ecs->subnet_source_mask <= INET6_SIZE*8);
121 sn_octs = ecs->subnet_source_mask / 8;
123 (size_t)((ecs->subnet_source_mask % 8)>0?1:0);
128 sldns_buffer_write_u16(buf, ecs->subnet_addr_fam);
129 sldns_buffer_write_u8(buf, ecs->subnet_source_mask);
130 sldns_buffer_write_u8(buf, ecs->subnet_scope_mask);
131 sldns_buffer_write(buf, ecs->subnet_addr, sn_octs);
133 sldns_buffer_write_u8(buf, ecs->subnet_addr[sn_octs] &
134 ~(0xFF >> (ecs->subnet_source_mask % 8)));
185 /* Address on whitelist or client query contains ECS option, we
186 * want to sent out ECS. Only add option if it is not already
204 /* Outgoing ECS option is set, but we don't want to sent it to
263 log_err("subnetcache: could not create ECS whitelist");
387 * allowed to look in the ECS cache */
475 struct ecs_data *ecs = &sq->ecs_client_in;
489 tree = (ecs->subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP4)?
495 node = addrtree_find(tree, (addrkey_t*)ecs->subnet_addr,
496 ecs->subnet_source_mask, *env->now);
514 sq->ecs_client_out.subnet_addr_fam = ecs->subnet_addr_fam;
515 sq->ecs_client_out.subnet_source_mask = ecs->subnet_source_mask;
516 memcpy(&sq->ecs_client_out.subnet_addr, &ecs->subnet_addr,
697 * because expired answers would otherwise resurface once the ecs data
698 * expires, giving once in a while global data responses for ecs
735 /** Parse EDNS opt data containing ECS */
737 parse_subnet_option(struct edns_option* ecs_option, struct ecs_data* ecs)
739 memset(ecs, 0, sizeof(*ecs));
743 ecs->subnet_addr_fam = sldns_read_uint16(ecs_option->opt_data);
744 ecs->subnet_source_mask = ecs_option->opt_data[2];
745 ecs->subnet_scope_mask = ecs_option->opt_data[3];
750 if (ecs_option->opt_len != (size_t)((ecs->subnet_source_mask+7)/8 + 4))
754 if (ecs->subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP4) {
755 if (ecs->subnet_source_mask > 32 || ecs->subnet_scope_mask > 32)
757 } else if (ecs->subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP6) {
758 if (ecs->subnet_source_mask > 128 ||
759 ecs->subnet_scope_mask > 128)
764 /* valid ECS data, write to ecs_data */
765 if (copy_clear(ecs->subnet_addr, INET6_SIZE, ecs_option->opt_data + 4,
766 ecs_option->opt_len - 4, ecs->subnet_source_mask))
768 ecs->subnet_validdata = 1;
773 subnet_option_from_ss(struct sockaddr_storage *ss, struct ecs_data* ecs,
780 ecs->subnet_source_mask = cfg->max_client_subnet_ipv4;
781 ecs->subnet_addr_fam = EDNSSUBNET_ADDRFAM_IP4;
783 if (!copy_clear( ecs->subnet_addr, INET6_SIZE,
785 ecs->subnet_source_mask)) {
786 ecs->subnet_validdata = 1;
791 ecs->subnet_source_mask = cfg->max_client_subnet_ipv6;
792 ecs->subnet_addr_fam = EDNSSUBNET_ADDRFAM_IP6;
794 if (!copy_clear( ecs->subnet_addr, INET6_SIZE,
796 ecs->subnet_source_mask)) {
797 ecs->subnet_validdata = 1;
816 /* REFUSED response to ECS query, remove ECS option. */
831 * longest received ECS prefix for all queries on this
872 /* Only skip global cache store if we sent an ECS option
876 * does not support ECS). */
948 /* Wrongly formatted ECS option. RFC mandates to
1054 /* ECS specific data required, do not look at the global