Committer: Tim Just <tim.just@xxxxxxxxxxxxxx> Date: Wed Feb 24 15:21:39 2010 +0100 Revision: 3567 Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: tiny Log: Handling of I2 and R1 packets now uses libmodularization. Modified: M hipd/init.c M hipd/input.c M hipd/input.h === modified file 'hipd/init.c' --- hipd/init.c 2010-02-24 13:06:21 +0000 +++ hipd/init.c 2010-02-24 14:21:39 +0000 @@ -441,6 +441,43 @@ #endif #endif + hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED, &hip_handle_i2, 0); + hip_register_handle_function(HIP_I2, HIP_STATE_NONE, &hip_handle_i2, 0); + +#if 0 +#ifdef CONFIG_HIP_PERFORMANCE + HIP_DEBUG("Start PERF_I2\n"); + hip_perf_start_benchmark(perf_set, PERF_I2); + HIP_DEBUG("Stop and write PERF_I2\n"); + hip_perf_stop_benchmark(perf_set, PERF_I2); + hip_perf_write_benchmark(perf_set, PERF_I2); +#endif +#endif + + hip_register_handle_function(HIP_R1, HIP_STATE_UNASSOCIATED, &hip_drop_packet, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT, &hip_handle_r1, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT, &hip_handle_r1, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_R2_SENT, &hip_drop_packet, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_ESTABLISHED, &hip_drop_packet, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING, &hip_handle_r1, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED, &hip_handle_r1, 0); + hip_register_handle_function(HIP_R1, HIP_STATE_NONE, &hip_drop_packet, 0); + +#if 0 +#ifdef CONFIG_HIP_PERFORMANCE + HIP_DEBUG("Start PERF_R1\n"); + hip_perf_start_benchmark(perf_set, PERF_R1); + HIP_DEBUG("Stop and write PERF_R1\n"); + hip_perf_stop_benchmark(perf_set, PERF_R1); + hip_perf_write_benchmark(perf_set, PERF_R1); +#endif +#endif return err; } === modified file 'hipd/input.c' --- hipd/input.c 2010-02-24 13:06:21 +0000 +++ hipd/input.c 2010-02-24 14:21:39 +0000 @@ -591,38 +591,13 @@ hip_run_handle_functions(type, state, &ctx); switch (type) { + case HIP_I1: case HIP_I2: - /* Possibly state. */ -#ifdef CONFIG_HIP_PERFORMANCE - HIP_DEBUG("Start PERF_I2\n"); - hip_perf_start_benchmark(perf_set, PERF_I2); -#endif - err = hip_handle_i2(type, state, &ctx); -#ifdef CONFIG_HIP_PERFORMANCE - HIP_DEBUG("Stop and write PERF_I2\n"); - hip_perf_stop_benchmark(perf_set, PERF_I2); - hip_perf_write_benchmark(perf_set, PERF_I2); -#endif + case HIP_R1: break; case HIP_LUPDATE: HIP_IFCS(ctx.hadb_entry, err = esp_prot_handle_light_update(type, state, &ctx)); break; - - case HIP_R1: -#ifdef CONFIG_HIP_PERFORMANCE - HIP_DEBUG("Start PERF_R1\n"); - hip_perf_start_benchmark(perf_set, PERF_R1); -#endif - /* State. */ - HIP_IFEL(!ctx.hadb_entry, -1, "No entry when receiving R1\n"); - HIP_IFCS(ctx.hadb_entry, err = hip_handle_r1(type, state, &ctx)); -#ifdef CONFIG_HIP_PERFORMANCE - HIP_DEBUG("Stop and write PERF_R1\n"); - hip_perf_stop_benchmark(perf_set, PERF_R1); - hip_perf_write_benchmark(perf_set, PERF_R1); -#endif - break; - case HIP_R2: #ifdef CONFIG_HIP_PERFORMANCE HIP_DEBUG("Start PERF_R2\n"); @@ -1115,6 +1090,14 @@ return err; } +void hip_drop_packet(const uint32_t packet_type, + const uint32_t ha_state, + struct hip_packet_context *packet_ctx) +{ + HIP_ERROR("Received packet type %d in state: %s. Dropping.\n", + packet_type, hip_state_str(ha_state)); +} + /** * Handles an incoming R1 packet. * @@ -1153,6 +1136,8 @@ char *str = NULL; struct in6_addr daddr; + HIP_IFEL(!packet_ctx->hadb_entry, -1, "No entry when receiving R1\n"); + #ifdef CONFIG_HIP_OPPORTUNISTIC /* Check and remove the IP of the peer from the opp non-HIP database */ hip_oppipdb_delentry(&(packet_ctx->hadb_entry->peer_addr)); @@ -1189,20 +1174,6 @@ HIP_DEBUG("Received R1 in state %s\n", hip_state_str(ha_state)); - switch (ha_state) { - case HIP_STATE_R2_SENT: - case HIP_STATE_ESTABLISHED: - goto out_err; - case HIP_STATE_NONE: - case HIP_STATE_UNASSOCIATED: - default: - /* Can't happen. */ - err = -EFAULT; - HIP_ERROR("R1 received in odd state: %d. Dropping.\n", - packet_ctx->hadb_entry); - break; - } - if (ha_state == HIP_STATE_I2_SENT) { HIP_DEBUG("Retransmission\n"); retransmission = 1; === modified file 'hipd/input.h' --- hipd/input.h 2010-02-24 08:47:11 +0000 +++ hipd/input.h 2010-02-24 14:21:39 +0000 @@ -85,6 +85,10 @@ struct in6_addr *daddr, hip_portpair_t *info); +void hip_drop_packet(const uint32_t packet_type, + const uint32_t ha_state, + struct hip_packet_context *packet_ctx); + int hip_receive_bos(struct hip_common *bos, struct in6_addr *bos_saddr, struct in6_addr *bos_daddr, hip_ha_t *entry, hip_portpair_t *bos_info);