[hipl-commit] [tiny] Rev 3754: Use consistently ctx as variable for the hip_packet_context.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Wed, 31 Mar 2010 18:06:11 +0300

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: 31/03/2010 at 18:06:11
Revision: 3754
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Use consistently ctx as variable for the hip_packet_context.
  
  Replace all occurrences of packet_ctx with ctx.

Modified:
  M  hipd/close.c
  M  hipd/esp_prot_hipd_msg.c
  M  hipd/esp_prot_hipd_msg.h
  M  hipd/hip_socket.c
  M  hipd/hipd.c
  M  hipd/hiprelay.c
  M  hipd/hiprelay.h
  M  hipd/input.c
  M  hipd/input.h
  M  hipd/output.c
  M  hipd/output.h
  M  lib/core/message.c
  M  lib/core/message.h
  M  modules/update/hipd/update.c

=== modified file 'hipd/close.c'
--- hipd/close.c        2010-03-27 13:19:14 +0000
+++ hipd/close.c        2010-03-31 15:04:18 +0000
@@ -198,7 +198,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -254,7 +254,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -312,7 +312,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -378,7 +378,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -450,7 +450,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host

=== modified file 'hipd/esp_prot_hipd_msg.c'
--- hipd/esp_prot_hipd_msg.c    2010-03-31 14:59:32 +0000
+++ hipd/esp_prot_hipd_msg.c    2010-03-31 15:04:18 +0000
@@ -539,7 +539,7 @@
  * @param ctx       packet context for the received R1 message
  * @return          always 0
  */
-int esp_prot_r1_handle_transforms(struct hip_packet_context *packet_ctx)
+int esp_prot_r1_handle_transforms(struct hip_packet_context *ctx)
 {
     struct hip_param *param                         = NULL;
     struct esp_prot_preferred_tfms *prot_transforms = NULL;
@@ -550,35 +550,35 @@
     if (hip_use_userspace_ipsec) {
         HIP_DEBUG("userspace IPsec hint: ESP extension might be in use\n");
 
-        param = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_ESP_PROT_TRANSFORMS);
+        param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_PROT_TRANSFORMS);
 
         // check if the transform parameter was sent
         if (param) {
             HIP_DEBUG("received preferred transforms from peer\n");
 
             // store that we received the param for further processing
-            packet_ctx->hadb_entry->esp_prot_param       = 1;
+            ctx->hadb_entry->esp_prot_param       = 1;
 
             prot_transforms           = (struct esp_prot_preferred_tfms *) 
param;
 
             // select transform and store it for this connection
-            packet_ctx->hadb_entry->esp_prot_transform = 
esp_prot_select_transform(prot_transforms->num_transforms,
+            ctx->hadb_entry->esp_prot_transform = 
esp_prot_select_transform(prot_transforms->num_transforms,
                                                                   
prot_transforms->transforms);
         } else {
             HIP_DEBUG("R1 does not contain preferred ESP protection " \
                       "transforms, locally setting UNUSED\n");
 
             // store that we didn't received the param
-            packet_ctx->hadb_entry->esp_prot_param       = 0;
+            ctx->hadb_entry->esp_prot_param       = 0;
 
             // if the other end-host does not want to use the extension, we 
don't either
-            packet_ctx->hadb_entry->esp_prot_transform = ESP_PROT_TFM_UNUSED;
+            ctx->hadb_entry->esp_prot_transform = ESP_PROT_TFM_UNUSED;
         }
     } else {
         HIP_DEBUG("no userspace IPsec hint for ESP extension, locally setting 
UNUSED\n");
 
         // make sure we don't add the anchor now and don't add any transform 
or anchor
-        packet_ctx->hadb_entry->esp_prot_transform = ESP_PROT_TFM_UNUSED;
+        ctx->hadb_entry->esp_prot_transform = ESP_PROT_TFM_UNUSED;
     }
 
     return err;

=== modified file 'hipd/esp_prot_hipd_msg.h'
--- hipd/esp_prot_hipd_msg.h    2010-03-31 14:59:32 +0000
+++ hipd/esp_prot_hipd_msg.h    2010-03-31 15:04:18 +0000
@@ -28,7 +28,7 @@
 int esp_prot_sa_add(hip_ha_t *entry, struct hip_common *msg, const int 
direction,
                     const int update);
 int esp_prot_r1_add_transforms(hip_common_t *msg);
-int esp_prot_r1_handle_transforms(struct hip_packet_context *packet_ctx);
+int esp_prot_r1_handle_transforms(struct hip_packet_context *ctx);
 int esp_prot_i2_add_anchor(struct hip_packet_context *ctx);
 int esp_prot_i2_handle_anchor(struct hip_packet_context *ctx);
 int esp_prot_r2_add_anchor(hip_common_t *r2, hip_ha_t *entry);

=== modified file 'hipd/hip_socket.c'
--- hipd/hip_socket.c   2010-03-26 15:59:15 +0000
+++ hipd/hip_socket.c   2010-03-31 15:04:18 +0000
@@ -25,15 +25,15 @@
  */
 static hip_ll_t *hip_sockets;
 
-static int hip_handle_raw_input_v6(struct hip_packet_context *packet_ctx)
+static int hip_handle_raw_input_v6(struct hip_packet_context *ctx)
 {
     int err = 0;
 
     if (hip_read_control_msg_v6(hip_raw_sock_input_v6,
-                                packet_ctx,
+                                ctx,
                                 0)) {
         HIP_ERROR("Reading network msg failed\n");
-        err = hip_receive_control_packet(packet_ctx);
+        err = hip_receive_control_packet(ctx);
         if (err) {
             HIP_ERROR("hip_receive_control_packet()!\n");
         }
@@ -42,16 +42,16 @@
     return err;
 }
 
-static int hip_handle_raw_input_v4(struct hip_packet_context *packet_ctx)
+static int hip_handle_raw_input_v4(struct hip_packet_context *ctx)
 {
     int err = 0;
 
     if (hip_read_control_msg_v4(hip_raw_sock_input_v4,
-                                packet_ctx,
+                                ctx,
                                 IPV4_HDR_SIZE)) {
         HIP_ERROR("Reading network msg failed\n");
     } else {
-        err = hip_receive_control_packet(packet_ctx);
+        err = hip_receive_control_packet(ctx);
         if (err) {
             HIP_ERROR("hip_receive_control_packet()!\n");
         }
@@ -60,7 +60,7 @@
     return err;
 }
 
-static int hip_handle_nat_input(struct hip_packet_context *packet_ctx)
+static int hip_handle_nat_input(struct hip_packet_context *ctx)
 {
     int err = 0;
 
@@ -69,34 +69,34 @@
               hip_nat_sock_input_udp);
 
     err = hip_read_control_msg_v4(hip_nat_sock_input_udp,
-                                  packet_ctx,
+                                  ctx,
                                   HIP_UDP_ZERO_BYTES_LEN);
     if (err) {
         HIP_ERROR("Reading network msg failed\n");
     } else {
-        err = hip_receive_udp_control_packet(packet_ctx);
+        err = hip_receive_udp_control_packet(ctx);
     }
 
     return err;
 }
 
-static int hip_handle_user_sock(struct hip_packet_context *packet_ctx)
+static int hip_handle_user_sock(struct hip_packet_context *ctx)
 {
     int err = 0;
     struct sockaddr_in6 app_src;
 
     if (hip_read_user_control_msg(hip_user_sock,
-                                  packet_ctx->input_msg,
+                                  ctx->input_msg,
                                   &app_src)) {
         HIP_ERROR("Reading user msg failed\n");
     } else {
-        err = hip_handle_user_msg(packet_ctx->input_msg, &app_src);
+        err = hip_handle_user_msg(ctx->input_msg, &app_src);
     }
 
     return err;
 }
 
-static int hip_handle_nl_ipsec_sock(struct hip_packet_context *packet_ctx)
+static int hip_handle_nl_ipsec_sock(struct hip_packet_context *ctx)
 {
     HIP_DEBUG("netlink receive\n");
     if (hip_netlink_receive(&hip_nl_ipsec,
@@ -108,7 +108,7 @@
     return 0;
 }
 
-static int hip_handle_nl_route_sock(struct hip_packet_context *packet_ctx)
+static int hip_handle_nl_route_sock(struct hip_packet_context *ctx)
 {
     HIP_DEBUG("netlink route receive\n");
     if (hip_netlink_receive(&hip_nl_route,

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-03-27 14:09:51 +0000
+++ hipd/hipd.c 2010-03-31 15:04:18 +0000
@@ -177,7 +177,7 @@
     fd_set read_fdset;
     int foreground = 1, highest_descriptor = 0, err = 0, fix_alignment = 0;
     struct timeval timeout;
-    struct hip_packet_context packet_ctx = {0};
+    struct hip_packet_context ctx = {0};
 
     /* The flushing is enabled by default. The reason for this is that
      * people are doing some very experimental features on some branches
@@ -298,13 +298,13 @@
     highest_descriptor = hip_get_highest_descriptor();
 
     /* Allocate user message. */
-    HIP_IFE(!(packet_ctx.input_msg = hip_msg_alloc()), 1);
-    packet_ctx.output_msg  = NULL;
-    packet_ctx.src_addr    = malloc(sizeof(struct in6_addr));
-    packet_ctx.dst_addr    = malloc(sizeof(struct in6_addr));
-    packet_ctx.msg_ports   = malloc(sizeof(struct hip_stateless_info));
-    packet_ctx.hadb_entry  = NULL;
-    packet_ctx.error = 0;
+    HIP_IFE(!(ctx.input_msg = hip_msg_alloc()), 1);
+    ctx.output_msg  = NULL;
+    ctx.src_addr    = malloc(sizeof(struct in6_addr));
+    ctx.dst_addr    = malloc(sizeof(struct in6_addr));
+    ctx.msg_ports   = malloc(sizeof(struct hip_stateless_info));
+    ctx.hadb_entry  = NULL;
+    ctx.error = 0;
 
     /* Enter to the select-loop */
     HIP_DEBUG_GL(HIP_DEBUG_GROUP_INIT,
@@ -323,8 +323,8 @@
 #ifdef CONFIG_HIP_FIREWALL
         if (hip_firewall_status < 0) {
 
-            hip_msg_init(packet_ctx.input_msg);
-            err = hip_build_user_hdr(packet_ctx.input_msg,
+            hip_msg_init(ctx.input_msg);
+            err = hip_build_user_hdr(ctx.input_msg,
                                      HIP_MSG_FIREWALL_STATUS,
                                      0);
             if (err) {
@@ -332,7 +332,7 @@
             } else {
                 hip_firewall_status = 0;
                 HIP_DEBUG("sent %d bytes to firewall\n",
-                          hip_sendto_firewall(packet_ctx.input_msg));
+                          hip_sendto_firewall(ctx.input_msg));
             }
         }
 #endif
@@ -362,7 +362,7 @@
         hip_perf_start_benchmark(perf_set, PERF_ALL);
 #endif
 
-        hip_run_socket_handles(&read_fdset, &packet_ctx);
+        hip_run_socket_handles(&read_fdset, &ctx);
 
 to_maintenance:
         err = hip_periodic_maintenance();
@@ -377,20 +377,20 @@
     /* free allocated resources */
     hip_exit(err);
 
-    if (packet_ctx.input_msg) {
-        HIP_FREE(packet_ctx.input_msg);
-    }
-
-    if (packet_ctx.src_addr) {
-        HIP_FREE(packet_ctx.src_addr);
-    }
-
-    if (packet_ctx.dst_addr) {
-        HIP_FREE(packet_ctx.dst_addr);
-    }
-
-    if (packet_ctx.msg_ports) {
-        HIP_FREE(packet_ctx.msg_ports);
+    if (ctx.input_msg) {
+        HIP_FREE(ctx.input_msg);
+    }
+
+    if (ctx.src_addr) {
+        HIP_FREE(ctx.src_addr);
+    }
+
+    if (ctx.dst_addr) {
+        HIP_FREE(ctx.dst_addr);
+    }
+
+    if (ctx.msg_ports) {
+        HIP_FREE(ctx.msg_ports);
     }
 
     HIP_INFO("hipd pid=%d exiting, retval=%d\n", getpid(), err);

=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c     2010-03-30 13:36:23 +0000
+++ hipd/hiprelay.c     2010-03-31 15:04:18 +0000
@@ -1083,7 +1083,7 @@
  */
 int hip_relay_handle_relay_to(const uint8_t packet_type,
                               const uint32_t ha_state,
-                              struct hip_packet_context *packet_ctx)
+                              struct hip_packet_context *ctx)
 {
     int err           = 0;
     hip_relrec_t *rec = NULL, dummy;
@@ -1102,9 +1102,9 @@
      * I's HIT. We should find one, if the I is
      * registered to relay.*/
     HIP_DEBUG_HIT("Searching relay record on HIT:",
-                  &packet_ctx->input_msg->hits);
+                  &ctx->input_msg->hits);
 
-    memcpy(&(dummy.hit_r), &packet_ctx->input_msg->hits, 
sizeof(packet_ctx->input_msg->hits));
+    memcpy(&(dummy.hit_r), &ctx->input_msg->hits, 
sizeof(ctx->input_msg->hits));
     rec = hip_relht_get(&dummy);
 
     if (rec == NULL) {
@@ -1117,7 +1117,7 @@
     HIP_DEBUG("handle_relay_to: Matching relay record found:Full-Relay.\n");
 
     //check if there is a relay_to parameter
-    relay_to = (struct hip_relay_to *) hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_RELAY_TO);
+    relay_to = (struct hip_relay_to *) hip_get_param(ctx->input_msg, 
HIP_PARAM_RELAY_TO);
     HIP_IFEL(!relay_to, 0, "No relay_to  found\n");
 
     // check msg type
@@ -1130,11 +1130,11 @@
                           (struct in6_addr *) &relay_to->address);
         HIP_DEBUG("the relay to ntohs(port): %d",
                   ntohs(relay_to->port));
-        hip_relay_forward_response(packet_ctx->input_msg,
+        hip_relay_forward_response(ctx->input_msg,
                                    packet_type,
-                                   packet_ctx->src_addr,
-                                   packet_ctx->dst_addr,
-                                   packet_ctx->msg_ports,
+                                   ctx->src_addr,
+                                   ctx->dst_addr,
+                                   ctx->msg_ports,
                                    (in6_addr_t *) &relay_to->address,
                                    ntohs(relay_to->port));
         //  state = HIP_STATE_NONE;
@@ -1434,13 +1434,13 @@
  */
 int hip_relay_handle_relay_to_in_client(const uint8_t packet_type,
                                         const uint32_t ha_state,
-                                        struct hip_packet_context *packet_ctx)
+                                        struct hip_packet_context *ctx)
 {
     int err = 0;
     struct hip_relay_to *relay_to;
     //check if full relay service is active
 
-    if (!packet_ctx->hadb_entry) {
+    if (!ctx->hadb_entry) {
         HIP_DEBUG("handle relay_to in client is failed\n");
         goto out_err;
     }
@@ -1450,7 +1450,7 @@
     // check if the relay has been registered
 
     //check if there is a relay_to parameter
-    relay_to = (struct hip_relay_to *) hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_RELAY_TO);
+    relay_to = (struct hip_relay_to *) hip_get_param(ctx->input_msg, 
HIP_PARAM_RELAY_TO);
     HIP_IFEL(!relay_to, 0, "No relay_to  found\n");
 
     // check msg type
@@ -1463,13 +1463,13 @@
         HIP_DEBUG_IN6ADDR("the relay to address: ",
                           (struct in6_addr *) &relay_to->address);
         HIP_DEBUG("the relay to ntohs(port): %d, local udp port %d\n",
-                  ntohs(relay_to->port), 
packet_ctx->hadb_entry->local_udp_port);
+                  ntohs(relay_to->port), ctx->hadb_entry->local_udp_port);
 
         if (ipv6_addr_cmp((struct in6_addr *) &relay_to->address,
-                          &packet_ctx->hadb_entry->our_addr)) {
+                          &ctx->hadb_entry->our_addr)) {
             HIP_DEBUG("relay_to address is saved as reflexive addr. \n");
-            packet_ctx->hadb_entry->local_reflexive_udp_port = 
ntohs(relay_to->port);
-            memcpy(&packet_ctx->hadb_entry->local_reflexive_address,
+            ctx->hadb_entry->local_reflexive_udp_port = ntohs(relay_to->port);
+            memcpy(&ctx->hadb_entry->local_reflexive_address,
                    &relay_to->address, sizeof(in6_addr_t));
         }
         //  state = HIP_STATE_NONE;

=== modified file 'hipd/hiprelay.h'
--- hipd/hiprelay.h     2010-03-17 22:28:05 +0000
+++ hipd/hiprelay.h     2010-03-31 15:04:18 +0000
@@ -114,10 +114,10 @@
 
 int hip_relay_handle_relay_to_in_client(const uint8_t packet_type,
                                         const uint32_t ha_state,
-                                        struct hip_packet_context *packet_ctx);
+                                        struct hip_packet_context *ctx);
 
 int hip_relay_handle_relay_to(const uint8_t packet_type,
                               const uint32_t ha_state,
-                              struct hip_packet_context *packet_ctx);
+                              struct hip_packet_context *ctx);
 
 #endif /* HIP_HIPD_HIPRELAY_H */

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-03-31 14:33:52 +0000
+++ hipd/input.c        2010-03-31 15:04:18 +0000
@@ -216,7 +216,7 @@
  * @param dhpv pointer to the DH public value choosen
  * @return zero on success, or negative on error.
  */
-int hip_produce_keying_material(struct hip_packet_context *packet_ctx,
+int hip_produce_keying_material(struct hip_packet_context *ctx,
                                 uint64_t I,
                                 uint64_t J,
                                 struct hip_dh_public_value **dhpv)
@@ -238,12 +238,12 @@
     _HIP_DEBUG("hip_produce_keying_material() invoked.\n");
     /* Perform light operations first before allocating memory or
      * using lots of CPU time */
-    HIP_IFEL(!(param = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_HIP_TRANSFORM)),
+    HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
              -EINVAL,
              "Could not find HIP transform\n");
     HIP_IFEL((hip_tfm = hip_select_hip_transform((struct hip_hip_transform *) 
param)) == 0,
              -EINVAL, "Could not select HIP transform\n");
-    HIP_IFEL(!(param = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_ESP_TRANSFORM)),
+    HIP_IFEL(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_TRANSFORM)),
              -EINVAL,
              "Could not find ESP transform\n");
     HIP_IFEL((esp_tfm = hip_select_esp_transform((struct hip_esp_transform *) 
param)) == 0,
@@ -274,7 +274,7 @@
                                hip_transf_length + hmac_transf_length;
 
     /* R1 contains no ESP_INFO */
-    esp_info = hip_get_param(packet_ctx->input_msg, HIP_PARAM_ESP_INFO);
+    esp_info = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_INFO);
 
     if (esp_info) {
         esp_keymat_index = ntohs(esp_info->keymat_index);
@@ -311,7 +311,7 @@
     memset(dh_shared_key, 0, dh_shared_len);
 
     HIP_IFEL(!(dhf = (struct hip_diffie_hellman *) hip_get_param(
-                   packet_ctx->input_msg, HIP_PARAM_DIFFIE_HELLMAN)),
+                   ctx->input_msg, HIP_PARAM_DIFFIE_HELLMAN)),
              -ENOENT,  "No Diffie-Hellman parameter found.\n");
 
     /* If the message has two DH keys, select (the stronger, usually) one. */
@@ -341,94 +341,94 @@
                     &km,
                     keymat,
                     keymat_len,
-                    &packet_ctx->input_msg->hits,
-                    &packet_ctx->input_msg->hitr,
-                    &packet_ctx->hadb_entry->keymat_calc_index,
+                    &ctx->input_msg->hits,
+                    &ctx->input_msg->hitr,
+                    &ctx->hadb_entry->keymat_calc_index,
                     I,
                     J);
 
     /* draw from km to keymat, copy keymat to dst, length of
      * keymat is len */
 
-    we_are_HITg = hip_hit_is_bigger(&packet_ctx->input_msg->hitr,
-                                    &packet_ctx->input_msg->hits);
+    we_are_HITg = hip_hit_is_bigger(&ctx->input_msg->hitr,
+                                    &ctx->input_msg->hits);
 
     HIP_DEBUG("We are %s HIT.\n", we_are_HITg ? "greater" : "lesser");
 
     if (we_are_HITg) {
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_enc_out.key, &km,
-                                 hip_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_hmac_out.key, &km,
-                                 hmac_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_enc_in.key, &km,
-                                 hip_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_hmac_in.key, &km,
-                                 hmac_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->esp_out.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_enc_out.key, &km,
+                                 hip_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_hmac_out.key, &km,
+                                 hmac_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_enc_in.key, &km,
+                                 hip_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_hmac_in.key, &km,
+                                 hmac_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->esp_out.key, &km,
                                  esp_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->auth_out.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->auth_out.key, &km,
                                  auth_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->esp_in.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->esp_in.key, &km,
                                  esp_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->auth_in.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->auth_in.key, &km,
                                  auth_transf_length);
     } else {
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_enc_in.key, &km,
-                                 hip_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_hmac_in.key, &km,
-                                 hmac_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_enc_out.key, &km,
-                                 hip_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->hip_hmac_out.key, &km,
-                                 hmac_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->esp_in.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_enc_in.key, &km,
+                                 hip_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_hmac_in.key, &km,
+                                 hmac_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_enc_out.key, &km,
+                                 hip_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->hip_hmac_out.key, &km,
+                                 hmac_transf_length);
+        hip_keymat_draw_and_copy(ctx->hadb_entry->esp_in.key, &km,
                                  esp_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->auth_in.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->auth_in.key, &km,
                                  auth_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->esp_out.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->esp_out.key, &km,
                                  esp_transf_length);
-        hip_keymat_draw_and_copy(packet_ctx->hadb_entry->auth_out.key, &km,
+        hip_keymat_draw_and_copy(ctx->hadb_entry->auth_out.key, &km,
                                  auth_transf_length);
     }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop PERF_DH_CREATE\n");
     hip_perf_stop_benchmark(perf_set, PERF_DH_CREATE);
 #endif
-    HIP_HEXDUMP("HIP-gl encryption:", &packet_ctx->hadb_entry->hip_enc_out.key,
+    HIP_HEXDUMP("HIP-gl encryption:", &ctx->hadb_entry->hip_enc_out.key,
                 hip_transf_length);
-    HIP_HEXDUMP("HIP-gl integrity (HMAC) key:", 
&packet_ctx->hadb_entry->hip_hmac_out.key,
+    HIP_HEXDUMP("HIP-gl integrity (HMAC) key:", 
&ctx->hadb_entry->hip_hmac_out.key,
                 hmac_transf_length);
     _HIP_DEBUG("skipping HIP-lg encryption key, %u bytes\n",
                hip_transf_length);
-    HIP_HEXDUMP("HIP-lg encryption:", &packet_ctx->hadb_entry->hip_enc_in.key,
+    HIP_HEXDUMP("HIP-lg encryption:", &ctx->hadb_entry->hip_enc_in.key,
                 hip_transf_length);
-    HIP_HEXDUMP("HIP-lg integrity (HMAC) key:", 
&packet_ctx->hadb_entry->hip_hmac_in.key,
+    HIP_HEXDUMP("HIP-lg integrity (HMAC) key:", 
&ctx->hadb_entry->hip_hmac_in.key,
                 hmac_transf_length);
-    HIP_HEXDUMP("SA-gl ESP encryption key:", 
&packet_ctx->hadb_entry->esp_out.key,
+    HIP_HEXDUMP("SA-gl ESP encryption key:", &ctx->hadb_entry->esp_out.key,
                 esp_transf_length);
-    HIP_HEXDUMP("SA-gl ESP authentication key:", 
&packet_ctx->hadb_entry->auth_out.key,
+    HIP_HEXDUMP("SA-gl ESP authentication key:", 
&ctx->hadb_entry->auth_out.key,
                 auth_transf_length);
-    HIP_HEXDUMP("SA-lg ESP encryption key:", 
&packet_ctx->hadb_entry->esp_in.key,
+    HIP_HEXDUMP("SA-lg ESP encryption key:", &ctx->hadb_entry->esp_in.key,
                 esp_transf_length);
-    HIP_HEXDUMP("SA-lg ESP authentication key:", 
&packet_ctx->hadb_entry->auth_in.key,
+    HIP_HEXDUMP("SA-lg ESP authentication key:", &ctx->hadb_entry->auth_in.key,
                 auth_transf_length);
 
     /* the next byte when creating new keymat */
-    packet_ctx->hadb_entry->current_keymat_index = keymat_len_min;     /* 
offset value, so no +1 ? */
-    packet_ctx->hadb_entry->keymat_calc_index    = 
(packet_ctx->hadb_entry->current_keymat_index / HIP_AH_SHA_LEN) + 1;
-    packet_ctx->hadb_entry->esp_keymat_index     = esp_keymat_index;
-
-    memcpy(packet_ctx->hadb_entry->current_keymat_K,
-           keymat + (packet_ctx->hadb_entry->keymat_calc_index - 1) * 
HIP_AH_SHA_LEN, HIP_AH_SHA_LEN);
-
-    _HIP_DEBUG("packet_ctx->hadb_entry: keymat_calc_index=%u 
current_keymat_index=%u\n",
-               packet_ctx->hadb_entry->keymat_calc_index, 
packet_ctx->hadb_entry->current_keymat_index);
-    _HIP_HEXDUMP("CTX CURRENT KEYMAT", 
packet_ctx->hadb_entry->current_keymat_K,
+    ctx->hadb_entry->current_keymat_index = keymat_len_min;     /* offset 
value, so no +1 ? */
+    ctx->hadb_entry->keymat_calc_index    = 
(ctx->hadb_entry->current_keymat_index / HIP_AH_SHA_LEN) + 1;
+    ctx->hadb_entry->esp_keymat_index     = esp_keymat_index;
+
+    memcpy(ctx->hadb_entry->current_keymat_K,
+           keymat + (ctx->hadb_entry->keymat_calc_index - 1) * HIP_AH_SHA_LEN, 
HIP_AH_SHA_LEN);
+
+    _HIP_DEBUG("ctx->hadb_entry: keymat_calc_index=%u 
current_keymat_index=%u\n",
+               ctx->hadb_entry->keymat_calc_index, 
ctx->hadb_entry->current_keymat_index);
+    _HIP_HEXDUMP("CTX CURRENT KEYMAT", ctx->hadb_entry->current_keymat_K,
                  HIP_AH_SHA_LEN);
 
     /* store DH shared key */
-    packet_ctx->hadb_entry->dh_shared_key     = dh_shared_key;
-    packet_ctx->hadb_entry->dh_shared_key_len = dh_shared_len;
+    ctx->hadb_entry->dh_shared_key     = dh_shared_key;
+    ctx->hadb_entry->dh_shared_key_len = dh_shared_len;
 
     /* on success HIP_FREE for dh_shared_key is called by caller */
 out_err:
@@ -498,14 +498,14 @@
 /**
  * Decides what action to take for an incoming HIP control packet.
  *
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
  *                    association database).
  * @return      zero on success, or negative error value on error.
  */
-int hip_receive_control_packet(struct hip_packet_context *packet_ctx)
+int hip_receive_control_packet(struct hip_packet_context *ctx)
 {
     int err = 0;
     struct in6_addr ipv6_any_addr = IN6ADDR_ANY_INIT;
@@ -516,67 +516,67 @@
      * printing packet data here works for all packets. To avoid excessive
      * debug printing do not print this information inside the individual
      * receive or handle functions. */
-    HIP_DEBUG_HIT("HIT Sender  ", &packet_ctx->input_msg->hits);
-    HIP_DEBUG_HIT("HIT Receiver", &packet_ctx->input_msg->hitr);
+    HIP_DEBUG_HIT("HIT Sender  ", &ctx->input_msg->hits);
+    HIP_DEBUG_HIT("HIT Receiver", &ctx->input_msg->hitr);
     HIP_DEBUG("source port: %u, destination port: %u\n",
-              packet_ctx->msg_ports->src_port,
-              packet_ctx->msg_ports->dst_port);
-
-    HIP_DUMP_MSG(packet_ctx->input_msg);
-
-    if (hip_hidb_hit_is_our(&packet_ctx->input_msg->hits) &&
-        (IN6_ARE_ADDR_EQUAL(&packet_ctx->input_msg->hitr,
-                            &packet_ctx->input_msg->hits) ||
-         IN6_ARE_ADDR_EQUAL(&packet_ctx->input_msg->hitr,
+              ctx->msg_ports->src_port,
+              ctx->msg_ports->dst_port);
+
+    HIP_DUMP_MSG(ctx->input_msg);
+
+    if (hip_hidb_hit_is_our(&ctx->input_msg->hits) &&
+        (IN6_ARE_ADDR_EQUAL(&ctx->input_msg->hitr,
+                            &ctx->input_msg->hits) ||
+         IN6_ARE_ADDR_EQUAL(&ctx->input_msg->hitr,
                             &ipv6_any_addr)) &&
-        !hip_addr_is_loopback(packet_ctx->dst_addr) &&
-        !hip_addr_is_loopback(packet_ctx->src_addr) &&
-        !IN6_ARE_ADDR_EQUAL(packet_ctx->src_addr, packet_ctx->dst_addr)) {
+        !hip_addr_is_loopback(ctx->dst_addr) &&
+        !hip_addr_is_loopback(ctx->src_addr) &&
+        !IN6_ARE_ADDR_EQUAL(ctx->src_addr, ctx->dst_addr)) {
         HIP_DEBUG("Invalid loopback packet. Dropping.\n");
         goto out_err;
     }
 
-    HIP_IFEL(hip_check_network_msg(packet_ctx->input_msg),
+    HIP_IFEL(hip_check_network_msg(ctx->input_msg),
              -1,
              "Checking control message failed.\n");
 
-    type  = hip_get_msg_type(packet_ctx->input_msg);
+    type  = hip_get_msg_type(ctx->input_msg);
 
     /** @todo Check packet csum.*/
 
-    packet_ctx->hadb_entry = hip_hadb_find_byhits(&packet_ctx->input_msg->hits,
-                                                  
&packet_ctx->input_msg->hitr);
+    ctx->hadb_entry = hip_hadb_find_byhits(&ctx->input_msg->hits,
+                                                  &ctx->input_msg->hitr);
 
     // Check if we need to drop the packet
-    if (packet_ctx->hadb_entry &&
-        hip_packet_to_drop(packet_ctx->hadb_entry,
+    if (ctx->hadb_entry &&
+        hip_packet_to_drop(ctx->hadb_entry,
                            type,
-                           &packet_ctx->input_msg->hitr) == 1) {
+                           &ctx->input_msg->hitr) == 1) {
         HIP_DEBUG("Ignoring the packet sent.\n");
         err = -1;
         goto out_err;
     }
 
-    if (packet_ctx->hadb_entry) {
-        state = packet_ctx->hadb_entry->state;
+    if (ctx->hadb_entry) {
+        state = ctx->hadb_entry->state;
     } else {
         state = HIP_STATE_NONE;
     }
 
 #ifdef CONFIG_HIP_OPPORTUNISTIC
-    if (!packet_ctx->hadb_entry && opportunistic_mode &&
+    if (!ctx->hadb_entry && opportunistic_mode &&
         (type == HIP_I1 || type == HIP_R1)) {
-        packet_ctx->hadb_entry =
-                hip_oppdb_get_hadb_entry_i1_r1(packet_ctx->input_msg,
-                                               packet_ctx->src_addr,
-                                               packet_ctx->dst_addr,
-                                               packet_ctx->msg_ports);
+        ctx->hadb_entry =
+                hip_oppdb_get_hadb_entry_i1_r1(ctx->input_msg,
+                                               ctx->src_addr,
+                                               ctx->dst_addr,
+                                               ctx->msg_ports);
     }
 #endif
 
 #ifdef CONFIG_HIP_RVS
     /* check if it a relaying msg */
-    if (hip_relay_handle_relay_to(type, state, packet_ctx)) {
+    if (hip_relay_handle_relay_to(type, state, ctx)) {
         err = -ECANCELED;
         goto out_err;
     } else {
@@ -584,7 +584,7 @@
     }
 #endif
 
-    hip_run_handle_functions(type, state, packet_ctx);
+    hip_run_handle_functions(type, state, ctx);
 
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Write PERF_SIGN, PERF_DSA_SIGN_IMPL, PERF_RSA_SIGN_IMPL," \
@@ -620,23 +620,23 @@
  * of hip_receive_control_packet() is the @c saddr of this function.</li>
  * </ol>
  *
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
  *                    association database).
  * @return      zero on success, or negative error value on error.
  */
-int hip_receive_udp_control_packet(struct hip_packet_context *packet_ctx)
+int hip_receive_udp_control_packet(struct hip_packet_context *ctx)
 {
     int err         = 0, type;
     hip_ha_t *entry = NULL;
 
     _HIP_DEBUG("hip_nat_receive_udp_control_packet() invoked.\n");
 
-    type  = hip_get_msg_type(packet_ctx->input_msg);
-    entry = hip_hadb_find_byhits(&packet_ctx->input_msg->hits,
-                                 &packet_ctx->input_msg->hitr);
+    type  = hip_get_msg_type(ctx->input_msg);
+    entry = hip_hadb_find_byhits(&ctx->input_msg->hits,
+                                 &ctx->input_msg->hitr);
 
 #ifndef CONFIG_HIP_RVS
     /* The ip of RVS is taken to be ip of the peer while using RVS server
@@ -651,10 +651,10 @@
          * used for setting up the SAs: handle_r1 creates one-way SA and
          * handle_i2 the other way; let's make sure that they are the
          * same. */
-        packet_ctx->src_addr = &entry->peer_addr;
+        ctx->src_addr = &entry->peer_addr;
     }
 #endif
-    HIP_IFEL(hip_receive_control_packet(packet_ctx), -1,
+    HIP_IFEL(hip_receive_control_packet(ctx), -1,
              "receiving of control packet failed\n");
 out_err:
     return err;
@@ -687,7 +687,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -706,7 +706,7 @@
  */
 int hip_handle_r1(const uint8_t packet_type,
                   const uint32_t ha_state,
-                  struct hip_packet_context *packet_ctx)
+                  struct hip_packet_context *ctx)
 {
     int mask = HIP_PACKET_CTRL_ANON, err = 0, retransmission = 0, written = 0, 
len;
     uint64_t solved_puzzle           = 0, I = 0;
@@ -724,40 +724,40 @@
     hip_perf_start_benchmark(perf_set, PERF_R1);
 #endif
 
-    HIP_IFEL(!packet_ctx->hadb_entry, -1,
+    HIP_IFEL(!ctx->hadb_entry, -1,
              "No entry in host association database when receiving R1." \
              "Dropping.\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));
+   hip_oppipdb_delentry(&(ctx->hadb_entry->peer_addr));
 #endif
 
-   if (ipv6_addr_any(&(packet_ctx->input_msg)->hitr)) {
+   if (ipv6_addr_any(&(ctx->input_msg)->hitr)) {
        HIP_DEBUG("Received NULL receiver HIT in R1. Not dropping\n");
    }
 
-   HIP_IFEL(!hip_controls_sane(ntohs(packet_ctx->input_msg->control), mask), 0,
+   HIP_IFEL(!hip_controls_sane(ntohs(ctx->input_msg->control), mask), 0,
             "Received illegal controls in R1: 0x%x Dropping\n",
-            ntohs(packet_ctx->input_msg->control));
+            ntohs(ctx->input_msg->control));
 
    /* An implicit and insecure REA. If sender's address is different than
     * the one that was mapped, then we will overwrite the mapping with the
     * newer address. This enables us to use the rendezvous server, while
     * not supporting the REA TLV. */
-   hip_hadb_get_peer_addr(packet_ctx->hadb_entry, &daddr);
-   if (ipv6_addr_cmp(&daddr, packet_ctx->src_addr) != 0) {
+   hip_hadb_get_peer_addr(ctx->hadb_entry, &daddr);
+   if (ipv6_addr_cmp(&daddr, ctx->src_addr) != 0) {
        HIP_DEBUG("Mapped address didn't match received address\n");
        HIP_DEBUG("Assuming that the mapped address was actually RVS's.\n");
        HIP_HEXDUMP("Mapping", &daddr, 16);
-       HIP_HEXDUMP("Received", packet_ctx->src_addr, 16);
-       hip_hadb_delete_peer_addrlist_one_old(packet_ctx->hadb_entry, &daddr);
-       hip_hadb_add_peer_addr(packet_ctx->hadb_entry,
-                              packet_ctx->src_addr,
+       HIP_HEXDUMP("Received", ctx->src_addr, 16);
+       hip_hadb_delete_peer_addrlist_one_old(ctx->hadb_entry, &daddr);
+       hip_hadb_add_peer_addr(ctx->hadb_entry,
+                              ctx->src_addr,
                               0,
                               0,
                               PEER_ADDR_STATE_ACTIVE,
-                              packet_ctx->msg_ports->src_port);
+                              ctx->msg_ports->src_port);
    }
 
    HIP_DEBUG("Received R1 in state %s\n", hip_state_str(ha_state));
@@ -769,10 +769,10 @@
         HIP_DEBUG("Not a retransmission\n");
     }
 
-    hip_relay_add_rvs_to_ha(packet_ctx->input_msg, packet_ctx->hadb_entry);
+    hip_relay_add_rvs_to_ha(ctx->input_msg, ctx->hadb_entry);
 
 #ifdef CONFIG_HIP_RVS
-    hip_relay_handle_relay_to_in_client(packet_type, ha_state, packet_ctx);
+    hip_relay_handle_relay_to_in_client(packet_type, ha_state, ctx);
 #endif /* CONFIG_HIP_RVS */
 
     /* According to the section 8.6 of the base draft, we must first check
@@ -782,22 +782,22 @@
      * verification must be delayed to the R2 */
     /* Store the peer's public key to HA and validate it */
     /** @todo Do not store the key if the verification fails. */
-    HIP_IFEL(!(peer_host_id = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_HOST_ID)),
+    HIP_IFEL(!(peer_host_id = hip_get_param(ctx->input_msg, 
HIP_PARAM_HOST_ID)),
              -ENOENT, "No HOST_ID found in R1\n");
     //copy hostname to hadb entry if local copy is empty
-    if (strlen((char *) (packet_ctx->hadb_entry->peer_hostname)) == 0) {
-        memcpy(packet_ctx->hadb_entry->peer_hostname,
+    if (strlen((char *) (ctx->hadb_entry->peer_hostname)) == 0) {
+        memcpy(ctx->hadb_entry->peer_hostname,
                hip_get_param_host_id_hostname(peer_host_id),
                HIP_HOST_ID_HOSTNAME_LEN_MAX - 1);
     }
-    HIP_IFE(hip_init_peer(packet_ctx->hadb_entry, packet_ctx->input_msg, 
peer_host_id), -EINVAL);
+    HIP_IFE(hip_init_peer(ctx->hadb_entry, ctx->input_msg, peer_host_id), 
-EINVAL);
 
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Start PERF_VERIFY\n");
     hip_perf_start_benchmark(perf_set, PERF_VERIFY);
 #endif
-    
HIP_IFEL(packet_ctx->hadb_entry->verify(packet_ctx->hadb_entry->peer_pub_key,
-                                            packet_ctx->input_msg),
+    HIP_IFEL(ctx->hadb_entry->verify(ctx->hadb_entry->peer_pub_key,
+                                            ctx->input_msg),
              -EINVAL,
              "Verification of R1 signature failed\n");
 #ifdef CONFIG_HIP_PERFORMANCE
@@ -809,24 +809,24 @@
      * the peer is behind NAT. We set NAT mode "on" and set the send function 
to
      * "hip_send_udp". The client UDP port is not stored until the handling
      * of R2 packet. Don't know if the entry is already locked... */
-    if (packet_ctx->msg_ports->dst_port != 0) {
-        HIP_LOCK_HA(packet_ctx->hadb_entry);
-        if (packet_ctx->hadb_entry->nat_mode == HIP_NAT_MODE_NONE) {
-            packet_ctx->hadb_entry->nat_mode = HIP_NAT_MODE_PLAIN_UDP;
+    if (ctx->msg_ports->dst_port != 0) {
+        HIP_LOCK_HA(ctx->hadb_entry);
+        if (ctx->hadb_entry->nat_mode == HIP_NAT_MODE_NONE) {
+            ctx->hadb_entry->nat_mode = HIP_NAT_MODE_PLAIN_UDP;
         }
         /* @todo Is this alternative xmit function necessary? */
         /* hip_hadb_set_xmit_function_set(entry, &nat_xmit_func_set); */
-        HIP_UNLOCK_HA(packet_ctx->hadb_entry);
+        HIP_UNLOCK_HA(ctx->hadb_entry);
     }
 
     /***** LOCATOR PARAMETER ******/
-    locator = (struct hip_locator *) hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_LOCATOR);
+    locator = (struct hip_locator *) hip_get_param(ctx->input_msg, 
HIP_PARAM_LOCATOR);
     if (locator) {
         err = handle_locator(locator,
-                             packet_ctx->src_addr,
-                             packet_ctx->dst_addr,
-                             packet_ctx->hadb_entry,
-                             packet_ctx->msg_ports);
+                             ctx->src_addr,
+                             ctx->dst_addr,
+                             ctx->hadb_entry,
+                             ctx->msg_ports);
     } else {
         HIP_DEBUG("R1 did not have locator\n");
     }
@@ -835,16 +835,16 @@
 
     /* We have problems with creating precreated R1s in reasonable
      * fashion... so we don't mind about generations. */
-    r1cntr = hip_get_param(packet_ctx->input_msg, HIP_PARAM_R1_COUNTER);
+    r1cntr = hip_get_param(ctx->input_msg, HIP_PARAM_R1_COUNTER);
 
     /* Do control bit stuff here... */
 
     /* We must store the R1 generation counter, _IF_ it exists. */
     if (r1cntr) {
-        HIP_LOCK_HA(packet_ctx->hadb_entry);
+        HIP_LOCK_HA(ctx->hadb_entry);
         HIP_DEBUG("Storing R1 generation counter %d\n", r1cntr->generation);
-        packet_ctx->hadb_entry->birthday = ntoh64(r1cntr->generation);
-        HIP_UNLOCK_HA(packet_ctx->hadb_entry);
+        ctx->hadb_entry->birthday = ntoh64(r1cntr->generation);
+        HIP_UNLOCK_HA(ctx->hadb_entry);
     }
 
     /* Solve puzzle: if this is a retransmission, we have to preserve
@@ -852,36 +852,36 @@
     if (!retransmission) {
         struct hip_puzzle *pz = NULL;
 
-        HIP_IFEL(!(pz = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_PUZZLE)), -EINVAL,
+        HIP_IFEL(!(pz = hip_get_param(ctx->input_msg, HIP_PARAM_PUZZLE)), 
-EINVAL,
                  "Malformed R1 packet. PUZZLE parameter missing\n");
         HIP_IFEL((solved_puzzle = hip_solve_puzzle(pz,
-                                                   packet_ctx->input_msg,
+                                                   ctx->input_msg,
                                                    HIP_SOLVE_PUZZLE)) == 0,
                                                    -EINVAL, "Solving of puzzle 
failed\n");
         I = pz->I;
-        packet_ctx->hadb_entry->puzzle_solution = solved_puzzle;
-        packet_ctx->hadb_entry->puzzle_i        = pz->I;
+        ctx->hadb_entry->puzzle_solution = solved_puzzle;
+        ctx->hadb_entry->puzzle_i        = pz->I;
     } else {
-        I             = packet_ctx->hadb_entry->puzzle_i;
-        solved_puzzle = packet_ctx->hadb_entry->puzzle_solution;
+        I             = ctx->hadb_entry->puzzle_i;
+        solved_puzzle = ctx->hadb_entry->puzzle_solution;
     }
 
     /* Allocate space for a new I2 message. */
-    HIP_IFEL(!(packet_ctx->output_msg = hip_msg_alloc()),
+    HIP_IFEL(!(ctx->output_msg = hip_msg_alloc()),
              -ENOMEM,
              "Allocation of I2 failed\n");
 
     HIP_DEBUG("Build normal I2.\n");
     /* create I2 */
-    hip_build_network_hdr(packet_ctx->output_msg,
+    hip_build_network_hdr(ctx->output_msg,
                           HIP_I2,
                           i2_mask,
-                          &packet_ctx->input_msg->hitr,
-                          &packet_ctx->input_msg->hits);
+                          &ctx->input_msg->hitr,
+                          &ctx->input_msg->hits);
 
     /* note: we could skip keying material generation in the case
      * of a retransmission but then we'd had to fill ctx->hmac etc */
-    HIP_IFEL(hip_produce_keying_material(packet_ctx,
+    HIP_IFEL(hip_produce_keying_material(ctx,
                                          I,
                                          solved_puzzle,
                                          &dhpv),
@@ -890,26 +890,26 @@
 
     /********** ESP_INFO **********/
     /* SPI is set below */
-    HIP_IFEL(hip_build_param_esp_info(packet_ctx->output_msg,
-                                      packet_ctx->hadb_entry->esp_keymat_index,
+    HIP_IFEL(hip_build_param_esp_info(ctx->output_msg,
+                                      ctx->hadb_entry->esp_keymat_index,
                                       0,
                                       0),
              -1,
              "building of ESP_INFO failed.\n");
 
     /********** SOLUTION **********/
-    HIP_IFEL(!(pz = hip_get_param(packet_ctx->input_msg, HIP_PARAM_PUZZLE)),
+    HIP_IFEL(!(pz = hip_get_param(ctx->input_msg, HIP_PARAM_PUZZLE)),
              -ENOENT,
              "Internal error: PUZZLE parameter mysteriously gone\n");
-    HIP_IFEL(hip_build_param_solution(packet_ctx->output_msg, pz, 
ntoh64(solved_puzzle)),
+    HIP_IFEL(hip_build_param_solution(ctx->output_msg, pz, 
ntoh64(solved_puzzle)),
              -1,
              "Building of solution failed\n");
 
     /********** Diffie-Hellman *********/
     /* calculate shared secret and create keying material */
-    packet_ctx->hadb_entry->dh_shared_key = NULL;
+    ctx->hadb_entry->dh_shared_key = NULL;
 
-    HIP_IFEL(!(dh_req = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_DIFFIE_HELLMAN)),
+    HIP_IFEL(!(dh_req = hip_get_param(ctx->input_msg, 
HIP_PARAM_DIFFIE_HELLMAN)),
              -ENOENT,
              "Internal error\n");
     HIP_IFEL((written = hip_insert_dh(dhpv->public_value,
@@ -918,7 +918,7 @@
                 -1,
                 "Could not extract the DH public key\n");
 
-    HIP_IFEL(hip_build_param_diffie_hellman_contents(packet_ctx->output_msg,
+    HIP_IFEL(hip_build_param_diffie_hellman_contents(ctx->output_msg,
                                                      dhpv->group_id,
                                                      dhpv->public_value,
                                                      written,
@@ -936,15 +936,15 @@
               hip_get_param_host_id_hostname(peer_host_id));
 
     /********* ESP protection preferred transforms [OPTIONAL] *********/
-    HIP_IFEL(esp_prot_r1_handle_transforms(packet_ctx),
+    HIP_IFEL(esp_prot_r1_handle_transforms(ctx),
              -1,
              "failed to handle preferred esp protection transforms\n");
 
     /******************************************************************/
 
     out_err:
-    if (packet_ctx->hadb_entry->dh_shared_key) {
-        HIP_FREE(packet_ctx->hadb_entry->dh_shared_key);
+    if (ctx->hadb_entry->dh_shared_key) {
+        HIP_FREE(ctx->hadb_entry->dh_shared_key);
     }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop and write PERF_R1\n");
@@ -993,7 +993,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -1004,7 +1004,7 @@
  */
 int hip_handle_r2(const uint8_t packet_type,
                   const uint32_t ha_state,
-                  struct hip_packet_context *packet_ctx)
+                  struct hip_packet_context *ctx)
 {
     int err                         = 0, tfm = 0, retransmission = 0, idx = 0;
     uint16_t mask                   = 0;
@@ -1017,22 +1017,22 @@
     hip_perf_start_benchmark(perf_set, PERF_R2);
 #endif
 
-    HIP_IFEL(ipv6_addr_any(&(packet_ctx->input_msg)->hitr), -1,
+    HIP_IFEL(ipv6_addr_any(&(ctx->input_msg)->hitr), -1,
              "Received NULL receiver HIT in R2. Dropping\n");
 
-    HIP_IFEL(!hip_controls_sane(ntohs(packet_ctx->input_msg->control), mask),
+    HIP_IFEL(!hip_controls_sane(ntohs(ctx->input_msg->control), mask),
              -1,
              "Received illegal controls in R2: 0x%x. Dropping\n",
-             ntohs(packet_ctx->input_msg->control));
+             ntohs(ctx->input_msg->control));
 
-    HIP_IFEL(!packet_ctx->hadb_entry, -1,
+    HIP_IFEL(!ctx->hadb_entry, -1,
              "No entry in host association database when receiving R2." \
              "Dropping.\n");
 
     /* if the NAT mode is used, update the port numbers of the host 
association */
-    if (packet_ctx->msg_ports->dst_port == hip_get_local_nat_udp_port()) {
-        packet_ctx->hadb_entry->local_udp_port = 
packet_ctx->msg_ports->dst_port;
-        packet_ctx->hadb_entry->peer_udp_port  = 
packet_ctx->msg_ports->src_port;
+    if (ctx->msg_ports->dst_port == hip_get_local_nat_udp_port()) {
+        ctx->hadb_entry->local_udp_port = ctx->msg_ports->dst_port;
+        ctx->hadb_entry->peer_udp_port  = ctx->msg_ports->src_port;
     }
 
     HIP_DEBUG("Received R2 in state %s\n", hip_state_str(ha_state));
@@ -1045,16 +1045,16 @@
     }
 
     /* Verify HMAC */
-    if (packet_ctx->hadb_entry->is_loopback) {
-        HIP_IFEL(hip_verify_packet_hmac2(packet_ctx->input_msg,
-                                         &packet_ctx->hadb_entry->hip_hmac_out,
-                                         packet_ctx->hadb_entry->peer_pub),
+    if (ctx->hadb_entry->is_loopback) {
+        HIP_IFEL(hip_verify_packet_hmac2(ctx->input_msg,
+                                         &ctx->hadb_entry->hip_hmac_out,
+                                         ctx->hadb_entry->peer_pub),
                  -1,
                  "HMAC validation on R2 failed.\n");
     } else {
-        HIP_IFEL(hip_verify_packet_hmac2(packet_ctx->input_msg,
-                                         &packet_ctx->hadb_entry->hip_hmac_in,
-                                         packet_ctx->hadb_entry->peer_pub),
+        HIP_IFEL(hip_verify_packet_hmac2(ctx->input_msg,
+                                         &ctx->hadb_entry->hip_hmac_in,
+                                         ctx->hadb_entry->peer_pub),
                  -1,
                  "HMAC validation on R2 failed.\n");
     }
@@ -1064,8 +1064,8 @@
     HIP_DEBUG("Start PERF_VERIFY(3)\n");
     hip_perf_start_benchmark(perf_set, PERF_VERIFY);
 #endif
-    
HIP_IFEL(packet_ctx->hadb_entry->verify(packet_ctx->hadb_entry->peer_pub_key,
-                                            packet_ctx->input_msg),
+    HIP_IFEL(ctx->hadb_entry->verify(ctx->hadb_entry->peer_pub_key,
+                                            ctx->input_msg),
              -EINVAL,
              "R2 signature verification failed.\n");
 #ifdef CONFIG_HIP_PERFORMANCE
@@ -1074,7 +1074,7 @@
 #endif
 
     /* The rest */
-    HIP_IFEL(!(esp_info = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_ESP_INFO)),
+    HIP_IFEL(!(esp_info = hip_get_param(ctx->input_msg, HIP_PARAM_ESP_INFO)),
              -EINVAL,
              "Parameter SPI not found.\n");
 
@@ -1082,67 +1082,67 @@
     memset(&spi_out_data, 0, sizeof(struct hip_spi_out_item));
     spi_out_data.spi = spi_recvd;
 
-    packet_ctx->hadb_entry->spi_outbound_current = spi_recvd;
+    ctx->hadb_entry->spi_outbound_current = spi_recvd;
     HIP_DEBUG("Set SPI out = 0x%x\n", spi_recvd);
 
     /* Copy SPI out value here or otherwise ICE code has zero SPI */
-    packet_ctx->hadb_entry->spi_outbound_new = spi_recvd;
+    ctx->hadb_entry->spi_outbound_new = spi_recvd;
     HIP_DEBUG("Set default SPI out = 0x%x\n", spi_recvd);
 
     HIP_DEBUG("entry should have only one spi_in now, test\n");
 
-    spi_in = packet_ctx->hadb_entry->spi_inbound_current;
+    spi_in = ctx->hadb_entry->spi_inbound_current;
     HIP_DEBUG("spi_in: 0x%x\n", spi_in);
 
-    tfm    = packet_ctx->hadb_entry->esp_transform;
+    tfm    = ctx->hadb_entry->esp_transform;
     HIP_DEBUG("esp_transform: %i\n", tfm);
 
     HIP_DEBUG("R2 packet source port: %d, destination port %d.\n",
-              packet_ctx->msg_ports->src_port, 
packet_ctx->msg_ports->dst_port);
+              ctx->msg_ports->src_port, ctx->msg_ports->dst_port);
 
     /********** ESP-PROT anchor [OPTIONAL] **********/
-    HIP_IFEL(esp_prot_r2_handle_anchor(packet_ctx->hadb_entry,
-                                       packet_ctx->input_msg),
+    HIP_IFEL(esp_prot_r2_handle_anchor(ctx->hadb_entry,
+                                       ctx->input_msg),
              -1,
              "failed to handle esp prot anchor\n");
 
     /***** LOCATOR PARAMETER *****/
-    locator = (struct hip_locator *) hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_LOCATOR);
+    locator = (struct hip_locator *) hip_get_param(ctx->input_msg, 
HIP_PARAM_LOCATOR);
     if (locator) {
         HIP_DEBUG("Locator parameter support in BEX is not implemented!\n");
     }
     //end add
 
     // moved from hip_send_i2
-    HIP_DEBUG_HIT("hit our", &(packet_ctx->hadb_entry)->hit_our);
-    HIP_DEBUG_HIT("hit peer", &(packet_ctx->hadb_entry)->hit_peer);
-    HIP_IFEL(hip_add_sa(packet_ctx->src_addr,
-                        packet_ctx->dst_addr,
-                        &packet_ctx->input_msg->hits,
-                        &packet_ctx->input_msg->hitr,
+    HIP_DEBUG_HIT("hit our", &(ctx->hadb_entry)->hit_our);
+    HIP_DEBUG_HIT("hit peer", &(ctx->hadb_entry)->hit_peer);
+    HIP_IFEL(hip_add_sa(ctx->src_addr,
+                        ctx->dst_addr,
+                        &ctx->input_msg->hits,
+                        &ctx->input_msg->hitr,
                         spi_in,
                         tfm,
-                        &(packet_ctx->hadb_entry)->esp_in,
-                        &(packet_ctx->hadb_entry)->auth_in,
+                        &(ctx->hadb_entry)->esp_in,
+                        &(ctx->hadb_entry)->auth_in,
                         0,
                         HIP_SPI_DIRECTION_IN,
                         0,
-                        packet_ctx->hadb_entry),
+                        ctx->hadb_entry),
             -1,
             "Failed to setup IPsec SPD/SA entries, peer:src\n");
 
-    HIP_IFEL(hip_add_sa(packet_ctx->dst_addr,
-                        packet_ctx->src_addr,
-                        &packet_ctx->input_msg->hitr,
-                        &packet_ctx->input_msg->hits,
+    HIP_IFEL(hip_add_sa(ctx->dst_addr,
+                        ctx->src_addr,
+                        &ctx->input_msg->hitr,
+                        &ctx->input_msg->hits,
                         spi_recvd,
                         tfm,
-                        &packet_ctx->hadb_entry->esp_out,
-                        &packet_ctx->hadb_entry->auth_out,
+                        &ctx->hadb_entry->esp_out,
+                        &ctx->hadb_entry->auth_out,
                         0,
                         HIP_SPI_DIRECTION_OUT,
                         0,
-                        packet_ctx->hadb_entry),
+                        ctx->hadb_entry),
              -1,
              "Failed to setup IPsec SPD/SA entries, peer:dst\n");
 
@@ -1152,40 +1152,40 @@
     /* Source IPv6 address is implicitly the preferred address after the
      * base exchange. */
 
-    idx = hip_devaddr2ifindex(packet_ctx->dst_addr);
+    idx = hip_devaddr2ifindex(ctx->dst_addr);
 
     if (idx != 0) {
         HIP_DEBUG("ifindex = %d\n", idx);
-        // hip_hadb_set_spi_ifindex_deprecated(packet_ctx->hadb_entry, spi_in, 
idx);
+        // hip_hadb_set_spi_ifindex_deprecated(ctx->hadb_entry, spi_in, idx);
     } else {
         HIP_ERROR("Couldn't get device ifindex of address\n");
     }
 
 #ifdef CONFIG_HIP_RVS
-        hip_relay_handle_relay_to_in_client(packet_type, ha_state, packet_ctx);
+        hip_relay_handle_relay_to_in_client(packet_type, ha_state, ctx);
 #endif /* CONFIG_HIP_RVS */
 
     /* Copying address list from temp location in entry
      * "entry->peer_addr_list_to_be_added" */
-    hip_copy_peer_addrlist_changed(packet_ctx->hadb_entry);
+    hip_copy_peer_addrlist_changed(ctx->hadb_entry);
 
     /* Handle REG_RESPONSE and REG_FAILED parameters. */
-    hip_handle_param_reg_response(packet_ctx->hadb_entry, 
packet_ctx->input_msg);
-    hip_handle_param_reg_failed(packet_ctx->hadb_entry, packet_ctx->input_msg);
+    hip_handle_param_reg_response(ctx->hadb_entry, ctx->input_msg);
+    hip_handle_param_reg_failed(ctx->hadb_entry, ctx->input_msg);
 
-    hip_handle_reg_from(packet_ctx->hadb_entry, packet_ctx->input_msg);
+    hip_handle_reg_from(ctx->hadb_entry, ctx->input_msg);
 
     /* These will change SAs' state from ACQUIRE to VALID, and wake up any
      * transport sockets waiting for a SA. */
     // hip_finalize_sa(&entry->hit_peer, spi_recvd);
     // hip_finalize_sa(&entry->hit_our, spi_in);
 
-    packet_ctx->hadb_entry->state = HIP_STATE_ESTABLISHED;
-    hip_hadb_insert_state(packet_ctx->hadb_entry);
+    ctx->hadb_entry->state = HIP_STATE_ESTABLISHED;
+    hip_hadb_insert_state(ctx->hadb_entry);
 
 #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));
+    hip_oppipdb_delentry(&(ctx->hadb_entry->peer_addr));
 #endif
     HIP_INFO("Reached ESTABLISHED state\n");
     HIP_INFO("Handshake completed\n");
@@ -1195,23 +1195,23 @@
     hip_perf_stop_benchmark(perf_set, PERF_BASE);
     hip_perf_write_benchmark(perf_set, PERF_BASE);
 #endif
-    if (packet_ctx->hadb_entry->hip_msg_retrans.buf) {
-        packet_ctx->hadb_entry->hip_msg_retrans.count = 0;
-        memset(packet_ctx->hadb_entry->hip_msg_retrans.buf,
+    if (ctx->hadb_entry->hip_msg_retrans.buf) {
+        ctx->hadb_entry->hip_msg_retrans.count = 0;
+        memset(ctx->hadb_entry->hip_msg_retrans.buf,
                0,
                HIP_MAX_NETWORK_PACKET);
     }
 
 out_err:
-    if (packet_ctx->hadb_entry->state == HIP_STATE_ESTABLISHED) {
+    if (ctx->hadb_entry->state == HIP_STATE_ESTABLISHED) {
         HIP_DEBUG("Send response to firewall.\n");
         hip_firewall_set_bex_data(HIP_MSG_FW_BEX_DONE,
-                                  packet_ctx->hadb_entry,
-                                  &(packet_ctx->hadb_entry)->hit_our,
-                                  &(packet_ctx->hadb_entry)->hit_peer);
+                                  ctx->hadb_entry,
+                                  &(ctx->hadb_entry)->hit_our,
+                                  &(ctx->hadb_entry)->hit_peer);
     } else {
         hip_firewall_set_bex_data(HIP_MSG_FW_BEX_DONE,
-                                  packet_ctx->hadb_entry,
+                                  ctx->hadb_entry,
                                   NULL,
                                   NULL);
     }
@@ -1226,7 +1226,7 @@
 
 int hip_check_i1(const uint8_t packet_type,
                  const uint32_t ha_state,
-                 struct hip_packet_context *packet_ctx)
+                 struct hip_packet_context *ctx)
 {
     int err = 0, mask = 0;
 #ifdef CONFIG_HIP_PERFORMANCE
@@ -1235,16 +1235,16 @@
     HIP_DEBUG("Start PERF_I1\n");
     hip_perf_start_benchmark(perf_set, PERF_I1);
 #endif
-    HIP_INFO_HIT("I1 Source HIT:", &(packet_ctx->input_msg)->hits);
-    HIP_INFO_IN6ADDR("I1 Source IP :", packet_ctx->src_addr);
-
-    HIP_ASSERT(!ipv6_addr_any(&(packet_ctx->input_msg)->hitr));
-
-    HIP_IFF(!hip_controls_sane(ntohs(packet_ctx->input_msg->control), mask),
+    HIP_INFO_HIT("I1 Source HIT:", &(ctx->input_msg)->hits);
+    HIP_INFO_IN6ADDR("I1 Source IP :", ctx->src_addr);
+
+    HIP_ASSERT(!ipv6_addr_any(&(ctx->input_msg)->hitr));
+
+    HIP_IFF(!hip_controls_sane(ntohs(ctx->input_msg->control), mask),
             -1,
-            packet_ctx->error = 1,
+            ctx->error = 1,
             "Received illegal controls in I1: 0x%x. Dropping\n",
-            ntohs(packet_ctx->input_msg->control));
+            ntohs(ctx->input_msg->control));
 
 out_err:
     return err;
@@ -1274,7 +1274,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -1290,7 +1290,7 @@
  */
 int hip_handle_i1(const uint8_t packet_type,
                   const uint32_t ha_state,
-                  struct hip_packet_context *packet_ctx)
+                  struct hip_packet_context *ctx)
 {
     int err = 0, src_hit_is_our;
 
@@ -1298,40 +1298,40 @@
      * arrive at the local host too. The following variable handles
      * that special case. Since we are using source HIT (and not
      * destination) it should handle also opportunistic I1 broadcast */
-    src_hit_is_our = hip_hidb_hit_is_our(&(packet_ctx->input_msg)->hits);
+    src_hit_is_our = hip_hidb_hit_is_our(&(ctx->input_msg)->hits);
 
     /* check i1 for broadcast/multicast addresses */
-    if (IN6_IS_ADDR_V4MAPPED(packet_ctx->dst_addr)) {
+    if (IN6_IS_ADDR_V4MAPPED(ctx->dst_addr)) {
         struct in_addr addr4;
 
-        IPV6_TO_IPV4_MAP(packet_ctx->dst_addr, &addr4);
+        IPV6_TO_IPV4_MAP(ctx->dst_addr, &addr4);
 
         if (addr4.s_addr == INADDR_BROADCAST) {
             HIP_DEBUG("Received I1 broadcast\n");
             HIP_IFF(src_hit_is_our,
                     -1,
-                    packet_ctx->error = 1,
+                    ctx->error = 1,
                     "Received a copy of own broadcast, dropping\n");
 
-            HIP_IFF(hip_select_source_address(packet_ctx->dst_addr, 
packet_ctx->src_addr),
+            HIP_IFF(hip_select_source_address(ctx->dst_addr, ctx->src_addr),
                     -1,
-                    packet_ctx->error = 1,
+                    ctx->error = 1,
                     "Could not find source address\n");
         }
-    } else if (IN6_IS_ADDR_MULTICAST(packet_ctx->dst_addr)) {
+    } else if (IN6_IS_ADDR_MULTICAST(ctx->dst_addr)) {
         HIP_IFF(src_hit_is_our,
                 -1,
-                packet_ctx->error = 1,
+                ctx->error = 1,
                 "Received a copy of own broadcast, dropping\n");
-        HIP_IFF(hip_select_source_address(packet_ctx->dst_addr, 
packet_ctx->src_addr),
+        HIP_IFF(hip_select_source_address(ctx->dst_addr, ctx->src_addr),
                 -1,
-                packet_ctx->error = 1,
+                ctx->error = 1,
                 "Could not find source address\n");
     }
 
 out_err:
     if (err) {
-        packet_ctx->error = err;
+        ctx->error = err;
     }
     return err;
 }
@@ -1620,7 +1620,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -1844,7 +1844,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host

=== modified file 'hipd/input.h'
--- hipd/input.h        2010-03-31 14:33:52 +0000
+++ hipd/input.h        2010-03-31 15:04:18 +0000
@@ -73,13 +73,13 @@
 int hip_verify_packet_rvs_hmac(struct hip_common *msg,
                                struct hip_crypto_key *crypto_key);
 
-int hip_receive_control_packet(struct hip_packet_context *packet_ctx);
+int hip_receive_control_packet(struct hip_packet_context *ctx);
 
-int hip_receive_udp_control_packet(struct hip_packet_context *packet_ctx);
+int hip_receive_udp_control_packet(struct hip_packet_context *ctx);
 
 int hip_check_i1(const uint8_t packet_type,
                  const uint32_t ha_state,
-                 struct hip_packet_context *packet_ctx);
+                 struct hip_packet_context *ctx);
 
 int hip_check_i2(const uint8_t packet_type,
                  const uint32_t ha_state,
@@ -107,9 +107,9 @@
 
 int hip_handle_r2(const uint8_t packet_type,
                   const uint32_t ha_state,
-                  struct hip_packet_context *packet_ctx);
+                  struct hip_packet_context *ctx);
 
-int hip_produce_keying_material(struct hip_packet_context *packet_ctx,
+int hip_produce_keying_material(struct hip_packet_context *ctx,
                                 uint64_t I,
                                 uint64_t J,
                                 struct hip_dh_public_value **dhpv);

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-03-27 14:09:51 +0000
+++ hipd/output.c       2010-03-31 15:04:18 +0000
@@ -398,7 +398,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -408,7 +408,7 @@
  */
 int hip_send_i2(const uint8_t packet_type,
                 const uint32_t ha_state,
-                struct hip_packet_context *packet_ctx)
+                struct hip_packet_context *ctx)
 {
     hip_transform_suite_t transform_hip_suite, transform_esp_suite;
     struct hip_spi_in_item spi_in_data;
@@ -421,7 +421,7 @@
     int err = 0, host_id_in_enc_len = 0;
     uint32_t spi_in = 0;
 
-    HIP_IFEL(packet_ctx->error,
+    HIP_IFEL(ctx->error,
              -1,
              "Abort packet processing.\n");
 
@@ -430,34 +430,34 @@
      * of the REG_INFO parameter. */
 
     HIP_DEBUG("R1 source port %u, destination port %d\n",
-              packet_ctx->msg_ports->src_port,
-              packet_ctx->msg_ports->dst_port);
-
-    HIP_ASSERT(packet_ctx->hadb_entry);
-
-    spi_in = packet_ctx->hadb_entry->spi_inbound_current;
+              ctx->msg_ports->src_port,
+              ctx->msg_ports->dst_port);
+
+    HIP_ASSERT(ctx->hadb_entry);
+
+    spi_in = ctx->hadb_entry->spi_inbound_current;
 
     /* TLV sanity checks are are already done by the caller of this
      * function. Now, begin to build I2 piece by piece. */
 
     /* Delete old SPDs and SAs, if present */
-    hip_delete_security_associations_and_sp(packet_ctx->hadb_entry);
+    hip_delete_security_associations_and_sp(ctx->hadb_entry);
 
     /********** R1 COUNTER (OPTIONAL) ********/
     /* we build this, if we have recorded some value (from previous R1s) */
     {
         uint64_t rtmp;
 
-        HIP_LOCK_HA(packet_ctx->hadb_entry);
-        rtmp = packet_ctx->hadb_entry->birthday;
-        HIP_UNLOCK_HA(packet_ctx->hadb_entry);
+        HIP_LOCK_HA(ctx->hadb_entry);
+        rtmp = ctx->hadb_entry->birthday;
+        HIP_UNLOCK_HA(ctx->hadb_entry);
 
-        HIP_IFEL(rtmp && hip_build_param_r1_counter(packet_ctx->output_msg, 
rtmp), -1,
+        HIP_IFEL(rtmp && hip_build_param_r1_counter(ctx->output_msg, rtmp), -1,
                  "Could not build R1 GENERATION parameter\n");
     }
 
     /********** HIP transform. **********/
-    HIP_IFE(!(param = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_HIP_TRANSFORM)),
+    HIP_IFE(!(param = hip_get_param(ctx->input_msg, HIP_PARAM_HIP_TRANSFORM)),
             -ENOENT);
     HIP_IFEL((transform_hip_suite =
                   hip_select_hip_transform((struct hip_hip_transform *) 
param)) == 0,
@@ -465,7 +465,7 @@
              "Could not find acceptable hip transform suite\n");
 
     /* Select only one transform */
-    HIP_IFEL(hip_build_param_hip_transform(packet_ctx->output_msg,
+    HIP_IFEL(hip_build_param_hip_transform(ctx->output_msg,
                                            &transform_hip_suite,
                                            1),
              -1,
@@ -477,11 +477,11 @@
     if (hip_encrypt_i2_hi) {
         switch (transform_hip_suite) {
         case HIP_HIP_AES_SHA1:
-            HIP_IFEL(hip_build_param_encrypted_aes_sha1(packet_ctx->output_msg,
-                                                        (struct hip_tlv_common 
*) packet_ctx->hadb_entry->our_pub),
+            HIP_IFEL(hip_build_param_encrypted_aes_sha1(ctx->output_msg,
+                                                        (struct hip_tlv_common 
*) ctx->hadb_entry->our_pub),
                      -1,
                      "Building of param encrypted failed.\n");
-            enc_in_msg     = hip_get_param(packet_ctx->output_msg,
+            enc_in_msg     = hip_get_param(ctx->output_msg,
                                            HIP_PARAM_ENCRYPTED);
             HIP_ASSERT(enc_in_msg);             /* Builder internal error. */
             iv             = ((struct hip_encrypted_aes_sha1 *) 
enc_in_msg)->iv;
@@ -489,11 +489,11 @@
             host_id_in_enc = enc_in_msg + sizeof(struct 
hip_encrypted_aes_sha1);
             break;
         case HIP_HIP_3DES_SHA1:
-            
HIP_IFEL(hip_build_param_encrypted_3des_sha1(packet_ctx->output_msg,
-                                                         (struct 
hip_tlv_common *) packet_ctx->hadb_entry->our_pub),
+            HIP_IFEL(hip_build_param_encrypted_3des_sha1(ctx->output_msg,
+                                                         (struct 
hip_tlv_common *) ctx->hadb_entry->our_pub),
                      -1,
                      "Building of param encrypted failed.\n");
-            enc_in_msg     = hip_get_param(packet_ctx->output_msg,
+            enc_in_msg     = hip_get_param(ctx->output_msg,
                                            HIP_PARAM_ENCRYPTED);
             HIP_ASSERT(enc_in_msg);             /* Builder internal error. */
             iv             = ((struct hip_encrypted_3des_sha1 *) 
enc_in_msg)->iv;
@@ -502,11 +502,11 @@
                              sizeof(struct hip_encrypted_3des_sha1);
             break;
         case HIP_HIP_NULL_SHA1:
-            
HIP_IFEL(hip_build_param_encrypted_null_sha1(packet_ctx->output_msg,
-                                                         (struct 
hip_tlv_common *) packet_ctx->hadb_entry->our_pub),
+            HIP_IFEL(hip_build_param_encrypted_null_sha1(ctx->output_msg,
+                                                         (struct 
hip_tlv_common *) ctx->hadb_entry->our_pub),
                      -1,
                      "Building of param encrypted failed.\n");
-            enc_in_msg     = hip_get_param(packet_ctx->output_msg,
+            enc_in_msg     = hip_get_param(ctx->output_msg,
                                            HIP_PARAM_ENCRYPTED);
             HIP_ASSERT(enc_in_msg);             /* Builder internal error. */
             iv             = NULL;
@@ -522,7 +522,7 @@
                 * the argument pointer, so we have to allocate some extra 
memory */
 
         HIP_IFEL(!(host_id_entry = 
hip_get_hostid_entry_by_lhi_and_algo(HIP_DB_LOCAL_HID,
-                                                                        
&packet_ctx->input_msg->hitr,
+                                                                        
&ctx->input_msg->hitr,
                                                                         
HIP_ANY_ALGO,
                                                                         -1)),
                    -1,
@@ -531,19 +531,19 @@
         _HIP_DEBUG("This HOST ID belongs to: %s\n",
                    hip_get_param_host_id_hostname(host_id_entry->host_id));
 
-        HIP_IFEL(hip_build_param(packet_ctx->output_msg, 
host_id_entry->host_id),
+        HIP_IFEL(hip_build_param(ctx->output_msg, host_id_entry->host_id),
                  -1,
                  "Building of host id failed\n");
     }
 
     /* REG_INFO parameter. This builds a REG_REQUEST parameter in the I2
      * packet. */
-    hip_handle_param_reg_info(packet_ctx->hadb_entry,
-                              packet_ctx->input_msg,
-                              packet_ctx->output_msg);
+    hip_handle_param_reg_info(ctx->hadb_entry,
+                              ctx->input_msg,
+                              ctx->output_msg);
 
     /********** ESP-ENC transform. **********/
-    HIP_IFE(!(param = hip_get_param(packet_ctx->input_msg,
+    HIP_IFE(!(param = hip_get_param(ctx->input_msg,
                                     HIP_PARAM_ESP_TRANSFORM)),
             -ENOENT);
 
@@ -551,14 +551,14 @@
     HIP_IFEL((transform_esp_suite =
                   hip_select_esp_transform((struct hip_esp_transform *) 
param)) == 0,
              -1, "Could not find acceptable hip transform suite\n");
-    HIP_IFEL(hip_build_param_esp_transform(packet_ctx->output_msg,
+    HIP_IFEL(hip_build_param_esp_transform(ctx->output_msg,
                                            &transform_esp_suite, 1), -1,
              "Building of ESP transform failed\n");
 
     /********** ESP-PROT anchor [OPTIONAL] **********/
 
     /** @todo Modularize esp_prot_* */
-    HIP_IFEL(esp_prot_i2_add_anchor(packet_ctx), -1,
+    HIP_IFEL(esp_prot_i2_add_anchor(ctx), -1,
              "failed to add esp protection anchor\n");
 
     /************************************************/
@@ -586,7 +586,7 @@
                      hip_get_param_total_len(host_id_in_enc));
         _HIP_HEXDUMP("encinmsg", enc_in_msg,
                      hip_get_param_total_len(enc_in_msg));
-        HIP_HEXDUMP("enc key", &packet_ctx->hadb_entry->hip_enc_out.key, 
HIP_MAX_KEY_LEN);
+        HIP_HEXDUMP("enc key", &ctx->hadb_entry->hip_enc_out.key, 
HIP_MAX_KEY_LEN);
         _HIP_HEXDUMP("IV", iv, 16);         // or 8
         HIP_DEBUG("host id type: %d\n",
                   hip_get_host_id_algo((struct hip_host_id *) host_id_in_enc));
@@ -596,7 +596,7 @@
         HIP_IFEL(hip_crypto_encrypted(host_id_in_enc, iv,
                                       transform_hip_suite,
                                       host_id_in_enc_len,
-                                      &packet_ctx->hadb_entry->hip_enc_out.key,
+                                      &ctx->hadb_entry->hip_enc_out.key,
                                       HIP_DIRECTION_ENCRYPT), -1,
                  "Building of param encrypted failed\n");
 
@@ -609,27 +609,27 @@
      * try to set up inbound IPsec SA, similarly as in hip_send_r2 */
 
     HIP_DEBUG("src %d, dst %d\n",
-              packet_ctx->msg_ports->src_port,
-              packet_ctx->msg_ports->dst_port);
-
-    packet_ctx->hadb_entry->local_udp_port = packet_ctx->msg_ports->src_port;
-    packet_ctx->hadb_entry->peer_udp_port  = packet_ctx->msg_ports->dst_port;
-
-    packet_ctx->hadb_entry->hip_transform  = transform_hip_suite;
+              ctx->msg_ports->src_port,
+              ctx->msg_ports->dst_port);
+
+    ctx->hadb_entry->local_udp_port = ctx->msg_ports->src_port;
+    ctx->hadb_entry->peer_udp_port  = ctx->msg_ports->dst_port;
+
+    ctx->hadb_entry->hip_transform  = transform_hip_suite;
 
     /* XXX: -EAGAIN */
     HIP_DEBUG("set up inbound IPsec SA, SPI=0x%x (host)\n", spi_in);
 
-    HIP_IFEL(hip_setup_hit_sp_pair(&packet_ctx->input_msg->hits,
-                                   &packet_ctx->input_msg->hitr,
-                                   packet_ctx->src_addr, packet_ctx->dst_addr,
+    HIP_IFEL(hip_setup_hit_sp_pair(&ctx->input_msg->hits,
+                                   &ctx->input_msg->hitr,
+                                   ctx->src_addr, ctx->dst_addr,
                                    IPPROTO_ESP,
                                    1,
                                    1),
              -1,
              "Setting up SP pair failed\n");
 
-    esp_info = hip_get_param(packet_ctx->output_msg, HIP_PARAM_ESP_INFO);
+    esp_info = hip_get_param(ctx->output_msg, HIP_PARAM_ESP_INFO);
     HIP_ASSERT(esp_info);     /* Builder internal error */
     esp_info->new_spi = htonl(spi_in);
     /* LSI not created, as it is local, and we do not support IPv4 */
@@ -639,17 +639,17 @@
     {
         struct hip_echo_request *ping;
 
-        ping = hip_get_param(packet_ctx->input_msg, 
HIP_PARAM_ECHO_REQUEST_SIGN);
+        ping = hip_get_param(ctx->input_msg, HIP_PARAM_ECHO_REQUEST_SIGN);
         if (ping) {
             int ln = hip_get_param_contents_len(ping);
-            HIP_IFEL(hip_build_param_echo(packet_ctx->output_msg, ping + 1, 
ln, 1, 0), -1,
+            HIP_IFEL(hip_build_param_echo(ctx->output_msg, ping + 1, ln, 1, 
0), -1,
                      "Error while creating echo reply parameter\n");
         }
     }
 
     /************* HMAC ************/
-    HIP_IFEL(hip_build_param_hmac_contents(packet_ctx->output_msg,
-                                           
&packet_ctx->hadb_entry->hip_hmac_out),
+    HIP_IFEL(hip_build_param_hmac_contents(ctx->output_msg,
+                                           &ctx->hadb_entry->hip_hmac_out),
              -1,
              "Building of HMAC failed\n");
 
@@ -660,8 +660,8 @@
     HIP_DEBUG("Start PERF_SIGN\n");
     hip_perf_start_benchmark(perf_set, PERF_SIGN);
 #endif
-    HIP_IFEL(packet_ctx->hadb_entry->sign(packet_ctx->hadb_entry->our_priv_key,
-                                          packet_ctx->output_msg),
+    HIP_IFEL(ctx->hadb_entry->sign(ctx->hadb_entry->our_priv_key,
+                                          ctx->output_msg),
              -EINVAL,
              "Could not create signature\n");
 #ifdef CONFIG_HIP_PERFORMANCE
@@ -674,10 +674,10 @@
     {
         struct hip_echo_request *ping;
 
-        ping = hip_get_param(packet_ctx->input_msg, HIP_PARAM_ECHO_REQUEST);
+        ping = hip_get_param(ctx->input_msg, HIP_PARAM_ECHO_REQUEST);
         if (ping) {
             int ln = hip_get_param_contents_len(ping);
-            HIP_IFEL(hip_build_param_echo(packet_ctx->output_msg, (ping + 1), 
ln, 0, 0), -1,
+            HIP_IFEL(hip_build_param_echo(ctx->output_msg, (ping + 1), ln, 0, 
0), -1,
                      "Error while creating echo reply parameter\n");
         }
     }
@@ -685,38 +685,38 @@
     /********** I2 packet complete **********/
     memset(&spi_in_data, 0, sizeof(struct hip_spi_in_item));
     spi_in_data.spi     = spi_in;
-    spi_in_data.ifindex = hip_devaddr2ifindex(packet_ctx->dst_addr);
-    HIP_LOCK_HA(packet_ctx->hadb_entry);
+    spi_in_data.ifindex = hip_devaddr2ifindex(ctx->dst_addr);
+    HIP_LOCK_HA(ctx->hadb_entry);
 
-    /* 99999 HIP_IFEB(hip_hadb_add_spi_old(packet_ctx->hadb_entry,
+    /* 99999 HIP_IFEB(hip_hadb_add_spi_old(ctx->hadb_entry,
                                            HIP_SPI_DIRECTION_IN, &spi_in_data),
                       -1,
-                      HIP_UNLOCK_HA(packet_ctx->hadb_entry));
+                      HIP_UNLOCK_HA(ctx->hadb_entry));
     */
 
-    packet_ctx->hadb_entry->esp_transform = transform_esp_suite;
+    ctx->hadb_entry->esp_transform = transform_esp_suite;
     HIP_DEBUG("Saving base exchange encryption data to hadb_entry \n");
-    HIP_DEBUG_HIT("Our HIT: ", &packet_ctx->hadb_entry->hit_our);
-    HIP_DEBUG_HIT("Peer HIT: ", &packet_ctx->hadb_entry->hit_peer);
+    HIP_DEBUG_HIT("Our HIT: ", &ctx->hadb_entry->hit_our);
+    HIP_DEBUG_HIT("Peer HIT: ", &ctx->hadb_entry->hit_peer);
 
     /** @todo Also store the keys that will be given to ESP later */
-    HIP_IFE(hip_hadb_get_peer_addr(packet_ctx->hadb_entry, &daddr), -1);
+    HIP_IFE(hip_hadb_get_peer_addr(ctx->hadb_entry, &daddr), -1);
 
     /* R1 packet source port becomes the I2 packet destination port. */
-    err = hip_send_pkt(packet_ctx->dst_addr, &daddr,
-                       (packet_ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
-                       packet_ctx->msg_ports->src_port, 
packet_ctx->output_msg, packet_ctx->hadb_entry, 1);
+    err = hip_send_pkt(ctx->dst_addr, &daddr,
+                       (ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
+                       ctx->msg_ports->src_port, ctx->output_msg, 
ctx->hadb_entry, 1);
     HIP_IFEL(err < 0, -ECOMM, "Sending I2 packet failed.\n");
 
     HIP_IFEL(err < 0, -1, "Creation of I2 failed\n");
 
-    if (packet_ctx->hadb_entry->state == HIP_STATE_I1_SENT) {
-        packet_ctx->hadb_entry->state = HIP_STATE_I2_SENT;
+    if (ctx->hadb_entry->state == HIP_STATE_I1_SENT) {
+        ctx->hadb_entry->state = HIP_STATE_I2_SENT;
     }
 
 out_err:
-    if (packet_ctx->output_msg) {
-        HIP_FREE(packet_ctx->output_msg);
+    if (ctx->output_msg) {
+        HIP_FREE(ctx->output_msg);
     }
 
     return err;
@@ -940,7 +940,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -1098,7 +1098,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host
@@ -1108,34 +1108,34 @@
  */
 int hip_send_r2(const uint8_t packet_type,
                 const uint32_t ha_state,
-                struct hip_packet_context *packet_ctx)
+                struct hip_packet_context *ctx)
 {
     struct hip_crypto_key hmac;
     int err          = 0;
     uint16_t mask    = 0;
 
-    HIP_IFEL(packet_ctx->error,
+    HIP_IFEL(ctx->error,
              -1,
              "Abort packet processing and don't send R1 packet.\n")
 
     /* Build and send R2: IP ( HIP ( SPI, HMAC, HIP_SIGNATURE ) ) */
-    HIP_IFEL(!(packet_ctx->output_msg = hip_msg_alloc()), -ENOMEM, "No memory 
for R2\n");
+    HIP_IFEL(!(ctx->output_msg = hip_msg_alloc()), -ENOMEM, "No memory for 
R2\n");
 
     /* Just swap the addresses to use the I2's destination HIT as the R2's
      * source HIT. */
-    hip_build_network_hdr(packet_ctx->output_msg,
+    hip_build_network_hdr(ctx->output_msg,
                           HIP_R2,
                           mask,
-                          &packet_ctx->hadb_entry->hit_our,
-                          &packet_ctx->hadb_entry->hit_peer);
+                          &ctx->hadb_entry->hit_our,
+                          &ctx->hadb_entry->hit_peer);
 
-    HIP_DUMP_MSG(packet_ctx->output_msg);
+    HIP_DUMP_MSG(ctx->output_msg);
 
     /* ESP_INFO */
-    HIP_IFEL(hip_build_param_esp_info(packet_ctx->output_msg,
-                                      packet_ctx->hadb_entry->esp_keymat_index,
+    HIP_IFEL(hip_build_param_esp_info(ctx->output_msg,
+                                      ctx->hadb_entry->esp_keymat_index,
                                       0,
-                                      
packet_ctx->hadb_entry->spi_inbound_current),
+                                      ctx->hadb_entry->spi_inbound_current),
              -1,
              "building of ESP_INFO failed.\n");
 
@@ -1144,25 +1144,25 @@
     /** @todo no caching is done for PUZZLE_M parameters. This may be
      *        a DOS attack vector.
      */
-    HIP_IFEL(hip_solve_puzzle_m(packet_ctx->output_msg,
-                                packet_ctx->input_msg,
-                                packet_ctx->hadb_entry),
+    HIP_IFEL(hip_solve_puzzle_m(ctx->output_msg,
+                                ctx->input_msg,
+                                ctx->hadb_entry),
              -1,
              "Building of Challenge_Response failed\n");
     char *midauth_cert = hip_pisa_get_certificate();
 
-    HIP_IFEL(hip_build_param(packet_ctx->output_msg, 
packet_ctx->hadb_entry->our_pub), -1,
+    HIP_IFEL(hip_build_param(ctx->output_msg, ctx->hadb_entry->our_pub), -1,
              "Building of host id failed\n");
 
     /* For now we just add some random data to see if it works */
-    HIP_IFEL(hip_build_param_cert(packet_ctx->output_msg, 1, 1, 1, 1, 
midauth_cert, strlen(midauth_cert)),
+    HIP_IFEL(hip_build_param_cert(ctx->output_msg, 1, 1, 1, 1, midauth_cert, 
strlen(midauth_cert)),
             -1,
             "Building of cert failed\n");
 
 #endif
 
     /********** ESP-PROT anchor [OPTIONAL] **********/
-    HIP_IFEL(esp_prot_r2_add_anchor(packet_ctx->output_msg, 
packet_ctx->hadb_entry), -1,
+    HIP_IFEL(esp_prot_r2_add_anchor(ctx->output_msg, ctx->hadb_entry), -1,
              "failed to add esp protection anchor\n");
     /************************************************/
 
@@ -1173,30 +1173,30 @@
      */
 
     /* Handle REG_REQUEST parameter. */
-    hip_handle_param_reg_request(packet_ctx->hadb_entry, 
packet_ctx->input_msg, packet_ctx->output_msg);
+    hip_handle_param_reg_request(ctx->hadb_entry, ctx->input_msg, 
ctx->output_msg);
 
 #endif
 
 #if defined(CONFIG_HIP_RVS)
     if (hip_relay_get_status() != HIP_RELAY_OFF) {
-        hip_build_param_reg_from(packet_ctx->output_msg, packet_ctx->src_addr, 
packet_ctx->msg_ports->src_port);
+        hip_build_param_reg_from(ctx->output_msg, ctx->src_addr, 
ctx->msg_ports->src_port);
     }
 
 #endif
 
 
     /* Create HMAC2 parameter. */
-    if (packet_ctx->hadb_entry->our_pub == NULL) {
-        HIP_DEBUG("packet_ctx->hadb_entry->our_pub is NULL.\n");
+    if (ctx->hadb_entry->our_pub == NULL) {
+        HIP_DEBUG("ctx->hadb_entry->our_pub is NULL.\n");
     } else {
-        _HIP_HEXDUMP("Host ID for HMAC2", packet_ctx->hadb_entry->our_pub,
-                     hip_get_param_total_len(packet_ctx->hadb_entry->our_pub));
+        _HIP_HEXDUMP("Host ID for HMAC2", ctx->hadb_entry->our_pub,
+                     hip_get_param_total_len(ctx->hadb_entry->our_pub));
     }
 
-    memcpy(&hmac, &packet_ctx->hadb_entry->hip_hmac_out, sizeof(hmac));
-    HIP_IFEL(hip_build_param_hmac2_contents(packet_ctx->output_msg,
+    memcpy(&hmac, &ctx->hadb_entry->hip_hmac_out, sizeof(hmac));
+    HIP_IFEL(hip_build_param_hmac2_contents(ctx->output_msg,
                                             &hmac,
-                                            packet_ctx->hadb_entry->our_pub),
+                                            ctx->hadb_entry->our_pub),
              -1,
              "Failed to build parameter HMAC2 contents.\n");
 
@@ -1205,42 +1205,42 @@
         err = 0;
     }
 
-    HIP_IFEL(packet_ctx->hadb_entry->sign(packet_ctx->hadb_entry->our_priv_key,
-                                          packet_ctx->output_msg),
+    HIP_IFEL(ctx->hadb_entry->sign(ctx->hadb_entry->our_priv_key,
+                                          ctx->output_msg),
              -EINVAL,
              "Could not sign R2. Failing\n");
 
-    err = hip_add_sa(packet_ctx->dst_addr,
-                     packet_ctx->src_addr,
-                     &packet_ctx->input_msg->hitr,
-                     &packet_ctx->input_msg->hits,
-                     packet_ctx->hadb_entry->spi_outbound_current,
-                     packet_ctx->hadb_entry->esp_transform,
-                     &packet_ctx->hadb_entry->esp_out,
-                     &packet_ctx->hadb_entry->auth_out,
+    err = hip_add_sa(ctx->dst_addr,
+                     ctx->src_addr,
+                     &ctx->input_msg->hitr,
+                     &ctx->input_msg->hits,
+                     ctx->hadb_entry->spi_outbound_current,
+                     ctx->hadb_entry->esp_transform,
+                     &ctx->hadb_entry->esp_out,
+                     &ctx->hadb_entry->auth_out,
                      1,
                      HIP_SPI_DIRECTION_OUT,
                      0,
-                     packet_ctx->hadb_entry);
+                     ctx->hadb_entry);
     if (err) {
         HIP_ERROR("Failed to setup outbound SA with SPI = %d.\n",
-                  packet_ctx->hadb_entry->spi_outbound_current);
+                  ctx->hadb_entry->spi_outbound_current);
 
-        /* delete all IPsec related SPD/SA for this packet_ctx->hadb_entry*/
-        hip_delete_security_associations_and_sp(packet_ctx->hadb_entry);
+        /* delete all IPsec related SPD/SA for this ctx->hadb_entry*/
+        hip_delete_security_associations_and_sp(ctx->hadb_entry);
         goto out_err;
     }
 
     /* @todo Check if err = -EAGAIN... */
     HIP_DEBUG("Set up outbound IPsec SA, SPI=0x%x\n",
-              packet_ctx->hadb_entry->spi_outbound_new);
+              ctx->hadb_entry->spi_outbound_new);
 
-    err = hip_send_pkt(packet_ctx->dst_addr,
-                       packet_ctx->src_addr,
-                       (packet_ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
-                       packet_ctx->hadb_entry->peer_udp_port,
-                       packet_ctx->output_msg,
-                       packet_ctx->hadb_entry,
+    err = hip_send_pkt(ctx->dst_addr,
+                       ctx->src_addr,
+                       (ctx->hadb_entry->nat_mode ? 
hip_get_local_nat_udp_port() : 0),
+                       ctx->hadb_entry->peer_udp_port,
+                       ctx->output_msg,
+                       ctx->hadb_entry,
                        1);
 
     if (err == 1) {
@@ -1250,8 +1250,8 @@
     HIP_IFEL(err, -ECOMM, "Sending R2 packet failed.\n");
 
 out_err:
-    if (packet_ctx->output_msg) {
-        free(packet_ctx->output_msg);
+    if (ctx->output_msg) {
+        free(ctx->output_msg);
     }
 #ifdef CONFIG_HIP_PERFORMANCE
     HIP_DEBUG("Stop and write PERF_I2\n");

=== modified file 'hipd/output.h'
--- hipd/output.h       2010-03-11 14:08:33 +0000
+++ hipd/output.h       2010-03-31 15:04:18 +0000
@@ -54,7 +54,7 @@
 
 int hip_send_r2(const uint8_t packet_type,
                 const uint32_t ha_state,
-                struct hip_packet_context *packet_ctx);
+                struct hip_packet_context *ctx);
 
 int hip_send_r2_response(struct hip_common *r2,
                          struct in6_addr *r2_saddr,
@@ -66,7 +66,7 @@
 
 int hip_send_i2(const uint8_t packet_type,
                 const uint32_t ha_state,
-                struct hip_packet_context *packet_ctx);
+                struct hip_packet_context *ctx);
 
 int are_addresses_compatible(const struct in6_addr *src_addr,
                              const struct in6_addr *dst_addr);

=== modified file 'lib/core/message.c'
--- lib/core/message.c  2010-03-17 15:05:58 +0000
+++ lib/core/message.c  2010-03-31 15:04:18 +0000
@@ -551,7 +551,7 @@
  * @return               -1 in case of an error, 0 otherwise.
  */
 static int hip_read_control_msg_all(int socket,
-                                    struct hip_packet_context *packet_ctx,
+                                    struct hip_packet_context *ctx,
                                     int encap_hdr_size,
                                     int is_ipv4)
 {
@@ -569,10 +569,10 @@
     int err = 0, len;
     int cmsg_level, cmsg_type;
 
-    hip_msg_init(packet_ctx->input_msg);
+    hip_msg_init(ctx->input_msg);
 
-    HIP_ASSERT(packet_ctx->src_addr);
-    HIP_ASSERT(packet_ctx->dst_addr);
+    HIP_ASSERT(ctx->src_addr);
+    HIP_ASSERT(ctx->dst_addr);
 
     HIP_DEBUG("hip_read_control_msg_all() invoked.\n");
 
@@ -593,7 +593,7 @@
     msg.msg_flags       = 0;
 
     iov.iov_len         = HIP_MAX_NETWORK_PACKET;
-    iov.iov_base        = packet_ctx->input_msg;
+    iov.iov_base        = ctx->input_msg;
 
     pktinfo.pktinfo_in4 = NULL;
 
@@ -626,44 +626,44 @@
     /* UDP port numbers */
     if (is_ipv4 && encap_hdr_size == HIP_UDP_ZERO_BYTES_LEN) {
         HIP_DEBUG("source port = %d\n", ntohs(addr_from4->sin_port));
-        packet_ctx->msg_ports->src_port = ntohs(addr_from4->sin_port);
+        ctx->msg_ports->src_port = ntohs(addr_from4->sin_port);
         /* Destination port is known from the bound socket. */
-        packet_ctx->msg_ports->dst_port = hip_get_local_nat_udp_port();
+        ctx->msg_ports->dst_port = hip_get_local_nat_udp_port();
     }
 
     /* IPv4 addresses */
     if (is_ipv4) {
         struct sockaddr_in *addr_to4 = (struct sockaddr_in *) &addr_to;
-        IPV4_TO_IPV6_MAP(&addr_from4->sin_addr, packet_ctx->src_addr);
-        IPV4_TO_IPV6_MAP(&pktinfo.pktinfo_in4->ipi_addr, packet_ctx->dst_addr);
+        IPV4_TO_IPV6_MAP(&addr_from4->sin_addr, ctx->src_addr);
+        IPV4_TO_IPV6_MAP(&pktinfo.pktinfo_in4->ipi_addr, ctx->dst_addr);
         addr_to4->sin_family = AF_INET;
         addr_to4->sin_addr   = pktinfo.pktinfo_in4->ipi_addr;
-        addr_to4->sin_port   = packet_ctx->msg_ports->dst_port;
+        addr_to4->sin_port   = ctx->msg_ports->dst_port;
     } else {   /* IPv6 addresses */
         struct sockaddr_in6 *addr_to6 =
             (struct sockaddr_in6 *) &addr_to;
-        memcpy(packet_ctx->src_addr, &addr_from6->sin6_addr,
+        memcpy(ctx->src_addr, &addr_from6->sin6_addr,
                sizeof(struct in6_addr));
-        memcpy(packet_ctx->dst_addr, &pktinfo.pktinfo_in6->ipi6_addr,
+        memcpy(ctx->dst_addr, &pktinfo.pktinfo_in6->ipi6_addr,
                sizeof(struct in6_addr));
         addr_to6->sin6_family = AF_INET6;
-        ipv6_addr_copy(&addr_to6->sin6_addr, packet_ctx->dst_addr);
+        ipv6_addr_copy(&addr_to6->sin6_addr, ctx->dst_addr);
     }
 
     if (is_ipv4 && (encap_hdr_size == IPV4_HDR_SIZE)) {    /* raw IPv4, !UDP */
         /* For some reason, the IPv4 header is always included.
          * Let's remove it here. */
-        memmove(packet_ctx->input_msg,
-                ((char *) packet_ctx->input_msg) + IPV4_HDR_SIZE,
+        memmove(ctx->input_msg,
+                ((char *) ctx->input_msg) + IPV4_HDR_SIZE,
                 HIP_MAX_PACKET - IPV4_HDR_SIZE);
     } else if (is_ipv4 && encap_hdr_size == HIP_UDP_ZERO_BYTES_LEN) {
         /* remove 32-bits of zeroes between UDP and HIP headers */
-        memmove(packet_ctx->input_msg,
-                ((char *) packet_ctx->input_msg) + HIP_UDP_ZERO_BYTES_LEN,
+        memmove(ctx->input_msg,
+                ((char *) ctx->input_msg) + HIP_UDP_ZERO_BYTES_LEN,
                 HIP_MAX_PACKET - HIP_UDP_ZERO_BYTES_LEN);
     }
 
-    HIP_IFEL(hip_verify_network_header(packet_ctx->input_msg,
+    HIP_IFEL(hip_verify_network_header(ctx->input_msg,
                                        (struct sockaddr *) &addr_from,
                                        (struct sockaddr *) &addr_to,
                                        len - encap_hdr_size), -1,
@@ -671,11 +671,11 @@
 
 
 
-    if (packet_ctx->src_addr) {
-        HIP_DEBUG_IN6ADDR("src", packet_ctx->src_addr);
+    if (ctx->src_addr) {
+        HIP_DEBUG_IN6ADDR("src", ctx->src_addr);
     }
-    if (packet_ctx->dst_addr) {
-        HIP_DEBUG_IN6ADDR("dst", packet_ctx->dst_addr);
+    if (ctx->dst_addr) {
+        HIP_DEBUG_IN6ADDR("dst", ctx->dst_addr);
     }
 
 out_err:
@@ -694,12 +694,12 @@
  * @return                .
  */
 int hip_read_control_msg_v6(int socket,
-                            struct hip_packet_context *packet_ctx,
+                            struct hip_packet_context *ctx,
                             int encap_hdr_size)
 {
     HIP_DEBUG("Receiving a message on raw HIP from IPv6/HIP socket "\
               " (file descriptor: %d).\n", socket);
-    return hip_read_control_msg_all(socket, packet_ctx, encap_hdr_size, 0);
+    return hip_read_control_msg_all(socket, ctx, encap_hdr_size, 0);
 }
 
 /**
@@ -714,10 +714,10 @@
  * @return                .
  */
 int hip_read_control_msg_v4(int socket,
-                            struct hip_packet_context *packet_ctx,
+                            struct hip_packet_context *ctx,
                             int encap_hdr_size)
 {
     HIP_DEBUG("Receiving a message on raw HIP from IPv4/HIP socket "\
               " (file descriptor: %d).\n", socket);
-    return hip_read_control_msg_all(socket, packet_ctx, encap_hdr_size, 1);
+    return hip_read_control_msg_all(socket, ctx, encap_hdr_size, 1);
 }

=== modified file 'lib/core/message.h'
--- lib/core/message.h  2010-03-11 08:07:12 +0000
+++ lib/core/message.h  2010-03-31 15:04:18 +0000
@@ -32,10 +32,10 @@
                               struct hip_common *hip_msg,
                               struct sockaddr_in6 *saddr);
 int hip_read_control_msg_v6(int socket,
-                            struct hip_packet_context *packet_ctx,
+                            struct hip_packet_context *ctx,
                             int encap_hdr_size);
 int hip_read_control_msg_v4(int socket,
-                            struct hip_packet_context *packet_ctx,
+                            struct hip_packet_context *ctx,
                             int encap_hdr_size);
 int hip_sendto(int sock,
                const struct hip_common *msg,

=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c        2010-03-31 14:59:32 +0000
+++ modules/update/hipd/update.c        2010-03-31 15:04:18 +0000
@@ -837,7 +837,7 @@
  *
  * @param packet_type The packet type of the control message (RFC 5201, 5.3.)
  * @param ha_state The host association state (RFC 5201, 4.4.1.)
- * @param *packet_ctx Pointer to the packet context, containing all
+ * @param *ctx Pointer to the packet context, containing all
  *                    information for the packet handling
  *                    (received message, source and destination address, the
  *                    ports and the corresponding entry from the host

Other related posts:

  • » [hipl-commit] [tiny] Rev 3754: Use consistently ctx as variable for the hip_packet_context. - Tim Just