[hipl-commit] [tiny] Rev 3640: Prepared packet reading in daemon main loop for modularization.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 9 Mar 2010 16:17:08 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Tue Mar 09 15:14:54 2010 +0100
Revision: 3640
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Prepared packet reading in daemon main loop for modularization.
  
  For reading of control messages the struct hip_packet_context is used.
  This unifies the packet handling.

Modified:
  M  hipd/hipd.c
  M  hipd/hipd.h
  M  hipd/init.c
  M  hipd/modularization.c
  M  hipd/modularization.h
  M  lib/core/message.c
  M  lib/core/message.h
  M  modules/heartbeat/hipd/heartbeat.c

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-03-09 10:57:49 +0000
+++ hipd/hipd.c 2010-03-09 14:14:54 +0000
@@ -21,12 +21,6 @@
 #include "lib/performance/performance.h"
 #endif
 
-
-/* Defined as a global just to allow freeing in exit(). Do not use outside
- * of this file! */
-struct hip_common *hipd_msg          = NULL;
-struct hip_common *hipd_msg_v4       = NULL;
-
 int is_active_mhaddr                 = 1; /**< Which mhaddr to use active or 
lazy? (default: active) */
 int is_hard_handover                 = 0; /**< if hard handover is forced to 
be used (default: no) */
 
@@ -221,6 +215,7 @@
     fd_set read_fdset;
     int foreground = 1, err = 0, fix_alignment = 0;
     struct timeval timeout;
+    struct hip_packet_context packet_ctx = {0};
 
     /* The flushing is enabled by default. The reason for this is that
      * people are doing some very experimental features on some branches
@@ -329,12 +324,16 @@
     /* Default initialization function. */
     HIP_IFEL(hipd_init(flush_ipsec, killold), 1, "hipd_init() failed!\n");
 
-    HIP_IFEL(create_configs_and_exit, 0,
-             "Configs created, exiting\n");
+    HIP_IFEL(create_configs_and_exit, 0, "Configs created, exiting\n");
 
     /* Allocate user message. */
-    HIP_IFE(!(hipd_msg = hip_msg_alloc()), 1);
-    HIP_IFE(!(hipd_msg_v4 = hip_msg_alloc()), 1);
+    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.drop_packet = 0;
     HIP_DEBUG("Daemon running. Entering select loop.\n");
 
     /* Enter to the select-loop */
@@ -354,14 +353,14 @@
 
 #ifdef CONFIG_HIP_FIREWALL
         if (hip_firewall_status < 0) {
-            hip_msg_init(hipd_msg);
-            err = hip_build_user_hdr(hipd_msg, SO_HIP_FIREWALL_STATUS, 0);
+            hip_msg_init(packet_ctx.input_msg);
+            err = hip_build_user_hdr(packet_ctx.input_msg, 
SO_HIP_FIREWALL_STATUS, 0);
             if (err) {
                 HIP_ERROR("hip_build_user_hdr\n");
             } else {
                 hip_firewall_status = 0;
                 HIP_DEBUG("sent %d bytes to firewall\n",
-                          hip_sendto_firewall(hipd_msg));
+                          hip_sendto_firewall(packet_ctx.input_msg));
             }
         }
 #endif
@@ -385,108 +384,64 @@
         }
 #endif
 
-        /* see bugzilla bug id 392 to see why */
-        if (FD_ISSET(hip_raw_sock_input_v6, &read_fdset) &&
-            FD_ISSET(hip_raw_sock_input_v4, &read_fdset)) {
-            int type, err_v6 = 0, err_v4 = 0;
-            struct in6_addr saddr, daddr;
-            struct in6_addr saddr_v4, daddr_v4;
-            hip_portpair_t pkt_info;
-            HIP_DEBUG("Receiving messages on raw HIP from IPv6/HIP and 
IPv4/HIP\n");
-            hip_msg_init(hipd_msg);
-            hip_msg_init(hipd_msg_v4);
-            err_v4 = hip_read_control_msg_v4(hip_raw_sock_input_v4, 
hipd_msg_v4,
-                                             &saddr_v4, &daddr_v4,
-                                             &pkt_info, IPV4_HDR_SIZE);
-            err_v6 = hip_read_control_msg_v6(hip_raw_sock_input_v6, hipd_msg,
-                                             &saddr, &daddr, &pkt_info, 0);
-            if (err_v4 > -1) {
-                type = hip_get_msg_type(hipd_msg_v4);
-                if (type == HIP_R2) {
-                    err = hip_receive_control_packet(hipd_msg_v4, &saddr_v4,
-                                                     &daddr_v4, &pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                    err = hip_receive_control_packet(hipd_msg, &saddr, &daddr,
-                                                     &pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                } else {
-                    err = hip_receive_control_packet(hipd_msg, &saddr, &daddr,
-                                                     &pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                    err = hip_receive_control_packet(hipd_msg_v4, &saddr_v4,
-                                                     &daddr_v4, &pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                }
-            }
-        } else {
-            if (FD_ISSET(hip_raw_sock_input_v6, &read_fdset)) {
 #ifdef CONFIG_HIP_PERFORMANCE
                 HIP_DEBUG("Start PERF_ALL\n");
                 bench_set = 1;         //1 = true; 0 = false
                 hip_perf_start_benchmark(perf_set, PERF_ALL);
 #endif
 
-                /* Receiving of a raw HIP message from IPv6 socket. */
-                struct in6_addr saddr, daddr;
-                hip_portpair_t pkt_info;
-                HIP_DEBUG("Receiving a message on raw HIP from " \
-                          "IPv6/HIP socket (file descriptor: %d).\n",
-                          hip_raw_sock_input_v6);
-                hip_msg_init(hipd_msg);
-                if (hip_read_control_msg_v6(hip_raw_sock_input_v6, hipd_msg,
-                                            &saddr, &daddr, &pkt_info, 0)) {
-                    HIP_ERROR("Reading network msg failed\n");
-                } else {
-                    err = hip_receive_control_packet(hipd_msg, &saddr, &daddr, 
&pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                }
-            }
-
-            if (FD_ISSET(hip_raw_sock_input_v4, &read_fdset)) {
-                HIP_DEBUG("HIP RAW SOCKET\n");
-                /* Receiving of a raw HIP message from IPv4 socket. */
-                struct in6_addr saddr, daddr;
-                hip_portpair_t pkt_info;
-                HIP_DEBUG("Receiving a message on raw HIP from " \
-                          "IPv4/HIP socket (file descriptor: %d).\n",
-                          hip_raw_sock_input_v4);
-                hip_msg_init(hipd_msg);
-                HIP_DEBUG("Getting a msg on v4\n");
-                /* Assuming that IPv4 header does not include any
-                 * options */
-                if (hip_read_control_msg_v4(hip_raw_sock_input_v4, hipd_msg,
-                                            &saddr, &daddr, &pkt_info, 
IPV4_HDR_SIZE)) {
-                    HIP_ERROR("Reading network msg failed\n");
-                } else {
-                    err = hip_receive_control_packet(hipd_msg, &saddr, &daddr, 
&pkt_info);
-                    if (err) {
-                        HIP_ERROR("hip_receive_control_packet()!\n");
-                    }
-                }
-            }
-        }
-
-//        if (FD_ISSET(hip_icmp_sock, &read_fdset)) {
-//            HIP_IFEL(hip_icmp_recvmsg(hip_icmp_sock), -1,
-//                     "Failed to recvmsg from ICMPv6\n");
-//        }
+        if (FD_ISSET(hip_raw_sock_input_v6, &read_fdset)) {
+            /* Receiving of a raw HIP message from IPv6 socket. */
+
+            hip_msg_init(packet_ctx.input_msg);
+
+            HIP_DEBUG("Receiving a message on raw HIP from " \
+                      "IPv6/HIP socket (file descriptor: %d).\n",
+                      hip_raw_sock_input_v6);
+            if (hip_read_control_msg_v6(hip_raw_sock_input_v6,
+                                        &packet_ctx,
+                                        0)) {
+                HIP_ERROR("Reading network msg failed\n");
+            } else {
+                err = hip_receive_control_packet(packet_ctx.input_msg,
+                                                 packet_ctx.src_addr,
+                                                 packet_ctx.dst_addr,
+                                                 packet_ctx.msg_ports);
+                if (err) {
+                    HIP_ERROR("hip_receive_control_packet()!\n");
+                }
+            }
+        }
+
+        if (FD_ISSET(hip_raw_sock_input_v4, &read_fdset)) {
+            HIP_DEBUG("HIP RAW SOCKET\n");
+            /* Receiving of a raw HIP message from IPv4 socket. */
+            HIP_DEBUG("Receiving a message on raw HIP from " \
+                      "IPv4/HIP socket (file descriptor: %d).\n",
+                      hip_raw_sock_input_v4);
+            hip_msg_init(packet_ctx.input_msg);
+            HIP_DEBUG("Getting a msg on v4\n");
+            /* Assuming that IPv4 header does not include any
+             * options */
+            if (hip_read_control_msg_v4(hip_raw_sock_input_v4,
+                                        &packet_ctx,
+                                        IPV4_HDR_SIZE)) {
+                HIP_ERROR("Reading network msg failed\n");
+            } else {
+                err = hip_receive_control_packet(packet_ctx.input_msg,
+                                                 packet_ctx.src_addr,
+                                                 packet_ctx.dst_addr,
+                                                 packet_ctx.msg_ports);
+                if (err) {
+                    HIP_ERROR("hip_receive_control_packet()!\n");
+                }
+            }
+        }
 
         if (FD_ISSET(hip_nat_sock_input_udp, &read_fdset)) {
             /* Data structures for storing the source and
              * destination addresses and ports of the incoming
              * packet. */
-            struct in6_addr saddr, daddr;
-            hip_portpair_t pkt_info;
 
             /* Receiving of a UDP message from NAT socket. */
             HIP_DEBUG("Receiving a message on UDP from NAT " \
@@ -495,26 +450,20 @@
 
             /* Initialization of the hip_common header struct. We'll
              * store the HIP header data here. */
-            hip_msg_init(hipd_msg);
+            hip_msg_init(packet_ctx.input_msg);
 
-            /* Read in the values to hip_msg, saddr, daddr and
-             * pkt_info. */
-            /* if ( hip_read_control_msg_v4(hip_nat_sock_udp, hipd_msg,&saddr, 
&daddr,&pkt_info, 0) ) */
             err = hip_read_control_msg_v4(hip_nat_sock_input_udp,
-                                          hipd_msg,
-                                          &saddr,
-                                          &daddr,
-                                          &pkt_info,
+                                          &packet_ctx,
                                           HIP_UDP_ZERO_BYTES_LEN);
             if (err) {
                 HIP_ERROR("Reading network msg failed\n");
                 /* If the values were read in successfully, we
                  * do the UDP specific stuff next. */
             } else {
-                err =  hip_receive_udp_control_packet(hipd_msg,
-                                                      &saddr,
-                                                      &daddr,
-                                                      &pkt_info);
+                err =  hip_receive_udp_control_packet(packet_ctx.input_msg,
+                                                      packet_ctx.src_addr,
+                                                      packet_ctx.dst_addr,
+                                                      packet_ctx.msg_ports);
             }
         }
 
@@ -524,17 +473,17 @@
 
             HIP_DEBUG("Receiving user message.\n");
 
-            hip_msg_init(hipd_msg);
+            hip_msg_init(packet_ctx.input_msg);
 
-            if (hip_read_user_control_msg(hip_user_sock, hipd_msg, &app_src)) {
+            if (hip_read_user_control_msg(hip_user_sock,
+                                          packet_ctx.input_msg,
+                                          &app_src)) {
                 HIP_ERROR("Reading user msg failed\n");
             } else {
-                err = hip_handle_user_msg(hipd_msg, &app_src);
+                err = hip_handle_user_msg(packet_ctx.input_msg, &app_src);
             }
         }
 
-        /* END DHT SOCKETS HANDLING */
-
         if (FD_ISSET(hip_nl_ipsec.fd, &read_fdset)) {
             /* Something on IF and address event netlink socket,
              * fetch it. */
@@ -568,6 +517,22 @@
     /* 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);
+    }
+
     HIP_INFO("hipd pid=%d exiting, retval=%d\n", getpid(), err);
 
     return err;

=== modified file 'hipd/hipd.h'
--- hipd/hipd.h 2010-03-09 11:07:41 +0000
+++ hipd/hipd.h 2010-03-09 14:14:54 +0000
@@ -114,9 +114,6 @@
 
 extern int hip_buddies_inuse;
 
-extern struct hip_common *hipd_msg;
-extern struct hip_common *hipd_msg_v4;
-
 extern int esp_prot_active;
 extern int esp_prot_num_transforms;
 extern long esp_prot_num_parallel_hchains;

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-03-09 11:07:41 +0000
+++ hipd/init.c 2010-03-09 14:14:54 +0000
@@ -359,12 +359,12 @@
 
 static void hip_init_sockets(void)
 {
-    hip_register_socket(hip_nl_route.fd,        10000);
-    hip_register_socket(hip_raw_sock_input_v6,  10100);
-    hip_register_socket(hip_user_sock,          10200);
-    hip_register_socket(hip_nl_ipsec.fd,        10300);
-    hip_register_socket(hip_raw_sock_input_v4,  10400);
-    hip_register_socket(hip_nat_sock_input_udp, 10500);
+    hip_register_socket(hip_nl_route.fd,        NULL, 10000);
+    hip_register_socket(hip_raw_sock_input_v6,  NULL, 10100);
+    hip_register_socket(hip_user_sock,          NULL, 10200);
+    hip_register_socket(hip_nl_ipsec.fd,        NULL, 10300);
+    hip_register_socket(hip_raw_sock_input_v4,  NULL, 10400);
+    hip_register_socket(hip_nat_sock_input_udp, NULL, 10500);
 }
 
 static int hip_init_handle_functions(void)
@@ -945,12 +945,6 @@
     /*reset TCP timeout to be original vaule , added By Tao Wan on 
14.Jan.2008. */
     reset_default_tcptimeout_parameters_value();
 #endif
-    if (hipd_msg) {
-        HIP_FREE(hipd_msg);
-    }
-    if (hipd_msg_v4) {
-        HIP_FREE(hipd_msg_v4);
-    }
 
     hip_delete_all_sp();    //empty
 

=== modified file 'hipd/modularization.c'
--- hipd/modularization.c       2010-03-09 10:57:49 +0000
+++ hipd/modularization.c       2010-03-09 14:14:54 +0000
@@ -27,6 +27,8 @@
 struct socketfd {
     uint16_t priority;
     int      fd;
+    int    (*func_ptr)(int socketfd,
+                       struct hip_packet_context *ctx);
 };
 
 /**
@@ -268,7 +270,10 @@
  * hip_register_socket
  *
  */
-int hip_register_socket(int socketfd, const uint16_t priority)
+int hip_register_socket(int socketfd,
+                        int (*func_ptr)(int socketfd,
+                                        struct hip_packet_context *ctx),
+                        const uint16_t priority)
 {
     int err = 0;
     struct socketfd *new_socket = NULL;

=== modified file 'hipd/modularization.h'
--- hipd/modularization.h       2010-03-09 10:57:49 +0000
+++ hipd/modularization.h       2010-03-09 14:14:54 +0000
@@ -34,7 +34,10 @@
 
 void hip_uninit_maint_functions(void);
 
-int hip_register_socket(int socketfd, const uint16_t priority);
+int hip_register_socket(int socketfd,
+                        int (*func_ptr)(int socketfd,
+                                        struct hip_packet_context *ctx),
+                        const uint16_t priority);
 
 int hip_get_highest_descriptor(void);
 

=== modified file 'lib/core/message.c'
--- lib/core/message.c  2010-03-05 17:28:01 +0000
+++ lib/core/message.c  2010-03-09 14:14:54 +0000
@@ -68,6 +68,7 @@
 #define _BSD_SOURCE
 
 #include "message.h"
+#include "protodefs.h"
 
 /**
  * Finds out how much data is coming from a socket
@@ -547,11 +548,10 @@
  *                       on IPv4.
  * @return               -1 in case of an error, 0 otherwise.
  */
-int hip_read_control_msg_all(int socket, struct hip_common *hip_msg,
-                             struct in6_addr *saddr,
-                             struct in6_addr *daddr,
-                             hip_portpair_t *msg_info,
-                             int encap_hdr_size, int is_ipv4)
+static int hip_read_control_msg_all(int socket,
+                                    struct hip_packet_context *packet_ctx,
+                                    int encap_hdr_size,
+                                    int is_ipv4)
 {
     struct sockaddr_storage addr_from, addr_to;
     struct sockaddr_in *addr_from4  = ((struct sockaddr_in *) &addr_from);
@@ -567,15 +567,17 @@
     int err = 0, len;
     int cmsg_level, cmsg_type;
 
-    HIP_ASSERT(saddr);
-    HIP_ASSERT(daddr);
+    HIP_ASSERT(packet_ctx->src_addr);
+    HIP_ASSERT(packet_ctx->dst_addr);
 
     HIP_DEBUG("hip_read_control_msg_all() invoked.\n");
 
-    HIP_IFEL(((len = hip_peek_recv_total_len(socket, encap_hdr_size, 
HIP_DEFAULT_MSG_TIMEOUT)) <= 0),
+    HIP_IFEL(((len = hip_peek_recv_total_len(socket,
+                                             encap_hdr_size,
+                                             HIP_DEFAULT_MSG_TIMEOUT)) <= 0),
              -1, "Bad packet length (%d)\n", len);
 
-    memset(msg_info, 0, sizeof(hip_portpair_t));
+//    memset(msg_info, 0, sizeof(hip_portpair_t));
     memset(&msg, 0, sizeof(msg));
     memset(cbuff, 0, sizeof(cbuff));
     memset(&addr_to, 0, sizeof(addr_to));
@@ -592,7 +594,7 @@
     msg.msg_flags       = 0;
 
     iov.iov_len         = len;
-    iov.iov_base        = hip_msg;
+    iov.iov_base        = packet_ctx->input_msg;
 
     pktinfo.pktinfo_in4 = NULL;
 
@@ -625,43 +627,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));
-        msg_info->src_port = ntohs(addr_from4->sin_port);
+        packet_ctx->msg_ports->src_port = ntohs(addr_from4->sin_port);
         /* Destination port is known from the bound socket. */
-        msg_info->dst_port = hip_get_local_nat_udp_port();
+        packet_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, saddr);
-        IPV4_TO_IPV6_MAP(&pktinfo.pktinfo_in4->ipi_addr,
-                         daddr);
+        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);
         addr_to4->sin_family = AF_INET;
         addr_to4->sin_addr   = pktinfo.pktinfo_in4->ipi_addr;
-        addr_to4->sin_port   = msg_info->dst_port;
+        addr_to4->sin_port   = packet_ctx->msg_ports->dst_port;
     } else {   /* IPv6 addresses */
         struct sockaddr_in6 *addr_to6 =
             (struct sockaddr_in6 *) &addr_to;
-        memcpy(saddr, &addr_from6->sin6_addr,
+        memcpy(packet_ctx->src_addr, &addr_from6->sin6_addr,
                sizeof(struct in6_addr));
-        memcpy(daddr, &pktinfo.pktinfo_in6->ipi6_addr,
+        memcpy(packet_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, daddr);
+        ipv6_addr_copy(&addr_to6->sin6_addr, packet_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(hip_msg, ((char *) hip_msg) + IPV4_HDR_SIZE,
+        memmove(packet_ctx->input_msg,
+                ((char *) packet_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(hip_msg, ((char *) hip_msg) + HIP_UDP_ZERO_BYTES_LEN,
+        memmove(packet_ctx->input_msg,
+                ((char *) packet_ctx->input_msg) + HIP_UDP_ZERO_BYTES_LEN,
                 HIP_MAX_PACKET - HIP_UDP_ZERO_BYTES_LEN);
     }
 
-    HIP_IFEL(hip_verify_network_header(hip_msg,
+    HIP_IFEL(hip_verify_network_header(packet_ctx->input_msg,
                                        (struct sockaddr *) &addr_from,
                                        (struct sockaddr *) &addr_to,
                                        len - encap_hdr_size), -1,
@@ -669,11 +672,11 @@
 
 
 
-    if (saddr) {
-        HIP_DEBUG_IN6ADDR("src", saddr);
+    if (packet_ctx->src_addr) {
+        HIP_DEBUG_IN6ADDR("src", packet_ctx->src_addr);
     }
-    if (daddr) {
-        HIP_DEBUG_IN6ADDR("dst", daddr);
+    if (packet_ctx->dst_addr) {
+        HIP_DEBUG_IN6ADDR("dst", packet_ctx->dst_addr);
     }
 
 out_err:
@@ -691,14 +694,11 @@
  * @param  encap_hdr_size .
  * @return                .
  */
-int hip_read_control_msg_v6(int socket, struct hip_common *hip_msg,
-                            struct in6_addr *saddr,
-                            struct in6_addr *daddr,
-                            hip_portpair_t *msg_info,
+int hip_read_control_msg_v6(int socket,
+                            struct hip_packet_context *packet_ctx,
                             int encap_hdr_size)
 {
-    return hip_read_control_msg_all(socket, hip_msg, saddr,
-                                    daddr, msg_info, encap_hdr_size, 0);
+    return hip_read_control_msg_all(socket, packet_ctx, encap_hdr_size, 0);
 }
 
 /**
@@ -712,12 +712,9 @@
  * @param  encap_hdr_size .
  * @return                .
  */
-int hip_read_control_msg_v4(int socket, struct hip_common *hip_msg,
-                            struct in6_addr *saddr,
-                            struct in6_addr *daddr,
-                            hip_portpair_t *msg_info,
+int hip_read_control_msg_v4(int socket,
+                            struct hip_packet_context *packet_ctx,
                             int encap_hdr_size)
 {
-    return hip_read_control_msg_all(socket, hip_msg, saddr,
-                                    daddr, msg_info, encap_hdr_size, 1);
+    return hip_read_control_msg_all(socket, packet_ctx, encap_hdr_size, 1);
 }

=== modified file 'lib/core/message.h'
--- lib/core/message.h  2010-03-03 13:16:18 +0000
+++ lib/core/message.h  2010-03-09 14:14:54 +0000
@@ -36,24 +36,11 @@
 int hip_read_user_control_msg(int socket,
                               struct hip_common *hip_msg,
                               struct sockaddr_in6 *saddr);
-int hip_read_control_msg_all(int socket,
-                             struct hip_common *hip_msg,
-                             struct in6_addr *saddr,
-                             struct in6_addr *daddr,
-                             hip_portpair_t *msg_info,
-                             int encap_hdr_size,
-                             int is_ipv4);
 int hip_read_control_msg_v6(int socket,
-                            struct hip_common *hip_msg,
-                            struct in6_addr *saddr,
-                            struct in6_addr *daddr,
-                            hip_portpair_t *msg_info,
+                            struct hip_packet_context *packet_ctx,
                             int encap_hdr_size);
 int hip_read_control_msg_v4(int socket,
-                            struct hip_common *hip_msg,
-                            struct in6_addr *saddr,
-                            struct in6_addr *daddr,
-                            hip_portpair_t *msg_info,
+                            struct hip_packet_context *packet_ctx,
                             int encap_hdr_size);
 int hip_sendto(int sock,
                const struct hip_common *msg,

=== modified file 'modules/heartbeat/hipd/heartbeat.c'
--- modules/heartbeat/hipd/heartbeat.c  2010-03-09 10:57:49 +0000
+++ modules/heartbeat/hipd/heartbeat.c  2010-03-09 14:14:54 +0000
@@ -181,6 +181,11 @@
     return 0;
 }
 
+//        if (FD_ISSET(hip_icmp_sock, &read_fdset)) {
+//            HIP_IFEL(hip_icmp_recvmsg(hip_icmp_sock), -1,
+//                     "Failed to recvmsg from ICMPv6\n");
+//        }
+
 /**
  * Initialize icmpv6 socket.
  */
@@ -191,7 +196,7 @@
     int *icmpsockfd = &hip_icmp_sock;
 
     hip_register_maint_function(&hip_heartbeat_maintenance, 10000);
-    hip_register_socket(hip_icmp_sock, 30000);
+    hip_register_socket(hip_icmp_sock, NULL, 30000);
 
     /* Make sure that hipd does not send icmpv6 immediately after base 
exchange */
     heartbeat_counter = HIP_HEARTBEAT_INTERVAL;

Other related posts:

  • » [hipl-commit] [tiny] Rev 3640: Prepared packet reading in daemon main loop for modularization. - Tim Just