free(a);
}
+/** Log the packet for a reply_packet from testpkts. */
+static void
+log_testpkt_reply_pkt(const char* txt, struct reply_packet* reppkt)
+{
+ if(!reppkt) {
+ log_info("%s <null>", txt);
+ return;
+ }
+ if(reppkt->reply_from_hex) {
+ log_pkt(txt, sldns_buffer_begin(reppkt->reply_from_hex),
+ sldns_buffer_limit(reppkt->reply_from_hex));
+ return;
+ }
+ log_pkt(txt, reppkt->reply_pkt, reppkt->reply_len);
+}
+
/**
* return: true if pending query matches the now event.
*/
p->start_step, p->end_step, (*entry)->lineno);
if(p->addrlen != 0)
log_addr(0, "matched ip", &p->addr, p->addrlen);
- log_pkt("matched pkt: ",
- (*entry)->reply_list->reply_pkt,
- (*entry)->reply_list->reply_len);
+ log_testpkt_reply_pkt("matched pkt: ",
+ (*entry)->reply_list);
return 1;
}
p = p->next_range;
while(reppkt && i--)
reppkt = reppkt->next;
if(!reppkt) fatal_exit("extra packet read from TCP stream but none is available");
- log_pkt("extra_packet ", reppkt->reply_pkt, reppkt->reply_len);
+ log_testpkt_reply_pkt("extra packet ", reppkt);
}
if(reppkt->reply_from_hex) {
c = sldns_buffer_begin(reppkt->reply_from_hex);
repinfo.c->type = comm_udp;
fill_buffer_with_reply(repinfo.c->buffer, todo->match, NULL, 0, 0);
log_info("testbound: incoming QUERY");
- log_pkt("query pkt", todo->match->reply_list->reply_pkt,
- todo->match->reply_list->reply_len);
+ log_testpkt_reply_pkt("query pkt ", todo->match->reply_list);
/* call the callback for incoming queries */
if((*runtime->callback_query)(repinfo.c, runtime->cb_arg,
NETEVENT_NOERROR, &repinfo)) {