From: W.C.A. Wijngaards Date: Fri, 1 Aug 2025 08:34:12 +0000 (+0200) Subject: - Fix testbound test program to accurately output packets from hex. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=HEAD;p=thirdparty%2Funbound.git - Fix testbound test program to accurately output packets from hex. --- diff --git a/doc/Changelog b/doc/Changelog index 10b5d95d8..883920b77 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +1 August 2025: Wouter + - Fix testbound test program to accurately output packets from hex. + 28 July 2025: Wouter - Fix redis cachedb module gettimeofday init failure. diff --git a/testcode/fake_event.c b/testcode/fake_event.c index ea05ea1ed..ce439edd1 100644 --- a/testcode/fake_event.c +++ b/testcode/fake_event.c @@ -188,6 +188,22 @@ delete_replay_answer(struct replay_answer* a) 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 ", 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. */ @@ -240,9 +256,8 @@ pending_find_match(struct replay_runtime* runtime, struct entry** entry, 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; @@ -330,7 +345,7 @@ fill_buffer_with_reply(sldns_buffer* buffer, struct entry* entry, uint8_t* q, 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); @@ -462,8 +477,7 @@ fake_front_query(struct replay_runtime* runtime, struct replay_moment *todo) 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)) {