2
2
* acct.c Accounting routines.
4
* Version: $Id: acct.c,v 1.30.2.2 2005/07/11 13:47:45 nbk Exp $
4
* Version: $Id: acct.c,v 1.30.2.4 2005/10/31 17:34:04 nbk Exp $
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
23
23
* Copyright 2000 Alan Curry <pacman@world.std.com>
26
static const char rcsid[] = "$Id: acct.c,v 1.30.2.2 2005/07/11 13:47:45 nbk Exp $";
26
static const char rcsid[] = "$Id: acct.c,v 1.30.2.4 2005/10/31 17:34:04 nbk Exp $";
28
28
#include "autoconf.h"
29
#include "libradius.h"
31
30
#include <stdlib.h>
34
32
#include "radiusd.h"
35
33
#include "modules.h"
39
36
* rad_accounting: call modules.
44
41
int rad_accounting(REQUEST *request)
46
int reply = RLM_MODULE_OK;
43
int result = RLM_MODULE_OK;
48
if (!request->proxy) { /* Only need to do this once, before proxying */
46
* Run the modules only once, before proxying.
48
if (!request->proxy) {
49
49
char *exec_program;
55
reply = module_preacct(request);
56
if (reply != RLM_MODULE_NOOP &&
57
reply != RLM_MODULE_OK &&
58
reply != RLM_MODULE_UPDATED)
55
result = module_preacct(request);
58
* The module has a number of OK return codes.
62
case RLM_MODULE_UPDATED:
65
* The module handled the request, stop here.
67
case RLM_MODULE_HANDLED:
70
* The module failed, or said the request is
71
* invalid, therefore we stop here.
74
case RLM_MODULE_INVALID:
75
case RLM_MODULE_NOTFOUND:
76
case RLM_MODULE_REJECT:
77
case RLM_MODULE_USERLOCK:
62
* Do accounting, ONLY the first time through.
63
* This is to ensure that we log the packet
64
* immediately, even if the proxy never does.
83
* Do the data storage before proxying. This is to ensure
84
* that we log the packet, even if the proxy never does.
66
86
vp = pairfind(request->config_items, PW_ACCT_TYPE);
88
DEBUG2(" Found Acct-Type %s", vp->strvalue);
68
89
acct_type = vp->lvalue;
69
reply = module_accounting(acct_type,request);
91
result = module_accounting(acct_type, request);
94
* In case the accounting module returns FAIL,
95
* it's still useful to send the data to the
101
case RLM_MODULE_UPDATED:
104
* The module handled the request, don't reply.
106
case RLM_MODULE_HANDLED:
109
* Neither proxy, nor reply to invalid requests.
111
case RLM_MODULE_INVALID:
112
case RLM_MODULE_NOTFOUND:
113
case RLM_MODULE_REJECT:
114
case RLM_MODULE_USERLOCK:
72
120
* See if we need to execute a program.
157
206
* storage did not succeed, so radiusd should not send
158
207
* Accounting-Response.
160
if (reply == RLM_MODULE_OK ||
161
reply == RLM_MODULE_UPDATED) {
164
* Now send back an ACK to the NAS.
166
request->reply->code = PW_ACCOUNTING_RESPONSE;
211
* Send back an ACK to the NAS.
214
case RLM_MODULE_UPDATED:
215
request->reply->code = PW_ACCOUNTING_RESPONSE;
218
* The module handled the request, don't reply.
220
case RLM_MODULE_HANDLED:
223
* Failed to log or to proxy the accounting data,
224
* therefore don't reply to the NAS.
226
case RLM_MODULE_FAIL:
227
case RLM_MODULE_INVALID:
228
case RLM_MODULE_NOOP:
229
case RLM_MODULE_NOTFOUND:
230
case RLM_MODULE_REJECT:
231
case RLM_MODULE_USERLOCK: