[hipl-commit] [tiny] Rev 3634: Modularized HIP_LUPDATE handling.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Fri, 5 Mar 2010 21:16:40 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Fri Mar 05 20:14:35 2010 +0100
Revision: 3634
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Modularized HIP_LUPDATE handling.
  
  Registered esp_prot_handle_light_update as handle function for this packet
  type and the states HIP_STATE_ESTABLISHED and HIP_STATE_R2_SENT.
  
  Now the complete control packet handling uses libmodularization.

Modified:
  M  hipd/esp_prot_light_update.c
  M  hipd/init.c
  M  hipd/input.c

=== modified file 'hipd/esp_prot_light_update.c'
--- hipd/esp_prot_light_update.c        2010-03-05 17:28:01 +0000
+++ hipd/esp_prot_light_update.c        2010-03-05 19:14:35 +0000
@@ -194,7 +194,12 @@
     uint32_t spi        = 0;
     int err             = 0;
 
-    HIP_IFEL(hip_verify_packet_hmac(ctx->input_msg, 
&(ctx->hadb_entry)->hip_hmac_in),
+    HIP_IFEL(!ctx->hadb_entry, -1,
+              "No entry in host association database when receiving " \
+              " HIP_LUPDATE. Dropping.\n");
+
+    HIP_IFEL(hip_verify_packet_hmac(ctx->input_msg,
+                                    &(ctx->hadb_entry)->hip_hmac_in),
              -1,
              "HMAC validation on UPDATE failed.\n");
 
@@ -206,7 +211,8 @@
         seq_no = ntohl(seq->update_id);
 
         HIP_DEBUG("SEQ parameter found with update ID: %u\n", seq_no);
-        HIP_DEBUG("previous incoming update id=%u\n", 
ctx->hadb_entry->light_update_id_in);
+        HIP_DEBUG("previous incoming update id=%u\n",
+                  ctx->hadb_entry->light_update_id_in);
 
         if (seq_no < ctx->hadb_entry->light_update_id_in) {
             HIP_DEBUG("old SEQ, dropping...\n");

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-03-05 19:01:11 +0000
+++ hipd/init.c 2010-03-05 19:14:35 +0000
@@ -27,6 +27,7 @@
 
 #include "init.h"
 #include "oppdb.h"
+#include "esp_prot_light_update.h"
 
 /**
  * HIP daemon lock file is used to prevent multiple instances
@@ -491,6 +492,9 @@
     hip_register_handle_function(HIP_BOS, HIP_STATE_I1_SENT,      
&hip_handle_bos, 1000);
     hip_register_handle_function(HIP_BOS, HIP_STATE_I2_SENT,      
&hip_handle_bos, 1000);
 
+    hip_register_handle_function(HIP_LUPDATE, HIP_STATE_ESTABLISHED, 
&esp_prot_handle_light_update, 1000);
+    hip_register_handle_function(HIP_LUPDATE, HIP_STATE_R2_SENT,     
&esp_prot_handle_light_update, 1000);
+
     return err;
 }
 

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-03-05 19:01:11 +0000
+++ hipd/input.c        2010-03-05 19:14:35 +0000
@@ -40,8 +40,6 @@
 #include "lib/core/state.h"
 #include "oppdb.h"
 #include "registration.h"
-#include "esp_prot_hipd_msg.h"
-#include "esp_prot_light_update.h"
 #include "hipd.h"
 #include "oppipdb.h"
 #include "modularization.h"
@@ -540,8 +538,7 @@
 
     HIP_IFEL(hip_check_network_msg(msg),
              -1,
-             "checking control message failed\n",
-             -1);
+             "Checking control message failed.\n");
 
     type  = hip_get_msg_type(msg);
 
@@ -551,17 +548,16 @@
 
     // Check if we need to drop the packet
     if (ctx.hadb_entry &&
-        hip_packet_to_drop(ctx.hadb_entry, type, &msg->hitr) == 1)
-    {
-        HIP_DEBUG("Ignoring the packet sent \n");
+        hip_packet_to_drop(ctx.hadb_entry, type, &msg->hitr) == 1) {
+        HIP_DEBUG("Ignoring the packet sent.\n");
         err = -1;
         goto out_err;
     }
 
-    ctx.input_msg        = msg;
-    ctx.src_addr   = src_addr;
-    ctx.dst_addr   = dst_addr;
-    ctx.msg_ports   = msg_info;
+    ctx.input_msg = msg;
+    ctx.src_addr  = src_addr;
+    ctx.dst_addr  = dst_addr;
+    ctx.msg_ports = msg_info;
 
     if (ctx.hadb_entry) {
         state = ctx.hadb_entry->state;
@@ -591,27 +587,6 @@
 
     hip_run_handle_functions(type, state, &ctx);
 
-    switch (type) {
-    case HIP_I1:
-    case HIP_I2:
-    case HIP_R1:
-    case HIP_R2:
-    case HIP_UPDATE:
-    case HIP_NOTIFY:
-    case HIP_CLOSE:
-    case HIP_CLOSE_ACK:
-    case HIP_BOS:
-        break;
-
-    case HIP_LUPDATE:
-        HIP_IFCS(ctx.hadb_entry, err = esp_prot_handle_light_update(type, 
state, &ctx));
-        break;
-
-    default:
-        HIP_ERROR("Unknown packet %d\n", type);
-        err = -ENOSYS;
-    }
-
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Write PERF_SIGN, PERF_DSA_SIGN_IMPL, PERF_RSA_SIGN_IMPL," \
               " PERF_VERIFY, PERF_DSA_VERIFY_IMPL, PERF_RSA_VERIFY_IMPL," \

Other related posts:

  • » [hipl-commit] [tiny] Rev 3634: Modularized HIP_LUPDATE handling. - Tim Just