newvector should be a bool
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 24 Jun 2014 12:18:27 +0000 (13:18 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 24 Jun 2014 12:57:35 +0000 (13:57 +0100)
17 files changed:
src/include/libradius.h
src/lib/radius.c
src/lib/tcp.c
src/main/command.c
src/main/detail.c
src/main/listen.c
src/main/process.c
src/main/radclient.c
src/main/radsniff.c
src/main/tls_listen.c
src/main/unittest.c
src/main/util.c
src/modules/proto_dhcp/dhcp.c
src/modules/proto_dhcp/dhcpclient.c
src/modules/proto_vmps/vqp.c
src/modules/rlm_eap/radeapclient.c
src/modules/rlm_replicate/rlm_replicate.c

index 48843c8..06e691e 100644 (file)
@@ -494,7 +494,7 @@ int         rad_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                         char const *secret);
 
 int rad_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length);
-RADIUS_PACKET  *rad_alloc(TALLOC_CTX *ctx, int newvector);
+RADIUS_PACKET  *rad_alloc(TALLOC_CTX *ctx, bool new_vector);
 RADIUS_PACKET  *rad_alloc_reply(TALLOC_CTX *ctx, RADIUS_PACKET *);
 RADIUS_PACKET *rad_copy_packet(TALLOC_CTX *ctx, RADIUS_PACKET const *in);
 
index feb7c19..0090f51 100644 (file)
@@ -2617,7 +2617,7 @@ RADIUS_PACKET *rad_recv(int fd, int flags)
        /*
         *      Allocate the new request data structure
         */
-       packet = rad_alloc(NULL, 0);
+       packet = rad_alloc(NULL, false);
        if (!packet) {
                fr_strerror_printf("out of memory");
                return NULL;
@@ -4602,10 +4602,10 @@ uint32_t fr_rand(void)
  *
  * @param ctx the context in which the packet is allocated. May be NULL if
  *     the packet is not associated with a REQUEST.
- * @param newvector if true a new request authenticator will be generated.
+ * @param new_vector if true a new request authenticator will be generated.
  * @return a new RADIUS_PACKET or NULL on error.
  */
-RADIUS_PACKET *rad_alloc(TALLOC_CTX *ctx, int newvector)
+RADIUS_PACKET *rad_alloc(TALLOC_CTX *ctx, bool new_vector)
 {
        RADIUS_PACKET   *rp;
 
@@ -4617,7 +4617,7 @@ RADIUS_PACKET *rad_alloc(TALLOC_CTX *ctx, int newvector)
        rp->id = -1;
        rp->offset = -1;
 
-       if (newvector) {
+       if (new_vector) {
                int i;
                uint32_t hash, base;
 
@@ -4649,7 +4649,7 @@ RADIUS_PACKET *rad_alloc_reply(TALLOC_CTX *ctx, RADIUS_PACKET *packet)
 
        if (!packet) return NULL;
 
-       reply = rad_alloc(ctx, 0);
+       reply = rad_alloc(ctx, false);
        if (!reply) return NULL;
 
        /*
@@ -4704,7 +4704,7 @@ RADIUS_PACKET *rad_copy_packet(TALLOC_CTX *ctx, RADIUS_PACKET const *in)
 {
        RADIUS_PACKET *out;
 
-       out = rad_alloc(ctx, 0);
+       out = rad_alloc(ctx, false);
        if (!out) return NULL;
 
        /*
index 211b182..186198c 100644 (file)
@@ -85,7 +85,7 @@ int fr_tcp_client_socket(fr_ipaddr_t *src_ipaddr,
 
 RADIUS_PACKET *fr_tcp_recv(int sockfd, int flags)
 {
-       RADIUS_PACKET *packet = rad_alloc(NULL, 0);
+       RADIUS_PACKET *packet = rad_alloc(NULL, false);
 
        if (!packet) return NULL;
 
index 14a0c40..1f82507 100644 (file)
@@ -1303,7 +1303,7 @@ static int command_inject_file(rad_listen_t *listener, int argc, char *argv[])
        fake->decode = null_socket_dencode;
        fake->send = null_socket_send;
 
-       packet = rad_alloc(NULL, 0);
+       packet = rad_alloc(NULL, false);
        packet->src_ipaddr = sock->src_ipaddr;
        packet->src_port = 0;
 
index 47c3053..437253c 100644 (file)
@@ -672,7 +672,7 @@ static RADIUS_PACKET *detail_poll(rad_listen_t *listener)
         *      Allocate the packet.  If we fail, it's a serious
         *      problem.
         */
-       packet = rad_alloc(NULL, 1);
+       packet = rad_alloc(NULL, true);
        if (!packet) {
                ERROR("FATAL: Failed allocating memory for detail");
                fr_exit(1);
index 37b613b..c05b892 100644 (file)
@@ -429,7 +429,7 @@ static int dual_tcp_recv(rad_listen_t *listener)
         *      Allocate a packet for partial reads.
         */
        if (!sock->packet) {
-               sock->packet = rad_alloc(sock, 0);
+               sock->packet = rad_alloc(sock, false);
                if (!sock->packet) return 0;
 
                sock->packet->sockfd = listener->fd;
index ba3e52e..0150a1c 100644 (file)
@@ -1727,7 +1727,7 @@ static REQUEST *request_setup(rad_listen_t *listener, RADIUS_PACKET *packet,
         *      Create and initialize the new request.
         */
        request = request_alloc(NULL);
-       request->reply = rad_alloc(request, 0);
+       request->reply = rad_alloc(request, false);
        if (!request->reply) {
                ERROR("No memory");
                talloc_free(request);
@@ -3080,7 +3080,7 @@ static void ping_home_server(void *ctx)
        request->number = request_num_counter++;
        NO_CHILD_THREAD;
 
-       request->proxy = rad_alloc(request, 1);
+       request->proxy = rad_alloc(request, true);
        rad_assert(request->proxy != NULL);
 
        if (home->ping_check == HOME_PING_CHECK_STATUS_SERVER) {
index 04bc729..7477f05 100644 (file)
@@ -313,7 +313,7 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files)
                        goto error;
                }
 
-               request->packet = rad_alloc(request, 1);
+               request->packet = rad_alloc(request, true);
                if (!request->packet) {
                        ERROR("Out of memory");
                        goto error;
index 39f28eb..1b45593 100644 (file)
@@ -1103,7 +1103,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt
         *      recover once some requests timeout, so make an effort to deal
         *      with allocation failures gracefully.
         */
-       current = rad_alloc(conf, 0);
+       current = rad_alloc(conf, false);
        if (!current) {
                REDEBUG("Failed allocating memory to hold decoded packet");
                rs_tv_add_ms(&header->ts, conf->stats.timeout, &stats->quiet);
index fb150fe..f4323a7 100644 (file)
@@ -130,7 +130,7 @@ static int tls_socket_recv(rad_listen_t *listener)
        RADCLIENT *client = sock->client;
 
        if (!sock->packet) {
-               sock->packet = rad_alloc(sock, 0);
+               sock->packet = rad_alloc(sock, false);
                if (!sock->packet) return 0;
 
                sock->packet->sockfd = listener->fd;
@@ -164,7 +164,7 @@ static int tls_socket_recv(rad_listen_t *listener)
                /*
                 *      Not sure if we should do this on every packet...
                 */
-               request->reply = rad_alloc(request, 0);
+               request->reply = rad_alloc(request, false);
                if (!request->reply) return 0;
 
                rad_assert(sock->ssn == NULL);
@@ -629,7 +629,7 @@ int proxy_tls_recv(rad_listen_t *listener)
 
        data = sock->data;
 
-       packet = rad_alloc(sock, 0);
+       packet = rad_alloc(sock, false);
        packet->sockfd = listener->fd;
        packet->src_ipaddr = sock->other_ipaddr;
        packet->src_port = sock->other_port;
index abee1fa..c4b0a35 100644 (file)
@@ -111,14 +111,14 @@ static REQUEST *request_setup(FILE *fp)
         */
        request = request_alloc(NULL);
 
-       request->packet = rad_alloc(request, 0);
+       request->packet = rad_alloc(request, false);
        if (!request->packet) {
                ERROR("No memory");
                talloc_free(request);
                return NULL;
        }
 
-       request->reply = rad_alloc(request, 0);
+       request->reply = rad_alloc(request, false);
        if (!request->reply) {
                ERROR("No memory");
                talloc_free(request);
index d00573b..c9d8b23 100644 (file)
@@ -376,13 +376,13 @@ REQUEST *request_alloc_fake(REQUEST *request)
         */
        fake->server = request->server;
 
-       fake->packet = rad_alloc(fake, 1);
+       fake->packet = rad_alloc(fake, true);
        if (!fake->packet) {
                talloc_free(fake);
                return NULL;
        }
 
-       fake->reply = rad_alloc(fake, 0);
+       fake->reply = rad_alloc(fake, false);
        if (!fake->reply) {
                talloc_free(fake);
                return NULL;
@@ -450,7 +450,7 @@ REQUEST *request_alloc_coa(REQUEST *request)
 
        request->coa->packet->code = 0; /* unknown, as of yet */
        request->coa->child_state = REQUEST_RUNNING;
-       request->coa->proxy = rad_alloc(request->coa, 0);
+       request->coa->proxy = rad_alloc(request->coa, false);
        if (!request->coa->proxy) {
                TALLOC_FREE(request->coa);
                return NULL;
index 3bfe40a..eec47f1 100644 (file)
@@ -225,7 +225,7 @@ RADIUS_PACKET *fr_dhcp_recv(int sockfd)
        uint8_t                 *code;
        ssize_t                 data_len;
 
-       packet = rad_alloc(NULL, 0);
+       packet = rad_alloc(NULL, false);
        if (!packet) {
                fr_strerror_printf("Failed allocating packet");
                return NULL;
index 052fb22..dad87a7 100644 (file)
@@ -107,7 +107,7 @@ static int request_init(char const *filename)
                fp = stdin;
        }
 
-       request = rad_alloc(NULL, 0);
+       request = rad_alloc(NULL, false);
 
        /*
         *      Read the VP's.
index 20c44d8..d8ec296 100644 (file)
@@ -278,7 +278,7 @@ RADIUS_PACKET *vqp_recv(int sockfd)
        /*
         *      Allocate the new request data structure
         */
-       packet = rad_alloc(NULL, 0);
+       packet = rad_alloc(NULL, false);
        if (!packet) {
                fr_strerror_printf("out of memory");
                return NULL;
index c16b8d8..3bbd00f 100644 (file)
@@ -1154,7 +1154,7 @@ int main(int argc, char **argv)
                DEBUG2("Including dictionary file %s/%s", radius_dir, RADIUS_DICTIONARY);
        }
 
-       req = rad_alloc(NULL, 1);
+       req = rad_alloc(NULL, true);
        if (!req) {
                ERROR("%s", fr_strerror());
                exit(1);
@@ -1502,13 +1502,13 @@ main(int argc, char *argv[])
                return 1;
        }
 
-       req = rad_alloc(NULL, 1)
+       req = rad_alloc(NULL, true)
        if (!req) {
                ERROR("%s", fr_strerror());
                exit(1);
        }
 
-       req2 = rad_alloc(NULL, 1);
+       req2 = rad_alloc(NULL, true);
        if (!req2) {
                ERROR("%s", fr_strerror());
                exit(1);
index 8b3e7ab..6df95f8 100644 (file)
@@ -118,7 +118,7 @@ static int replicate_packet(UNUSED void *instance, REQUEST *request, pair_lists_
                 *      we built here.
                 */
                if (!packet) {
-                       packet = rad_alloc(request, 1);
+                       packet = rad_alloc(request, true);
                        if (!packet) {
                                return RLM_MODULE_FAIL;
                        }