Massively cleaned up #include's, so they're in a consistent
[freeradius.git] / src / modules / rlm_sim_files / rlm_sim_files.c
index a64bc38..c7f5bc3 100644 (file)
  *
  *   You should have received a copy of the GNU General Public License
  *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
  * Copyright 2004  Michael Richardson <mcr@sandelman.ottawa.on.ca>
+ * Copyright 2006  The FreeRADIUS server project
  *
  * (Adapted from rlm_files/rlm_files.c )
  */
  */
 
 
-static const char rcsid[] = "$Id$";
+#include       <freeradius-devel/ident.h>
+RCSID("$Id$")
 
-#include       "autoconf.h"
-#include       "libradius.h"
+#include       <freeradius-devel/radiusd.h>
+#include       <freeradius-devel/modules.h>
 
 #include       <sys/stat.h>
-
-#include       <stdlib.h>
-#include       <string.h>
-#include       <netdb.h>
 #include       <ctype.h>
 #include       <fcntl.h>
 #include       <limits.h>
 
-#include       "radiusd.h"
-#include       "modules.h"
 #include        "../rlm_eap/libeap/eap_sim.h"
 
 struct sim_file_instance {
@@ -76,7 +72,7 @@ struct sim_file_instance {
        char *file;
 };
 
-static CONF_PARSER module_config[] = {
+static const CONF_PARSER module_config[] = {
        { "simtriplets",        PW_TYPE_STRING_PTR,
          offsetof(struct sim_file_instance, file),
          NULL, "${raddbdir}/simtriplets.dat" },
@@ -134,7 +130,7 @@ static int sim_file_authorize(void *instance, REQUEST *request)
         *      Grab the canonical user name.
         */
        namepair = request->username;
-       name = namepair ? (char *) namepair->strvalue : "NONE";
+       name = namepair ? (char *) namepair->vp_strvalue : "NONE";
 
        triplets = fopen(inst->file, "r");
 
@@ -146,7 +142,7 @@ static int sim_file_authorize(void *instance, REQUEST *request)
 
        imsicount = 0;
        lineno = 0;
-       
+
        while(fgets(tripbuf, sizeof(tripbuf), triplets) == tripbuf
              && imsicount < 3)
        {
@@ -208,33 +204,33 @@ static int sim_file_authorize(void *instance, REQUEST *request)
                        /* complain about malformed line */
                        continue;
                }
-               
-                       
+
+
                r = paircreate(ATTRIBUTE_EAP_SIM_RAND1 + imsicount, PW_TYPE_OCTETS);
                r = pairparsevalue(r, chal);
                pairadd(reply_pairs, r);
-               
+
                k = paircreate(ATTRIBUTE_EAP_SIM_KC1 + imsicount, PW_TYPE_OCTETS);
                k = pairparsevalue(k, kc);
                rad_assert(k != NULL);
                pairadd(reply_pairs, k);
-               
+
                s = paircreate(ATTRIBUTE_EAP_SIM_SRES1 + imsicount, PW_TYPE_OCTETS);
                s = pairparsevalue(s, sres);
                pairadd(reply_pairs, s);
-               
+
                imsicount++;
        }
        fclose(triplets);
-       
+
        if (imsicount < 3)
        {
                DEBUG("rlm_sim_files: "
-                     "insufficient number of challenges for imsi %s: %d\n", 
+                     "insufficient number of challenges for imsi %s: %d\n",
                      name, imsicount);
                return RLM_MODULE_NOTFOUND;
        }
-       
+
        DEBUG("rlm_sim_files: "
              "authorized user/imsi %s\n", name);
 
@@ -275,10 +271,11 @@ static int sim_file_detach(void *instance)
 
 /* globally exported name */
 module_t rlm_sim_files = {
+       RLM_MODULE_INIT,
        "sim_files",
        0,                              /* type: reserved */
-       NULL,                           /* initialization */
        sim_file_instantiate,           /* instantiation */
+       sim_file_detach,                /* detach */
        {
                NULL,                   /* authentication */
                sim_file_authorize,     /* authorization */
@@ -289,7 +286,5 @@ module_t rlm_sim_files = {
                NULL,                   /* post-proxy */
                NULL                    /* post-auth */
        },
-       sim_file_detach,                /* detach */
-       NULL                            /* destroy */
 };