Committer: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx> Date: 18/05/2010 at 01:12:06 Revision: 4549 Revision-id: mircea.gherzan@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Shadowing fixes, part 1. Modified: M hipd/blind.c M hipd/close.c M hipd/hidb.c M hipd/hipd.c M hipd/init.c M hipd/input.c M hipd/keymat.c M hipd/maintenance.c M lib/core/builder.c M lib/core/certtools.c M lib/core/conf.c M lib/core/debug.c M lib/core/hashtree.c M lib/core/hostid.c M lib/core/message.c M lib/core/performance.c M lib/opphip/wrap.c M lib/opphip/wrap_db.c M lib/tool/nlink.c M test/dh_performance.c === modified file 'hipd/blind.c' --- hipd/blind.c 2010-05-17 16:55:10 +0000 +++ hipd/blind.c 2010-05-17 22:11:11 +0000 @@ -471,10 +471,11 @@ * build_param_encrypted_aes has already taken care that there is * enough padding */ if (entry->hip_transform == HIP_HIP_AES_SHA1) { - int remainder = host_id_in_enc_len % 16; - if (remainder) { + /* remainder */ + int rem = host_id_in_enc_len % 16; + if (rem) { HIP_DEBUG("Remainder %d (for AES)\n", remainder); - host_id_in_enc_len += remainder; + host_id_in_enc_len += rem; } } === modified file 'hipd/close.c' --- hipd/close.c 2010-05-17 16:55:10 +0000 +++ hipd/close.c 2010-05-17 22:11:11 +0000 @@ -26,16 +26,16 @@ */ static int hip_xmit_close(hip_ha_t *entry, void *opaque) { + int err = 0, mask = 0; + int delete_ha_info = *(int *) ((uint8_t *)opaque + sizeof(hip_hit_t)); + hip_hit_t *peer = (hip_hit_t *) opaque; + struct hip_common *msg_close = NULL; + #ifdef CONFIG_HIP_PERFORMANCE HIP_DEBUG("Start PERF_CLOSE_SEND, PERF_CLOSE_COMPLETE\n"); hip_perf_start_benchmark( perf_set, PERF_CLOSE_SEND ); hip_perf_start_benchmark( perf_set, PERF_CLOSE_COMPLETE ); #endif - int err = 0, mask = 0; - hip_hit_t *peer = (hip_hit_t *) opaque; - int delete_ha_info = *(int *) ((uint8_t *)opaque + sizeof(hip_hit_t)); - - struct hip_common *close = NULL; if (peer) { HIP_DEBUG_HIT("Peer HIT to be closed", peer); @@ -73,9 +73,9 @@ &entry->hit_our, &entry->hit_peer); - HIP_IFE(!(close = hip_msg_alloc()), -ENOMEM); + HIP_IFE(!(msg_close = hip_msg_alloc()), -ENOMEM); - entry->hadb_misc_func->hip_build_network_hdr(close, + entry->hadb_misc_func->hip_build_network_hdr(msg_close, HIP_CLOSE, mask, &entry->hit_our, @@ -85,23 +85,23 @@ get_random_bytes(entry->echo_data, sizeof(entry->echo_data)); - HIP_IFEL(hip_build_param_echo(close, entry->echo_data, sizeof(entry->echo_data), 1, 1), + HIP_IFEL(hip_build_param_echo(msg_close, entry->echo_data, sizeof(entry->echo_data), 1, 1), -1, "Failed to build echo param.\n"); /************* HMAC ************/ - HIP_IFEL(hip_build_param_hmac_contents(close, &entry->hip_hmac_out), + HIP_IFEL(hip_build_param_hmac_contents(msg_close, &entry->hip_hmac_out), -1, "Building of HMAC failed.\n"); /********** Signature **********/ - HIP_IFEL(entry->sign(entry->our_priv_key, close), + HIP_IFEL(entry->sign(entry->our_priv_key, msg_close), -EINVAL, "Could not create signature.\n"); HIP_IFEL(entry->hadb_xmit_func-> hip_send_pkt(NULL, &entry->peer_addr, (entry->nat_mode ? hip_get_local_nat_udp_port() : 0), - entry->peer_udp_port, close, entry, 0), + entry->peer_udp_port, msg_close, entry, 0), -ECOMM, "Sending CLOSE message failed.\n"); entry->state = HIP_STATE_CLOSING; @@ -112,8 +112,8 @@ #endif out_err: - if (close) { - free(close); + if (msg_close) { + free(msg_close); } return err; @@ -194,11 +194,11 @@ /** * process a CLOSE message * - * @param close the CLOSE message process - * @param entry the corresponding host association - * @return zero on success or negative on error + * @param close_msg the CLOSE message process + * @param entry the corresponding host association + * @return zero on success or negative on error */ -int hip_handle_close(struct hip_common *close, hip_ha_t *entry) +int hip_handle_close(struct hip_common *close_msg, hip_ha_t *entry) { #ifdef CONFIG_HIP_PERFORMANCE HIP_DEBUG("Start PERF_HANDLE_CLOSE\n"); @@ -211,21 +211,21 @@ /* verify HMAC */ if (entry->is_loopback) { - HIP_IFEL(hip_verify_packet_hmac(close, &entry->hip_hmac_out), + HIP_IFEL(hip_verify_packet_hmac(close_msg, &entry->hip_hmac_out), -ENOENT, "HMAC validation on close failed.\n"); } else { - HIP_IFEL(hip_verify_packet_hmac(close, &entry->hip_hmac_in), + HIP_IFEL(hip_verify_packet_hmac(close_msg, &entry->hip_hmac_in), -ENOENT, "HMAC validation on close failed.\n"); } /* verify signature */ - HIP_IFEL(entry->verify(entry->peer_pub_key, close), -EINVAL, + HIP_IFEL(entry->verify(entry->peer_pub_key, close_msg), -EINVAL, "Verification of close signature failed.\n"); HIP_IFE(!(close_ack = hip_msg_alloc()), -ENOMEM); HIP_IFEL(!(request = - hip_get_param(close, HIP_PARAM_ECHO_REQUEST_SIGN)), + hip_get_param(close_msg, HIP_PARAM_ECHO_REQUEST_SIGN)), -1, "No echo request under signature.\n"); echo_len = hip_get_param_contents_len(request); @@ -261,13 +261,13 @@ #ifdef CONFIG_HIP_RVS if (hip_relay_get_status()) { hip_relrec_t dummy; - memcpy(&(dummy.hit_r), &(close->hits), - sizeof(close->hits)); + memcpy(&(dummy.hit_r), &(close_msg->hits), + sizeof(close_msg->hits)); hip_relht_rec_free_doall(&dummy); /* Check that the element really got deleted. */ if (hip_relht_get(&dummy) == NULL) { HIP_DEBUG_HIT("Deleted relay record for HIT", - &(close->hits)); + &(close_msg->hits)); } } #endif @@ -295,7 +295,7 @@ * @param entry the corresponding host association * @return zero on success or negative on error */ -int hip_receive_close(struct hip_common *close, +int hip_receive_close(struct hip_common *close_msg, hip_ha_t *entry) { int state = 0; @@ -305,12 +305,12 @@ /* XX FIX: CHECK THE SIGNATURE */ HIP_DEBUG("\n"); - HIP_IFEL(ipv6_addr_any(&close->hitr), -1, + HIP_IFEL(ipv6_addr_any(&close_msg->hitr), -1, "Received NULL receiver HIT in CLOSE. Dropping\n"); - if (!hip_controls_sane(ntohs(close->control), mask)) { + if (!hip_controls_sane(ntohs(close_msg->control), mask)) { HIP_ERROR("Received illegal controls in CLOSE: 0x%x. Dropping\n", - ntohs(close->control)); + ntohs(close_msg->control)); goto out_err; } @@ -325,7 +325,7 @@ switch (state) { case HIP_STATE_ESTABLISHED: case HIP_STATE_CLOSING: - err = entry->hadb_handle_func->hip_handle_close(close, entry); + err = entry->hadb_handle_func->hip_handle_close(close_msg, entry); break; default: HIP_ERROR("Internal state (%d) is incorrect\n", state); === modified file 'hipd/hidb.c' --- hipd/hidb.c 2010-05-17 18:24:10 +0000 +++ hipd/hidb.c 2010-05-17 22:11:11 +0000 @@ -278,8 +278,8 @@ * @param db database structure. * @param lhi HIT * @param host_id HI - * @param insert the handler to call right after the host id is added - * @param remove the handler to call right before the host id is removed + * @param add the handler to call right after the host id is added + * @param del the handler to call right before the host id is removed * @param arg argument passed for the handlers * @return 0 on success, otherwise an negative error value is returned. */ @@ -287,8 +287,8 @@ const struct hip_lhi *lhi, hip_lsi_t *lsi, const struct hip_host_id_priv *host_id, - int (*insert)(struct hip_host_id_entry *, void **arg), - int (*remove)(struct hip_host_id_entry *, void **arg), + int (*add)(struct hip_host_id_entry *, void **arg), + int (*del)(struct hip_host_id_entry *, void **arg), void *arg) { int err = 0; @@ -322,8 +322,8 @@ HIP_IFEL((hip_hidb_add_lsi(db, id_entry)) < 0, -EEXIST, "No LSI free\n"); memcpy(lsi, &id_entry->lsi, sizeof(hip_lsi_t)); - id_entry->insert = insert; - id_entry->remove = remove; + id_entry->insert = add; + id_entry->remove = del; id_entry->arg = arg; list_add(id_entry, db); @@ -349,8 +349,8 @@ /* Called while the database is locked, perhaps not the best * option but HIs are not added often */ - if (insert) { - insert(id_entry, &arg); + if (add) { + add(id_entry, &arg); } out_err: @@ -532,6 +532,7 @@ /* T could easily have been an int, since the compiler will * probably add 3 alignment bytes here anyway. */ uint8_t T; + uint16_t temp; struct hip_host_id *ret; /* check T, Miika won't like this */ @@ -549,7 +550,8 @@ memcpy(ret, hi, sizeof(struct hip_host_id)); /* the secret component of the DSA key is always 20 bytes */ - ret->hi_length = htons(ntohs(hi->hi_length) - DSA_PRIV); + temp = ntohs(hi->hi_length) - DSA_PRIV; + ret->hi_length = htons(temp); memset((char *) (&ret->key) + ntohs(ret->hi_length) - sizeof(hi->rdata), 0, sizeof(ret->key) - ntohs(ret->hi_length)); ret->length = htons(sizeof(struct hip_host_id)); === modified file 'hipd/hipd.c' --- hipd/hipd.c 2010-05-16 17:58:14 +0000 +++ hipd/hipd.c 2010-05-17 22:11:11 +0000 @@ -164,13 +164,13 @@ #ifdef CONFIG_HIP_FIREWALL int n = 0; HIP_DEBUG("CONFIG_HIP_FIREWALL DEFINED AND STATUS IS %d\n", hip_get_firewall_status()); - struct sockaddr_in6 hip_firewall_addr; + struct sockaddr_in6 hip_fw_addr; socklen_t alen = sizeof(hip_firewall_addr); bzero(&hip_firewall_addr, alen); - hip_firewall_addr.sin6_family = AF_INET6; - hip_firewall_addr.sin6_port = htons(HIP_FIREWALL_PORT); - hip_firewall_addr.sin6_addr = in6addr_loopback; + hip_fw_addr.sin6_family = AF_INET6; + hip_fw_addr.sin6_port = htons(HIP_FIREWALL_PORT); + hip_fw_addr.sin6_addr = in6addr_loopback; n = sendto(hip_firewall_sock, msg, === modified file 'hipd/init.c' --- hipd/init.c 2010-05-16 22:21:30 +0000 +++ hipd/init.c 2010-05-17 22:11:11 +0000 @@ -248,32 +248,33 @@ } /** - * initialize a raw ipv4 socket - * - * @param hip_raw_sock_v4 the raw socket to initialize + * Initialize a raw ipv4 socket. * @param proto the protocol for the raw socket - * @return zero on success or negative on failure + * @return positive fd on success, -1 otherwise */ -static int hip_init_raw_sock_v4(int *hip_raw_sock_v4, int proto) +static int hip_init_raw_sock_v4(int proto) { int on = 1, off = 0, err = 0; + int sock; - *hip_raw_sock_v4 = socket(AF_INET, SOCK_RAW, proto); - set_cloexec_flag(*hip_raw_sock_v4, 1); - HIP_IFEL(*hip_raw_sock_v4 <= 0, 1, "Raw socket v4 creation failed. Not root?\n"); + sock = socket(AF_INET, SOCK_RAW, proto); + set_cloexec_flag(sock, 1); + HIP_IFEL(sock <= 0, 1, "Raw socket v4 creation failed. Not root?\n"); /* see bug id 212 why RECV_ERR is off */ - err = setsockopt(*hip_raw_sock_v4, IPPROTO_IP, IP_RECVERR, &off, sizeof(on)); + err = setsockopt(sock, IPPROTO_IP, IP_RECVERR, &off, sizeof(on)); HIP_IFEL(err, -1, "setsockopt v4 recverr failed\n"); - err = setsockopt(*hip_raw_sock_v4, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); + err = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); HIP_IFEL(err, -1, "setsockopt v4 failed to set broadcast \n"); - err = setsockopt(*hip_raw_sock_v4, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on)); + err = setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on)); HIP_IFEL(err, -1, "setsockopt v4 pktinfo failed\n"); - err = setsockopt(*hip_raw_sock_v4, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); HIP_IFEL(err, -1, "setsockopt v4 reuseaddr failed\n"); + return sock; + out_err: - return err; + return -1; } /** @@ -488,30 +489,30 @@ /** * Init raw ipv6 socket - * - * @param hip_raw_sock_v6 the socket to initialize * @param proto protocol for the socket - * - * @return zero on success or negative on failure + * @return positive socket fd on success, -1 otherwise */ -static int hip_init_raw_sock_v6(int *hip_raw_sock_v6, int proto) +static int hip_init_raw_sock_v6(int proto) { int on = 1, off = 0, err = 0; + int sock; - *hip_raw_sock_v6 = socket(AF_INET6, SOCK_RAW, proto); - set_cloexec_flag(*hip_raw_sock_v6, 1); - HIP_IFEL(*hip_raw_sock_v6 <= 0, 1, "Raw socket creation failed. Not root?\n"); + sock = socket(AF_INET6, SOCK_RAW, proto); + set_cloexec_flag(sock, 1); + HIP_IFEL(sock <= 0, 1, "Raw socket creation failed. Not root?\n"); /* see bug id 212 why RECV_ERR is off */ - err = setsockopt(*hip_raw_sock_v6, IPPROTO_IPV6, IPV6_RECVERR, &off, sizeof(on)); + err = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVERR, &off, sizeof(on)); HIP_IFEL(err, -1, "setsockopt recverr failed\n"); - err = setsockopt(*hip_raw_sock_v6, IPPROTO_IPV6, IPV6_2292PKTINFO, &on, sizeof(on)); + err = setsockopt(sock, IPPROTO_IPV6, IPV6_2292PKTINFO, &on, sizeof(on)); HIP_IFEL(err, -1, "setsockopt pktinfo failed\n"); - err = setsockopt(*hip_raw_sock_v6, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + err = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); HIP_IFEL(err, -1, "setsockopt v6 reuseaddr failed\n"); + return sock; + out_err: - return err; + return -1; } /** @@ -592,13 +593,13 @@ /** * exit gracefully by sending CLOSE to all peers * - * @param signal the signal hipd received from OS + * @param sig the signal hipd received from OS */ -void hip_close(int signal) +void hip_close(int sig) { static int terminate = 0; - HIP_ERROR("Signal: %d\n", signal); + HIP_ERROR("Signal: %d\n", sig); terminate++; /* Close SAs with all peers */ @@ -610,8 +611,9 @@ HIP_DEBUG("Send still once this signal to force daemon exit...\n"); } else if (terminate > 2) { HIP_DEBUG("Terminating daemon.\n"); - hip_exit(signal); - exit(signal); + hip_exit(sig); + /*TODO why exit with non-zero ? */ + exit(sig); } } @@ -621,10 +623,9 @@ * * @param signal the signal hipd received */ -void hip_exit(int signal) +void hip_exit(int sig) { struct hip_common *msg = NULL; - HIP_ERROR("Signal: %d\n", signal); default_ipsec_func_set.hip_delete_default_prefix_sp_pair(); @@ -952,16 +953,27 @@ hip_xfrm_set_nl_ipsec(&hip_nl_ipsec); - HIP_IFEL(hip_init_raw_sock_v6(&hip_raw_sock_output_v6, IPPROTO_HIP), -1, "raw sock output v6\n"); - HIP_IFEL(hip_init_raw_sock_v4(&hip_raw_sock_output_v4, IPPROTO_HIP), -1, "raw sock output v4\n"); + hip_raw_sock_output_v6 = hip_init_raw_sock_v6(IPPROTO_HIP); + HIP_IFEL(hip_raw_sock_output_v6, -1, "raw sock output v6\n"); + + hip_raw_sock_output_v4 = hip_init_raw_sock_v4(IPPROTO_HIP); + HIP_IFEL(hip_raw_sock_output_v4, -1, "raw sock output v4\n"); + /* hip_nat_sock_input should be initialized after hip_nat_sock_output because for the sockets bound to the same address/port, only the last socket seems to receive the packets. NAT input socket is a normal UDP socket where as NAT output socket is a raw socket. A raw output socket support better the "shotgun" extension (sending packets from multiple source addresses). */ - HIP_IFEL(hip_init_raw_sock_v4(&hip_nat_sock_output_udp, IPPROTO_UDP), -1, "raw sock output udp\n"); - HIP_IFEL(hip_init_raw_sock_v6(&hip_raw_sock_input_v6, IPPROTO_HIP), -1, "raw sock input v6\n"); - HIP_IFEL(hip_init_raw_sock_v4(&hip_raw_sock_input_v4, IPPROTO_HIP), -1, "raw sock input v4\n"); + + hip_nat_sock_output_udp = hip_init_raw_sock_v4(IPPROTO_UDP); + HIP_IFEL(hip_nat_sock_output_udp, -1, "raw sock output udp\n"); + + hip_raw_sock_input_v6 = hip_init_raw_sock_v6(IPPROTO_HIP); + HIP_IFEL(hip_raw_sock_input_v6, -1, "raw sock input v6\n"); + + hip_raw_sock_input_v4 = hip_init_raw_sock_v4(IPPROTO_HIP); + HIP_IFEL(hip_raw_sock_input_v4, -1, "raw sock input v4\n"); + HIP_IFEL(hip_create_nat_sock_udp(&hip_nat_sock_input_udp, 0, 0), -1, "raw sock input udp\n"); HIP_IFEL(hip_init_icmp_v6(&hip_icmp_sock), -1, "icmpv6 sock\n"); === modified file 'hipd/input.c' --- hipd/input.c 2010-05-17 18:24:10 +0000 +++ hipd/input.c 2010-05-17 22:11:11 +0000 @@ -1101,10 +1101,11 @@ * build_param_encrypted_aes has already taken care that there is * enough padding */ if (transform_hip_suite == HIP_HIP_AES_SHA1) { - int remainder = host_id_in_enc_len % 16; - if (remainder) { + /* remainder */ + int rem = host_id_in_enc_len % 16; + if (rem) { HIP_DEBUG("Remainder %d (for AES)\n", remainder); - host_id_in_enc_len += remainder; + host_id_in_enc_len += rem; } } === modified file 'hipd/keymat.c' --- hipd/keymat.c 2010-05-17 16:55:10 +0000 +++ hipd/keymat.c 2010-05-17 22:11:11 +0000 @@ -198,23 +198,23 @@ * hip_keymat_draw - draw keying material * @param keymat pointer to the keymat structure which contains information * about the actual - * @param length size of keymat structure + * @param len size of keymat structure * * @return pointer the next point where one can draw the next keymaterial */ -static void *hip_keymat_draw(struct hip_keymat_keymat *keymat, int length) +static void *hip_keymat_draw(struct hip_keymat_keymat *keymat, int len) { /* todo: remove this function */ void *ret = NULL; - if (length > keymat->keymatlen - keymat->offset) { + if (len > keymat->keymatlen - keymat->offset) { HIP_DEBUG("Tried to draw more keys than are available\n"); goto out_err; } ret = (uint8_t *) keymat->keymatdst + keymat->offset; - keymat->offset += length; + keymat->offset += len; out_err: return ret; === modified file 'hipd/maintenance.c' --- hipd/maintenance.c 2010-05-16 17:58:14 +0000 +++ hipd/maintenance.c 2010-05-17 22:11:11 +0000 @@ -312,9 +312,9 @@ int hip_firewall_set_bex_data(int action, hip_ha_t *entry, struct in6_addr *hit_s, struct in6_addr *hit_r) { struct hip_common *msg = NULL; - struct sockaddr_in6 hip_firewall_addr; + struct sockaddr_in6 hip_fw_addr; int err = 0, n = 0, r_is_our; - socklen_t alen = sizeof(hip_firewall_addr); + socklen_t alen = sizeof(hip_fw_addr); if (!hip_get_firewall_status()) { goto out_err; @@ -335,10 +335,10 @@ (void *) (r_is_our ? hit_r : hit_s), HIP_PARAM_HIT, sizeof(struct in6_addr)), -1, "build param contents failed\n"); - bzero(&hip_firewall_addr, alen); - hip_firewall_addr.sin6_family = AF_INET6; - hip_firewall_addr.sin6_port = htons(HIP_FIREWALL_PORT); - hip_firewall_addr.sin6_addr = in6addr_loopback; + bzero(&hip_fw_addr, alen); + hip_fw_addr.sin6_family = AF_INET6; + hip_fw_addr.sin6_port = htons(HIP_FIREWALL_PORT); + hip_fw_addr.sin6_addr = in6addr_loopback; n = sendto(hip_firewall_sock_lsi_fd, (char *) msg, === modified file 'lib/core/builder.c' --- lib/core/builder.c 2010-05-17 18:24:10 +0000 +++ lib/core/builder.c 2010-05-17 22:11:11 +0000 @@ -2839,7 +2839,7 @@ * @todo Remove index and rename. */ hip_transform_suite_t hip_get_param_transform_suite_id(const void *transform_tlv, - const uint16_t index) + const uint16_t idx) { /** @todo Why do we have hip_select_esp_transform separately? */ @@ -2897,18 +2897,18 @@ /** * build a HIP locator parameter * - * @param msg the message where the REA will be appended - * @param addresses list of addresses + * @param msg the message where the REA will be appended + * @param addrs list of addresses * @param address_count number of addresses * @return 0 on success, otherwise < 0. */ int hip_build_param_locator(struct hip_common *msg, - struct hip_locator_info_addr_item *addresses, - int address_count) + struct hip_locator_info_addr_item *addrs, + int addr_count) { int err = 0; struct hip_locator *locator_info = NULL; - int addrs_len = address_count * (sizeof(struct hip_locator_info_addr_item)); + int addrs_len = addr_count * (sizeof(struct hip_locator_info_addr_item)); HIP_IFE(!(locator_info = malloc(sizeof(struct hip_locator) + addrs_len)), -1); @@ -2922,7 +2922,7 @@ sizeof(struct hip_tlv_common) + addrs_len); - memcpy(locator_info + 1, addresses, addrs_len); + memcpy(locator_info + 1, addrs, addrs_len); HIP_IFE(hip_build_param(msg, locator_info), -1); _HIP_DEBUG("msgtotlen=%d addrs_len=%d\n", hip_get_msg_total_len(msg), @@ -4221,15 +4221,13 @@ } /** - * retreive a locator address item from a list - * - * retreive a @c LOCATOR ADDRESS ITEM@c from a list. - * - * @param item_list a pointer to the first item in the list - * @param index the index of the item in the list - * @return the locator addres item + * Retreive a @c LOCATOR ADDRESS ITEM@c from a list. + * + * @param item_list a pointer to the first item in the list + * @param idx the index of the item in the list + * @return the locator addres item */ -union hip_locator_info_addr *hip_get_locator_item(void *item_list, int index) +union hip_locator_info_addr *hip_get_locator_item(void *item_list, int idx) { int i = 0; struct hip_locator_info_addr_item *temp; @@ -4237,7 +4235,7 @@ result = (char *) item_list; - for (i = 0; i <= index - 1; i++) { + for (i = 0; i <= idx - 1; i++) { temp = (struct hip_locator_info_addr_item *) result; if (temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_ESP_SPI || temp->locator_type == HIP_LOCATOR_LOCATOR_TYPE_IPV6) { @@ -4247,8 +4245,7 @@ } } _HIP_DEBUG("*****locator %d has offset :%d \n", - index, - (char *) result - (char *) item_list); + idx, (char *) result - (char *) item_list); return (union hip_locator_info_addr *) result; } === modified file 'lib/core/certtools.c' --- lib/core/certtools.c 2010-05-17 18:24:10 +0000 +++ lib/core/certtools.c 2010-05-17 22:11:11 +0000 @@ -812,20 +812,20 @@ /** * hip_cert_der_to_x509 - Function that converts the DER encoded X509 to X509 struct * - * @param der points to DER encoded certificate - * @param length of the DER given in bytes + * @param der pointer to DER encoded certificate + * @param len length of the DER given in bytes * * @return * X509 or on error NULL is returned */ -X509 *hip_cert_der_to_x509(const unsigned char *der, int length) +X509 *hip_cert_der_to_x509(const unsigned char *der, int len) { int err = 0; X509 *cert = NULL; - _HIP_HEXDUMP("DER:\n", der, length); - _HIP_DEBUG("DER length %d\n", length); + _HIP_HEXDUMP("DER:\n", der, len); + _HIP_DEBUG("DER length %d\n", len); - HIP_IFEL(((cert = d2i_X509(NULL, (const unsigned char **) &der, length)) == NULL), -1, + HIP_IFEL(((cert = d2i_X509(NULL, (const unsigned char **) &der, len)) == NULL), -1, "Failed to convert cert from DER to internal format\n"); out_err: if (err == -1) { === modified file 'lib/core/conf.c' --- lib/core/conf.c 2010-05-17 18:24:10 +0000 +++ lib/core/conf.c 2010-05-17 22:11:11 +0000 @@ -931,7 +931,6 @@ if (inet_pton(AF_INET6, opt[index_of_ip], &ipv6) <= 0) { struct in_addr ipv4; if (inet_pton(AF_INET, opt[index_of_ip], &ipv4) <= 0) { - int i; /* First try to find an IPv4 or IPv6 address. Second, * settle for HIT if no routable address found. * The second step is required with dnsproxy === modified file 'lib/core/debug.c' --- lib/core/debug.c 2010-05-17 18:24:10 +0000 +++ lib/core/debug.c 2010-05-17 22:11:11 +0000 @@ -220,9 +220,9 @@ * @note Do not use this function outside of this file at all. * */ -void hip_handle_log_error(int logtype) +void hip_handle_log_error(int log_type) { - fprintf(stderr, "log (type=%d) failed, ignoring\n", logtype); + fprintf(stderr, "log (type=%d) failed, ignoring\n", log_type); } /** === modified file 'lib/core/hashtree.c' --- lib/core/hashtree.c 2010-04-15 16:57:50 +0000 +++ lib/core/hashtree.c 2010-05-17 22:11:11 +0000 @@ -51,7 +51,7 @@ hash_tree_t *tree = NULL; int tmp_length = 0; int err = 0, i; - double log = 0.0; + double loga = 0.0; HIP_ASSERT(num_data_blocks > 0); HIP_ASSERT(max_data_length > 0); @@ -64,11 +64,11 @@ memset(tree, 0, sizeof(hash_tree_t)); // check here whether leaf_set_size is a power of 2 and compute correct value if it is not - log = log_x(2, num_data_blocks); + loga = log_x(2, num_data_blocks); if (num_data_blocks == 1) { tree->leaf_set_size = 2; - } else if (floor(log) != ceil(log)) { - tree->leaf_set_size = pow(2, ceil(log)); + } else if (floor(loga) != ceil(loga)) { + tree->leaf_set_size = pow(2, ceil(loga)); } else { tree->leaf_set_size = num_data_blocks; } === modified file 'lib/core/hostid.c' --- lib/core/hostid.c 2010-04-15 20:47:19 +0000 +++ lib/core/hostid.c 2010-05-17 22:11:11 +0000 @@ -161,10 +161,10 @@ struct in6_addr *hit, int hit_type) { + uint16_t temp; + int contents_len, total_len; int err = 0; struct hip_host_id *host_id_pub = NULL; - int contents_len; - int total_len; contents_len = hip_get_param_contents_len(host_id); total_len = hip_get_param_total_len(host_id); @@ -182,7 +182,8 @@ memcpy(host_id_pub, host_id, sizeof(struct hip_tlv_common) + contents_len - DSA_PRIV); - host_id_pub->hi_length = htons(ntohs(host_id_pub->hi_length) - DSA_PRIV); + temp = ntohs(host_id_pub->hi_length) - DSA_PRIV; + host_id_pub->hi_length = htons(temp); hip_set_param_contents_len((struct hip_tlv_common *) host_id_pub, contents_len - DSA_PRIV); @@ -216,8 +217,9 @@ int hit_type) { int err = 0; + int rsa_pub_len, rsa_priv_len; + uint16_t temp; struct hip_host_id host_id_pub; - int rsa_pub_len, rsa_priv_len; struct hip_rsa_keylen keylen; /* Length of the private part of the RSA key d + p + q @@ -231,8 +233,9 @@ memcpy(&host_id_pub, host_id, sizeof(host_id_pub) - sizeof(host_id_pub.key) - sizeof(host_id_pub.hostname)); - host_id_pub.hi_length = - htons(ntohs(host_id_pub.hi_length) - rsa_priv_len); + + temp = ntohs(host_id_pub.hi_length) - rsa_priv_len; + host_id_pub.hi_length = htons(temp); memcpy(host_id_pub.key, host_id->key, rsa_pub_len); _HIP_HEXDUMP("extracted pubkey", &host_id_pub, === modified file 'lib/core/message.c' --- lib/core/message.c 2010-05-16 17:58:14 +0000 +++ lib/core/message.c 2010-05-17 22:11:11 +0000 @@ -60,7 +60,7 @@ /** * Finds out how much data is coming from a socket * - * @param socket a file descriptor. + * @param sockfd the socked file descriptor. * @param encap_hdr_size udp etc header size * @param timeout -1 for blocking sockets, 0 or positive nonblocking * @return Number of bytes received on success or a negative error value on @@ -70,7 +70,7 @@ * actual bytes read. If you decide to reimplement this functionality, * remember to preserve the timeout property. */ -int hip_peek_recv_total_len(int socket, +int hip_peek_recv_total_len(int sockfd, int encap_hdr_size, unsigned long timeout) { @@ -98,7 +98,7 @@ do { errno = 0; nanosleep(&ts, NULL); - bytes = recv(socket, msg, hdr_size, flags); + bytes = recv(sockfd, msg, hdr_size, flags); timeout_left -= ts.tv_nsec; _HIP_DEBUG("tol=%ld, ts=%ld, bytes=%d errno=%d\n", timeout_left, ts.tv_nsec, bytes, errno); @@ -111,7 +111,7 @@ } else if (bytes < hdr_size) { HIP_ERROR("Packet payload is smaller than HIP header. Dropping.\n"); /* Read and discard the datagram */ - recv(socket, msg, 0, 0); + recv(sockfd, msg, 0, 0); err = -bytes; goto out_err; } @@ -121,7 +121,7 @@ if (bytes == 0) { HIP_ERROR("HIP message is of zero length. Dropping.\n"); - recv(socket, msg, 0, 0); + recv(sockfd, msg, 0, 0); err = -EBADMSG; errno = EBADMSG; goto out_err; @@ -181,7 +181,7 @@ * ports if it fails to obtain a privileged port and then hipd allows * only certain operations for the calling process. * - * @param socket the socket to bind to + * @param sockfd the socket to bind to * @param sa An IPv6-based socket address structure. The sin6_port * field may be filled in in the case of e.g. sockets * remaining open for long time periods. Alternetively, @@ -190,7 +190,7 @@ * of the function). * @return zero on success and negative on failure */ -int hip_daemon_bind_socket(int socket, struct sockaddr *sa) +int hip_daemon_bind_socket(int sockfd, struct sockaddr *sa) { int err = 0, port = 0, on = 1; struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sa; @@ -199,14 +199,14 @@ errno = 0; - if (setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) { + if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) { HIP_DEBUG("Failed to set socket option SO_REUSEADDR %s \n", strerror(errno)); } if (addr->sin6_port) { HIP_DEBUG("Bind to fixed port %d\n", addr->sin6_port); - err = bind(socket, (struct sockaddr *) addr, + err = bind(sockfd, (struct sockaddr *) addr, sizeof(struct sockaddr_in6)); err = -errno; goto out_err; @@ -217,7 +217,7 @@ while (port++ < 61000) { _HIP_DEBUG("trying bind() to port %d\n", port); addr->sin6_port = htons(port); - err = bind(socket, (struct sockaddr *) addr, + err = bind(sockfd, (struct sockaddr *) addr, hip_sockaddr_len(addr)); if (err == -1) { if (errno == EACCES) { @@ -256,13 +256,13 @@ * Send one-way data to hipd. Do not call this function directly, use * hip_send_recv_daemon_info instead! * - * @param socket the socket to use for sending - * @param msg the message to send to hipd - * @param len the length of the message in bytes - * @return zero on success and negative on failure + * @param sockfd the socket to use for sending + * @param msg the message to send to hipd + * @param len the length of the message in bytes + * @return zero on success and negative on failure * @note currently the only SOCK_DGRAM and AF_INET6 are supported */ -static int hip_sendto_hipd(int socket, struct hip_common *msg, int len) +static int hip_sendto_hipd(int sockfd, struct hip_common *msg, int len) { /* Variables. */ struct sockaddr_in6 sock_addr; @@ -276,9 +276,9 @@ alen = sizeof(sock_addr); HIP_DEBUG("Sending user message %d to HIPD on socket %d\n", - hip_get_msg_type(msg), socket); + hip_get_msg_type(msg), sockfd); - n = sendto(socket, msg, len, MSG_NOSIGNAL, + n = sendto(sockfd, msg, len, MSG_NOSIGNAL, (struct sockaddr *) &sock_addr, alen); HIP_DEBUG("Sent %d bytes\n", n); @@ -464,13 +464,13 @@ /** * Read an interprocess (user) message * - * @param socket a socket from where to read - * @param hip_msg the message will be written here - * @param saddr the sender information is stored here - * @return zero on success and negative on error + * @param socket a socket from where to read + * @param hip_msg the message will be written here + * @param saddr the sender information is stored here + * @return zero on success and negative on error * @note currently the only SOCK_DGRAM and AF_INET6 are supported */ -int hip_read_user_control_msg(int socket, struct hip_common *hip_msg, +int hip_read_user_control_msg(int sockfd, struct hip_common *hip_msg, struct sockaddr_in6 *saddr) { int err = 0, bytes = 0, total; @@ -480,7 +480,7 @@ len = sizeof(*saddr); - HIP_IFEL(((total = hip_peek_recv_total_len(socket, 0, HIP_DEFAULT_MSG_TIMEOUT)) <= 0), + HIP_IFEL(((total = hip_peek_recv_total_len(sockfd, 0, HIP_DEFAULT_MSG_TIMEOUT)) <= 0), -1, "recv peek failed\n"); @@ -489,7 +489,7 @@ /** @todo Compiler warning; * warning: pointer targets in passing argument 6 of 'recvfrom' * differ in signedness. */ - HIP_IFEL(((bytes = recvfrom(socket, hip_msg, total, 0, + HIP_IFEL(((bytes = recvfrom(sockfd, hip_msg, total, 0, (struct sockaddr *) saddr, &len)) != total), -1, "recv\n"); @@ -532,7 +532,7 @@ * on IPv4. * @return -1 in case of an error, 0 otherwise. */ -int hip_read_control_msg_all(int socket, struct hip_common *hip_msg, +int hip_read_control_msg_all(int sockfd, struct hip_common *hip_msg, struct in6_addr *saddr, struct in6_addr *daddr, hip_portpair_t *msg_info, @@ -578,7 +578,7 @@ pktinfo.pktinfo_in4 = NULL; - len = recvmsg(socket, &msg, 0); + len = recvmsg(sockfd, &msg, 0); HIP_IFEL((len < 0), -1, "ICMP%s error: errno=%d, %s\n", (is_ipv4 ? "v4" : "v6"), errno, strerror(errno)); @@ -666,7 +666,7 @@ /** * Read an IPv6 control message * - * @param socket a socket file descriptor. + * @param sockfd a socket file descriptor. * @param hip_msg a pointer to a HIP message. * @param saddr source IPv6 address. * @param daddr destination IPv6 address. @@ -674,20 +674,20 @@ * @param encap_hdr_size . * @return . */ -int hip_read_control_msg_v6(int socket, struct hip_common *hip_msg, +int hip_read_control_msg_v6(int sockfd, struct hip_common *hip_msg, struct in6_addr *saddr, struct in6_addr *daddr, hip_portpair_t *msg_info, int encap_hdr_size) { - return hip_read_control_msg_all(socket, hip_msg, saddr, + return hip_read_control_msg_all(sockfd, hip_msg, saddr, daddr, msg_info, encap_hdr_size, 0); } /** * Read an IPv4 control message * - * @param socket a socket file descriptor. + * @param sockfd a socket file descriptor. * @param hip_msg a pointer to a HIP message. * @param saddr source IPv4 address. * @param daddr destination IPv4 address. @@ -695,12 +695,12 @@ * @param encap_hdr_size . * @return . */ -int hip_read_control_msg_v4(int socket, struct hip_common *hip_msg, +int hip_read_control_msg_v4(int sockfd, struct hip_common *hip_msg, struct in6_addr *saddr, struct in6_addr *daddr, hip_portpair_t *msg_info, int encap_hdr_size) { - return hip_read_control_msg_all(socket, hip_msg, saddr, + return hip_read_control_msg_all(sockfd, hip_msg, saddr, daddr, msg_info, encap_hdr_size, 1); } === modified file 'lib/core/performance.c' --- lib/core/performance.c 2010-04-16 01:36:19 +0000 +++ lib/core/performance.c 2010-05-17 22:11:11 +0000 @@ -35,33 +35,33 @@ perf_set_t *hip_perf_create(int num) { /* create the perf set struct*/ - perf_set_t *perf_set; - perf_set = malloc(sizeof(perf_set_t)); - memset(perf_set, 0, sizeof(perf_set_t)); + perf_set_t *set; + set = malloc(sizeof(perf_set_t)); + memset(set, 0, sizeof(perf_set_t)); - perf_set->num_files = num; + set->num_files = num; /* allocate memory for filenames and file pointers*/ - perf_set->files = malloc(sizeof(FILE *) * num); - memset(perf_set->files, 0, sizeof(FILE *) * num); - - perf_set->names = malloc(sizeof(char *) * num); - memset(perf_set->names, 0, sizeof(char *) * num); - - perf_set->linecount = malloc(sizeof(int) * num); - memset(perf_set->linecount, 0, sizeof(int) * num); - - perf_set->times = malloc(sizeof(struct timeval) * num); - memset(perf_set->times, 0, sizeof(struct timeval) * num); - - perf_set->result = malloc(sizeof(double) * num); - memset(perf_set->result, 0, sizeof(double) * num); - - perf_set->running = malloc(sizeof(int) * num); - memset(perf_set->running, 0, sizeof(int) * num); - - perf_set->writable = malloc(sizeof(int) * num); - memset(perf_set->writable, 0, sizeof(int) * num); + set->files = malloc(sizeof(FILE *) * num); + memset(set->files, 0, sizeof(FILE *) * num); + + set->names = malloc(sizeof(char *) * num); + memset(set->names, 0, sizeof(char *) * num); + + set->linecount = malloc(sizeof(int) * num); + memset(set->linecount, 0, sizeof(int) * num); + + set->times = malloc(sizeof(struct timeval) * num); + memset(set->times, 0, sizeof(struct timeval) * num); + + set->result = malloc(sizeof(double) * num); + memset(set->result, 0, sizeof(double) * num); + + set->running = malloc(sizeof(int) * num); + memset(set->running, 0, sizeof(int) * num); + + set->writable = malloc(sizeof(int) * num); + memset(set->writable, 0, sizeof(int) * num); return perf_set; } @@ -72,23 +72,23 @@ * Assigns a filename to each performance measurement slot. * \author Tobias Heer * - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \see hip_perf_create * \param slot The slot number beginning with 0. * \param name The filename. * \return Returns error code. 0 = Success, 1 = Error. */ -int hip_perf_set_name(perf_set_t *perf_set, int slot, const char *name) +int hip_perf_set_name(perf_set_t *set, int slot, const char *name) { int err = 0, len = 0; - HIP_IFEL(perf_set == NULL, -1, "Performance set is empty\n"); - HIP_IFEL(perf_set->files_open, -1, "Files have already been opened\n"); - HIP_IFEL(perf_set->names[slot], -1, "Slot is already named\n"); - HIP_IFEL(slot >= perf_set->num_files, -1, "Slot %d does not exist\n", slot); + HIP_IFEL(set == NULL, -1, "Performance set is empty\n"); + HIP_IFEL(set->files_open, -1, "Files have already been opened\n"); + HIP_IFEL(set->names[slot], -1, "Slot is already named\n"); + HIP_IFEL(slot >= set->num_files, -1, "Slot %d does not exist\n", slot); len = strlen(name); - perf_set->names[slot] = malloc(len + 1); - memcpy(perf_set->names[slot], name, len + 1); + set->names[slot] = malloc(len + 1); + memcpy(set->names[slot], name, len + 1); out_err: return err; } @@ -101,19 +101,19 @@ * * \see hip_perf_create * \note Filenames must have been set by hip_perf_set_name before calling this function. - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \return Returns error code. 0 = Success, 1 = Error. */ -int hip_perf_open(perf_set_t *perf_set) +int hip_perf_open(perf_set_t *set) { int err = 0, i = 0; - HIP_IFEL(!perf_set, -1, "Performance set is empty\n"); - HIP_IFEL(perf_set->files_open, -1, "Files already open\n"); + HIP_IFEL(!set, -1, "Performance set is empty\n"); + HIP_IFEL(set->files_open, -1, "Files already open\n"); - for (i = 0; i < perf_set->num_files; i++) { - if (perf_set->names[i]) { - perf_set->files[i] = fopen(perf_set->names[i], "a"); - if (!perf_set->files[i]) { + for (i = 0; i < set->num_files; i++) { + if (set->names[i]) { + set->files[i] = fopen(set->names[i], "a"); + if (!set->files[i]) { HIP_ERROR("Error opening file for slot %d\n", i); } } else { @@ -133,15 +133,15 @@ * \author Tobias Heer * * \see hip_perf_create - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \param slot The slot number beginning with 0. * \return void */ -void hip_perf_start_benchmark(perf_set_t *perf_set, int slot) +void hip_perf_start_benchmark(perf_set_t *set, int slot) { - if (perf_set->num_files > slot) { - gettimeofday(&perf_set->times[slot], NULL); - perf_set->running[slot] = 1; + if (set->num_files > slot) { + gettimeofday(&set->times[slot], NULL); + set->running[slot] = 1; } } @@ -158,19 +158,19 @@ * \see hip_perf_write_benchmark * \see hip_perf_create * - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \param slot The slot number beginning with 0. * \return void */ -void hip_perf_stop_benchmark(perf_set_t *perf_set, int slot) +void hip_perf_stop_benchmark(perf_set_t *set, int slot) { struct timeval now; - if (perf_set->num_files > slot && perf_set->running[slot] == 1) { + if (set->num_files > slot && set->running[slot] == 1) { gettimeofday(&now, NULL); - perf_set->result[slot] = ((now.tv_sec - perf_set->times[slot].tv_sec) * 1000000 + - (now.tv_usec - perf_set->times[slot].tv_usec)) / 1000000.0; - perf_set->running[slot] = 0; - perf_set->writable[slot] = 1; + set->result[slot] = ((now.tv_sec - set->times[slot].tv_sec) * 1000000 + + (now.tv_usec - set->times[slot].tv_usec)) / 1000000.0; + set->running[slot] = 0; + set->writable[slot] = 1; } } @@ -185,23 +185,23 @@ * \see hip_perf_write_benchmark * \see hip_perf_create * - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \param slot The slot number beginning with 0. * \return Returns error code. 0 = Success, 1 = Error. */ -int hip_perf_write_benchmark(perf_set_t *perf_set, int slot) +int hip_perf_write_benchmark(perf_set_t *set, int slot) { int err = 0; - HIP_IFEL(!perf_set, -1, "Performance set is empty\n"); + HIP_IFEL(!set, -1, "Performance set is empty\n"); char buffer[30]; memset(buffer, 0, 30); - if (perf_set->num_files > slot && perf_set->writable[slot] == 1) { - if (perf_set->files[slot]) { - sprintf(buffer, "%4d\t%8.8lf\n", perf_set->linecount[slot]++, - perf_set->result[slot]); - fputs(buffer, perf_set->files[slot]); - perf_set->result[slot] = 0; - perf_set->writable[slot] = 0; + if (set->num_files > slot && set->writable[slot] == 1) { + if (set->files[slot]) { + sprintf(buffer, "%4d\t%8.8lf\n", set->linecount[slot]++, + set->result[slot]); + fputs(buffer, set->files[slot]); + set->result[slot] = 0; + set->writable[slot] = 0; } else { HIP_ERROR("Name for slot %d not set \n", slot); err = 1; @@ -222,17 +222,17 @@ * \see hip_perf_write_benchmark * \see hip_perf_create * - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \return Returns error code. 0 = Success, 1 = Error. */ -int hip_perf_close(perf_set_t *perf_set) +int hip_perf_close(perf_set_t *set) { int err = 0, i = 0; - for (i = 0; i < perf_set->num_files; i++) { - if (perf_set->files[i]) { - fclose(perf_set->files[i]); - perf_set->files[i] = NULL; + for (i = 0; i < set->num_files; i++) { + if (set->files[i]) { + fclose(set->files[i]); + set->files[i] = NULL; } else { HIP_ERROR("Name for slot %d not set \n"); err = 1; @@ -251,57 +251,57 @@ * * \see hip_perf_close * - * \param perf_set The respective performance measurement created by hip_perf_create. + * \param set The respective performance measurement created by hip_perf_create. * \return Nothing. */ -void hip_perf_destroy(perf_set_t *perf_set) +void hip_perf_destroy(perf_set_t *set) { int slot = 0; - if (perf_set->files) { - free(perf_set->files); - perf_set->files = NULL; + if (set->files) { + free(set->files); + set->files = NULL; } - /* Deallocate every slot in perf_set->names. + /* Deallocate every slot in set->names. * You need to do it because every slot memory is allocated * in hip_perf_set_name(). */ - if (perf_set->names) { + if (set->names) { for (slot = 0; slot < PERF_MAX; slot++) { - if (perf_set->names[slot]) { - free(perf_set->names[slot]); - perf_set->names[slot] = NULL; + if (set->names[slot]) { + free(set->names[slot]); + set->names[slot] = NULL; } } - free(perf_set->names); - perf_set->names = NULL; - } - - if (perf_set->linecount) { - free(perf_set->linecount); - perf_set->linecount = NULL; - } - if (perf_set->times) { - free(perf_set->times); - perf_set->times = NULL; - } - if (perf_set->result) { - free(perf_set->result); - perf_set->result = NULL; - } - if (perf_set->running) { - free(perf_set->running); - perf_set->running = NULL; - } - if (perf_set->writable) { - free(perf_set->writable); - perf_set->writable = NULL; - } - - if (perf_set) { - free(perf_set); - perf_set = NULL; + free(set->names); + set->names = NULL; + } + + if (set->linecount) { + free(set->linecount); + set->linecount = NULL; + } + if (set->times) { + free(set->times); + set->times = NULL; + } + if (set->result) { + free(set->result); + set->result = NULL; + } + if (set->running) { + free(set->running); + set->running = NULL; + } + if (set->writable) { + free(set->writable); + set->writable = NULL; + } + + if (set) { + free(set); + set = NULL; } return; === modified file 'lib/opphip/wrap.c' --- lib/opphip/wrap.c 2010-05-17 18:24:10 +0000 +++ lib/opphip/wrap.c 2010-05-17 22:11:11 +0000 @@ -296,12 +296,12 @@ */ static void hip_store_orig_socket_info(hip_opp_socket_t *entry, int is_peer, - const int socket, + const int sockfd, const struct sockaddr *sa, const socklen_t sa_len) { /* Fill in the information of original socket */ - entry->orig_socket = socket; + entry->orig_socket = sockfd; if (is_peer) { memcpy(&entry->orig_peer_id, sa, sa_len); entry->orig_peer_id_len = sa_len; === modified file 'lib/opphip/wrap_db.c' --- lib/opphip/wrap_db.c 2010-04-15 16:57:50 +0000 +++ lib/opphip/wrap_db.c 2010-05-17 22:11:11 +0000 @@ -31,14 +31,14 @@ * @param tid thread id * @return one if socket existists in the database or zero otherwise */ -int hip_exists_translation(int pid, int socket, pthread_t tid) +int hip_exists_translation(int pid, int sockfd, pthread_t tid) { hip_opp_socket_t *entry = NULL; - entry = hip_socketdb_find_entry(pid, socket, tid); + entry = hip_socketdb_find_entry(pid, sockfd, tid); if (entry) { - if (entry->pid == pid && entry->orig_socket == socket && + if (entry->pid == pid && entry->orig_socket == sockfd && entry->tid == tid) { return 1; } else { @@ -145,19 +145,19 @@ * This function searches for a hip_opp_socket_t entry from the socketdb * by pid and orig_socket. * - * @param pid the pid of the calling sockets API function - * @param the socket of the calling sockets API function - * @param tid the thread id of the calling sockets API function - * @return NULL or the database entry if found + * @param pid the pid of the calling sockets API function + * @param sockfd fd of the calling sockets API function + * @param tid the thread id of the calling sockets API function + * @return NULL or the database entry if found */ -hip_opp_socket_t *hip_socketdb_find_entry(int pid, int socket, pthread_t tid) +hip_opp_socket_t *hip_socketdb_find_entry(int pid, int sockfd, pthread_t tid) { hip_opp_socket_t opp, *ret; opp.pid = pid; - opp.orig_socket = socket; + opp.orig_socket = sockfd; opp.tid = tid; - _HIP_DEBUG("pid %d socket %d computed key\n", pid, socket); + _HIP_DEBUG("pid %d socket %d computed key\n", pid, sockfd); ret = (hip_opp_socket_t *) hip_ht_find(socketdb, (void *) &opp); @@ -197,7 +197,7 @@ * @param tid thread id of the sockets API function caller * @return zero on success or non-zero on error */ -int hip_socketdb_add_entry(int pid, int socket, pthread_t tid) +int hip_socketdb_add_entry(int pid, int sockfd, pthread_t tid) { hip_opp_socket_t *new_item = NULL; int err = 0; @@ -212,7 +212,7 @@ memset(new_item, 0, sizeof(hip_opp_socket_t)); new_item->pid = pid; - new_item->orig_socket = socket; + new_item->orig_socket = sockfd; new_item->tid = tid; err = hip_ht_add(socketdb, new_item); _HIP_DEBUG("pid %d, orig_sock %d, tid %d are added to HT socketdb, entry=%p\n", @@ -229,11 +229,11 @@ * @param tid thread id of the sockets API function caller * @return zero on success or non-zero on error */ -int hip_socketdb_del_entry(int pid, int socket, pthread_t tid) +int hip_socketdb_del_entry(int pid, int sockfd, pthread_t tid) { hip_opp_socket_t *entry = NULL; - entry = hip_socketdb_find_entry(pid, socket, tid); + entry = hip_socketdb_find_entry(pid, sockfd, tid); if (!entry) { return -ENOENT; } === modified file 'lib/tool/nlink.c' --- lib/tool/nlink.c 2010-05-17 18:24:10 +0000 +++ lib/tool/nlink.c 2010-05-17 22:11:11 +0000 @@ -296,7 +296,6 @@ goto out_err; } for (h = (struct nlmsghdr *) buf; status >= sizeof(*h); ) { - int err; int len = h->nlmsg_len; int l = len - sizeof(*h); @@ -750,11 +749,11 @@ return 0; } if (h->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *err = (struct nlmsgerr *) NLMSG_DATA(h); + struct nlmsgerr *nlerr = (struct nlmsgerr *) NLMSG_DATA(h); if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { HIP_ERROR("ERROR truncated\n"); } else { - errno = -err->error; + errno = -nlerr->error; HIP_PERROR("RTNETLINK answers"); } return -1; @@ -1075,11 +1074,11 @@ } if (h->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *err = (struct nlmsgerr *) NLMSG_DATA(h); + struct nlmsgerr *nlerr = (struct nlmsgerr *) NLMSG_DATA(h); if (l < sizeof(struct nlmsgerr)) { HIP_ERROR("ERROR truncated\n"); } else { - errno = -err->error; + errno = -nlerr->error; if (errno == 0) { if (answer) { memcpy(answer, h, h->nlmsg_len); === modified file 'test/dh_performance.c' --- test/dh_performance.c 2010-04-21 12:16:58 +0000 +++ test/dh_performance.c 2010-05-17 22:11:11 +0000 @@ -339,7 +339,7 @@ float bench_secs = 0.0; struct timeval bench_time; unsigned int sig_len; - perf_set_t *perf_set = NULL; + perf_set_t *perfset = NULL; printf("Default settings RSA: key pool of %d keys of length %d.\n", sw_create_rsa, @@ -364,20 +364,20 @@ } if (sw_file_output) { - perf_set = hip_perf_create(PS_MAX); + perfset = hip_perf_create(PS_MAX); check_and_create_dir("results", DEFAULT_CONFIG_DIR_MODE); - hip_perf_set_name(perf_set, PS_DH_CREATE, "PS_DH_CREATE.csv"); - hip_perf_set_name(perf_set, PS_DH_SHARE, "PS_DH_SHARE.csv"); - hip_perf_set_name(perf_set, PS_RSA_CREATE, "PS_RSA_CREATE.csv"); - hip_perf_set_name(perf_set, PS_RSA_SIGN, "PS_RSA_SIGN.csv"); - hip_perf_set_name(perf_set, PS_RSA_VERIFY, "PS_RSA_VERIFY.csv"); - hip_perf_set_name(perf_set, PS_DSA_CREATE, "PS_DSA_CREATE.csv"); - hip_perf_set_name(perf_set, PS_DSA_SIGN, "PS_DSA_SIGN.csv"); - hip_perf_set_name(perf_set, PS_DSA_VERIFY, "PS_DSA_VERIFY.csv"); - hip_perf_set_name(perf_set, PS_HC_CREATE, "PS_HC_CREATE.csv"); - hip_perf_set_name(perf_set, PS_HASH, + hip_perf_set_name(perfset, PS_DH_CREATE, "PS_DH_CREATE.csv"); + hip_perf_set_name(perfset, PS_DH_SHARE, "PS_DH_SHARE.csv"); + hip_perf_set_name(perfset, PS_RSA_CREATE, "PS_RSA_CREATE.csv"); + hip_perf_set_name(perfset, PS_RSA_SIGN, "PS_RSA_SIGN.csv"); + hip_perf_set_name(perfset, PS_RSA_VERIFY, "PS_RSA_VERIFY.csv"); + hip_perf_set_name(perfset, PS_DSA_CREATE, "PS_DSA_CREATE.csv"); + hip_perf_set_name(perfset, PS_DSA_SIGN, "PS_DSA_SIGN.csv"); + hip_perf_set_name(perfset, PS_DSA_VERIFY, "PS_DSA_VERIFY.csv"); + hip_perf_set_name(perfset, PS_HC_CREATE, "PS_HC_CREATE.csv"); + hip_perf_set_name(perfset, PS_HASH, "PS_HC_HASHLOOPS_100_PER_ENTRY.csv"); printf( "-------------------------------\n" @@ -395,7 +395,7 @@ " PS_HC_CREATE: Hash chain creation\n" " PS_HC_HASHLOOPS_100_PER_ENTRY: Hash performance. 100 hashes per row!\n" "-------------------------------\n\n"); - hip_perf_open(perf_set); + hip_perf_open(perfset); } if (!sw_cpuload) {