1 |
/* This file is part of GNU RADIUS. |
/* This file is part of GNU Radius |
2 |
Copyright (C) 2001, Sergey Poznyakoff |
Copyright (C) 2001, 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 |
#define RADIUS_MODULE_BUILDDBM_C |
#define RADIUS_MODULE_BUILDDBM_C |
28 |
#include <symtab.h> |
#include <symtab.h> |
29 |
#include <parser.h> |
#include <parser.h> |
30 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = |
|
|
"@(#) $Id$"; |
|
|
#endif |
|
|
|
|
31 |
#define NINT(n) ((n) + sizeof(int) - 1)/sizeof(int) |
#define NINT(n) ((n) + sizeof(int) - 1)/sizeof(int) |
32 |
|
|
33 |
typedef struct { |
typedef struct { |
44 |
static int list_length(VALUE_PAIR *vp); |
static int list_length(VALUE_PAIR *vp); |
45 |
|
|
46 |
int |
int |
47 |
append_symbol(closure, sym) |
append_symbol(DBM_closure *closure, User_symbol *sym) |
|
DBM_closure *closure; |
|
|
User_symbol *sym; |
|
48 |
{ |
{ |
49 |
int check_len; |
int check_len; |
50 |
int reply_len; |
int reply_len; |
108 |
} |
} |
109 |
|
|
110 |
int |
int |
111 |
list_length(vp) |
list_length(VALUE_PAIR *vp) |
|
VALUE_PAIR *vp; |
|
112 |
{ |
{ |
113 |
int len; |
int len; |
114 |
|
|
123 |
} |
} |
124 |
|
|
125 |
int |
int |
126 |
builddbm(name) |
builddbm(char *name) |
|
char *name; |
|
127 |
{ |
{ |
128 |
DBM_closure closure; |
DBM_closure closure; |
129 |
char *db_file; |
char *db_file; |
170 |
#define NINT(n) ((n) + sizeof(int) - 1)/sizeof(int) |
#define NINT(n) ((n) + sizeof(int) - 1)/sizeof(int) |
171 |
|
|
172 |
VALUE_PAIR * |
VALUE_PAIR * |
173 |
decode_dbm(pptr) |
decode_dbm(int **pptr) |
|
int **pptr; |
|
174 |
{ |
{ |
175 |
int *ptr, *endp, len; |
int *ptr, *endp, len; |
176 |
VALUE_PAIR *next_pair, *first_pair, *last_pair; |
VALUE_PAIR *next_pair, *first_pair, *last_pair; |
208 |
* for both calls is needed. |
* for both calls is needed. |
209 |
*/ |
*/ |
210 |
int |
int |
211 |
dbm_find(file, name, req, check_pairs, reply_pairs) |
dbm_find(DBM_FILE file, char *name, RADIUS_REQ *req, |
212 |
DBM_FILE file; |
VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs) |
|
char *name; |
|
|
RADIUS_REQ *req; |
|
|
VALUE_PAIR **check_pairs; |
|
|
VALUE_PAIR **reply_pairs; |
|
213 |
{ |
{ |
214 |
DBM_DATUM named; |
DBM_DATUM named; |
215 |
DBM_DATUM contentd; |
DBM_DATUM contentd; |
279 |
|
|
280 |
/*ARGSUSED*/ |
/*ARGSUSED*/ |
281 |
char * |
char * |
282 |
_dbm_dup_name(buf, bufsize, name, ordnum) |
_dbm_dup_name(char *buf, size_t bufsize, char *name, int ordnum) |
|
char *buf; |
|
|
size_t bufsize; |
|
|
char *name; |
|
|
int ordnum; |
|
283 |
{ |
{ |
284 |
strncpy(buf, name, bufsize); |
strncpy(buf, name, bufsize); |
285 |
buf[bufsize-1] = 0; |
buf[bufsize-1] = 0; |
287 |
} |
} |
288 |
|
|
289 |
char * |
char * |
290 |
_dbm_number_name(buf, bufsize, name, ordnum) |
_dbm_number_name(char *buf, size_t bufsize, char *name, int ordnum) |
|
char *buf; |
|
|
size_t bufsize; |
|
|
char *name; |
|
|
int ordnum; |
|
291 |
{ |
{ |
292 |
snprintf(buf, bufsize, "%s%d", name, ordnum); |
snprintf(buf, bufsize, "%s%d", name, ordnum); |
293 |
return buf; |
return buf; |
294 |
} |
} |
295 |
|
|
296 |
int |
int |
297 |
dbm_match(dbmfile, name, fn, req, check_pairs, reply_pairs, fallthru) |
dbm_match(DBM_FILE dbmfile, char *name, char *(*fn)(), RADIUS_REQ *req, |
298 |
DBM_FILE dbmfile; |
VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs, int *fallthru) |
|
char *name; |
|
|
char *(*fn)(); |
|
|
RADIUS_REQ *req; |
|
|
VALUE_PAIR **check_pairs; |
|
|
VALUE_PAIR **reply_pairs; |
|
|
int *fallthru; |
|
299 |
{ |
{ |
300 |
int found = 0; |
int found = 0; |
301 |
int i, r; |
int i, r; |
345 |
* Find matching profile in the DBM database |
* Find matching profile in the DBM database |
346 |
*/ |
*/ |
347 |
int |
int |
348 |
user_find_db(name, req, check_pairs, reply_pairs) |
user_find_db(char *name, RADIUS_REQ *req, |
349 |
char *name; |
VALUE_PAIR **check_pairs, VALUE_PAIR **reply_pairs) |
|
RADIUS_REQ *req; |
|
|
VALUE_PAIR **check_pairs; |
|
|
VALUE_PAIR **reply_pairs; |
|
350 |
{ |
{ |
351 |
int found = 0; |
int found = 0; |
352 |
char *path; |
char *path; |