Delete trailing whitespace.
[freeradius.git] / src / main / radclient.c
index cd1ccb0..fb8cd40 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSID("$Id$")
 
-#include <freeradius-devel/autoconf.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef HAVE_UNISTD_H
-#      include <unistd.h>
-#endif
+#include <freeradius-devel/libradius.h>
+#include <freeradius-devel/conf.h>
+#include <freeradius-devel/radpaths.h>
 
-#include <string.h>
 #include <ctype.h>
-#include <netdb.h>
-
-#ifdef HAVE_SYS_SELECT_H
-#      include <sys/select.h>
-#endif
 
 #ifdef HAVE_GETOPT_H
 #      include <getopt.h>
@@ -48,11 +37,6 @@ RCSID("$Id$")
 
 #include <assert.h>
 
-#include <freeradius-devel/conf.h>
-#include <freeradius-devel/radpaths.h>
-#include <freeradius-devel/missing.h>
-#include <freeradius-devel/libradius.h>
-
 static int retries = 10;
 static float timeout = 3;
 static const char *secret = NULL;
@@ -246,16 +230,16 @@ static radclient_t *radclient_init(const char *filename)
                                 *      the attributes read from the file.
                                 */
                        case PW_PACKET_TYPE:
-                               radclient->request->code = vp->lvalue;
+                               radclient->request->code = vp->vp_integer;
                                break;
 
                        case PW_PACKET_DST_PORT:
-                               radclient->request->dst_port = (vp->lvalue & 0xffff);
+                               radclient->request->dst_port = (vp->vp_integer & 0xffff);
                                break;
 
                        case PW_PACKET_DST_IP_ADDRESS:
                                radclient->request->dst_ipaddr.af = AF_INET;
-                               radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+                               radclient->request->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
                                break;
 
                        case PW_PACKET_DST_IPV6_ADDRESS:
@@ -264,12 +248,12 @@ static radclient_t *radclient_init(const char *filename)
                                break;
 
                        case PW_PACKET_SRC_PORT:
-                               radclient->request->src_port = (vp->lvalue & 0xffff);
+                               radclient->request->src_port = (vp->vp_integer & 0xffff);
                                break;
 
                        case PW_PACKET_SRC_IP_ADDRESS:
                                radclient->request->src_ipaddr.af = AF_INET;
-                               radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->lvalue;
+                               radclient->request->src_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
                                break;
 
                        case PW_PACKET_SRC_IPV6_ADDRESS:
@@ -437,7 +421,7 @@ static void print_hex(RADIUS_PACKET *packet)
                printf("%02x", packet->data[i]);
        }
        printf("\n");
-       
+
        if (packet->data_len > 20) {
                int total;
                const uint8_t *ptr;
@@ -581,7 +565,7 @@ static int send_one_packet(radclient_t *radclient)
                if (!lrad_packet_list_insert(pl, &radclient->request)) {
                        assert(0 == 1);
                }
-               
+
 
        } else {                /* radclient->request->id >= 0 */
                time_t now = time(NULL);
@@ -614,7 +598,7 @@ static int send_one_packet(radclient_t *radclient)
                 */
                if (radclient->tries == retries) {
                        assert(radclient->request->id >= 0);
-                       
+
                        /*
                         *      Delete the request from the tree of
                         *      outstanding requests.
@@ -623,7 +607,7 @@ static int send_one_packet(radclient_t *radclient)
 
                        fprintf(stderr, "radclient: no response from server for ID %d socket %d\n", radclient->request->id, radclient->request->sockfd);
                        deallocate_id(radclient);
-                       
+
                        /*
                         *      Normally we mark it "done" when we've received
                         *      the response, but this is a special case.
@@ -751,11 +735,12 @@ packet_done:
         *      Once we've sent the packet as many times as requested,
         *      mark it done.
         */
-       if ((radclient->resend == resend_count) && radclient->reply) {
+       if ((radclient->done) ||
+           (radclient->resend == resend_count)) {
                assert(lrad_packet_list_find(pl, radclient->request) == NULL);
                radclient->done = 1;
-               rad_free(&radclient->reply);
        }
+       rad_free(&radclient->reply);
 
        return 0;
 }
@@ -925,7 +910,7 @@ int main(int argc, char **argv)
                        if ((p - argv[1]) >= sizeof(buffer)) {
                                usage();
                        }
-                       
+
                        memcpy(buffer, argv[1] + 1, p - argv[1] - 1);
                        buffer[p - argv[1] - 1] = '\0';
 
@@ -1143,7 +1128,7 @@ int main(int argc, char **argv)
                                                tv.tv_sec = 0;
                                                tv.tv_usec = 1000000/persec;
                                        }
-                                       
+
                                        /*
                                         *      Sleep for milliseconds,
                                         *      portably.