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 |
|
|
|
#ifndef lint |
|
|
static char rcsid[] = |
|
|
"@(#) $Id$"; |
|
|
#endif |
|
18 |
#if defined(HAVE_CONFIG_H) |
#if defined(HAVE_CONFIG_H) |
19 |
# include <config.h> |
# include <config.h> |
20 |
#endif |
#endif |
85 |
}; |
}; |
86 |
|
|
87 |
static error_t |
static error_t |
88 |
parse_opt (key, arg, state) |
parse_opt(int key, char *arg, struct argp_state *state) |
|
int key; |
|
|
char *arg; |
|
|
struct argp_state *state; |
|
89 |
{ |
{ |
90 |
switch (key) { |
switch (key) { |
91 |
case 'a': |
case 'a': |
92 |
assign(optarg); |
assign(optarg); |
93 |
break; |
break; |
94 |
|
|
95 |
case 'q': |
case 'q': |
96 |
quick++; |
quick++; |
97 |
break; |
break; |
98 |
|
|
99 |
case 'r': |
case 'r': |
100 |
retry = strtol(optarg, NULL, 0); |
retry = strtol(optarg, NULL, 0); |
101 |
break; |
break; |
102 |
|
|
103 |
case 's': |
case 's': |
104 |
server = optarg; |
server = optarg; |
105 |
break; |
break; |
106 |
|
|
107 |
case 'f': |
case 'f': |
108 |
filename = optarg; |
filename = optarg; |
109 |
*(int *)state->input = state->next; |
*(int *)state->input = state->next; |
110 |
state->next = state->argc; |
state->next = state->argc; |
111 |
break; |
break; |
112 |
|
|
113 |
case 't': |
case 't': |
114 |
timeout = strtol(optarg, NULL, 0); |
timeout = strtol(optarg, NULL, 0); |
115 |
break; |
break; |
116 |
|
|
117 |
case 'x': |
case 'x': |
118 |
set_debug_levels(optarg); |
set_debug_levels(optarg); |
119 |
break; |
break; |
120 |
|
|
121 |
case 'v': |
case 'v': |
122 |
verbose++; |
verbose++; |
123 |
set_module_debug_level("radpdu", 100); |
set_module_debug_level("radpdu", 100); |
124 |
set_module_debug_level("client", 100); |
set_module_debug_level("client", 100); |
125 |
break; |
break; |
126 |
|
|
127 |
default: |
default: |
128 |
return ARGP_ERR_UNKNOWN; |
return ARGP_ERR_UNKNOWN; |
129 |
} |
} |
140 |
}; |
}; |
141 |
|
|
142 |
int |
int |
143 |
main(argc, argv) |
main(int argc, char **argv) |
|
int argc; |
|
|
char **argv; |
|
144 |
{ |
{ |
145 |
char *p; |
char *p; |
146 |
int index; |
int index; |
282 |
} |
} |
283 |
|
|
284 |
void |
void |
285 |
assign(s) |
assign(char *s) |
|
char *s; |
|
286 |
{ |
{ |
287 |
char *p; |
char *p; |
288 |
Variable *var; |
Variable *var; |
305 |
} |
} |
306 |
|
|
307 |
int |
int |
308 |
parse_datum(p, dp) |
parse_datum(char *p, union datum *dp) |
|
char *p; |
|
|
union datum *dp; |
|
309 |
{ |
{ |
310 |
int type = Undefined; |
int type = Undefined; |
311 |
int length; |
int length; |
352 |
} |
} |
353 |
|
|
354 |
char * |
char * |
355 |
print_ident(var) |
print_ident(Variable *var) |
|
Variable *var; |
|
356 |
{ |
{ |
357 |
char buf[64]; |
char buf[64]; |
358 |
switch (var->type) { |
switch (var->type) { |
375 |
} |
} |
376 |
|
|
377 |
void |
void |
378 |
print_pairs(fp, pair) |
print_pairs(FILE *fp, VALUE_PAIR *pair) |
|
FILE *fp; |
|
|
VALUE_PAIR *pair; |
|
379 |
{ |
{ |
380 |
for (; pair; pair = pair->next) { |
for (; pair; pair = pair->next) { |
381 |
fprintf(fp, " %s = ", pair->name); |
fprintf(fp, " %s = ", pair->name); |
408 |
} |
} |
409 |
|
|
410 |
void |
void |
411 |
var_print(var) |
var_print(Variable *var) |
|
Variable *var; |
|
412 |
{ |
{ |
413 |
char buf[DOTTED_QUAD_LEN]; |
char buf[DOTTED_QUAD_LEN]; |
414 |
if (!var) |
if (!var) |
438 |
} |
} |
439 |
|
|
440 |
void |
void |
441 |
var_free(var) |
var_free(Variable *var) |
|
Variable *var; |
|
442 |
{ |
{ |
443 |
if (var->name) |
if (var->name) |
444 |
return; /* named variables are not freed */ |
return; /* named variables are not freed */ |
453 |
} |
} |
454 |
|
|
455 |
void |
void |
456 |
radtest_send(port, code, var) |
radtest_send(int port, int code, Variable *var) |
|
int port; |
|
|
int code; |
|
|
Variable *var; |
|
457 |
{ |
{ |
458 |
RADIUS_REQ *auth; |
RADIUS_REQ *auth; |
459 |
|
|
488 |
|
|
489 |
/* FIXME: duplicated in radiusd/files.c */ |
/* FIXME: duplicated in radiusd/files.c */ |
490 |
int |
int |
491 |
comp_op(op, result) |
comp_op(int op, int result) |
|
int op; |
|
|
int result; |
|
492 |
{ |
{ |
493 |
switch (op) { |
switch (op) { |
494 |
default: |
default: |
526 |
} |
} |
527 |
|
|
528 |
int |
int |
529 |
compare_lists(reply, sample) |
compare_lists(VALUE_PAIR *reply, VALUE_PAIR *sample) |
|
VALUE_PAIR *reply, *sample; |
|
530 |
{ |
{ |
531 |
int result = 0; |
int result = 0; |
532 |
|
|