static void ippool_action_print(REQUEST *request, ippool_action_t action, fr_log_lvl_t lvl, uint8_t const *key_prefix, size_t key_prefix_len, char const *ip_str, uint8_t const *device_id, size_t device_id_len, uint8_t const *gateway_id, size_t gateway_id_len, uint32_t expires) { char *key_prefix_str, *device_str = NULL, *gateway_str = NULL; key_prefix_str = fr_asprint(request, (char const *)key_prefix, key_prefix_len, '"'); if (gateway_id) gateway_str = fr_asprint(request, (char const *)gateway_id, gateway_id_len, '"'); if (device_id) device_str = fr_asprint(request, (char const *)device_id, device_id_len, '"'); switch (action) { case POOL_ACTION_ALLOCATE: RDEBUGX(lvl, "Allocating lease from pool \"%s\"%s%s%s%s%s%s, expires in %us", key_prefix_str, device_str ? ", to \"" : "", device_str ? device_str : "", device_str ? "\"" : "", gateway_str ? ", on \"" : "", gateway_str ? gateway_str : "", gateway_str ? "\"" : "", expires); break; case POOL_ACTION_UPDATE: RDEBUGX(lvl, "Updating %s in pool \"%s\"%s%s%s%s%s%s, expires in %us", ip_str, key_prefix_str, device_str ? ", device \"" : "", device_str ? device_str : "", device_str ? "\"" : "", gateway_str ? ", gateway \"" : "", gateway_str ? gateway_str : "", gateway_str ? "\"" : "", expires); break; case POOL_ACTION_RELEASE: RDEBUGX(lvl, "Releasing %s%s%s%s to pool \"%s\"", ip_str, device_str ? " leased by \"" : "", device_str ? device_str : "", device_str ? "\"" : "", key_prefix_str); break; default: break; } /* * Ordering is important, needs to be LIFO * for proper talloc pool re-use. */ talloc_free(key_prefix_str); talloc_free(device_str); talloc_free(gateway_str); }
/** Print a list of valuepairs to the request list. * * @param[in] level Debug level (1-4). * @param[in] request to read logging params from. * @param[in] vp to print. */ void rdebug_pair_list(int level, REQUEST *request, VALUE_PAIR *vp) { vp_cursor_t cursor; char buffer[256]; if (!vp || !request || !request->log.func) return; if (!radlog_debug_enabled(L_DBG, level, request)) return; for (vp = fr_cursor_init(&cursor, &vp); vp; vp = fr_cursor_next(&cursor)) { /* * Take this opportunity to verify all the VALUE_PAIRs are still valid. */ if (!talloc_get_type(vp, VALUE_PAIR)) { REDEBUG("Expected VALUE_PAIR pointer got \"%s\"", talloc_get_name(vp)); fr_log_talloc_report(vp); rad_assert(0); } vp_prints(buffer, sizeof(buffer), vp); RDEBUGX(level, "\t%s", buffer); } }
/** Print the response data in a useful treelike form * * @param lvl to print data at. * @param reply to print. * @param request The current request. * @param idx Response number. */ void fr_redis_reply_print(fr_log_lvl_t lvl, redisReply *reply, REQUEST *request, int idx) { size_t i = 0; if (!reply) return; switch (reply->type) { case REDIS_REPLY_ERROR: REDEBUG("(%i) error : %s", idx, reply->str); break; case REDIS_REPLY_STATUS: RDEBUGX(lvl, "(%i) status : %s", idx, reply->str); break; case REDIS_REPLY_STRING: RDEBUGX(lvl, "(%i) string : %s", idx, reply->str); break; case REDIS_REPLY_INTEGER: RDEBUGX(lvl, "(%i) integer : %lld", idx, reply->integer); break; case REDIS_REPLY_NIL: RDEBUGX(lvl, "(%i) nil", idx); break; case REDIS_REPLY_ARRAY: RDEBUGX(lvl, "(%i) array[%zu]", idx, reply->elements); for (i = 0; i < reply->elements; i++) { RINDENT(); fr_redis_reply_print(lvl, reply->element[i], request, i); REXDENT(); } break; } }
/** Print a list of VALUE_PAIRs. * * @param[in] lvl Debug lvl (1-4). * @param[in] request to read logging params from. * @param[in] vp to print. * @param[in] prefix (optional). */ void log_request_pair_list(fr_log_lvl_t lvl, REQUEST *request, VALUE_PAIR *vp, char const *prefix) { fr_cursor_t cursor; if (!vp || !request || !request->log.dst) return; if (!log_debug_enabled(L_DBG, lvl, request)) return; RINDENT(); for (vp = fr_cursor_init(&cursor, &vp); vp; vp = fr_cursor_next(&cursor)) { VP_VERIFY(vp); RDEBUGX(lvl, "%s%pP", prefix ? prefix : "&", vp); } REXDENT(); }