Skip to content

Commit 5758427

Browse files
committed
- Fix testbound test program to accurately output packets from hex.
1 parent 4f12148 commit 5758427

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

doc/Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1 August 2025: Wouter
2+
- Fix testbound test program to accurately output packets from hex.
3+
14
28 July 2025: Wouter
25
- Fix redis cachedb module gettimeofday init failure.
36

testcode/fake_event.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ delete_replay_answer(struct replay_answer* a)
188188
free(a);
189189
}
190190

191+
/** Log the packet for a reply_packet from testpkts. */
192+
static void
193+
log_testpkt_reply_pkt(const char* txt, struct reply_packet* reppkt)
194+
{
195+
if(!reppkt) {
196+
log_info("%s <null>", txt);
197+
return;
198+
}
199+
if(reppkt->reply_from_hex) {
200+
log_pkt(txt, sldns_buffer_begin(reppkt->reply_from_hex),
201+
sldns_buffer_limit(reppkt->reply_from_hex));
202+
return;
203+
}
204+
log_pkt(txt, reppkt->reply_pkt, reppkt->reply_len);
205+
}
206+
191207
/**
192208
* return: true if pending query matches the now event.
193209
*/
@@ -240,9 +256,8 @@ pending_find_match(struct replay_runtime* runtime, struct entry** entry,
240256
p->start_step, p->end_step, (*entry)->lineno);
241257
if(p->addrlen != 0)
242258
log_addr(0, "matched ip", &p->addr, p->addrlen);
243-
log_pkt("matched pkt: ",
244-
(*entry)->reply_list->reply_pkt,
245-
(*entry)->reply_list->reply_len);
259+
log_testpkt_reply_pkt("matched pkt: ",
260+
(*entry)->reply_list);
246261
return 1;
247262
}
248263
p = p->next_range;
@@ -330,7 +345,7 @@ fill_buffer_with_reply(sldns_buffer* buffer, struct entry* entry, uint8_t* q,
330345
while(reppkt && i--)
331346
reppkt = reppkt->next;
332347
if(!reppkt) fatal_exit("extra packet read from TCP stream but none is available");
333-
log_pkt("extra_packet ", reppkt->reply_pkt, reppkt->reply_len);
348+
log_testpkt_reply_pkt("extra packet ", reppkt);
334349
}
335350
if(reppkt->reply_from_hex) {
336351
c = sldns_buffer_begin(reppkt->reply_from_hex);
@@ -462,8 +477,7 @@ fake_front_query(struct replay_runtime* runtime, struct replay_moment *todo)
462477
repinfo.c->type = comm_udp;
463478
fill_buffer_with_reply(repinfo.c->buffer, todo->match, NULL, 0, 0);
464479
log_info("testbound: incoming QUERY");
465-
log_pkt("query pkt", todo->match->reply_list->reply_pkt,
466-
todo->match->reply_list->reply_len);
480+
log_testpkt_reply_pkt("query pkt ", todo->match->reply_list);
467481
/* call the callback for incoming queries */
468482
if((*runtime->callback_query)(repinfo.c, runtime->cb_arg,
469483
NETEVENT_NOERROR, &repinfo)) {

0 commit comments

Comments
 (0)