</varlistentry>
<varlistentry>
- <term><option>+[no]subnet=addr[/netmask]</option></term>
+ <term><option>+[no]subnet=addr[/prefix-length]</option></term>
<listitem>
<para>
Send (don't send) an EDNS Client Subnet option with the
- specified IP address or network prefix.
+ specified IP address or network prefix.
</para>
<para>
<command>dig +subnet=0.0.0.0/0</command>, or simply
- <command>dig +subnet=0</command> for short, sends a
- Client Subnet option with an empty address and a
- source prefix length of zero, which signals a resolver
- that the EDNS Client Subnet option should not be used
- when resolving this query.
+ <command>dig +subnet=0</command> for short, sends an EDNS
+ client-subnet option with an empty address and a source
+ prefix-length of zero, which signals a resolver that
+ the client's address information must
+ <emphasis>not</emphasis> be used when resolving
+ this query.
</para>
</listitem>
</varlistentry>
isc_sockaddr_t *sa = NULL;
struct in_addr in4;
struct in6_addr in6;
- isc_uint32_t netmask = 0xffffffff;
+ isc_uint32_t prefix_length = 0xffffffff;
char *slash = NULL;
isc_boolean_t parsed = ISC_FALSE;
char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX/128")];
slash = strchr(buf, '/');
if (slash != NULL) {
*slash = '\0';
- result = isc_parse_uint32(&netmask, slash + 1, 10);
+ result = isc_parse_uint32(&prefix_length, slash + 1, 10);
if (result != ISC_R_SUCCESS) {
fatal("invalid prefix length in '%s': %s\n",
value, isc_result_totext(result));
}
} else if (strcmp(value, "0") == 0) {
- netmask = 0;
+ parsed = ISC_TRUE;
+ prefix_length = 0;
}
sa = isc_mem_allocate(mctx, sizeof(*sa));
if (inet_pton(AF_INET6, buf, &in6) == 1) {
parsed = ISC_TRUE;
isc_sockaddr_fromin6(sa, &in6, 0);
- if (netmask > 128)
- netmask = 128;
+ if (prefix_length > 128)
+ prefix_length = 128;
} else if (inet_pton(AF_INET, buf, &in4) == 1) {
parsed = ISC_TRUE;
isc_sockaddr_fromin(sa, &in4, 0);
- if (netmask > 32)
- netmask = 32;
- } else if (netmask != 0xffffffff) {
+ if (prefix_length > 32)
+ prefix_length = 32;
+ } else if (prefix_length != 0xffffffff && prefix_length != 0) {
int i;
for (i = 0; i < 3 && strlen(buf) < sizeof(buf) - 2; i++) {
}
}
- if (netmask > 32)
- netmask = 32;
+ if (prefix_length > 32)
+ prefix_length = 32;
}
if (!parsed)
fatal("invalid address '%s'", value);
- sa->length = netmask;
+ sa->length = prefix_length;
+ if (prefix_length == 0)
+ sa->type.sa.sa_family = AF_UNSPEC;
+
*sap = sa;
return (ISC_R_SUCCESS);
opts[i].length = (isc_uint16_t) addrl + 4;
check_result(result, "isc_buffer_allocate");
isc_buffer_init(&b, ecsbuf, sizeof(ecsbuf));
- if (sa->sa_family == AF_INET) {
+ switch (sa->sa_family) {
+ case AF_UNSPEC:
+ INSIST(plen == 0);
+ family = 0;
+ break;
+ case AF_INET:
family = 1;
sin = (struct sockaddr_in *) sa;
memmove(addr, &sin->sin_addr, 4);
- if ((plen % 8) != 0)
- addr[addrl-1] &=
- ~0 << (8 - (plen % 8));
- } else {
+ break;
+ case AF_INET6:
family = 2;
sin6 = (struct sockaddr_in6 *) sa;
memmove(addr, &sin6->sin6_addr, 16);
+ break;
+ default:
+ INSIST(0);
}
/* Mask off last address byte */
#define NS_CLIENTATTR_WANTEXPIRE 0x0800 /*%< return seconds to expire */
#define NS_CLIENTATTR_HAVEEXPIRE 0x1000 /*%< return seconds to expire */
#define NS_CLIENTATTR_WANTOPT 0x2000 /*%< add opt to reply */
-#define NS_CLIENTATTR_HAVEECS 0x4000 /*%< sent an ECS option */
+#define NS_CLIENTATTR_HAVEECS 0x4000 /*%< received an ECS option */
#define NS_CLIENTATTR_NOSETFC 0x8000 /*%< don't set servfail cache */
</varlistentry>
<varlistentry>
- <term><option>+[no]subnet=addr[/netmask]</option></term>
+ <term><option>+[no]subnet=addr[/prefix-length]</option></term>
<listitem>
<para>
Send (don't send) an EDNS Client Subnet option with the
</para>
<para>
<command>mdig +subnet=0.0.0.0/0</command>, or simply
- <command>mdig +subnet=0</command> for short, sends a
- Client Subnet option with an empty address and a
- source prefix length of zero, which signals a resolver
- that the EDNS Client Subnet option should not be used
- when resolving this query.
+ <command>mdig +subnet=0</command> for short, sends an EDNS
+ client-subnet option with an empty address and a source
+ prefix-length of zero, which signals a resolver that
+ the client's address information must
+ <emphasis>not</emphasis> be used when resolving
+ this query.
</para>
</listitem>
</varlistentry>
0x00, 0x08, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00
},
- 8, ISC_FALSE
+ 8, ISC_TRUE
},
{
/* Option code family 1 (ipv4), source 0, scope 0 */
0x00, 0x08, 0x00, 0x04,
0x00, 0x01, 0x00, 0x00
},
- 8, ISC_TRUE
+ 8, ISC_FALSE
},
{
/* Option code family 2 (ipv6) , source 0, scope 0 */
0x00, 0x08, 0x00, 0x04,
0x00, 0x02, 0x00, 0x00
},
- 8, ISC_TRUE
+ 8, ISC_FALSE
},
{
/* extra octet */
&dctx, 0, &target1);
dns_decompress_invalidate(&dctx);
if (test_data[i].ok)
- ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
+ ATF_CHECK_EQ(result, ISC_R_SUCCESS);
else
- ATF_REQUIRE(result != ISC_R_SUCCESS);
+ ATF_CHECK(result != ISC_R_SUCCESS);
}
}