Committer: Tim Just <tim.just@xxxxxxxxxxxxxx> Date: Thu Mar 04 16:12:47 2010 +0100 Revision: 3615 Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: tiny Log: Make use of drop_packet flag in I1 packet handling. If in hip_handle_i1 an error is detected the flag drop_packet from the packet context is set. hip_send_r1 returns without sending an R1 packet if this flag was set by a prior function. Modified: M hipd/input.c M hipd/output.c === modified file 'hipd/input.c' --- hipd/input.c 2010-03-04 14:23:17 +0000 +++ hipd/input.c 2010-03-04 15:12:47 +0000 @@ -2257,25 +2257,40 @@ if (addr4.s_addr == INADDR_BROADCAST) { HIP_DEBUG("Received I1 broadcast\n"); - HIP_IFEL(src_hit_is_our, -1, - "Received a copy of own broadcast, dropping\n"); - HIP_IFEL(hip_select_source_address(ctx->dst_addr, ctx->src_addr), -1, - "Could not find source address\n"); + HIP_IFEBL2(src_hit_is_our, + -1, + ctx->drop_packet = 1, + "Received a copy of own broadcast, dropping\n"); + + HIP_IFEBL2(hip_select_source_address(ctx->dst_addr, ctx->src_addr), + -1, + ctx->drop_packet = 1, + "Could not find source address\n"); } } else if (IN6_IS_ADDR_MULTICAST(ctx->dst_addr)) { - HIP_IFEL(src_hit_is_our, -1, - "Received a copy of own broadcast, dropping\n"); - HIP_IFEL(hip_select_source_address(ctx->dst_addr, ctx->src_addr), -1, - "Could not find source address\n"); + HIP_IFEBL2(src_hit_is_our, + -1, + ctx->drop_packet = 1, + "Received a copy of own broadcast, dropping\n"); + HIP_IFEBL2(hip_select_source_address(ctx->dst_addr, ctx->src_addr), + -1, + ctx->drop_packet = 1, + "Could not find source address\n"); } - HIP_IFEL(!hip_controls_sane(ntohs(ctx->msg->control), mask), -1, - "Received illegal controls in I1: 0x%x. Dropping\n", ntohs(ctx->msg->control)); + HIP_IFEBL2(!hip_controls_sane(ntohs(ctx->msg->control), mask), + -1, + ctx->drop_packet = 1, + "Received illegal controls in I1: 0x%x. Dropping\n", + ntohs(ctx->msg->control)); HIP_INFO_HIT("I1 Source HIT:", &(ctx->msg)->hits); HIP_INFO_IN6ADDR("I1 Source IP :", ctx->src_addr); -out_err: +/** + * @todo Change macro HIP_IFEBL2: add goto out_err and uncomment the label. + * out_err: + */ return err; } === modified file 'hipd/output.c' --- hipd/output.c 2010-03-04 14:23:17 +0000 +++ hipd/output.c 2010-03-04 15:12:47 +0000 @@ -750,9 +750,12 @@ *local_plain_hit = NULL, *r1_src_addr = ctx->dst_addr; in_port_t r1_dst_port = 0; - in_port_t dst_port = 0; uint16_t relay_para_type = 0; + HIP_IFEL(ctx->drop_packet, + -1, + "Abort packet processing and don't send R1 packet.\n") + HIP_DEBUG_IN6ADDR("i1_saddr", ctx->src_addr); HIP_DEBUG_IN6ADDR("i1_daddr", ctx->dst_addr); HIP_DEBUG_IN6ADDR("dst_ip", &dst_ip); @@ -841,7 +844,7 @@ if (relay_para_type == HIP_PARAM_RELAY_FROM) { HIP_DEBUG("Build param relay from\n"); hip_build_param_relay_to( - r1pkt, &dst_ip, dst_port); + r1pkt, &dst_ip, r1_dst_port); } else if (relay_para_type == HIP_PARAM_FROM) { HIP_DEBUG("Build param from\n"); hip_build_param_via_rvs(r1pkt, ctx->src_addr);