/[radius]/radius/radiusd/files.c
ViewVC logotype

Diff of /radius/radiusd/files.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.67 by gray, Mon Apr 28 12:08:46 2003 UTC revision 1.68 by gray, Tue Apr 29 13:57:59 2003 UTC
# Line 1  Line 1 
1  /* This file is part of GNU RADIUS.  /* This file is part of GNU Radius.
2     Copyright (C) 2000,2001, Sergey Poznyakoff     Copyright (C) 2000,2001,2002,2003 Sergey Poznyakoff
3        
4     This program is free software; you can redistribute it and/or modify     GNU Radius is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.     (at your option) any later version.
8        
9     This program is distributed in the hope that it will be useful,     GNU Radius is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.     GNU General Public License for more details.
13        
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software Foundation,     along with GNU Radius; if not, write to the Free Software Foundation,
16     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17    
18  /* This file deals with contents of /etc/raddb directory (except config and  /* This file deals with contents of /etc/raddb directory (except config and
19     dictionaries) */     dictionaries) */
20    
21  #define RADIUS_MODULE_FILES_C  #define RADIUS_MODULE_FILES_C
 #ifndef lint  
 static char rcsid[] =  
 "@(#) $Id$";  
 #endif  
22    
23  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
24  # include <config.h>  # include <config.h>
# Line 56  static char rcsid[] = Line 52  static char rcsid[] =
52  #endif  #endif
53  #include <raddbm.h>  #include <raddbm.h>
54  #include <obstack1.h>  #include <obstack1.h>
 #include <slist.h>  
55    
56  /*  /*
57   * Symbol tables and lists   * Symbol tables and lists
# Line 66  Symtab          *deny_tab;     /* raddb/ Line 61  Symtab          *deny_tab;     /* raddb/
61    
62  MATCHING_RULE   *huntgroups;   /* raddb/huntgroups */  MATCHING_RULE   *huntgroups;   /* raddb/huntgroups */
63  MATCHING_RULE   *hints;        /* raddb/hints */  MATCHING_RULE   *hints;        /* raddb/hints */
64  CLIENT          *clients;      /* raddb/clients */  LIST /* of CLIENT */ *clients; /* raddb/clients */
65  RADCK_TYPE      *radck_type;   /* raddb/nastypes */  LIST /* of RADCK_TYPE */ *radck_type;   /* raddb/nastypes */
66    
67  static struct keyword op_tab[] = {  static struct keyword op_tab[] = {
68          "=", OPERATOR_EQUAL,          "=", OPERATOR_EQUAL,
# Line 846  read_naslist_file(file) Line 841  read_naslist_file(file)
841   */   */
842  /*ARGSUSED*/  /*ARGSUSED*/
843  int  int
844  read_clients_entry(unused, fc, fv, file, lineno)  read_clients_entry(void *u ARG_UNUSED, int fc, char **fv,
845          void *unused;                     char *file, int lineno)
         int fc;  
         char **fv;  
         char *file;  
         int lineno;  
846  {  {
847          CLIENT *cp;          CLIENT *cp;
848                    
# Line 862  read_clients_entry(unused, fc, fv, file, Line 853  read_clients_entry(unused, fc, fv, file,
853                  return -1;                  return -1;
854          }          }
855    
856          cp = mem_alloc(sizeof(CLIENT));          cp = emalloc(sizeof(CLIENT));
857    
858          cp->ipaddr = ip_gethostaddr(fv[0]);          cp->ipaddr = ip_gethostaddr(fv[0]);
859          cp->secret = estrdup(fv[1]);          cp->secret = estrdup(fv[1]);
860          if (fc == 3)          if (fc == 3)
861                  STRING_COPY(cp->shortname, fv[2]);                  STRING_COPY(cp->shortname, fv[2]);
862          ip_gethostname(cp->ipaddr, cp->longname, sizeof(cp->longname));          ip_gethostname(cp->ipaddr, cp->longname, sizeof(cp->longname));
863            list_append(clients, cp);
         cp->next = clients;  
         clients = cp;  
   
864          return 0;          return 0;
865  }  }
866    
867  static void  static int
868  client_free(cl)  client_free(void *item, void *data ARG_UNUSED)
         CLIENT *cl;  
869  {  {
870          efree(cl->secret);          CLIENT *cl = item;
871            efree(cl->secret);
872            efree(cl);
873            return 0;
874  }  }
875    
876  /*  /*
877   * Read the clients file.   * Read the clients file.
878   */   */
879  int  int
880  read_clients_file(file)  read_clients_file(char *file)
         char *file;  
881  {  {
882          free_slist((struct slist*)clients, client_free);          list_destroy(&clients, client_free, NULL);
883          clients = NULL;          clients = list_create();
   
884          return read_raddb_file(file, 1, read_clients_entry, NULL);          return read_raddb_file(file, 1, read_clients_entry, NULL);
885  }  }
886    
# Line 901  read_clients_file(file) Line 889  read_clients_file(file)
889   * Find a client in the CLIENTS list.   * Find a client in the CLIENTS list.
890   */   */
891  CLIENT *  CLIENT *
892  client_lookup_ip(ipaddr)  client_lookup_ip(UINT4 ipaddr)
         UINT4 ipaddr;  
893  {  {
894          CLIENT *cl;          CLIENT *cl;
895    
896          for(cl = clients; cl; cl = cl->next)          for (cl = list_first(clients); cl; cl = list_next(clients))
897                  if (ipaddr == cl->ipaddr)                  if (ipaddr == cl->ipaddr)
898                          break;                          break;
899    
# Line 918  client_lookup_ip(ipaddr) Line 905  client_lookup_ip(ipaddr)
905   * Find the name of a client (prefer short name).   * Find the name of a client (prefer short name).
906   */   */
907  char *  char *
908  client_lookup_name(ipaddr, buf, bufsize)  client_lookup_name(UINT4 ipaddr, char *buf, size_t bufsize)
         UINT4 ipaddr;  
         char *buf;  
         size_t bufsize;  
909  {  {
910          CLIENT *cl;          CLIENT *cl;
911    
# Line 938  client_lookup_name(ipaddr, buf, bufsize) Line 922  client_lookup_name(ipaddr, buf, bufsize)
922   * raddb/nastypes   * raddb/nastypes
923   */   */
924    
 int read_nastypes_entry(void *unused, int fc, char **fv, char *file,  
                         int lineno);  
 int read_nastypes_file(char *file);  
   
925    
926  /*  /*
927   * parser   * parser
928   */   */
929  /*ARGSUSED*/  /*ARGSUSED*/
930  int  int
931  read_nastypes_entry(unused, fc, fv, file, lineno)  read_nastypes_entry(void *u ARG_UNUSED, int fc, char **fv,
932          void *unused;                      char *file, int lineno)
         int fc;  
         char **fv;  
         char *file;  
         int lineno;  
933  {  {
934          RADCK_TYPE *mp;          RADCK_TYPE *mp;
935          int method;          int method;
# Line 975  read_nastypes_entry(unused, fc, fv, file Line 951  read_nastypes_entry(unused, fc, fv, file
951                  return -1;                  return -1;
952          }          }
953                                                    
954          mp = mem_alloc(sizeof(*mp));          mp = emalloc(sizeof(*mp));
955          mp->type = estrdup(fv[0]);          mp->type = estrdup(fv[0]);
956          mp->method = method;          mp->method = method;
957          if (fc > 2)          if (fc > 2)
958                  mp->args = envar_parse_argcv(fc-2, &fv[2]);                  mp->args = envar_parse_argcv(fc-2, &fv[2]);
959          else          else
960                  mp->args = NULL;                  mp->args = NULL;
961          mp->next = radck_type;          list_append(radck_type, mp);
         radck_type = mp;  
962          return 0;          return 0;
963  }  }
964                    
965  void  static int
966  free_radck_type(rp)  free_radck_type(void *item, void *data ARG_UNUSED)
         RADCK_TYPE *rp;  
967  {  {
968            RADCK_TYPE *rp = item;
969    
970          efree(rp->type);          efree(rp->type);
971          envar_free_list(rp->args);          envar_free_list(&rp->args);
972            efree(rp);
973            return 0;
974  }  }
975    
976  int  int
977  read_nastypes_file(file)  read_nastypes_file(char *file)
         char *file;  
978  {  {
979          free_slist((struct slist *)radck_type, free_radck_type);          list_destroy(&radck_type, free_radck_type, NULL);
980          radck_type = NULL;          radck_type = list_create();
981          return read_raddb_file(file, 0, read_nastypes_entry, NULL);          return read_raddb_file(file, 0, read_nastypes_entry, NULL);
982  }  }
983    
# Line 1010  find_radck_type(name) Line 987  find_radck_type(name)
987  {  {
988          RADCK_TYPE *tp;          RADCK_TYPE *tp;
989                    
990          for (tp = radck_type; tp && strcmp(tp->type, name); tp = tp->next)          for (tp = list_first(radck_type);
991                 tp && strcmp(tp->type, name);
992                 tp = list_next(radck_type))
993                  ;                  ;
994          return tp;          return tp;
995  }  }

Legend:
Removed from v.1.67  
changed lines
  Added in v.1.68

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26