From: Alan T. DeKok Date: Thu, 19 Jan 2023 14:40:38 +0000 (-0500) Subject: use normal APIs to print the reply packet X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35f3911ef7abb55d21d040c1fa7a6716f4a5fb1a;p=thirdparty%2Ffreeradius-server.git use normal APIs to print the reply packet and make sure that the contents all go to the same FILE* handle --- diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 595a23e9c43..80788416f23 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -294,34 +294,19 @@ static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, RADCLIENT *client static void print_packet(FILE *fp, fr_radius_packet_t *packet, fr_pair_list_t *list) { - fr_pair_t *vp; - fr_dcursor_t cursor; fr_dict_enum_value_t *dv; + fr_log_t log; - if (fr_pair_list_empty(list)) { - fprintf(fp, "\n"); - return; - } + (void) fr_log_init_fp(&log, fp); dv = fr_dict_enum_by_value(attr_packet_type, fr_box_uint32(packet->code)); - if (dv) fprintf(fp, "%s\n", dv->name); - - for (vp = fr_pair_dcursor_init(&cursor, list); - vp; - vp = fr_dcursor_next(&cursor)) { - /* - * Take this opportunity to verify all the fr_pair_ts are still valid. - */ - if (!talloc_get_type(vp, fr_pair_t)) { - ERROR("Expected fr_pair_t pointer got \"%s\"", talloc_get_name(vp)); - - fr_log_talloc_report(vp); - fr_assert(0); - } - - fr_log(&default_log, L_DBG, __FILE__, __LINE__, "%pP", vp); + if (dv) { + fr_log(&default_log, L_DBG, __FILE__, __LINE__, "Packet-Type = %s", dv->name); + } else { + fr_log(&default_log, L_DBG, __FILE__, __LINE__, "Packet-Type = %u", packet->code); } - fflush(fp); + + fr_pair_list_log(&default_log, 2, list); }