luaCtx.registerMember<dnsheader(dnsdist::DNSPacketOverlay::*)>(std::string("dh"), [](const dnsdist::DNSPacketOverlay& overlay) { return overlay.d_header; });
luaCtx.registerFunction<uint16_t (dnsdist::DNSPacketOverlay::*)(uint8_t) const>("getRecordsCountInSection", [](const dnsdist::DNSPacketOverlay& overlay, uint8_t section) -> uint16_t {
- if (section > 3) {
+ if (section > DNSResourceRecord::ADDITIONAL) {
return 0;
}
uint16_t count = 0;
bool dnsdist_ffi_dnspacket_parse(const char* packet, size_t packetSize, dnsdist_ffi_dnspacket_t** out)
{
- if (out == nullptr || packetSize < sizeof(dnsheader)) {
+ if (packet == nullptr || out == nullptr || packetSize < sizeof(dnsheader)) {
return false;
}
uint16_t dnsdist_ffi_dnspacket_get_records_count_in_section(const dnsdist_ffi_dnspacket_t* packet, uint8_t section)
{
- if (packet == nullptr || section > 3) {
+ if (packet == nullptr || section > DNSResourceRecord::ADDITIONAL) {
return 0;
}
print(overlay.qname)
print(overlay.qtype)
print(overlay.qclass)
- local count = overlay:getRecordsCountInSection(1)
+ local count = overlay:getRecordsCountInSection(DNSSection.Answer)
print(count)
for idx=0, count-1 do
local record = overlay:getRecord(idx)
.. method:: DNSPacketOverlay:getRecordsCountInSection(section) -> int
Returns the number of records in the ANSWER (1), AUTHORITY (2) and
- ADDITIONAL (3) section of this packet. The number of records in the
+ ADDITIONAL (3) :ref:`DNSSection` of this packet. The number of records in the
QUESTION (0) is always set to 0, look at the dnsheader if you need
the actual qdcount.