[hipl-dev] [Branch ~toxedvirus/hipl/options] Rev 5269: addressed comments on revisions 5262 and 5263

  • From: noreply@xxxxxxxxxxxxx
  • To: HIPL core team <hipl-dev@xxxxxxxxxxxxx>
  • Date: Fri, 17 Dec 2010 15:20:53 -0000

------------------------------------------------------------
revno: 5269
committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
branch nick: hipl
timestamp: Fri 2010-12-10 09:50:38 +0100
message:
  addressed comments on revisions 5262 and 5263
  
  fixed long lines, renamed param to wire_host_id, substracted
  hip_common header.
  
  NOTE: I did not look into refactoring as suggested by Diego.
modified:
  hipd/hip_socket.c
  lib/core/builder.c
  lib/core/message.c


--
lp:~toxedvirus/hipl/options
https://code.launchpad.net/~toxedvirus/hipl/options

Your team HIPL core team is subscribed to branch lp:~toxedvirus/hipl/options.
To unsubscribe from this branch go to 
https://code.launchpad.net/~toxedvirus/hipl/options/+edit-subscription
=== modified file 'hipd/hip_socket.c'
--- hipd/hip_socket.c   2010-11-29 08:58:13 +0000
+++ hipd/hip_socket.c   2010-12-10 08:50:38 +0000
@@ -66,6 +66,8 @@
 {
     int err = 0;
 
+    HIP_DEBUG("received on: hip_raw_sock_input_v6");
+
     if (hip_read_control_msg_v6(hip_raw_sock_input_v6,
                                 ctx,
                                 0)) {
@@ -84,6 +86,8 @@
 {
     int err = 0;
 
+    HIP_DEBUG("received on: hip_raw_sock_input_v4");
+
     if (hip_read_control_msg_v4(hip_raw_sock_input_v4,
                                 ctx,
                                 IPV4_HDR_SIZE)) {
@@ -102,9 +106,7 @@
 {
     int err = 0;
 
-    HIP_DEBUG("Receiving a message on UDP from NAT " \
-              "socket (file descriptor: %d).\n",
-              hip_nat_sock_input_udp);
+    HIP_DEBUG("received on: hip_nat_sock_input_udp");
 
     err = hip_read_control_msg_v4(hip_nat_sock_input_udp,
                                   ctx,
@@ -124,6 +126,7 @@
     uint8_t msg_type = 0;
     struct sockaddr_in6 app_src;
 
+    HIP_DEBUG("received on: hip_user_sock");
 
     HIP_IFEL(hip_read_user_control_msg(hip_user_sock,
                                        ctx->input_msg,
@@ -162,7 +165,8 @@
 
 static int hip_handle_nl_ipsec_sock(UNUSED struct hip_packet_context *ctx)
 {
-    HIP_DEBUG("netlink receive\n");
+    HIP_DEBUG("received on: hip_nl_ipsec");
+
     if (hip_netlink_receive(&hip_nl_ipsec,
                             hip_netdev_event, NULL)) {
         HIP_ERROR("Netlink receiving failed\n");
@@ -174,7 +178,8 @@
 
 static int hip_handle_nl_route_sock(UNUSED struct hip_packet_context *ctx)
 {
-    HIP_DEBUG("netlink route receive\n");
+    HIP_DEBUG("received on: hip_nl_route");
+
     if (hip_netlink_receive(&hip_nl_route,
                             hip_netdev_event, NULL)) {
         HIP_ERROR("Netlink receiving failed\n");

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-12-08 18:40:04 +0000
+++ lib/core/builder.c  2010-12-10 08:50:38 +0000
@@ -3147,25 +3147,31 @@
  *
  * @return 0 on success, negative on error (if parameter was of wrong type)
  */
-int hip_build_host_id_from_param(const struct hip_host_id *param, struct 
hip_host_id *peer_host_id) {
+int hip_build_host_id_from_param(const struct hip_host_id *wire_host_id,
+                                 struct hip_host_id *peer_host_id)
+{
     int err = 0;
     uint16_t header_len;
     uint16_t key_len;
     uint16_t fqdn_len;
-    HIP_IFEL(!(hip_get_param_type(param) == HIP_PARAM_HOST_ID),
+    HIP_IFEL(!(hip_get_param_type(wire_host_id) == HIP_PARAM_HOST_ID),
              -1, "Param has wrong type (not HIP_PARAM_HOST_ID)");
 
     // copy the header, key and fqdn
-    header_len  = sizeof(struct hip_host_id) - sizeof(peer_host_id->key) - 
sizeof(peer_host_id->hostname);
-    fqdn_len    = ntohs(param->di_type_length) & 0x0FFF;
-    key_len     = ntohs(param->hi_length) - sizeof(struct 
hip_host_id_key_rdata);
+    header_len  = sizeof(struct hip_host_id) -
+                  sizeof(peer_host_id->key) -
+                  sizeof(peer_host_id->hostname);
+    fqdn_len    = ntohs(wire_host_id->di_type_length) & 0x0FFF;
+    key_len     = ntohs(wire_host_id->hi_length) -
+                  sizeof(struct hip_host_id_key_rdata);
     memcpy(peer_host_id, param, header_len);
-    memcpy(peer_host_id->key, &param->key[0], key_len);
-    memcpy(peer_host_id->hostname, &param->key[key_len], fqdn_len);
+    memcpy(peer_host_id->key, wire_host_id->key, key_len);
+    memcpy(peer_host_id->hostname, &wire_host_id->key[key_len], fqdn_len);
 
     // with the header we also copied the compressed length value, so correct 
this
     hip_set_param_contents_len((struct hip_tlv_common *) peer_host_id,
-                               sizeof(struct hip_host_id) - sizeof(struct 
hip_tlv_common));
+                               sizeof(struct hip_host_id) -
+                               sizeof(struct hip_tlv_common));
 
 out_err:
     return err;
@@ -3181,7 +3187,8 @@
  * @see hip_build_param()
  */
 int hip_build_param_host_id(struct hip_common *msg,
-                            const struct hip_host_id *host_id) {
+                            const struct hip_host_id *host_id)
+{
     struct hip_host_id new_host_id;
     uint16_t header_len;
     uint16_t fqdn_len;
@@ -3189,9 +3196,12 @@
     uint16_t par_len;
 
     // eliminate unused space by copying fqdn directly behind the keyrr
-    header_len  = sizeof(struct hip_host_id) - sizeof(host_id->key) - 
sizeof(host_id->hostname);
+    header_len  = sizeof(struct hip_host_id) -
+                  sizeof(host_id->key) -
+                  sizeof(host_id->hostname);
     fqdn_len    = ntohs(host_id->di_type_length) & 0x0FFF;
-    key_len     = ntohs(host_id->hi_length) - sizeof(struct 
hip_host_id_key_rdata);
+    key_len     = ntohs(host_id->hi_length) -
+                  sizeof(struct hip_host_id_key_rdata);
     memcpy(&new_host_id, host_id, header_len);
     memcpy(&new_host_id.key[0], host_id->key, key_len);
     memcpy(&new_host_id.key[key_len], host_id->hostname, fqdn_len);
@@ -3199,7 +3209,8 @@
     // set the new contents length
     // = | length fields | + | keyrr header | + | HI | + | FQDN |
     par_len = header_len + key_len + fqdn_len;
-    hip_set_param_contents_len((struct hip_tlv_common *) &new_host_id, 
par_len);
+    hip_set_param_contents_len((struct hip_tlv_common *) &new_host_id,
+                               par_len - sizeof(struct hip_tlv_common);
 
     return hip_build_param(msg, &new_host_id);
 }

=== modified file 'lib/core/message.c'
--- lib/core/message.c  2010-11-30 14:50:30 +0000
+++ lib/core/message.c  2010-12-10 08:50:38 +0000
@@ -465,7 +465,7 @@
     n   = send(hip_user_sock, msg, len, 0);
 
     if (n < len) {
-        HIP_ERROR("Could not send message to daemon.\n");
+        HIP_ERROR("Could not send message to daemon: %s\n", strerror(errno););
         err = -1;
         goto out_err;
     }

Other related posts:

  • » [hipl-dev] [Branch ~toxedvirus/hipl/options] Rev 5269: addressed comments on revisions 5262 and 5263 - noreply