Sorry I needed the libc for some other things ( I also created a new c++-Class which i called inside my Module )<br><br>No the _t did not have any special significance in C++ I only followed the convetion!<br><br><br>Here also is my rlm_cpp.cpp Module<br>
<br><br>#define operator op3578000<br>#define template tem34123<br><br>extern "C" {<br> #include <freeradius-devel/ident.h><br> #include <stdio.h><br> #include <stdlib.h><br> #include <string.h><br>
RCSID("$Id$") <br> #include <freeradius-devel/radiusd.h><br> #include <freeradius-devel/modules.h><br><br> <br>typedef struct rlm_cpp_t {<br> int boolean;<br> int value;<br>
char *string;<br> uint32_t ipaddr;<br>} rlm_cpp_t;<br><br><br><br>extern "C" <br>const CONF_PARSER module_config[] = {<br> { "integer", PW_TYPE_INTEGER, offsetof(rlm_cpp_t,value), NULL, "1" },<br>
{ "boolean", PW_TYPE_BOOLEAN, offsetof(rlm_cpp_t,boolean), NULL, "no"},<br> { "string", PW_TYPE_STRING_PTR, offsetof(rlm_cpp_t,string), NULL, NULL},<br> { "ipaddr", PW_TYPE_IPADDR, offsetof(rlm_cpp_t,ipaddr), NULL, "*"},<br>
<br><br> { NULL, -1, 0, NULL, NULL } /* end the list */<br>};<br><br><br><br><br><br>extern "C" {<br>static int cpp_instantiate(CONF_SECTION *conf, void **instance)<br>{<br> ...<br> return RLM_MODULE_OK;<br>
}<br>}<br><br><br>extern "C" {<br>static int cpp_post_auth(void *instance, REQUEST *request)<br>{ <br> VALUE_PAIR *reply;<br> VALUE_PAIR *state;<br><br> <br> ...<br><br> return RLM_MODULE_OK;<br>
}<br>}<br><br><br><br>extern "C" {<br>static int cpp_preacct(void *instance, REQUEST *request)<br>{<br> /* quiet the compiler */<br> instance = instance;<br> request = request; <br> <br> ...<br>
<br> return RLM_MODULE_OK;<br>}<br>}<br><br><br>extern "C" {<br>static int cpp_authorize(void *instance, REQUEST *request)<br>{<br> /* quiet the compiler */<br> instance = instance;<br> request = request; <br>
<br> ...<br><br> return RLM_MODULE_OK; <br>}<br>}<br><br><br><br><br><br>extern "C" {<br>module_t rlm_cpp = {<br> RLM_MODULE_INIT,<br> "cpp",<br> RLM_TYPE_THREAD_SAFE, /* type */<br>
cpp_instantiate, /* instantiation */<br> NULL, /* detach */<br> {<br> NULL, /* authentication */<br> cpp_authorize, /* authorization */<br>
cpp_preacct, /* preaccounting */<br> NULL, /* accounting */<br> NULL, /* checksimul */<br> NULL, /* pre-proxy */<br> NULL, /* post-proxy */<br>
cpp_post_auth /* post-auth */<br> },<br>};<br>} <br><br><br><br><br><div class="gmail_quote">2013/3/11 Arran Cudbard-Bell <span dir="ltr"><<a href="mailto:a.cudbardb@freeradius.org" target="_blank">a.cudbardb@freeradius.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">><br>
> • Creating an new Directory in the modules Directory<br>
<div class="im">> I created an new Directory named "rlm_cpp" where I putted an Makefile and my rlm_cpp.cpp File<br>
><br>
><br>
> Makefile:<br>
><br>
> TARGET = rlm_cpp<br>
> SRCS = rlm_cpp.cpp<br>
> HEADERS =<br>
> RLM_CFLAGS = -I/usr/include<br>
> RLM_LIBS = -lc<br>
> RLM_INSTALL = install-example<br>
<br>
</div>You have to link to libc explicitly?<br>
<div class="im"><br>
> My outgoing rlm_cpp.cpp File was the *.c File I took.<br>
> Then I need to change every function of this file like this:<br>
><br>
> extern "C" {<br>
> static int cpp_authorize(void *instance, REQUEST *request)<br>
> {<br>
> ...<br>
> }<br>
> }<br>
<br>
</div>Still not 100% sure whether this is required, my suspicion is that the module will still link and execute, but that it's probably good practice to declare the C linkages explicity.<br>
<br>
In any case I think you can just do :<br>
<div class="im"><br>
extern "C" static int cpp_authorize(void *instance, REQUEST *request)<br>
{<br>
<br>
}<br>
<br>
</div>Looks cleaner.<br>
<div class="im"><br>
><br>
> Then I added two DEFINES at the TOP of my rlm_cpp.cpp File, because the two words are reserved names in in C.<br>
><br>
> #define operator op3578000<br>
> #define template tem34123<br>
<br>
</div>You mean in C++, they're not reserved keywords in C. I already changed "op" in master, i'll have a look at template.<br>
<div class="im"><br>
> At the end I needed to change the the struct. First I changed the struct in radiusd.conf<br>
<br>
</div>radiusd.conf is a configuration file...<br>
<div class="im"><br>
> struct auth_req {<br>
> ...<br>
> home_server_t *home_server<br>
> ...<br>
> }<br>
><br>
> typedef struct radclient {<br>
> ...<br>
> home_server_t *coa_server;<br>
> ...<br>
> } RADCLIENT;<br>
><br>
> Also change the Typedef to:<br>
><br>
> typedef struct home_server {<br>
> ...<br>
> }home_server_t;<br>
><br>
> Every struct in the Source of FreeRadius need to be changed to home_server_t!<br>
<br>
</div>Does the _t have a special significance in C++ or did you just want to follow convention?<br>
<div class="im"><br>
> now you should made finallay the main make and see the all should be fine compiled! at the end run "make install " and implement the new C++ Module in an Section in the radiusd.conf and it will run!<br>
<br>
</div>Sure. This is nice and all, but if you want your modules in the standard distribution of FreeRADIUS it's probably better to just write them in C. The only exception would be if they dependended on an external library for which there was no C equivalent, or which did not expose a C API (the MySQL ndb client library is like this, which is why i've also been investigating).<br>
<br>
Interesting all the same. Thanks for posting the info.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Arran<br>
</font></span><div class="HOEnZb"><div class="h5">-<br>
List info/subscribe/unsubscribe? See <a href="http://www.freeradius.org/list/devel.html" target="_blank">http://www.freeradius.org/list/devel.html</a><br>
</div></div></blockquote></div><br>