<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Ruslan Shevchenko,<br>
      <br>
      I you have created an C++ Module for FreeRadius, maybe you could
      post it ?<br>
      <br>
      Greetz<br>
      Patrick<br>
      <br>
      Am 11.03.13 16:35, schrieb Ruslan Shevchenko:<br>
    </div>
    <blockquote
cite="mid:CAPkMhiW+2HhTvQrTwfHk3kxbwdKBjLj27nJS3Kn_JZnW-6gm9g@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html;
        charset=windows-1252">
      <div dir="ltr">Some time ago  I wrote C++ module for freeradius
        (to interact with billing interface)  with next approach:
        <div><br>
        </div>
        <div>1.  write special c file where freeradius API is imported,
          and API which is callable from "C++" for access to radius
          struct </div>
        <div><br>
        </div>
        <div>2.  and special .h "freeradius_cpp_api.h" file where
          prototypes with this "accessors from C++" is defined with
          external "C" linkage.</div>
        <div><br>
        </div>
        <div>
          3.   import in c++ "freeradius_cpp_api.h" instead freeradius
          headers.</div>
        <div><br>
        </div>
        <div>and at least with gcc - all works fine after linking with
          right libraries.</div>
        <div> </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Mon, Mar 11, 2013 at 3:58 PM,
          Patrick Ko <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:patrick0585@googlemail.com" target="_blank">patrick0585@googlemail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote">Hello everybody,<br>
            here are my Steps how i created an C++ Module for
            FreeRadius.<br>
            <br>
            <ul>
              <li><b>Adaptions in the radiusd.conf</b></li>
            </ul>
                     Create an new Module Section like:<br>
            <br>
                    
            <p class="MsoNormal">modules {<span>                                                                  
              </span><span><br>
              </span></p>
            <p class="MsoNormal"><span>                        </span>cpp
              {</p>
            <p class="MsoNormal"><span>                                  
              </span>…</p>
            <p class="MsoNormal"><span>                        </span><span>      
              </span>}</p>
            <p class="MsoNormal"><span>            </span><span>    </span>}</p>
            <br>
            <br>
            <ul>
              <li>Creating an new Directory in the modules Directory <br>
              </li>
            </ul>
                      I created an new Directory named "<b>rlm_cpp</b>"
            where I putted an Makefile and my <b>rlm_cpp.cpp</b> File<br>
            <br>
            <br>
                      <b>Makefile:</b><br>
            <br>
                      <i>TARGET      = rlm_cpp<br>
            </i>
            <div><i>SRCS        = rlm_cpp.cpp <br>
              </i></div>
            <div><i>HEADERS     = <br>
                RLM_CFLAGS  =  -I/usr/include<br>
                RLM_LIBS    =  -lc<br>
                RLM_INSTALL = install-example<br>
                <br>
                ## this uses the RLM_CFLAGS and RLM_LIBS and SRCS defs
                to make TARGET.<br>
                include ../rules.mak<br>
                <br>
                $(LT_OBJS): $(HEADERS)<br>
                <br>
                ## the rule that RLM_INSTALL tells the parent rules.mak
                to use.<br>
                install-example:<br>
                        touch .</i><br>
              <br>
              <br>
            </div>
            <div>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>
              <b>extern "C"</b> {<br>
              <div>static int cpp_authorize(void *instance, REQUEST
                *request)<br>
                {<br>
                <div>...<br>
                </div>
                }<br>
              </div>
              }<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>
              <b>#define operator op3578000<br>
                #define template tem34123</b><br>
              <br>
              At the end I needed to change the the struct. First I
              changed the struct in radiusd.conf<br>
              <br>
              struct auth_req {<br>
              <div>
                ...<br>
                home_server<b>_t </b>                    *home_server<br>
                ...<br>
              </div>
              }<br>
              <br>
              typedef struct radclient {<br>
              ...<br>
              <div>home_server<b>_t </b>          *coa_server;<br>
              </div>
              ...<br>
              } RADCLIENT;<br>
              <br>
              Also change the Typedef to:<br>
              <br>
              <span lang="EN-GB">typedef struct
                home_server {<br>
                ...<br>
                }</span><span lang="EN-GB">home_server<b><span>_t;</span></b></span><br>
              <br>
              Every struct in the Source of FreeRadius need to be
              changed to <b>home_server_t</b>!<br>
              <br>
              <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>
              <br>
            </div>
            Greetz<span class="HOEnZb"><br>
              Patrick<br>
              <br>
            </span><br>
            -<br>
            List info/subscribe/unsubscribe? See <a
              moz-do-not-send="true"
              href="http://www.freeradius.org/list/devel.html"
              target="_blank">http://www.freeradius.org/list/devel.html</a><br>
          </blockquote>
        </div>
        <br>
        <br>
        <div><br>
        </div>
        -- <br>
        Ruslan Shevchenko<br>
        Software Engineer.<br>
        <a moz-do-not-send="true"
          href="http://ua.linkedin.com/in/ruslanshevchenko"
          target="_blank">http://ua.linkedin.com/in/ruslanshevchenko</a>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">-
List info/subscribe/unsubscribe? See <a class="moz-txt-link-freetext" href="http://www.freeradius.org/list/devel.html">http://www.freeradius.org/list/devel.html</a></pre>
    </blockquote>
    <br>
  </body>
</html>