3 ms·
Okay, here's some code I wrote [1], with the existing comment: /*------------------------------------------------------------------------ ; For the RR
by spc476 4y ago
Okay, here's some code I wrote [1], with the existing comment:
/*------------------------------------------------------------------------
; For the RR OPT, the class field is actually the size of the UDP payload,
; and the TTL field are a bunch of flags. We have a separate field for
; the UDP payload size, so here we make the adjustment behind the scenes
; so you don't have to know this crap.
;-------------------------------------------------------------------------*/
if (answer->generic.type == RR_OPT)
{
answer->opt.class = answer->opt.udp_payload;
answer->opt.ttl = ((data->rcode >> 4) & 0xFF) << 24
| (answer->opt.version & 0xFF) << 16
| (answer->opt.fdo ? 0x80 : 0x00) << 8
| htons(answer->opt.z & 0xFFFF)
;
}
I'd like to see how I could do away with the comment and make this more "self-documenting".
[1] Code to encode/decode DNS packets: https://github.com/spc476/SPCDNS/blob/05aead581acf050edf610c6cb5cf86d33c686062/src/codec.c#L864 https://github.com/spc476/SPCDNS/blob/05aead581acf050edf610c...