dns: improve handling of tx pick up on response

pull/2001/head
Victor Julien 10 years ago
parent c2f0f82bb4
commit 167d94efff

@ -277,27 +277,29 @@ static int DNSUDPResponseParse(Flow *f, void *dstate,
} }
} }
/* parse rcode, e.g. "noerror" or "nxdomain" */ /* if we previously didn't have a tx, it could have been created by the
uint8_t rcode = ntohs(dns_header->flags) & 0x0F; * above code, so lets check again */
if (rcode <= DNS_RCODE_NOTZONE) { if (tx == NULL) {
SCLogDebug("rcode %u", rcode); tx = DNSTransactionFindByTxId(dns_state, ntohs(dns_header->tx_id));
if (tx != NULL)
tx->rcode = rcode;
} else {
/* this is not invalid, rcodes can be user defined */
SCLogDebug("unexpected DNS rcode %u", rcode);
} }
if (tx != NULL) {
/* parse rcode, e.g. "noerror" or "nxdomain" */
uint8_t rcode = ntohs(dns_header->flags) & 0x0F;
if (rcode <= DNS_RCODE_NOTZONE) {
SCLogDebug("rcode %u", rcode);
tx->rcode = rcode;
} else {
/* this is not invalid, rcodes can be user defined */
SCLogDebug("unexpected DNS rcode %u", rcode);
}
if (ntohs(dns_header->flags) & 0x0080) { if (ntohs(dns_header->flags) & 0x0080) {
SCLogDebug("recursion desired"); SCLogDebug("recursion desired");
if (tx != NULL)
tx->recursion_desired = 1; tx->recursion_desired = 1;
} }
if (tx != NULL) {
tx->replied = 1; tx->replied = 1;
} }
SCReturnInt(1); SCReturnInt(1);
bad_data: bad_data:

Loading…
Cancel
Save