[ldns-users] NSID support

Willem Toorop willem at nlnetlabs.nl
Tue Dec 3 09:51:16 UTC 2019


Op 02-12-2019 om 17:28 schreef Vladimir Levijev:
> On Thu, Sep 5, 2019 at 6:23 PM Vladimir Levijev
> <vladimir.levijev at gmail.com> wrote:
> 
> Hi,
> 
> Getting back to your example that fetches NSID from the target name
> server (see question below).
> 
>>> I have attached a "small" example program (nsid-example.c) that
>>> illustrates how to use the ldns_pkt_set_edns_data() and
>>> ldns_pkt_edns_data() functions to set and get EDNS Options.
>>> Here are some usage examples:
>>>
>>> $ ./nsid-example
>>> ./nsid-example <upstream IP>
>>>
>>> $ ./nsid-example 193.0.14.129
>>> upstream 193.0.14.129, returned NSID: "ns2.nl-ams.k.ripe.net"
>>>
>>> $ ./nsid-example 37.209.192.10
>>> upstream 37.209.192.10, returned NSID: "dns5.mel"
>>>
>>> $ ./nsid-example 9.9.9.10
>>> upstream 9.9.9.10, returned NSID: "res210.ams.rrdns.pch.net"
>>>
>>> $ ./nsid-example 8.8.8.8
>>> Could not get EDNS data
> 
> One question regarding the part of the code where the NSID is fetched
> from reply, specifically:
> 
> ---------------------------------------------------------------------------------------
> while (size >= 4) {
>     /* Read option code */
>     opt_code = ldns_read_uint16(data);
>     size -= 2; data += 2;
> 
>     /* Read option length */
>     opt_len  = ldns_read_uint16(data);
>     size -= 2; data += 2;
> 
>     if (opt_code == LDNS_EDNS_NSID) {
>         printf("upstream ");
>         ldns_rdf_print(stdout, upstream);
>         printf(", returned NSID: \"%.*s\"\n", (int)opt_len, data);
>         break;
>     }
> 
>    /* Next option */
>     size = opt_len > size ? 0 : size - opt_len;
> }
> ---------------------------------------------------------------------------------------
> 
> If `opt_code` is not `LDNS_EDNS_NSID` (commented as "Next option"),
> shouldn't we skip `opt_len` bytes in `data`?

Absolutely! Good catch!

  Cheers,

WT

>> Cheers,
> 
> VL
> 




More information about the ldns-users mailing list