[hipl-commit] [tiny] Rev 3610: Refined I1 packet handling and changed handle function priority for BEX.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 4 Mar 2010 15:48:16 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Thu Mar 04 14:44:35 2010 +0100
Revision: 3610
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Refined I1 packet handling and changed handle function priority for BEX.
  
  Removed call of hip_xmit_r1 from hip_handle_i1 and registered hip_xmit_r1 as
  handle function.
  
  All BEX handle functions for BEX now have priority 1000. The Transmit/Send
  functions will get priority 1100 (like hip_xmit_r1).

Modified:
  M  hipd/init.c
  M  hipd/input.c
  M  hipd/output.c
  M  hipd/output.h

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-03-02 14:48:42 +0000
+++ hipd/init.c 2010-03-04 13:44:35 +0000
@@ -409,75 +409,91 @@
 
     HIP_DEBUG("Initialize handle functions.\n");
 
-    hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, 
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED,  
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED,       
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_I1, HIP_STATE_NONE,         
&hip_handle_i1, 0);
-
-    hip_register_handle_function(HIP_DATA, HIP_STATE_UNASSOCIATED, 
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_I1_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_I2_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_R2_SENT,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_ESTABLISHED,  
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSING,      
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSED,       
&hip_handle_i1, 0);
-    hip_register_handle_function(HIP_DATA, HIP_STATE_NONE,         
&hip_handle_i1, 0);
-
-    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);
-
-    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);
-
-    hip_register_handle_function(HIP_R2, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_I1_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT,      
&hip_handle_r2, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_R2_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_ESTABLISHED,  
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_CLOSING,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_CLOSED,       
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_R2, HIP_STATE_NONE,         
&hip_drop_packet, 0);
-
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT,     
&hip_handle_notify, 0);
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT,     
&hip_handle_notify, 0);
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT,     
&hip_handle_notify, 0);
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, 
&hip_handle_notify, 0);
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING,     
&hip_handle_notify, 0);
-    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED,      
&hip_handle_notify, 0);
-
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_I1_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_I2_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_R2_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED,  
&hip_handle_close, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING,      
&hip_handle_close, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSED,       
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE, HIP_STATE_NONE,         
&hip_drop_packet, 0);
-
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_I1_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_I2_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_R2_SENT,      
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_ESTABLISHED,  
&hip_drop_packet, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING,      
&hip_handle_close_ack, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED,       
&hip_handle_close_ack, 0);
-    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_NONE,         
&hip_drop_packet, 0);
+    hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, 
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_UNASSOCIATED, &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_I1_SENT,      &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_I2_SENT,      &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_R2_SENT,      &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED,  
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_ESTABLISHED,  &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSING,      &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED,       
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_CLOSED,       &hip_xmit_r1, 
1100);
+    hip_register_handle_function(HIP_I1, HIP_STATE_NONE,         
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_I1, HIP_STATE_NONE,         &hip_xmit_r1, 
1100);
+
+    hip_register_handle_function(HIP_DATA, HIP_STATE_UNASSOCIATED, 
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_UNASSOCIATED, 
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_I1_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_I1_SENT,      
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_I2_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_I2_SENT,      
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_R2_SENT,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_R2_SENT,      
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_ESTABLISHED,  
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_ESTABLISHED,  
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSING,      
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSING,      
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSED,       
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_CLOSED,       
&hip_xmit_r1, 1100);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_NONE,         
&hip_handle_i1, 1000);
+    hip_register_handle_function(HIP_DATA, HIP_STATE_NONE,         
&hip_xmit_r1, 1100);
+
+    hip_register_handle_function(HIP_I2, HIP_STATE_UNASSOCIATED, 
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_I1_SENT,      
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_I2_SENT,      
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_R2_SENT,      
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_ESTABLISHED,  
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_CLOSING,      
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_CLOSED,       
&hip_handle_i2, 1000);
+    hip_register_handle_function(HIP_I2, HIP_STATE_NONE,         
&hip_handle_i2, 1000);
+
+    hip_register_handle_function(HIP_R1, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_I1_SENT,      
&hip_handle_r1, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_I2_SENT,      
&hip_handle_r1, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_R2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_ESTABLISHED,  
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_CLOSING,      
&hip_handle_r1, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_CLOSED,       
&hip_handle_r1, 1000);
+    hip_register_handle_function(HIP_R1, HIP_STATE_NONE,         
&hip_drop_packet, 1000);
+
+    hip_register_handle_function(HIP_R2, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_I1_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_I2_SENT,      
&hip_handle_r2, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_R2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_ESTABLISHED,  
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_CLOSING,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_CLOSED,       
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_R2, HIP_STATE_NONE,         
&hip_drop_packet, 1000);
+
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I1_SENT,     
&hip_handle_notify, 1000);
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_I2_SENT,     
&hip_handle_notify, 1000);
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_R2_SENT,     
&hip_handle_notify, 1000);
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_ESTABLISHED, 
&hip_handle_notify, 1000);
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSING,     
&hip_handle_notify, 1000);
+    hip_register_handle_function(HIP_NOTIFY, HIP_STATE_CLOSED,      
&hip_handle_notify, 1000);
+
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_I1_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_I2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_R2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_ESTABLISHED,  
&hip_handle_close, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSING,      
&hip_handle_close, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_CLOSED,       
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE, HIP_STATE_NONE,         
&hip_drop_packet, 1000);
+
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_UNASSOCIATED, 
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_I1_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_I2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_R2_SENT,      
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_ESTABLISHED,  
&hip_drop_packet, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSING,      
&hip_handle_close_ack, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_CLOSED,       
&hip_handle_close_ack, 1000);
+    hip_register_handle_function(HIP_CLOSE_ACK, HIP_STATE_NONE,         
&hip_drop_packet, 1000);
 
     return err;
 }

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-03-03 14:56:11 +0000
+++ hipd/input.c        2010-03-04 13:44:35 +0000
@@ -2411,9 +2411,6 @@
     hip_perf_start_benchmark(perf_set, PERF_I1);
 #endif
     int err = 0, mask = 0, src_hit_is_our;
-    hip_tlv_type_t relay_para_type = 0;
-    in6_addr_t dest;    /* For the IP address in FROM/RELAY_FROM */
-    in_port_t dest_port = 0; /* For the port in RELAY_FROM */
 
     HIP_ASSERT(!ipv6_addr_any(&(ctx->msg)->hitr));
 
@@ -2449,21 +2446,6 @@
     HIP_INFO_HIT("I1 Source HIT:", &(ctx->msg)->hits);
     HIP_INFO_IN6ADDR("I1 Source IP :", ctx->src_addr);
 
-    ipv6_addr_copy(&dest, &in6addr_any);
-
-    err = hip_xmit_r1(ctx->msg,
-                      ctx->src_addr,
-                      ctx->dst_addr,
-                      &dest,
-                      dest_port,
-                      ctx->msg_info,
-                      relay_para_type);
-
-#ifdef CONFIG_HIP_PERFORMANCE
-    HIP_DEBUG("Stop and write PERF_I1\n");
-    hip_perf_stop_benchmark(perf_set, PERF_I1);
-    hip_perf_write_benchmark(perf_set, PERF_I1);
-#endif
 out_err:
     return err;
 }

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-03-02 13:47:43 +0000
+++ hipd/output.c       2010-03-04 13:44:35 +0000
@@ -734,32 +734,34 @@
  * @param rvs_count     number of addresses in @c traversed_rvs.
  * @return              zero on success, or negative error value on error.
  */
-int hip_xmit_r1(hip_common_t *i1, in6_addr_t *i1_saddr, in6_addr_t *i1_daddr,
-                in6_addr_t *dst_ip, const in_port_t dst_port,
-                hip_portpair_t *i1_info, uint16_t relay_para_type)
+int hip_xmit_r1(const uint32_t packet_type,
+                const uint32_t ha_state,
+                struct hip_packet_context *ctx)
 {
+    int err = 0;
     hip_common_t *r1pkt     = NULL;
-    in6_addr_t *r1_dst_addr = NULL, *local_plain_hit = NULL,
-    *r1_src_addr            = i1_daddr;
-    in_port_t r1_dst_port   = 0;
-    int err                 = 0;
-
-    _HIP_DEBUG("hip_xmit_r1() invoked.\n");
-
-    HIP_DEBUG_IN6ADDR("i1_saddr", i1_saddr);
-    HIP_DEBUG_IN6ADDR("i1_daddr", i1_daddr);
-    HIP_DEBUG_IN6ADDR("dst_ip", dst_ip);
+    struct in6_addr dst_ip = IN6ADDR_ANY_INIT,
+                   *r1_dst_addr = NULL,
+                   *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_DEBUG_IN6ADDR("i1_saddr", ctx->src_addr);
+    HIP_DEBUG_IN6ADDR("i1_daddr", ctx->dst_addr);
+    HIP_DEBUG_IN6ADDR("dst_ip", &dst_ip);
 
     /* Get the final destination address and port for the outgoing R1.
      * dst_ip and dst_port have values only if the incoming I1 had
      * FROM/FROM_NAT parameter. */
-    if (!ipv6_addr_any(dst_ip) && relay_para_type) {
+    if (!ipv6_addr_any(&dst_ip) && relay_para_type) {
         //from RVS or relay
         if (relay_para_type == HIP_PARAM_RELAY_FROM) {
             HIP_DEBUG("Param relay from\n");
             //from relay
-            r1_dst_addr = i1_saddr;
-            r1_dst_port = i1_info->src_port;
+            r1_dst_addr = ctx->src_addr;
+            r1_dst_port = ctx->msg_info->src_port;
             // I---> NAT--> RVS-->R is not supported yet
             /*
              * r1_dst_addr =  dst_ip;
@@ -768,8 +770,8 @@
         } else if (relay_para_type == HIP_PARAM_FROM)    {
             HIP_DEBUG("Param from\n");
             //from RVS, answer to I
-            r1_dst_addr =  dst_ip;
-            if (i1_info->src_port) {
+            r1_dst_addr =  &dst_ip;
+            if (ctx->msg_info->src_port) {
                 // R and RVS is in the UDP mode or I send UDP to RVS with 
incoming port hip_get_peer_nat_udp_port()
                 r1_dst_port =  hip_get_peer_nat_udp_port();
             } else {
@@ -780,18 +782,18 @@
     } else {
         HIP_DEBUG("No RVS or relay\n");
         /* no RVS or RELAY found;  direct connection */
-        r1_dst_addr = i1_saddr;
-        r1_dst_port = i1_info->src_port;
+        r1_dst_addr = ctx->src_addr;
+        r1_dst_port = ctx->msg_info->src_port;
     }
 
 /* removed by santtu because relay supported
- *      r1_dst_addr = (ipv6_addr_any(dst_ip) ? i1_saddr : dst_ip);
- *      r1_dst_port = (dst_port == 0 ? i1_info->src_port : dst_port);
+ *      r1_dst_addr = (ipv6_addr_any(dst_ip) ? ctx->src_addr : dst_ip);
+ *      r1_dst_port = (dst_port == 0 ? ctx->msg_info->src_port : dst_port);
  */
 #ifdef CONFIG_HIP_OPPORTUNISTIC
     /* It should not be null hit, null hit has been replaced by real local
      * hit. */
-    HIP_ASSERT(!hit_is_opportunistic_hit(&i1->hitr));
+    HIP_ASSERT(!hit_is_opportunistic_hit(&ctx->msg->hitr));
 #endif
 
     /* Case: I ----->IPv4---> RVS ---IPv6---> R */
@@ -808,12 +810,12 @@
         }
     }
 
-    HIP_IFEL(!(r1pkt = hip_get_r1(r1_dst_addr, i1_daddr,
-                                  &i1->hitr, &i1->hits)),
+    HIP_IFEL(!(r1pkt = hip_get_r1(r1_dst_addr, ctx->dst_addr,
+                                  &ctx->msg->hitr, &ctx->msg->hits)),
              -ENOENT, "No precreated R1\n");
 
-    if (&i1->hits) {
-        ipv6_addr_copy(&r1pkt->hitr, &i1->hits);
+    if (&ctx->msg->hits) {
+        ipv6_addr_copy(&r1pkt->hitr, &ctx->msg->hits);
     } else {
         memset(&r1pkt->hitr, 0, sizeof(struct in6_addr));
     }
@@ -828,16 +830,16 @@
      *  parameter is the last parameter. */
     /* If I1 had a FROM/RELAY_FROM, then we must build a RELAY_TO/VIA_RVS
      * parameter. */
-    if (!ipv6_addr_any(dst_ip) && relay_para_type) { // dst_port has the value 
of RELAY_FROM port.
+    if (!ipv6_addr_any(&dst_ip) && relay_para_type) { // dst_port has the 
value of RELAY_FROM port.
                                                     //there is port no value 
for FROM parameter
                                                     //here condition is not 
enough
         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, dst_port);
         } else if (relay_para_type == HIP_PARAM_FROM)    {
             HIP_DEBUG("Build param from\n");
-            hip_build_param_via_rvs(r1pkt, i1_saddr);
+            hip_build_param_via_rvs(r1pkt, ctx->src_addr);
         }
     }
 #endif
@@ -860,6 +862,11 @@
     }
 
 out_err:
+#ifdef CONFIG_HIP_PERFORMANCE
+    HIP_DEBUG("Stop and write PERF_I1\n");
+    hip_perf_stop_benchmark(perf_set, PERF_I1);
+    hip_perf_write_benchmark(perf_set, PERF_I1);
+#endif
     if (r1pkt) {
         HIP_FREE(r1pkt);
     }

=== modified file 'hipd/output.h'
--- hipd/output.h       2010-02-17 16:39:54 +0000
+++ hipd/output.h       2010-03-04 13:44:35 +0000
@@ -50,35 +50,10 @@
                                  void *private_key,
                                  const struct hip_host_id *host_id_pub,
                                  int cookie_k);
-/**
- * Transmits an R1 packet to the network.
- *
- * Sends an R1 packet to the peer and stores the cookie information that was
- * sent. The packet is sent either to @c i1_saddr or  @c dst_ip depending on 
the
- * value of @c dst_ip. If @c dst_ip is all zeroes (::/128) or NULL, R1 is sent
- * to @c i1_saddr; otherwise it is sent to @c dst_ip. In case the incoming I1
- * was relayed through a middlebox (e.g. rendezvous server) @c i1_saddr should
- * have the address of that middlebox.
- *
- * @param i1_saddr      a pointer to the source address from where the I1 
packet
- *                      was received.
- * @param i1_daddr      a pointer to the destination address where to the I1
- *                      packet was sent to (own address).
- * @param src_hit       a pointer to the source HIT i.e. responder HIT
- *                      (own HIT).
- * @param dst_ip        a pointer to the destination IPv6 address where the R1
- *                      should be sent (peer ip).
- * @param dst_port      Destination port for R1. If zero, I1 source port is
- *                      used.
- * @param dst_hit       a pointer to the destination HIT i.e. initiator HIT
- *                      (peer HIT).
- * @param i1_info       a pointer to the source and destination ports
- *                      (when NAT is in use).
- * @return              zero on success, or negative error value on error.
- */
-int hip_xmit_r1(hip_common_t *i1, in6_addr_t *i1_saddr, in6_addr_t *i1_daddr,
-                in6_addr_t *dst_ip, const in_port_t dst_port,
-                hip_portpair_t *i1_info, uint16_t relay_para_type);
+
+int hip_xmit_r1(const uint32_t packet_type,
+                const uint32_t ha_state,
+                struct hip_packet_context *ctx);
 
 int hip_send_r2_response(struct hip_common *r2,
                          struct in6_addr *r2_saddr,

Other related posts:

  • » [hipl-commit] [tiny] Rev 3610: Refined I1 packet handling and changed handle function priority for BEX. - Tim Just