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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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$";
38 #include <sys/socket.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
44 #ifdef HAVE_SYS_SELECT_H
45 # include <sys/select.h>
57 #include "libradius.h"
59 static int retries = 10;
60 static float timeout = 3;
61 static const char *secret = NULL;
62 static int do_output = 1;
63 static int totalapp = 0;
64 static int totaldeny = 0;
65 static int totallost = 0;
67 static int server_port = 0;
68 static int packet_code = 0;
69 static lrad_ipaddr_t server_ipaddr;
70 static int resend_count = 1;
74 static int radius_id[256];
75 static int last_used_id = -1;
77 static rbtree_t *filename_tree = NULL;
78 static rbtree_t *request_tree = NULL;
80 static int sleep_time = -1;
82 typedef struct radclient_t {
83 struct radclient_t *prev;
84 struct radclient_t *next;
87 int packet_number; /* in the file */
90 RADIUS_PACKET *request;
97 static radclient_t *radclient_head = NULL;
98 static radclient_t *radclient_tail = NULL;
101 static void usage(void)
103 fprintf(stderr, "Usage: radclient [options] server[:port] <command> [<secret>]\n");
105 fprintf(stderr, " <command> One of auth, acct, status, or disconnect.\n");
106 fprintf(stderr, " -c count Send each packet 'count' times.\n");
107 fprintf(stderr, " -d raddb Set dictionary directory.\n");
108 fprintf(stderr, " -f file Read packets from file, not stdin.\n");
109 fprintf(stderr, " -i id Set request id to 'id'. Values may be 0..255\n");
110 fprintf(stderr, " -n num Send N requests/s\n");
111 fprintf(stderr, " -p num Send 'num' packets from a file in parallel.\n");
112 fprintf(stderr, " -q Do not print anything out.\n");
113 fprintf(stderr, " -r retries If timeout, retry sending the packet 'retries' times.\n");
114 fprintf(stderr, " -s Print out summary information of auth results.\n");
115 fprintf(stderr, " -S file read secret from file, not command line.\n");
116 fprintf(stderr, " -t timeout Wait 'timeout' seconds before retrying (may be a floating point number).\n");
117 fprintf(stderr, " -v Show program version information.\n");
118 fprintf(stderr, " -x Debugging mode.\n");
119 fprintf(stderr, " -4 Use IPv4 address of server\n");
120 fprintf(stderr, " -6 Use IPv6 address of server.\n");
126 * Free a radclient struct, which may (or may not)
127 * already be in the list.
129 static void radclient_free(radclient_t *radclient)
131 radclient_t *prev, *next;
133 if (radclient->request) rad_free(&radclient->request);
134 if (radclient->reply) rad_free(&radclient->reply);
136 prev = radclient->prev;
137 next = radclient->next;
140 assert(radclient_head != radclient);
142 } else if (radclient_head) {
143 assert(radclient_head == radclient);
144 radclient_head = next;
148 assert(radclient_tail != radclient);
150 } else if (radclient_tail) {
151 assert(radclient_tail == radclient);
152 radclient_tail = prev;
159 * Initialize a radclient data structure
161 static radclient_t *radclient_init(const char *filename)
165 radclient_t *start, *radclient, *prev = NULL;
167 int packet_number = 1;
170 assert(filename != NULL);
173 * Determine where to read the VP's from.
175 if (strcmp(filename, "-") != 0) {
176 fp = fopen(filename, "r");
178 fprintf(stderr, "radclient: Error opening %s: %s\n",
179 filename, strerror(errno));
187 * Loop until the file is done.
193 radclient = malloc(sizeof(*radclient));
195 perror("radclient: ");
196 return NULL; /* memory leak "start" */
198 memset(radclient, 0, sizeof(*radclient));
200 radclient->request = rad_alloc(1);
201 if (!radclient->request) {
202 librad_perror("radclient: ");
203 radclient_free(radclient);
204 return NULL; /* memory leak "start" */
207 radclient->filename = filename;
208 radclient->request->id = -1; /* allocate when sending */
209 radclient->packet_number = packet_number++;
214 radclient->request->vps = readvp2(fp, &filedone, "radclient:");
215 if (!radclient->request->vps) {
216 radclient_free(radclient);
217 return start; /* done: return the list */
221 * Keep a copy of the the User-Password attribute.
223 if ((vp = pairfind(radclient->request->vps, PW_PASSWORD)) != NULL) {
224 strNcpy(radclient->password, vp->vp_strvalue,
225 sizeof(radclient->password));
227 * Otherwise keep a copy of the CHAP-Password attribute.
229 } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
230 strNcpy(radclient->password, vp->vp_strvalue,
231 sizeof(radclient->password));
233 radclient->password[0] = '\0';
237 * Fix up Digest-Attributes issues
239 for (vp = radclient->request->vps; vp != NULL; vp = vp->next) {
240 switch (vp->attribute) {
245 * Allow it to set the packet type in
246 * the attributes read from the file.
249 radclient->request->code = vp->lvalue;
252 case PW_PACKET_DST_PORT:
253 radclient->request->dst_port = (vp->lvalue & 0xffff);
256 case PW_PACKET_DST_IP_ADDRESS:
257 radclient->request->dst_ipaddr.af = AF_INET;
258 radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
261 case PW_PACKET_DST_IPV6_ADDRESS:
262 radclient->request->dst_ipaddr.af = AF_INET6;
263 radclient->request->dst_ipaddr.ipaddr.ip6addr = vp->vp_ipv6addr;
266 case PW_PACKET_SRC_PORT:
267 radclient->request->src_port = (vp->lvalue & 0xffff);
270 case PW_PACKET_SRC_IP_ADDRESS:
271 radclient->request->src_ipaddr.af = AF_INET;
272 radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
275 case PW_PACKET_SRC_IPV6_ADDRESS:
276 radclient->request->src_ipaddr.af = AF_INET6;
277 radclient->request->src_ipaddr.ipaddr.ip6addr = vp->vp_ipv6addr;
280 case PW_DIGEST_REALM:
281 case PW_DIGEST_NONCE:
282 case PW_DIGEST_METHOD:
285 case PW_DIGEST_ALGORITHM:
286 case PW_DIGEST_BODY_DIGEST:
287 case PW_DIGEST_CNONCE:
288 case PW_DIGEST_NONCE_COUNT:
289 case PW_DIGEST_USER_NAME:
291 memmove(&vp->vp_octets[2], &vp->vp_octets[0],
293 vp->vp_octets[0] = vp->attribute - PW_DIGEST_REALM + 1;
295 vp->vp_octets[1] = vp->length;
296 vp->attribute = PW_DIGEST_ATTRIBUTES;
299 } /* loop over the VP's we read in */
305 prev->next = radclient;
306 radclient->prev = prev;
309 } while (!filedone); /* loop until the file is done. */
311 if (fp != stdin) fclose(fp);
321 * Sanity check each argument.
323 static int radclient_sane(radclient_t *radclient)
325 if (radclient->request->dst_port == 0) {
326 radclient->request->dst_port = server_port;
328 if (radclient->request->dst_ipaddr.af == AF_UNSPEC) {
329 if (server_ipaddr.af == AF_UNSPEC) {
330 fprintf(stderr, "radclient: No server was given, but request %d in file %s did not contain Packet-Dst-IP-Address\n",
331 radclient->packet_number, radclient->filename);
334 radclient->request->dst_ipaddr = server_ipaddr;
336 if (radclient->request->code == 0) {
337 if (packet_code == -1) {
338 fprintf(stderr, "radclient: Request was \"auto\", but request %d in file %s did not contain Packet-Type\n",
339 radclient->packet_number, radclient->filename);
343 radclient->request->code = packet_code;
345 radclient->request->sockfd = sockfd;
352 * For request handline.
354 static int filename_cmp(const void *one, const void *two)
356 return strcmp((const char *) one, (const char *) two);
359 static int filename_walk(void *context, void *data)
361 const char *filename = data;
362 radclient_t *radclient;
364 context = context; /* -Wunused */
367 * Initialize the request we're about
370 radclient = radclient_init(filename);
375 if (!radclient_head) {
376 assert(radclient_tail == NULL);
377 radclient_head = radclient;
379 assert(radclient_tail->next == NULL);
380 radclient_tail->next = radclient;
381 radclient->prev = radclient_tail;
385 * We may have had a list of "radclient" structures
388 while (radclient->next) radclient = radclient->next;
389 radclient_tail = radclient;
396 * Compare two RADIUS_PACKET data structures, based on a number
399 static int request_cmp(const void *one, const void *two)
402 const radclient_t *a = one;
403 const radclient_t *b = two;
406 * The following code looks unreasonable, but it's
407 * the only way to make the comparisons work.
409 if (a->request->id < b->request->id) return -1;
410 if (a->request->id > b->request->id) return +1;
412 if (a->request->dst_ipaddr.af < b->request->dst_ipaddr.af) return -1;
413 if (a->request->dst_ipaddr.af > b->request->dst_ipaddr.af) return +1;
415 switch (a->request->dst_ipaddr.af) {
417 rcode = memcmp(&a->request->dst_ipaddr.ipaddr.ip4addr,
418 &b->request->dst_ipaddr.ipaddr.ip4addr,
419 sizeof(a->request->dst_ipaddr.ipaddr.ip4addr));
422 rcode = memcmp(&a->request->dst_ipaddr.ipaddr.ip6addr,
423 &b->request->dst_ipaddr.ipaddr.ip6addr,
424 sizeof(a->request->dst_ipaddr.ipaddr.ip6addr));
426 default: /* FIXME: die! */
430 if (rcode != 0) return rcode;
432 if (a->request->dst_port < b->request->dst_port) return -1;
433 if (a->request->dst_port > b->request->dst_port) return +1;
436 * Everything's equal. Say so.
444 static void request_free(void *data)
446 radclient_t *radclient = (radclient_t *) data;
448 if (!radclient || !radclient->request ||
449 (radclient->request->id < 0)) {
454 * One more unused RADIUS ID.
456 radius_id[radclient->request->id] = 0;
457 radclient->request->id = -1;
460 * If we've already sent a packet, free up the old one,
461 * and ensure that the next packet has a unique
462 * authentication vector.
464 if (radclient->request->data) {
465 free(radclient->request->data);
466 radclient->request->data = NULL;
469 if (radclient->reply) rad_free(&radclient->reply);
476 static int send_one_packet(radclient_t *radclient)
480 assert(radclient->done == 0);
483 * Remember when we have to wake up, to re-send the
484 * request, of we didn't receive a response.
486 if ((sleep_time == -1) ||
487 (sleep_time > (int) timeout)) {
488 sleep_time = (int) timeout;
492 * Haven't sent the packet yet. Initialize it.
494 if (radclient->request->id == -1) {
497 assert(radclient->reply == NULL);
500 * Find a free packet Id
502 for (i = 0; i < 256; i++) {
503 if (radius_id[(last_used_id + i) & 0xff] == 0) {
504 last_used_id = (last_used_id + i) & 0xff;
505 radius_id[last_used_id] = 1;
506 radclient->request->id = last_used_id++;
513 * Didn't find a free packet ID, we're not done,
514 * we don't sleep, and we stop trying to process
523 assert(radclient->request->id != -1);
524 assert(radclient->request->data == NULL);
526 librad_md5_calc(radclient->request->vector, radclient->request->vector,
527 sizeof(radclient->request->vector));
530 * Update the password, so it can be encrypted with the
531 * new authentication vector.
533 if (radclient->password[0] != '\0') {
536 if ((vp = pairfind(radclient->request->vps, PW_PASSWORD)) != NULL) {
537 strNcpy(vp->vp_strvalue, radclient->password,
538 sizeof(vp->vp_strvalue));
539 vp->length = strlen(vp->vp_strvalue);
541 } else if ((vp = pairfind(radclient->request->vps, PW_CHAP_PASSWORD)) != NULL) {
542 strNcpy(vp->vp_strvalue, radclient->password,
543 sizeof(vp->vp_strvalue));
544 vp->length = strlen(vp->vp_strvalue);
546 rad_chap_encode(radclient->request,
548 radclient->request->id, vp);
553 radclient->timestamp = time(NULL);
554 radclient->tries = 1;
558 * Duplicate found. Serious error!
560 if (rbtree_insert(request_tree, radclient) == 0) {
564 } else { /* radclient->request->id >= 0 */
565 time_t now = time(NULL);
568 * FIXME: Accounting packets are never retried!
569 * The Acct-Delay-Time attribute is updated to
570 * reflect the delay, and the packet is re-sent
575 * Not time for a retry, do so.
577 if ((now - radclient->timestamp) < timeout) {
579 * When we walk over the tree sending
580 * packets, we update the minimum time
583 if ((sleep_time == -1) ||
584 (sleep_time > (now - radclient->timestamp))) {
585 sleep_time = now - radclient->timestamp;
591 * We're not trying later, maybe the packet is done.
593 if (radclient->tries == retries) {
595 assert(radclient->request->id >= 0);
598 * Delete the request from the tree of
599 * outstanding requests.
601 node = rbtree_find(request_tree, radclient);
602 assert(node != NULL);
604 fprintf(stderr, "radclient: no response from server for ID %d\n", radclient->request->id);
605 rbtree_delete(request_tree, node);
608 * Normally we mark it "done" when we've received
609 * the response, but this is a special case.
611 if (radclient->resend == resend_count) {
619 * We are trying later.
621 radclient->timestamp = now;
629 if (rad_send(radclient->request, NULL, secret) < 0) {
630 fprintf(stderr, "radclient: Failed to send packet for ID %d: %s\n",
631 radclient->request->id, librad_errstr);
638 * Receive one packet, maybe.
640 static int recv_one_packet(int wait_time)
644 radclient_t myclient, *radclient;
645 RADIUS_PACKET myrequest, *reply;
649 /* And wait for reply, timing out as necessary */
651 FD_SET(sockfd, &set);
653 if (wait_time <= 0) {
656 tv.tv_sec = wait_time;
661 * No packet was received.
663 if (select(sockfd + 1, &set, NULL, NULL, &tv) != 1) {
668 * Look for the packet.
670 reply = rad_recv(sockfd);
672 fprintf(stderr, "radclient: received bad packet: %s\n",
674 return -1; /* bad packet */
677 myclient.request = &myrequest;
678 myrequest.id = reply->id;
679 myrequest.dst_ipaddr = reply->src_ipaddr;
680 myrequest.dst_port = reply->src_port;
682 node = rbtree_find(request_tree, &myclient);
684 fprintf(stderr, "radclient: received response to request we did not send.\n");
686 return -1; /* got reply to packet we didn't send */
689 radclient = rbtree_node2data(request_tree, node);
690 assert(radclient != NULL);
691 rbtree_delete(request_tree, node);
692 assert(radclient->request->id == -1);
693 assert(radclient->request->data == NULL);
695 assert(radclient->reply == NULL);
696 radclient->reply = reply;
699 * FIXME: Do stuff to process the reply.
701 if (rad_decode(reply, radclient->request, secret) != 0) {
702 librad_perror("rad_decode");
703 rad_free(&radclient->reply);
708 /* libradius debug already prints out the value pairs for us */
709 if (!librad_debug && do_output) {
710 printf("Received response ID %d, code %d, length = %d\n",
711 reply->id, reply->code, reply->data_len);
712 vp_printlist(stdout, reply->vps);
714 if (reply->code != PW_AUTHENTICATION_REJECT) {
720 if (radclient->reply) rad_free(&radclient->reply);
723 * Once we've sent the packet as many times as requested,
726 if (radclient->resend == resend_count) {
727 assert((node = rbtree_find(request_tree, radclient)) == NULL);
735 static int getport(const char *name)
739 svp = getservbyname (name, "udp");
744 return ntohs(svp->s_port);
747 int main(int argc, char **argv)
751 const char *radius_dir = RADDBDIR;
752 char filesecret[256];
758 int force_af = AF_UNSPEC;
760 struct sockaddr_storage ss;
761 struct sockaddr_in *s4;
765 filename_tree = rbtree_create(filename_cmp, NULL, 0);
766 if (!filename_tree) {
767 fprintf(stderr, "radclient: Out of memory\n");
771 request_tree = rbtree_create(request_cmp, request_free, 0);
773 fprintf(stderr, "radclient: Out of memory\n");
777 while ((c = getopt(argc, argv, "46c:d:f:hi:n:p:qr:sS:t:vx")) != EOF) switch(c) {
785 if (!isdigit((int) *optarg))
787 resend_count = atoi(optarg);
793 rbtree_insert(filename_tree, optarg);
796 if (!isdigit((int) *optarg))
798 last_used_id = atoi(optarg);
799 if ((last_used_id < 0) || (last_used_id > 255)) {
805 persec = atoi(optarg);
806 if (persec <= 0) usage();
810 parallel = atoi(optarg);
811 if (parallel <= 0) usage();
818 if (!isdigit((int) *optarg))
820 retries = atoi(optarg);
821 if ((retries == 0) || (retries > 1000)) usage();
827 fp = fopen(optarg, "r");
829 fprintf(stderr, "radclient: Error opening %s: %s\n",
830 optarg, strerror(errno));
833 if (fgets(filesecret, sizeof(filesecret), fp) == NULL) {
834 fprintf(stderr, "radclient: Error reading %s: %s\n",
835 optarg, strerror(errno));
840 /* truncate newline */
841 p = filesecret + strlen(filesecret) - 1;
842 while ((p >= filesecret) &&
848 if (strlen(filesecret) < 2) {
849 fprintf(stderr, "radclient: Secret in %s is too short\n", optarg);
855 if (!isdigit((int) *optarg))
857 timeout = atof(optarg);
860 printf("radclient: $Id$ built on " __DATE__ " at " __TIME__ "\n");
871 argc -= (optind - 1);
872 argv += (optind - 1);
875 ((secret == NULL) && (argc < 4))) {
879 if (dict_init(radius_dir, RADIUS_DICTIONARY) < 0) {
880 librad_perror("radclient");
887 server_ipaddr.af = force_af;
888 if (strcmp(argv[1], "-") != 0) {
889 const char *hostname = argv[1];
890 const char *portname = argv[1];
893 if (*argv[1] == '[') { /* IPv6 URL encoded */
894 p = strchr(argv[1], ']');
895 if ((p - argv[1]) >= sizeof(buffer)) {
899 memcpy(buffer, argv[1] + 1, p - argv[1] - 1);
900 buffer[p - argv[1] - 1] = '\0';
906 p = strchr(portname, ':');
907 if (p && (strchr(p + 1, ':') == NULL)) {
914 if (ip_hton(hostname, force_af, &server_ipaddr) < 0) {
915 fprintf(stderr, "radclient: Failed to find IP address for host %s: %s\n", argv[1], strerror(errno));
920 * Strip port from hostname if needed.
922 if (portname) server_port = atoi(portname);
925 memset(radius_id, 0, sizeof(radius_id));
928 * See what kind of request we want to send.
930 if (strcmp(argv[2], "auth") == 0) {
931 if (server_port == 0) server_port = getport("radius");
932 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
933 packet_code = PW_AUTHENTICATION_REQUEST;
935 } else if (strcmp(argv[2], "challenge") == 0) {
936 if (server_port == 0) server_port = getport("radius");
937 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
938 packet_code = PW_ACCESS_CHALLENGE;
940 } else if (strcmp(argv[2], "acct") == 0) {
941 if (server_port == 0) server_port = getport("radacct");
942 if (server_port == 0) server_port = PW_ACCT_UDP_PORT;
943 packet_code = PW_ACCOUNTING_REQUEST;
946 } else if (strcmp(argv[2], "status") == 0) {
947 if (server_port == 0) server_port = getport("radius");
948 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
949 packet_code = PW_STATUS_SERVER;
951 } else if (strcmp(argv[2], "disconnect") == 0) {
952 if (server_port == 0) server_port = PW_POD_UDP_PORT;
953 packet_code = PW_DISCONNECT_REQUEST;
955 } else if (strcmp(argv[2], "auto") == 0) {
958 } else if (isdigit((int) argv[2][0])) {
959 if (server_port == 0) server_port = getport("radius");
960 if (server_port == 0) server_port = PW_AUTH_UDP_PORT;
961 packet_code = atoi(argv[2]);
969 if (argv[3]) secret = argv[3];
972 * If no '-f' is specified, we're reading from stdin.
974 if (rbtree_num_elements(filename_tree) == 0) {
975 rbtree_insert(filename_tree, "-");
979 * Walk over the list of filenames, creating the requests.
981 if (rbtree_walk(filename_tree, InOrder, filename_walk, NULL) != 0) {
986 * No packets read. Die.
988 if (!radclient_head) {
989 fprintf(stderr, "radclient: Nothing to send.\n");
994 * Bind only if Packet-Src-IP(v6)Address Attribute is found
996 switch (radclient_head->request->src_ipaddr.af) {
1002 if ((sockfd = socket(server_ipaddr.af, SOCK_DGRAM, 0)) < 0) {
1003 perror("radclient: socket: ");
1008 #ifdef HAVE_STRUCT_SOCKADDR_IN6
1011 struct sockaddr_in6 *s6;
1012 s6 = (struct sockaddr_in6 *)&ss;
1013 len = sizeof(struct sockaddr_in6);
1014 s6->sin6_family = AF_INET6;
1015 s6->sin6_flowinfo = 0;
1016 s6->sin6_port = htons(radclient_head->request->src_port);
1017 memcpy(&s6->sin6_addr, &radclient_head->request->src_ipaddr.ipaddr, 16);
1023 s4 = (struct sockaddr_in *)&ss;
1024 len = sizeof(struct sockaddr_in);
1025 s4->sin_family = AF_INET;
1026 s4->sin_port = htons(radclient_head->request->src_port);
1027 memcpy(&s4->sin_addr, &radclient_head->request->src_ipaddr.ipaddr, 4);
1031 if ((sockfd = socket(radclient_head->request->src_ipaddr.af,
1032 SOCK_DGRAM, 0)) < 0) {
1034 perror("radclient: socket: ");
1037 if (bind(sockfd, (struct sockaddr *)&ss, len) < 0) {
1038 perror("radclient: bind: ");
1045 * Walk over the list of packets, sanity checking
1048 for (this = radclient_head; this != NULL; this = this->next) {
1049 if (radclient_sane(this) != 0) {
1054 if (last_used_id < 0) last_used_id = getpid() & 0xff;
1057 * Walk over the packets to send, until
1060 * FIXME: This currently busy-loops until it receives
1061 * all of the packets. It should really have some sort of
1062 * send packet, get time to wait, select for time, etc.
1068 const char *filename = NULL;
1074 * Walk over the packets, sending them.
1077 for (this = radclient_head; this != NULL; this = next) {
1081 * If there's a packet to receive,
1082 * receive it, but don't wait for a
1088 * This packet is done. Delete it.
1091 radclient_free(this);
1096 * Packets from multiple '-f' are sent
1099 * Packets from one file are sent in
1100 * series, unless '-p' is specified, in
1101 * which case N packets from each file
1102 * are sent in parallel.
1104 if (this->filename != filename) {
1105 filename = this->filename;
1113 * Send the current packet.
1115 send_one_packet(this);
1118 * Wait a little before sending
1119 * the next packet, if told to.
1125 * Don't sleep elsewhere.
1134 tv.tv_usec = 1000000/persec;
1138 * Sleep for milliseconds,
1141 * If we get an error or
1142 * a signal, treat it like
1145 select(0, NULL, NULL, NULL, &tv);
1149 * If we haven't sent this packet
1150 * often enough, we're not done,
1151 * and we shouldn't sleep.
1153 if (this->resend < resend_count) {
1157 } else { /* haven't sent this packet, we're not done */
1158 assert(this->done == 0);
1159 assert(this->reply == NULL);
1165 * Still have outstanding requests.
1167 if (rbtree_num_elements(request_tree) > 0) {
1174 * Nothing to do until we receive a request, so
1175 * sleep until then. Once we receive one packet,
1176 * we go back, and walk through the whole list again,
1177 * sending more packets (if necessary), and updating
1180 if (!done && (sleep_time > 0)) {
1181 recv_one_packet(sleep_time);
1185 rbtree_free(filename_tree);
1186 rbtree_free(request_tree);
1189 printf("\n\t Total approved auths: %d\n", totalapp);
1190 printf("\t Total denied auths: %d\n", totaldeny);
1191 printf("\t Total lost auths: %d\n", totallost);