@@ -188,6 +188,22 @@ delete_replay_answer(struct replay_answer* a)
188
188
free (a );
189
189
}
190
190
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
+
191
207
/**
192
208
* return: true if pending query matches the now event.
193
209
*/
@@ -240,9 +256,8 @@ pending_find_match(struct replay_runtime* runtime, struct entry** entry,
240
256
p -> start_step , p -> end_step , (* entry )-> lineno );
241
257
if (p -> addrlen != 0 )
242
258
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 );
246
261
return 1 ;
247
262
}
248
263
p = p -> next_range ;
@@ -330,7 +345,7 @@ fill_buffer_with_reply(sldns_buffer* buffer, struct entry* entry, uint8_t* q,
330
345
while (reppkt && i -- )
331
346
reppkt = reppkt -> next ;
332
347
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 );
334
349
}
335
350
if (reppkt -> reply_from_hex ) {
336
351
c = sldns_buffer_begin (reppkt -> reply_from_hex );
@@ -462,8 +477,7 @@ fake_front_query(struct replay_runtime* runtime, struct replay_moment *todo)
462
477
repinfo .c -> type = comm_udp ;
463
478
fill_buffer_with_reply (repinfo .c -> buffer , todo -> match , NULL , 0 , 0 );
464
479
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 );
467
481
/* call the callback for incoming queries */
468
482
if ((* runtime -> callback_query )(repinfo .c , runtime -> cb_arg ,
469
483
NETEVENT_NOERROR , & repinfo )) {
0 commit comments