* indicates that an unextended RCODE is in use (values 0 through 15).
*/
stuff.extRCode = extRCode>>4;
- if (extRCode != 0) { // As this trumps the existing RCODE
+ if (extRCode > 15) { // As this trumps the existing RCODE
getHeader()->rcode = extRCode;
}
if (p->hasEDNS() && p->getEDNSVersion() > 0) {
r = p->replyPacket();
- r->setRcode(16 & 0xF);
- r->setEDNSRcode((16 & 0xFFF0)>>4); // set rcode to BADVERS
+
+ // PacketWriter::addOpt will take care of setting this correctly in the packet
+ r->setEDNSRcode(ERCode::BADVERS);
return r;
}