2 * radclient.c General radius packet debug tool.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2000 The FreeRADIUS server project
21 * Copyright 2000 Miquel van Smoorenburg <miquels@cistron.nl>
22 * Copyright 2000 Alan DeKok <aland@ox.org>
24 static const char rcsid[] = "$Id$";
26 #include <freeradius-devel/autoconf.h>
39 #ifdef HAVE_SYS_SELECT_H
40 # include <sys/select.h>
49 #include <freeradius-devel/conf.h>
50 #include <freeradius-devel/radpaths.h>
51 #include <freeradius-devel/missing.h>
52 #include <freeradius-devel/libradius.h>
54 static int retries = 10;
55 static float timeout = 3;
56 static const char *secret = NULL;
57 static int do_output = 1;
58 static int totalapp = 0;
59 static int totaldeny = 0;
60 static int totallost = 0;
62 static int server_port = 0;
63 static int packet_code = 0;
64 static lrad_ipaddr_t server_ipaddr;
65 static int resend_count = 1;
68 static lrad_ipaddr_t client_ipaddr;
69 static int client_port = 0;
72 static int last_used_id = -1;
74 static rbtree_t *filename_tree = NULL;
75 static lrad_packet_list_t *pl = NULL;
77 static int sleep_time = -1;
79 typedef struct radclient_t {
80 struct radclient_t *prev;
81 struct radclient_t *next;
84 int packet_number; /* in the file */
87 RADIUS_PACKET *request;
94 static radclient_t *radclient_head = NULL;
95 static radclient_t *radclient_tail = NULL;
98 static void NEVER_RETURNS usage(void)
100 fprintf(stderr, "Usage: radclient [options] server[:port] <command> [<secret>]\n");
102 fprintf(stderr, " <command> One of auth, acct, status, coa, or disconnect.\n");
103 fprintf(stderr, " -c count Send each packet 'count' times.\n");
104 fprintf(stderr, " -d raddb Set dictionary directory.\n");
105 fprintf(stderr, " -f file Read packets from file, not stdin.\n");
106 fprintf(stderr, " -i id Set request id to 'id'. Values may be 0..255\n");
107 fprintf(stderr, " -n num Send N requests/s\n");
108 fprintf(stderr, " -p num Send 'num' packets from a file in parallel.\n");
109 fprintf(stderr, " -q Do not print anything out.\n");
110 fprintf(stderr, " -r retries If timeout, retry sending the packet 'retries' times.\n");
111 fprintf(stderr, " -s Print out summary information of auth results.\n");
112 fprintf(stderr, " -S file read secret from file, not command line.\n");
113 fprintf(stderr, " -t timeout Wait 'timeout' seconds before retrying (may be a floating point number).\n");
114 fprintf(stderr, " -v Show program version information.\n");
115 fprintf(stderr, " -x Debugging mode.\n");
116 fprintf(stderr, " -4 Use IPv4 address of server\n");
117 fprintf(stderr, " -6 Use IPv6 address of server.\n");
123 * Free a radclient struct, which may (or may not)
124 * already be in the list.
126 static void radclient_free(radclient_t *radclient)
128 radclient_t *prev, *next;
130 if (radclient->request) rad_free(&radclient->request);
131 if (radclient->reply) rad_free(&radclient->reply);
133 prev = radclient->prev;
134 next = radclient->next;
137 assert(radclient_head != radclient);
139 } else if (radclient_head) {
140 assert(radclient_head == radclient);
141 radclient_head = next;
145 assert(radclient_tail != radclient);
147 } else if (radclient_tail) {
148 assert(radclient_tail == radclient);
149 radclient_tail = prev;
156 * Initialize a radclient data structure
158 static radclient_t *radclient_init(const char *filename)
162 radclient_t *start, *radclient, *prev = NULL;
164 int packet_number = 1;
167 assert(filename != NULL);
170 * Determine where to read the VP's from.
172 if (strcmp(filename, "-") != 0) {
173 fp = fopen(filename, "r");
175 fprintf(stderr, "radclient: Error opening %s: %s\n",
176 filename, strerror(errno));
184 * Loop until the file is done.
190 radclient = malloc(sizeof(*radclient));
192 perror("radclient: X");
193 return NULL; /* memory leak "start" */
195 memset(radclient, 0, sizeof(*radclient));
197 radclient->request = rad_alloc(1);
198 if (!radclient->request) {
199 librad_perror("radclient: Y");
200 radclient_free(radclient);
201 return NULL; /* memory leak "start" */
204 radclient->filename = filename;
205 radclient->request->id = -1; /* allocate when sending */
206 radclient->packet_number = packet_number++;
211 radclient->request->vps = readvp2(fp, &filedone, "radclient:");
212 if (!radclient->request->vps) {
213 radclient_free(radclient);
214 return start; /* done: return the list */
218 * Keep a copy of the the User-Password attribute.
220 if ((vp = pairfind(radclient->request->vps, PW_USER_PASSWORD)) != NULL) {
221 strNcpy(radclient->password, vp->vp_strvalue,
222 sizeof(radclient->password));
224 * Otherwise keep a copy of the CHAP-Password attribute.
226 } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
227 strNcpy(radclient->password, vp->vp_strvalue,
228 sizeof(radclient->password));
230 radclient->password[0] = '\0';
234 * Fix up Digest-Attributes issues
236 for (vp = radclient->request->vps; vp != NULL; vp = vp->next) {
237 switch (vp->attribute) {
242 * Allow it to set the packet type in
243 * the attributes read from the file.
246 radclient->request->code = vp->lvalue;
249 case PW_PACKET_DST_PORT:
250 radclient->request->dst_port = (vp->lvalue & 0xffff);
253 case PW_PACKET_DST_IP_ADDRESS:
254 radclient->request->dst_ipaddr.af = AF_INET;
255 radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
258 case PW_PACKET_DST_IPV6_ADDRESS:
259 radclient->request->dst_ipaddr.af = AF_INET6;
260 radclient->request->dst_ipaddr.ipaddr.ip6addr = vp->vp_ipv6addr;
263 case PW_PACKET_SRC_PORT:
264 radclient->request->src_port = (vp->lvalue & 0xffff);
267 case PW_PACKET_SRC_IP_ADDRESS:
268 radclient->request->src_ipaddr.af = AF_INET;
269 radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
272 case PW_PACKET_SRC_IPV6_ADDRESS:
273 radclient->request->src_ipaddr.af = AF_INET6;
274 radclient->request->src_ipaddr.ipaddr.ip6addr = vp->vp_ipv6addr;
277 case PW_DIGEST_REALM:
278 case PW_DIGEST_NONCE:
279 case PW_DIGEST_METHOD:
282 case PW_DIGEST_ALGORITHM:
283 case PW_DIGEST_BODY_DIGEST:
284 case PW_DIGEST_CNONCE:
285 case PW_DIGEST_NONCE_COUNT:
286 case PW_DIGEST_USER_NAME:
288 memmove(&vp->vp_octets[2], &vp->vp_octets[0],
290 vp->vp_octets[0] = vp->attribute - PW_DIGEST_REALM + 1;
292 vp->vp_octets[1] = vp->length;
293 vp->attribute = PW_DIGEST_ATTRIBUTES;
296 } /* loop over the VP's we read in */
302 prev->next = radclient;
303 radclient->prev = prev;
306 } while (!filedone); /* loop until the file is done. */
308 if (fp != stdin) fclose(fp);
318 * Sanity check each argument.
320 static int radclient_sane(radclient_t *radclient)
322 if (radclient->request->dst_port == 0) {
323 radclient->request->dst_port = server_port;
325 if (radclient->request->dst_ipaddr.af == AF_UNSPEC) {
326 if (server_ipaddr.af == AF_UNSPEC) {
327 fprintf(stderr, "radclient: No server was given, but request %d in file %s did not contain Packet-Dst-IP-Address\n",
328 radclient->packet_number, radclient->filename);
331 radclient->request->dst_ipaddr = server_ipaddr;
333 if (radclient->request->code == 0) {
334 if (packet_code == -1) {
335 fprintf(stderr, "radclient: Request was \"auto\", but request %d in file %s did not contain Packet-Type\n",
336 radclient->packet_number, radclient->filename);
340 radclient->request->code = packet_code;
342 radclient->request->sockfd = -1;
349 * For request handline.
351 static int filename_cmp(const void *one, const void *two)
353 return strcmp((const char *) one, (const char *) two);
356 static int filename_walk(void *context, void *data)
358 const char *filename = data;
359 radclient_t *radclient;
361 context = context; /* -Wunused */
364 * Initialize the request we're about
367 radclient = radclient_init(filename);
372 if (!radclient_head) {
373 assert(radclient_tail == NULL);
374 radclient_head = radclient;
376 assert(radclient_tail->next == NULL);
377 radclient_tail->next = radclient;
378 radclient->prev = radclient_tail;
382 * We may have had a list of "radclient" structures
385 while (radclient->next) radclient = radclient->next;
386 radclient_tail = radclient;
393 * Deallocate packet ID, etc.
395 static void deallocate_id(radclient_t *radclient)
397 if (!radclient || !radclient->request ||
398 (radclient->request->id < 0)) {
403 * One more unused RADIUS ID.
405 lrad_packet_list_id_free(pl, radclient->request);
406 radclient->request->id = -1;
409 * If we've already sent a packet, free up the old one,
410 * and ensure that the next packet has a unique
411 * authentication vector.
413 if (radclient->request->data) {
414 free(radclient->request->data);
415 radclient->request->data = NULL;
418 if (radclient->reply) rad_free(&radclient->reply);
422 static void print_hex(RADIUS_PACKET *packet)
426 if (!packet->data) return;
428 printf(" Code:\t\t%u\n", packet->data[0]);
429 printf(" Id:\t\t%u\n", packet->data[1]);
430 printf(" Length:\t%u\n", ((packet->data[2] << 8) |
432 printf(" Vector:\t");
433 for (i = 4; i < 20; i++) {
434 printf("%02x", packet->data[i]);
438 if (packet->data_len > 20) {
443 total = packet->data_len - 20;
444 ptr = packet->data + 20;
450 if (total < 2) { /* too short */
451 printf("%02x\n", *ptr);
455 if (ptr[1] > total) { /* too long */
456 for (i = 0; i < total; i++) {
457 printf("%02x ", ptr[i]);
462 printf("%02x %02x ", ptr[0], ptr[1]);
463 attrlen = ptr[1] - 2;
467 for (i = 0; i < attrlen; i++) {
468 if ((i > 0) && ((i & 0x0f) == 0x00))
470 printf("%02x ", ptr[i]);
471 if ((i & 0x0f) == 0x0f) printf("\n");
474 if ((attrlen & 0x0f) != 0x00) printf("\n");
486 static int send_one_packet(radclient_t *radclient)
488 assert(radclient->done == 0);
491 * Remember when we have to wake up, to re-send the
492 * request, of we didn't receive a response.
494 if ((sleep_time == -1) ||
495 (sleep_time > (int) timeout)) {
496 sleep_time = (int) timeout;
500 * Haven't sent the packet yet. Initialize it.
502 if (radclient->request->id == -1) {
505 assert(radclient->reply == NULL);
508 * Didn't find a free packet ID, we're not done,
509 * we don't sleep, and we stop trying to process
513 rcode = lrad_packet_list_id_alloc(pl, radclient->request);
517 mysockfd = lrad_socket(&client_ipaddr, 0);
519 fprintf(stderr, "radclient: Can't open new socket\n");
522 if (!lrad_packet_list_socket_add(pl, mysockfd)) {
523 fprintf(stderr, "radclient: Can't add new socket\n");
535 assert(radclient->request->id != -1);
536 assert(radclient->request->data == NULL);
538 for (i = 0; i < 4; i++) {
539 *((uint32_t *) radclient->request->vector) = lrad_rand();
543 * Update the password, so it can be encrypted with the
544 * new authentication vector.
546 if (radclient->password[0] != '\0') {
549 if ((vp = pairfind(radclient->request->vps, PW_USER_PASSWORD)) != NULL) {
550 strNcpy(vp->vp_strvalue, radclient->password,
551 sizeof(vp->vp_strvalue));
552 vp->length = strlen(vp->vp_strvalue);
554 } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
556 * FIXME: AND there's no CHAP-Challenge,
557 * AND vp->length != 17
558 * AND rad_chap_encode() != vp->vp_octets
560 strNcpy(vp->vp_strvalue, radclient->password,
561 sizeof(vp->vp_strvalue));
562 vp->length = strlen(vp->vp_strvalue);
564 rad_chap_encode(radclient->request,
566 radclient->request->id, vp);
571 radclient->timestamp = time(NULL);
572 radclient->tries = 1;
576 * Duplicate found. Serious error!
578 if (!lrad_packet_list_insert(pl, &radclient->request)) {
583 } else { /* radclient->request->id >= 0 */
584 time_t now = time(NULL);
587 * FIXME: Accounting packets are never retried!
588 * The Acct-Delay-Time attribute is updated to
589 * reflect the delay, and the packet is re-sent
594 * Not time for a retry, do so.
596 if ((now - radclient->timestamp) < timeout) {
598 * When we walk over the tree sending
599 * packets, we update the minimum time
602 if ((sleep_time == -1) ||
603 (sleep_time > (now - radclient->timestamp))) {
604 sleep_time = now - radclient->timestamp;
610 * We're not trying later, maybe the packet is done.
612 if (radclient->tries == retries) {
613 assert(radclient->request->id >= 0);
616 * Delete the request from the tree of
617 * outstanding requests.
619 lrad_packet_list_yank(pl, radclient->request);
621 fprintf(stderr, "radclient: no response from server for ID %d socket %d\n", radclient->request->id, radclient->request->sockfd);
622 deallocate_id(radclient);
625 * Normally we mark it "done" when we've received
626 * the response, but this is a special case.
628 if (radclient->resend == resend_count) {
636 * We are trying later.
638 radclient->timestamp = now;
646 if (rad_send(radclient->request, NULL, secret) < 0) {
647 fprintf(stderr, "radclient: Failed to send packet for ID %d: %s\n",
648 radclient->request->id, librad_errstr);
651 if (librad_debug > 2) print_hex(radclient->request);
657 * Receive one packet, maybe.
659 static int recv_one_packet(int wait_time)
663 radclient_t *radclient;
664 RADIUS_PACKET *reply, **request_p;
667 /* And wait for reply, timing out as necessary */
670 max_fd = lrad_packet_list_fd_set(pl, &set);
671 if (max_fd < 0) exit(1); /* no sockets to listen on! */
673 if (wait_time <= 0) {
676 tv.tv_sec = wait_time;
681 * No packet was received.
683 if (select(max_fd, &set, NULL, NULL, &tv) <= 0) {
688 * Look for the packet.
690 reply = lrad_packet_list_recv(pl, &set);
692 fprintf(stderr, "radclient: received bad packet: %s\n",
694 return -1; /* bad packet */
697 if (librad_debug > 2) print_hex(reply);
699 request_p = lrad_packet_list_find_byreply(pl, reply);
701 fprintf(stderr, "radclient: received response to request we did not send. (id=%d socket %d)\n", reply->id, reply->sockfd);
703 return -1; /* got reply to packet we didn't send */
705 radclient = lrad_packet2myptr(radclient_t, request, request_p);
708 * Fails the signature validation: not a real reply.
709 * FIXME: Silently drop it and listen for another packet.
711 if (rad_verify(reply, radclient->request, secret) < 0) {
712 librad_perror("rad_verify");
714 goto packet_done; /* shared secret is incorrect */
717 lrad_packet_list_yank(pl, radclient->request);
718 deallocate_id(radclient);
719 radclient->reply = reply;
722 * If this fails, we're out of memory.
724 if (rad_decode(reply, radclient->request, secret) != 0) {
725 librad_perror("rad_decode");
730 /* libradius debug already prints out the value pairs for us */
731 if (!librad_debug && do_output) {
732 printf("Received response ID %d, code %d, length = %d\n",
733 reply->id, reply->code, reply->data_len);
734 vp_printlist(stdout, reply->vps);
736 if (reply->code != PW_AUTHENTICATION_REJECT) {
743 rad_free(&radclient->reply);
746 * Once we've sent the packet as many times as requested,
749 if (radclient->resend == resend_count) {
750 assert(lrad_packet_list_find(pl, radclient->request) == NULL);
758 static int getport(const char *name)
762 svp = getservbyname (name, "udp");
767 return ntohs(svp->s_port);
770 int main(int argc, char **argv)
774 const char *radius_dir = RADDBDIR;
775 char filesecret[256];
781 int force_af = AF_UNSPEC;
785 filename_tree = rbtree_create(filename_cmp, NULL, 0);
786 if (!filename_tree) {
787 fprintf(stderr, "radclient: Out of memory\n");
791 while ((c = getopt(argc, argv, "46c:d:f:hi:n:p:qr:sS:t:vx")) != EOF) switch(c) {
799 if (!isdigit((int) *optarg))
801 resend_count = atoi(optarg);
807 rbtree_insert(filename_tree, optarg);
809 case 'i': /* currently broken */
810 if (!isdigit((int) *optarg))
812 last_used_id = atoi(optarg);
813 if ((last_used_id < 0) || (last_used_id > 255)) {
819 persec = atoi(optarg);
820 if (persec <= 0) usage();
824 * Note that sending MANY requests in
825 * parallel can over-run the kernel
826 * queues, and Linux will happily discard
827 * packets. So even if the server responds,
828 * the client may not see the response.
831 parallel = atoi(optarg);
832 if (parallel <= 0) usage();
839 if (!isdigit((int) *optarg))
841 retries = atoi(optarg);
842 if ((retries == 0) || (retries > 1000)) usage();
848 fp = fopen(optarg, "r");
850 fprintf(stderr, "radclient: Error opening %s: %s\n",
851 optarg, strerror(errno));
854 if (fgets(filesecret, sizeof(filesecret), fp) == NULL) {
855 fprintf(stderr, "radclient: Error reading %s: %s\n",
856 optarg, strerror(errno));
861 /* truncate newline */
862 p = filesecret + strlen(filesecret) - 1;
863 while ((p >= filesecret) &&
869 if (strlen(filesecret) < 2) {
870 fprintf(stderr, "radclient: Secret in %s is too short\n", optarg);
876 if (!isdigit((int) *optarg))
878 timeout = atof(optarg);
881 printf("radclient: $Id$ built on " __DATE__ " at " __TIME__ "\n");
892 argc -= (optind - 1);
893 argv += (optind - 1);
896 ((secret == NULL) && (argc < 4))) {
900 if (dict_init(radius_dir, RADIUS_DICTIONARY) < 0) {
901 librad_perror("radclient");
908 server_ipaddr.af = force_af;
909 if (strcmp(argv[1], "-") != 0) {
910 const char *hostname = argv[1];
911 const char *portname = argv[1];
914 if (*argv[1] == '[') { /* IPv6 URL encoded */
915 p = strchr(argv[1], ']');
916 if ((p - argv[1]) >= sizeof(buffer)) {
920 memcpy(buffer, argv[1] + 1, p - argv[1] - 1);
921 buffer[p - argv[1] - 1] = '\0';
927 p = strchr(portname, ':');
928 if (p && (strchr(p + 1, ':') == NULL)) {
935 if (ip_hton(hostname, force_af, &server_ipaddr) < 0) {
936 fprintf(stderr, "radclient: Failed to find IP address for host %s: %s\n", hostname, strerror(errno));
941 * Strip port from hostname if needed.
943 if (portname) server_port = atoi(portname);
947 * See what kind of request we want to send.
949 if (strcmp(argv[2], "auth") == 0) {
950 if (server_port == 0) server_port = getport("radius");
951 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
952 packet_code = PW_AUTHENTICATION_REQUEST;
954 } else if (strcmp(argv[2], "challenge") == 0) {
955 if (server_port == 0) server_port = getport("radius");
956 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
957 packet_code = PW_ACCESS_CHALLENGE;
959 } else if (strcmp(argv[2], "acct") == 0) {
960 if (server_port == 0) server_port = getport("radacct");
961 if (server_port == 0) server_port = PW_ACCT_UDP_PORT;
962 packet_code = PW_ACCOUNTING_REQUEST;
965 } else if (strcmp(argv[2], "status") == 0) {
966 if (server_port == 0) server_port = getport("radius");
967 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
968 packet_code = PW_STATUS_SERVER;
970 } else if (strcmp(argv[2], "disconnect") == 0) {
971 if (server_port == 0) server_port = PW_POD_UDP_PORT;
972 packet_code = PW_DISCONNECT_REQUEST;
974 } else if (strcmp(argv[2], "coa") == 0) {
975 if (server_port == 0) server_port = PW_POD_UDP_PORT;
976 packet_code = PW_COA_REQUEST;
978 } else if (strcmp(argv[2], "auto") == 0) {
981 } else if (isdigit((int) argv[2][0])) {
982 if (server_port == 0) server_port = getport("radius");
983 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
984 packet_code = atoi(argv[2]);
992 if (argv[3]) secret = argv[3];
995 * If no '-f' is specified, we're reading from stdin.
997 if (rbtree_num_elements(filename_tree) == 0) {
998 rbtree_insert(filename_tree, "-");
1002 * Walk over the list of filenames, creating the requests.
1004 if (rbtree_walk(filename_tree, InOrder, filename_walk, NULL) != 0) {
1009 * No packets read. Die.
1011 if (!radclient_head) {
1012 fprintf(stderr, "radclient: Nothing to send.\n");
1017 * Bind to the first specified IP address and port.
1018 * This means we ignore later ones.
1020 if (radclient_head->request->src_ipaddr.af == AF_UNSPEC) {
1021 memset(&client_ipaddr, 0, sizeof(client_ipaddr));
1022 client_ipaddr.af = server_ipaddr.af;
1025 client_ipaddr = radclient_head->request->src_ipaddr;
1026 client_port = radclient_head->request->src_port;
1028 sockfd = lrad_socket(&client_ipaddr, client_port);
1030 fprintf(stderr, "radclient: socket: %s\n", librad_errstr);
1034 pl = lrad_packet_list_create(1);
1036 fprintf(stderr, "radclient: Out of memory\n");
1040 if (!lrad_packet_list_socket_add(pl, sockfd)) {
1041 fprintf(stderr, "radclient: Out of memory\n");
1046 * Walk over the list of packets, sanity checking
1049 for (this = radclient_head; this != NULL; this = this->next) {
1050 this->request->src_ipaddr = client_ipaddr;
1051 this->request->src_port = client_port;
1052 if (radclient_sane(this) != 0) {
1058 * Walk over the packets to send, until
1061 * FIXME: This currently busy-loops until it receives
1062 * all of the packets. It should really have some sort of
1063 * send packet, get time to wait, select for time, etc.
1069 const char *filename = NULL;
1075 * Walk over the packets, sending them.
1078 for (this = radclient_head; this != NULL; this = next) {
1082 * If there's a packet to receive,
1083 * receive it, but don't wait for a
1089 * This packet is done. Delete it.
1092 radclient_free(this);
1097 * Packets from multiple '-f' are sent
1100 * Packets from one file are sent in
1101 * series, unless '-p' is specified, in
1102 * which case N packets from each file
1103 * are sent in parallel.
1105 if (this->filename != filename) {
1106 filename = this->filename;
1114 * Send the current packet.
1116 send_one_packet(this);
1119 * Wait a little before sending
1120 * the next packet, if told to.
1126 * Don't sleep elsewhere.
1135 tv.tv_usec = 1000000/persec;
1139 * Sleep for milliseconds,
1142 * If we get an error or
1143 * a signal, treat it like
1146 select(0, NULL, NULL, NULL, &tv);
1150 * If we haven't sent this packet
1151 * often enough, we're not done,
1152 * and we shouldn't sleep.
1154 if (this->resend < resend_count) {
1158 } else { /* haven't sent this packet, we're not done */
1159 assert(this->done == 0);
1160 assert(this->reply == NULL);
1166 * Still have outstanding requests.
1168 if (lrad_packet_list_num_elements(pl) > 0) {
1175 * Nothing to do until we receive a request, so
1176 * sleep until then. Once we receive one packet,
1177 * we go back, and walk through the whole list again,
1178 * sending more packets (if necessary), and updating
1181 if (!done && (sleep_time > 0)) {
1182 recv_one_packet(sleep_time);
1186 rbtree_free(filename_tree);
1187 lrad_packet_list_free(pl);
1190 printf("\n\t Total approved auths: %d\n", totalapp);
1191 printf("\t Total denied auths: %d\n", totaldeny);
1192 printf("\t Total lost auths: %d\n", totallost);