------------------------------------------------------------ revno: 5187 committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx> branch nick: mobility-fixes timestamp: Mon 2010-11-29 11:21:23 +0100 message: fixed indentation and other issues from branch review modified: lib/core/state.h modules/update/hipd/update.c -- lp:~hipl-core/hipl/mobility-fixes https://code.launchpad.net/~hipl-core/hipl/mobility-fixes Your team HIPL core team is subscribed to branch lp:~hipl-core/hipl/mobility-fixes. To unsubscribe from this branch go to https://code.launchpad.net/~hipl-core/hipl/mobility-fixes/+edit-subscription
=== modified file 'lib/core/state.h' --- lib/core/state.h 2010-11-23 15:05:53 +0000 +++ lib/core/state.h 2010-11-29 10:21:23 +0000 @@ -320,7 +320,7 @@ /** Used for UPDATE and CLOSE. When we sent multiple identical UPDATE * packets between different address combinations, we don't modify * the opaque data. */ - unsigned char echo_data[4]; + unsigned char echo_data[4]; HIP_HASHTABLE * peer_addr_list_to_be_added; /** For storing retransmission related data. */ === modified file 'modules/update/hipd/update.c' --- modules/update/hipd/update.c 2010-11-23 17:31:11 +0000 +++ modules/update/hipd/update.c 2010-11-29 10:21:23 +0000 @@ -517,59 +517,59 @@ } switch (type) { - case HIP_UPDATE_LOCATOR: - HIP_IFEL(hip_select_local_addr_for_first_update(ha, - src_addr, - dst_addr, - &local_addr), - -1, - "No source address found for first update\n"); - HIP_DEBUG_IN6ADDR("Sending update from", &local_addr); - HIP_DEBUG_IN6ADDR("to", dst_addr); - - hip_send_update_pkt(update_packet_to_send, ha, &local_addr, - dst_addr); - - break; - case HIP_UPDATE_ECHO_RESPONSE: - HIP_DEBUG_IN6ADDR("Sending update from", src_addr); - HIP_DEBUG_IN6ADDR("to", dst_addr); - - hip_send_update_pkt(update_packet_to_send, ha, src_addr, - dst_addr); - - break; - case HIP_UPDATE_ECHO_REQUEST: - localstate = lmod_get_state_item(ha->hip_modular_state, "update"); - - // Randomize the echo response opaque data before sending ECHO_REQUESTS. - // Notice that we're using the same opaque value for the identical - // UPDATE packets sent between different address combinations. - RAND_bytes(ha->echo_data, sizeof(ha->echo_data)); - - list_for_each_safe(item, tmp, localstate->addresses_to_send_echo_request, i) { - dst_addr = (struct in6_addr *) list_entry(item); - - if (!are_addresses_compatible(src_addr, dst_addr)) { - continue; - } - - HIP_DEBUG_IN6ADDR("Sending echo requests from", src_addr); - HIP_DEBUG_IN6ADDR("to", dst_addr); - - hip_send_update_pkt(update_packet_to_send, ha, - src_addr, dst_addr); + case HIP_UPDATE_LOCATOR: + HIP_IFEL(hip_select_local_addr_for_first_update(ha, + src_addr, + dst_addr, + &local_addr), + -1, + "No source address found for first update\n"); + HIP_DEBUG_IN6ADDR("Sending update from", &local_addr); + HIP_DEBUG_IN6ADDR("to", dst_addr); + + hip_send_update_pkt(update_packet_to_send, ha, &local_addr, + dst_addr); + + break; + case HIP_UPDATE_ECHO_RESPONSE: + HIP_DEBUG_IN6ADDR("Sending update from", src_addr); + HIP_DEBUG_IN6ADDR("to", dst_addr); + + hip_send_update_pkt(update_packet_to_send, ha, src_addr, + dst_addr); + + break; + case HIP_UPDATE_ECHO_REQUEST: + localstate = lmod_get_state_item(ha->hip_modular_state, "update"); + + // Randomize the echo response opaque data before sending ECHO_REQUESTS. + // Notice that we're using the same opaque value for the identical + // UPDATE packets sent between different address combinations. + RAND_bytes(ha->echo_data, sizeof(ha->echo_data)); + + list_for_each_safe(item, tmp, localstate->addresses_to_send_echo_request, i) { + dst_addr = (struct in6_addr *) list_entry(item); + + if (!are_addresses_compatible(src_addr, dst_addr)) { + continue; } - break; - case HIP_UPDATE_ESP_ANCHOR: - case HIP_UPDATE_ESP_ANCHOR_ACK: - // TODO re-implement sending of esp prot anchors - HIP_DEBUG_IN6ADDR("Sending update from", src_addr); + HIP_DEBUG_IN6ADDR("Sending echo requests from", src_addr); HIP_DEBUG_IN6ADDR("to", dst_addr); - hip_send_update_pkt(update_packet_to_send, ha, src_addr, dst_addr); - break; + hip_send_update_pkt(update_packet_to_send, ha, + src_addr, dst_addr); + } + + break; + case HIP_UPDATE_ESP_ANCHOR: + case HIP_UPDATE_ESP_ANCHOR_ACK: + // TODO re-implement sending of esp prot anchors + HIP_DEBUG_IN6ADDR("Sending update from", src_addr); + HIP_DEBUG_IN6ADDR("to", dst_addr); + + hip_send_update_pkt(update_packet_to_send, ha, src_addr, dst_addr); + break; } out_err: @@ -874,8 +874,8 @@ * @return zero on success or negative on failure */ static int hip_handle_second_update_packet(struct hip_packet_context *ctx, - const struct hip_esp_info *esp_info, - const struct hip_seq *seq) + const struct hip_esp_info *esp_info, + const struct hip_seq *seq) { struct update_state *localstate = NULL; int err = 0; @@ -886,8 +886,10 @@ "failed to look up UPDATE-specific state\n"); // set active addresses - ipv6_addr_copy(&ctx->hadb_entry->our_addr, &ctx->dst_addr); - ipv6_addr_copy(&ctx->hadb_entry->peer_addr, &ctx->src_addr); + ipv6_addr_copy(&ctx->hadb_entry->our_addr, + &ctx->dst_addr); + ipv6_addr_copy(&ctx->hadb_entry->peer_addr, + &ctx->src_addr); // set the new spi value for the association ctx->hadb_entry->spi_outbound_new = ntohl(esp_info->new_spi); @@ -923,8 +925,10 @@ static void hip_handle_third_update_packet(struct hip_packet_context *ctx) { // set active addresses - ipv6_addr_copy(&ctx->hadb_entry->our_addr, &ctx->dst_addr); - ipv6_addr_copy(&ctx->hadb_entry->peer_addr, &ctx->src_addr); + ipv6_addr_copy(&ctx->hadb_entry->our_addr, + &ctx->dst_addr); + ipv6_addr_copy(&ctx->hadb_entry->peer_addr, + &ctx->src_addr); hip_recreate_security_associations_and_sp(ctx->hadb_entry, &ctx->dst_addr, @@ -948,7 +952,7 @@ } /** - * Checks, if update should be sent + * Check if update should be sent. * * @return 0 on success, else negative value */ @@ -998,12 +1002,12 @@ err = lmod_add_state_item(state, update_state, "update"); -out_err: + out_err: return err; } /** - * Checks if UPDATE sequence and acknowledgement numbers are as expected + * Check if UPDATE sequence and acknowledgment numbers are as expected. * * @param packet_type the packet type * @param ha_state the HA state @@ -1014,8 +1018,8 @@ UNUSED const uint32_t ha_state, struct hip_packet_context *ctx) { struct update_state *localstate = NULL; - const struct hip_seq *seq = NULL; - const struct hip_ack *ack = NULL; + const struct hip_seq *seq = NULL; + const struct hip_ack *ack = NULL; uint32_t seq_update_id = 0; uint32_t ack_peer_update_id = 0; int err = 0; @@ -1043,8 +1047,8 @@ HIP_DEBUG("SEQ parameter found with Update ID %u.\n", seq_update_id); // old updates are bad updates (may be replayed) - if (localstate->update_id_in != 0 - && seq_update_id < localstate->update_id_in) { + if (localstate->update_id_in != 0 && + seq_update_id < localstate->update_id_in) { HIP_DEBUG("Update ID (%u) in the SEQ parameter is before " "previous Update ID (%u). Dropping the packet.\n", @@ -1057,7 +1061,7 @@ // check freshness of ack, if available ack = hip_get_param(ctx->input_msg, HIP_PARAM_ACK); - if (ack != NULL) { + if (ack) { ack_peer_update_id = ntohl(ack->peer_update_id); HIP_DEBUG("ACK parameter found with peer Update ID %u.\n", ack_peer_update_id); @@ -1076,9 +1080,7 @@ } out_err: - if (err) { - ctx->error = err; - } + ctx->error = err; return err; } @@ -1118,9 +1120,7 @@ "HMAC validation on UPDATE failed.\n"); out_err: - if (err) { - ctx->error = err; - } + ctx->error = err; return err; } @@ -1168,47 +1168,45 @@ echo_request, echo_response); switch (update_type) { - case FIRST_PACKET: - err = hip_handle_first_update_packet(ctx, - esp_info, - locator, - seq); - break; - case SECOND_PACKET: - hip_handle_second_update_packet(ctx, - esp_info, - seq); - break; - case THIRD_PACKET: - hip_handle_third_update_packet(ctx); - break; - default: - if (esp_prot_update_type(ctx->input_msg) - == ESP_PROT_FIRST_UPDATE_PACKET) { - esp_prot_handle_first_update_packet(ctx->input_msg, - ctx->hadb_entry, - &ctx->src_addr, - &ctx->dst_addr); - } - else if (esp_prot_update_type(ctx->input_msg) - == ESP_PROT_SECOND_UPDATE_PACKET) { - esp_prot_handle_second_update_packet(ctx->hadb_entry, - &ctx->src_addr, - &ctx->dst_addr); - } - else { - HIP_ERROR("UPDATE packet unknown\n"); - err = -1; - goto out_err; - } + case FIRST_PACKET: + err = hip_handle_first_update_packet(ctx, + esp_info, + locator, + seq); + break; + case SECOND_PACKET: + err = hip_handle_second_update_packet(ctx, + esp_info, + seq); + break; + case THIRD_PACKET: + hip_handle_third_update_packet(ctx); + break; + default: + if (esp_prot_update_type(ctx->input_msg) + == ESP_PROT_FIRST_UPDATE_PACKET) { + esp_prot_handle_first_update_packet(ctx->input_msg, + ctx->hadb_entry, + &ctx->src_addr, + &ctx->dst_addr); + } + else if (esp_prot_update_type(ctx->input_msg) + == ESP_PROT_SECOND_UPDATE_PACKET) { + esp_prot_handle_second_update_packet(ctx->hadb_entry, + &ctx->src_addr, + &ctx->dst_addr); + } + else { + HIP_ERROR("UPDATE packet unknown\n"); + err = -1; + goto out_err; + } } hip_empty_oppipdb_old(); out_err: - if (err) { - ctx->error = err; - } + ctx->error = err; return err; } @@ -1307,6 +1305,6 @@ -1, "Error on registering UPDATE maintenance function.\n"); -out_err: + out_err: return err; }