Enable building #WITHOUT_PROXY
[freeradius.git] / src / modules / rlm_detail / rlm_detail.c
index 685fa72..6446359 100644 (file)
@@ -26,6 +26,7 @@ RCSID("$Id$")
 #include       <freeradius-devel/radiusd.h>
 #include       <freeradius-devel/modules.h>
 #include       <freeradius-devel/rad_assert.h>
+#include       <freeradius-devel/detail.h>
 
 #include       <sys/stat.h>
 #include       <ctype.h>
@@ -33,62 +34,6 @@ RCSID("$Id$")
 
 #define        DIRLEN  8192
 
-static const char *packet_codes[] = {
-  "",
-  "Access-Request",
-  "Access-Accept",
-  "Access-Reject",
-  "Accounting-Request",
-  "Accounting-Response",
-  "Accounting-Status",
-  "Password-Request",
-  "Password-Accept",
-  "Password-Reject",
-  "Accounting-Message",
-  "Access-Challenge"
-  "Status-Server",
-  "Status-Client",
-  "14",
-  "15",
-  "16",
-  "17",
-  "18",
-  "19",
-  "20",
-  "Resource-Free-Request",
-  "Resource-Free-Response",
-  "Resource-Query-Request",
-  "Resource-Query-Response",
-  "Alternate-Resource-Reclaim-Request",
-  "NAS-Reboot-Request",
-  "NAS-Reboot-Response",
-  "28",
-  "Next-Passcode",
-  "New-Pin",
-  "Terminate-Session",
-  "Password-Expired",
-  "Event-Request",
-  "Event-Response",
-  "35",
-  "36",
-  "37",
-  "38",
-  "39",
-  "Disconnect-Request",
-  "Disconnect-ACK",
-  "Disconnect-NAK",
-  "CoA-Request",
-  "CoA-ACK",
-  "CoA-NAK",
-  "46",
-  "47",
-  "48",
-  "49",
-  "IP-Address-Allocate",
-  "IP-Address-Release"
-};
-
-
 struct detail_instance {
        /* detail file */
        char *detailfile;
@@ -400,9 +345,9 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                 *      Numbers, if not.
                 */
                if ((packet->code > 0) &&
-                   (packet->code < 52)) {
+                   (packet->code < FR_MAX_PACKET_CODE)) {
                        fprintf(outfp, "\tPacket-Type = %s\n",
-                               packet_codes[packet->code]);
+                               fr_packet_codes[packet->code]);
                } else {
                        fprintf(outfp, "\tPacket-Type = %d\n", packet->code);
                }
@@ -487,6 +432,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
         *      Add non-protocol attibutes.
         */
        if (compat) {
+#ifdef WITH_PROXY
                if (request->proxy) {
                        char proxy_buffer[128];
 
@@ -498,6 +444,7 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
                                RDEBUG("Freeradius-Proxied-To = %s",
                                      proxy_buffer);
                }
+#endif
 
                fprintf(outfp, "\tTimestamp = %ld\n",
                        (unsigned long) request->timestamp);
@@ -531,7 +478,9 @@ static int do_detail(void *instance, REQUEST *request, RADIUS_PACKET *packet,
  */
 static int detail_accounting(void *instance, REQUEST *request)
 {
-       if (request->listener->type == RAD_LISTEN_DETAIL) {
+       if (request->listener->type == RAD_LISTEN_DETAIL &&
+           strcmp(((struct detail_instance *)instance)->detailfile,
+                  ((listen_detail_t *)request->listener->data)->filename) == 0) {
                RDEBUG("Suppressing writes to detail file as the request was just read from a detail file.");
                return RLM_MODULE_NOOP;
        }
@@ -576,6 +525,7 @@ static int detail_send_coa(void *instance, REQUEST *request)
 /*
  *     Outgoing Access-Request to home server - write the detail files.
  */
+#ifdef WITH_PROXY
 static int detail_pre_proxy(void *instance, REQUEST *request)
 {
        if (request->proxy &&
@@ -616,6 +566,7 @@ static int detail_post_proxy(void *instance, REQUEST *request)
 
        return RLM_MODULE_NOOP;
 }
+#endif
 
 
 /* globally exported name */
@@ -631,8 +582,12 @@ module_t rlm_detail = {
                NULL,                   /* preaccounting */
                detail_accounting,      /* accounting */
                NULL,                   /* checksimul */
+#ifdef WITH_PROXY
                detail_pre_proxy,       /* pre-proxy */
                detail_post_proxy,      /* post-proxy */
+#else
+               NULL, NULL,
+#endif
                detail_postauth         /* post-auth */
 #ifdef WITH_COA
                , detail_recv_coa,