[ldns-users] how to check existence of EDNS in read packet

Bedrich Kosata bedrich.kosata at nic.cz
Tue Oct 26 05:54:29 UTC 2010


On 10/25/2010 06:21 PM, Ray Bellis wrote:
>
> On 25 Oct 2010, at 14:40, Bedrich Kosata wrote:
>
>> Hello,
>>
>> I have the following problem. When parsing DNS packets, I need to know if an OPT RR containing EDNS is present. However, it seems that ldns parses this RR separately and then removes it from the additional section.
>> What is the best way to find out if this RR was present in the original data? I need this to find out if the zero returned for edns version is a real value or a default one.
>> It seems that the best I can do for now is to use the value of _edns_udp_size, but this could be zero as well (at least in theory), could it not?
>>
>> I would be glad for any insight.
>
> This function should give you the original EDNS RR (if any)
>
>    ldns_rdf *ldns_pkt_edns_data(const ldns_pkt *packet)
>
> Ray
>

Unfortunately, this does not seem to be the case. This structure only 
contains the optional data that might be present in the OPT RR, but 
which is often empty and thus this value is NULL.
It seems that the best I could do, is to use "ldns_pkt_edns" which tells 
if there is data in the packet that would require use of EDNS. However, 
this function is meant to be used when constructing a packet, so it 
would not be reliable in case the packet arrived with OPT RR but 
contained zeroes in every field.
It would be cool, if there could be an indicator value in the ldns_pkt 
struct which would tell if there was an OPT RR in the raw data.

Best regards

Beda


-- 
Bedrich Kosata
CZ.NIC Labs <http://labs.nic.cz>



More information about the ldns-users mailing list