From 7ef12be818da3784f2dfd78742b46392cc95a354 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 13 Jan 2016 17:20:37 -0500 Subject: [PATCH] Allow setting of Response-Packet-Type in Post-Proxy-Type fail which lets you "invent" responses when the home server times out --- src/main/process.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/process.c b/src/main/process.c index ff466051779..d3c44dbe802 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -2395,7 +2395,7 @@ static int process_proxy_reply(REQUEST *request, RADIUS_PACKET *reply) } #ifdef WITH_COA - if (request->packet->code == request->proxy->code) + if (request->packet->code == request->proxy->code) { /* * Don't run the next bit if we originated a CoA * packet, after receiving an Access-Request or @@ -2403,21 +2403,31 @@ static int process_proxy_reply(REQUEST *request, RADIUS_PACKET *reply) */ #endif - /* - * There may NOT be a proxy reply, as we may be - * running Post-Proxy-Type = Fail. - */ - if (reply) { - fr_pair_add(&request->reply->vps, fr_pair_list_copy(request->reply, reply->vps)); - /* - * Delete the Proxy-State Attributes from - * the reply. These include Proxy-State - * attributes from us and remote server. + * There may NOT be a proxy reply, as we may be + * running Post-Proxy-Type = Fail. */ - fr_pair_delete_by_num(&request->reply->vps, PW_PROXY_STATE, 0, TAG_ANY); - } + if (reply) { + fr_pair_add(&request->reply->vps, fr_pair_list_copy(request->reply, reply->vps)); + + /* + * Delete the Proxy-State Attributes from + * the reply. These include Proxy-State + * attributes from us and remote server. + */ + fr_pair_delete_by_num(&request->reply->vps, PW_PROXY_STATE, 0, TAG_ANY); + } else { + vp = fr_pair_find_by_num(request->config, PW_RESPONSE_PACKET_TYPE, 0, TAG_ANY); + if (vp) { + request->proxy_reply = rad_alloc_reply(request, request->proxy); + request->proxy_reply->code = vp->vp_integer; + fr_pair_delete_by_num(&request->config, PW_RESPONSE_PACKET_TYPE, 0, TAG_ANY); + } + } +#ifdef WITH_COA + } +#endif switch (rcode) { default: /* Don't do anything */ break; -- 2.47.3