[prev in list] [next in list] [prev in thread] [next in thread]
List: freeradius-users
Subject: =?utf-8?B?UmU6IE1vZHVsZSBTdGF0aXN0aWNzIGluIGZyZWVyYWRpdXM=?=
From: "Himanshu Pandey" <pandey_himanshu80 () rediffmail ! com>
Date: 2014-09-27 13:41:10
Message-ID: 1411755198.S.8005.25675.F.H.TkFsYW4gRGVLb2sAUmU6IE1vZHVsZSBTdGF0aXN0aWNzIGluIGZyZWVyYWRpdXM_.RU.rfs310, rfs310, 829,
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Dear Alan,
I have completed my coding to achieve my task. I tried my best not to disturb much of \
the server code. Here is my code snippet. I request you to suggest me If my \
added code is correct or wrong. Also, suggest me if there is any other best way to \
achieve this or you think my added can be optimized more.
/* Structure */
/** Return codes indicating the result of the module call
* *
* * All module functions must return one of the codes listed \
below (apart from * * RLM_MODULE_NUMCODES, which is used to \
check for validity). * */
typedef enum rlm_rcodes {
RLM_MODULE_REJECT = 0, //!< \
Immediately reject the request. \
RLM_MODULE_FAIL, \
//!< Module failed, don't reply. \
RLM_MODULE_OK, \
//!< The module is OK, continue. \
RLM_MODULE_HANDLED, //!< The module handled the request, so \
stop. \
RLM_MODULE_INVALID, //!< The module considers \
the request invalid. \
RLM_MODULE_USERLOCK, //!< Reject the request (user is locked out). \
RLM_MODULE_NOTFOUND, \
//!< User not found. \
RLM_MODULE_NOOP, //!< \
Module succeeded without doing anything. \
RLM_MODULE_UPDATED, //!< OK (pairs modified). \
RLM_MODULE_NUMCODES, //!< How \
many valid return codes there are. \
RLM_MODULE_UNKNOWN //!< Error resolving rcode \
(should not be   \
; & \
nbsp; \
//!< returned by modules). } rlm_rcode_t;
typedef struct module_t {
\
uint64_t \
magic; \
//!< Used to validate module struct. \
char const \
*name; \
//!< The name of the module (without rlm_ prefix). \
\
int \
type; \
//!< One or more of the RLM_TYPE_* constants. \
\
size_t \
inst_size; //!< \
Size of the instance data CONF_PARSER \
const \
*config; \
//!< Configuration information \
instantiate_t \
instantiate; \
//!< Function to use for instantiation. \
detach_t \
detach; \
//!< Function to use to free module instance. \
\
packetmethod \
methods[RLM_COMPONENT_COUNT]; //!< Pointers to the various \
section \
\
\
\
\
\
\
//functions, ordering \
&n \
bsp; &nbs \
p; \
\
//!< determines which function is mapped \
\
\
\
\
\
\
//to &n! \
bsp; &nbs \
p; \
& \
nbsp; &nb \
sp;   \
; \
//!< which section \
\
\
\
\
\
\
 !
;   \
; & \
nbsp; &nb \
sp;   \
; & \
nbsp; &nb \
sp;   \
; & \
nbsp; &nb \
sp;   \
; &nb!
sp; &
nbsp; \
\
uint64_t \
rtcode[RLM_MODULE_NUMCODES]; //Used for module return \
codes \
} module_t;
Now in function: modcall_recurse() I added
modcall_recurse() {
rlm_rcode_t result;
module_t const *module;
result = call_modsingle(c->method, sp, request);
module->rtcode[result] = module->rtcode[result] + 1;
}
Also, in radius.c in function main I will use memset to initialize my rtcode array to \
zero. will add this statement:
memset(module->rtcode,0,sizeof(module->rtcode));
Regards,
Sonu
From: Alan DeKok <aland@deployingradius.com>
Sent: Fri, 26 Sep 2014 23:43:18
To: FreeRadius users mailing list <freeradius-users@lists.freeradius.org>
Subject: Re: Module Statistics in freeradius
Himanshu Pandey wrote:
> But as we discussed, the server does NOT keep track of statistics for
> each module return codes.
Yes... I've said that repeatedly. Perhaps you could repeat it some
more, to be sure that I understand how the server works?
> The very first thing that I did was finding out the basic module
> structure in freeradius, if I am not wrong this is the basic module
> structure used:
Yes.
> Now I added an unsigned long array in this structure in which module
> return code act as an index. Please see the snippet below:
That's not a good idea. For one, the module return codes are already
in a typedef. Just use that one. There's no reason to create a new one.
And "unsigned long" isn't used anywhere else in the server. Just use
"uint64_t".
> Please advice me that how should I update this my unsigned long
> rtcode[RLM_RETCODE_COUNT] array with each module return code.
Use C code to increment the array entry. See modcall.c, \
call_modsingle().
Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
[Attachment #5 (unknown)]
Dear Alan,<br><br>I have completed my coding to achieve my task. I tried my best not \
to disturb much of the server code. Here is my code snippet. I request you to suggest \
me If my added code is correct or wrong. Also, suggest me if there is any other \
best way to achieve this or you think my added can be optimized more.<br><br>/* \
Structure */<br><br>/** Return codes indicating the result of \
the module call<br> * *<br> * * All module \
functions must return one of the codes listed below (apart \
from<br> * * RLM_MODULE_NUMCODES, which is used to check for \
validity).<br> * */<br>typedef enum rlm_rcodes \
{<br> RLM_MODULE_REJECT = 0, //!< \
Immediately reject the request.<br> \
RLM_MODULE_FAIL, \
//!< Module failed, don't reply.<br> \
RLM_MODULE_OK, \
//!< The module is OK, continue.<br> \
RLM_MODULE_HANDLED, //!< The module handled the request, so \
stop.<br> \
RLM_MODULE_INVALID, //!< The module considers \
the request invalid.<br> \
RLM_MODULE_USERLOCK, //!< Reject the request (user is locked \
out).<br> \
RLM_MODULE_NOTFOUND, //!< User not \
found.<br> \
RLM_MODULE_NOOP, //!< \
Module succeeded without doing \
anything.<br> \
RLM_MODULE_UPDATED, //!< OK (pairs \
modified).<br> RLM_MODULE_NUMCODES, \
//!< How many valid return codes there \
are.<br> \
RLM_MODULE_UNKNOWN //!< Error resolving rcode \
(should not be<br> &n \
bsp; &nbs \
p; \
//!< returned by modules).<br>} rlm_rcode_t;<br><br>typedef struct module_t \
{<br> \
uint64_t \
magic; \
//!< Used to validate module struct.<br> \
char const \
*name; \
//!< The name of the module (without rlm_ \
prefix).<br> \
int \
type; \
//!< One or more of the RLM_TYPE_* \
constants.<br> \
size_t \
inst_size; //!< \
Size of the instance data<br> CONF_PARSER \
const \
*config; \
//!< Configuration information<br> \
instantiate_t \
instantiate; \
//!< Function to use for \
instantiation.<br> \
detach_t \
detach; \
//!< Function to use to free module \
instance.<br> \
packetmethod \
methods[RLM_COMPONENT_COUNT]; //!< Pointers to the various \
section <span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
//</span><span></span>functions, \
ordering<br> &n \
bsp; &nbs \
p; \
\
//!< determines which function is mapped <span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> \
</span>//to &nb \
sp;   \
; \
<br> &nbs \
p; \
&n \
bsp; \
//!< which section <span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> </span><span> \
</span><span> \
</span> & \
nbsp; &nb \
sp;   \
; & \
nbsp; &nb \
sp;   \
; & \
nbsp; &nb \
sp;   \
; & \
nbsp; &nb \
sp;   \
; & \
nbsp; \
<br> \
<b>uint64_t \
rtcode[RLM_MODULE_NUMCODES]; //Used for module return \
codes</b> \
<br>} module_t;<br><br>Now in function: modcall_recurse() I \
added<br><br>modcall_recurse() {<br><br>rlm_rcode_t result;<br><b>module_t const \
*module;</b><br><br>result = call_modsingle(c->method, sp, \
request);<br><b>module->rtcode[result] = module->rtcode[result] + \
1;</b><br>} <br><br>Also, in radius.c in function main I will use memset to \
initialize my rtcode array to zero.<br>will add this \
statement:<br><br><b>memset(module->rtcode,0,sizeof(module->rtcode));<br></b><br>Regards,<br>Sonu<br><br><br>From: \
Alan DeKok <aland@deployingradius.com><br>Sent: Fri, 26 Sep 2014 23:43:18 \
<br>To: FreeRadius users mailing list \
<freeradius-users@lists.freeradius.org><br>Subject: Re: Module Statistics in \
freeradius<br>Himanshu Pandey wrote:<br> > But as we discussed, the server does \
NOT keep track of statistics for<br> > each module return codes.<br>
<br>
Yes... I've said that repeatedly. Perhaps you could repeat it some<br>
more, to be sure that I understand how the server works?<br>
<br>
> The very first thing that I did was finding out the basic module<br>
> structure in freeradius, if I am not wrong this is the basic module<br>
> structure used:<br>
<br>
Yes.<br>
<br>
> Now I added an unsigned long array in this structure in which module<br>
> return code act as an index. Please see the snippet below:<br>
<br>
That's not a good idea. For one, the module return codes are already<br>
in a typedef. Just use that one. There's no reason to create a new \
one.<br> <br>
And "unsigned long" isn't used anywhere else in the server. Just use<br>
"uint64_t".<br>
<br>
> Please advice me that how should I update this my unsigned long<br>
> rtcode[RLM_RETCODE_COUNT] array with each module return code.<br>
<br>
Use C code to increment the array entry. See modcall.c, \
call_modsingle().<br> <br>
Alan DeKok.<br>
-<br>
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html<br>
<br><A HREF="http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?" \
target="_blank"><IMG \
SRC="http://sigads.rediff.com/RealMedia/ads/adstream_nx.ads/www.rediffmail.com/signatureline.htm@Middle"></A><table \
cellpadding="0" cellspacing="0"><tbody><tr><td><div style="font-family: Arial, \
Helvetica, sans-serif; font-size:14px">Get your own <span style="padding-bottom: 0px; \
background-color: #cc0000; padding-left: 3px; padding-RIGHT: 3px; font-family: Arial, \
Helvetica, sans-serif; color: #ffffff; font-size: 12px; padding-top: \
0px"><b>FREE</b></span> website, <span style="padding-bottom: 0px; background-color: \
#c00; padding-left: 3px; padding-RIGHT: 3px; font-family: Arial, Helvetica, \
sans-serif; color: #ffffff; font-size: 12px; padding-top: 0px"><b>FREE</b></span> \
domain & <span style="padding-bottom: 0px; background-color: #c00; padding-left: \
3px; padding-RIGHT: 3px; font-family: Arial, Helvetica, sans-serif; color: #ffffff; \
font-size: 12px; padding-top: 0px"><b>FREE</b></span> mobile app with Company email. \
</div></td><td><a \
href="http://track.rediff.com/click?url=___http://businessemail.rediff.com/email-ids-f \
or-companies-with-less-than-50-employees?sc_cid=sign-1-10-13___&cmp=host&lnk=sign-1-10-13&nsrv1=host" \
style="font-family: Arial, Helvetica, sans-serif; color: #fff; font-size: 14px; \
color:#0000cc" target="_blank"><b>Know More ></b></a><!-- <in-put type="button" \
cl-ass="button" on-click="parent.location='http://track.rediff.com/click?url=___ht \
tp://businessemail.rediff.com/company-email-hosting-services?sc_cid=signature-23-9-13___&cmp=signature-23-9-13&lnk=mypagelogout&nsrv1=host'" \
value="Know more >"> </input> --></td></tr></tbody></table>
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic