Accessing REQUEST structure data outside FreeRADIUS module
Hello and thanks for replies I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work. Code which works /***********************************************************************/ static int wcp_lt_vms_authorize(void *pt_instance, REQUEST *pt_request) { VALUE_PAIR *lpt_value_pair = NULL; ... if ((lpt_value_pair = pairfind(pt_request->packet->vps, PW_USER_NAME)) == NULL ) { WCP_DEBUG("User-Name not found !"); } else { WCP_DEBUG("RADIUS attribute name %s, value: [%s]", lpt_value_pair->name, lpt_value_pair->strvalue); } ... } /***********************************************************************/ This works fine, when the server receive a request Tue Apr 11 16:05:03 2006 : wcp_lt_vms_authorize: RADIUS attribute name User-Name, value: [330001] The problem comes when doing the same thing but by calling a function. /***********************************************************************/ static int wcp_lt_vms_authorize(void *pt_instance, REQUEST *pt_request) { ... lib_com_filter_traffic(pt_request); ... } /***********************************************************************/ and in anotherfile, lib_com.c int lib_com_filter_traffic(REQUEST *pt_request) { VALUE_PAIR *lpt_value_pair = NULL; ... if ((lpt_value_pair = pairfind(pt_request->packet->vps, PW_USER_NAME)) == NULL ) { WCP_DEBUG("User-Name not found !"); } else { WCP_DEBUG("RADIUS attribute name %s, value: [%s]", lpt_value_pair->name, lpt_value_pair->strvalue); } /***********************************************************************/ This doesn't work. when receiving one request, FreeRADIUS takes a lot of processor time and then the server crashes. Tue Apr 11 17:00:30 2006 : Error: WARNING: Unresponsive child (id 3) for request 0 I don't understand why all works when accessing REQUEST data inside the module and not in the lib function. It's like the lib can't accessed to this memory. Any help would be appreciated.
Nicolas Castel wrote:
Hello and thanks for replies
I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work.
and in anotherfile, lib_com.c
What happens when your "external" function is in the same file as your module function?
2006/4/12, Joe Maimon <jmaimon@ttec.com>:
Nicolas Castel wrote:
Hello and thanks for replies
I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work.
and in anotherfile, lib_com.c
What happens when your "external" function is in the same file as your module function?
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks for responding, When i put the function in the module all works fine too. I tried to access directly the packet field of the REQUEST structure in the function in my library and it works in this case. int lib_com_filter_traffic_bis(RADIUS_PACKET *pt_packet) { VALUE_PAIR *lpt_value_pair = NULL; if ((lpt_value_pair = pairfind(pt_packet->vps, PW_USER_NAME)) == NULL ) { WCP_DEBUG("User-Name not found !"); } else { WCP_DEBUG("RADIUS attribute name %s, value: [%s]", lpt_value_pair->name, lpt_value_pair->strvalue); } So, with the RADIUS_PACKET passed in parameter, it works fine, so why does it not work with the REQUEST parameter ? Have you any idea ? Is REQUEST address protected or else ??? I think about static function ... Thanks
Nicolas Castel wrote:
2006/4/12, Joe Maimon <jmaimon@ttec.com>:
Nicolas Castel wrote:
Hello and thanks for replies
I'm using FreeRADIUS v1.1.0. I'm developping some modules and I try to access auth_req structure (REQUEST) data from an external function (out of my module) and it fails. All works fine when accessing this data from the module itself but when i call an external function with the address of REQUEST, it doesn't work.
and in anotherfile, lib_com.c
What happens when your "external" function is in the same file as your module function?
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks for responding,
When i put the function in the module all works fine too.
Let me rewrite that: When you put the function into the same c language file as the rest of the module functions, all works fine. If that is correct, than I would suggest you are having an include file problem and/or a linking problem. If I am correct, there isnt much I can do without seeing your code other than suggest you duplicate what you do for the file that works and/or you examine other successfull built modules with multiple files and their build process. Of course, I could be very wide off the mark here.
Let me rewrite that:
When you put the function into the same c language file as the rest of the module functions, all works fine.
If that is correct, than I would suggest you are having an include file problem and/or a linking problem.
If I am correct, there isnt much I can do without seeing your code other than suggest you duplicate what you do for the file that works and/or you examine other successfull built modules with multiple files and their build process.
Of course, I could be very wide off the mark here.
I don't think it's an include problem, the compiler would have notice it. The lib is statically linked to the module, i don't think it causes problems. Here the compilation i used : gcc -D_WCP_LOG_RADLOG_ -I/home1/appdata/frad0/dev/src/include -I/appdata/frad0/freeradius-1.1.0/src/include -fPIC -DPIC -ansi -c lib_com.c -o lib_com.o ar -r lib_com.a lib_com.o rlm_wcp_lt_vms-1.1.0.so: rlm_wcp_lt_vms.o gcc -g -shared rlm_wcp_lt_vms.o -o rlm_wcp_lt_vms-1.1.0.so -lc -lpthread -L$(LIB_DIR) -lcom If it could help ... It seems correct to me The most surprising is that the lib function works fine with packet address and not with the request address itself. For the moment, i'll use the packet address as parameter but i would prefer to use request one.
participants (2)
-
Joe Maimon -
Nicolas Castel