[hipl-commit] [trunk] Rev 4256: Move hip_blind_find_local_hi() to the only place it is used and make it static.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 13 Apr 2010 14:34:18 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 13/04/2010 at 14:34:18
Revision: 4256
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Move hip_blind_find_local_hi() to the only place it is used and make it 
static.

Modified:
  M  hipd/blind.c
  M  hipd/cookie.c
  M  hipd/hidb.c
  M  hipd/hidb.h
  M  hipd/input.c
  M  hipd/output.c

=== modified file 'hipd/blind.c'
--- hipd/blind.c        2010-04-13 11:10:38 +0000
+++ hipd/blind.c        2010-04-13 11:33:54 +0000
@@ -10,11 +10,72 @@
 #define _BSD_SOURCE
 
 #include "blind.h"
+#include "lib/core/hit.h"
 #include "lib/core/hostid.h"
 
 static int hip_blind_fingerprints(hip_ha_t *entry);
 
 /**
+ * find the blinded local host identifier from the HIDB
+ *
+ * @param nonce the nonce used to blind the HIT
+ * @param test_hit the blinded HIT
+ * @param local_hit the unblinded HIT will be copied here
+ * @return zero on success or negative on error
+ */
+static int hip_blind_find_local_hi(uint16_t *nonce,  struct in6_addr *test_hit,
+                                   struct in6_addr *local_hit)
+{
+    hip_list_t *curr, *iter;
+    struct hip_host_id_entry *tmp;
+    int err                    = 0, c;
+    char *key                  = NULL;
+    unsigned int key_len       = sizeof(struct in6_addr);
+    struct in6_addr *blind_hit = NULL;
+
+    // generate key = nonce|hit_our
+    HIP_IFEL((key = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct in6_addr), 0)) 
== NULL,
+             -1, "Couldn't allocate memory\n");
+
+    HIP_IFEL((blind_hit = HIP_MALLOC(sizeof(struct in6_addr), 0)) == NULL,
+             -1, "Couldn't allocate memory\n");
+
+    HIP_READ_LOCK_DB(hip_local_hostid_db);
+
+    list_for_each_safe(curr, iter, hip_local_hostid_db, c)
+    {
+        tmp = (struct hip_host_id_entry *) list_entry(curr);
+        HIP_HEXDUMP("Found HIT", &tmp->lhi.hit, 16);
+
+        // let's test the hit
+        memcpy(key, &tmp->lhi.hit, sizeof(struct in6_addr));
+        memcpy(key + sizeof(struct in6_addr), &nonce, sizeof(uint16_t));
+        HIP_IFEL(hip_do_blind(key, key_len, blind_hit), -1, "hip_do_blind 
failed \n");
+        if (blind_hit == NULL) {
+            err = -1;
+            goto out_err;
+        }
+        HIP_HEXDUMP("test HIT:", test_hit, 16);
+        if (hip_match_hit(test_hit, blind_hit)) {
+            HIP_HEXDUMP("Plain HIT found:", &tmp->lhi.hit, 16);
+            memcpy(local_hit, &tmp->lhi.hit, sizeof(struct in6_addr));
+            goto out_err;
+        }
+    }
+
+    HIP_READ_UNLOCK_DB(hip_local_hostid_db);
+
+out_err:
+    if (key) {
+        HIP_FREE(key);
+    }
+    if (blind_hit) {
+        HIP_FREE(blind_hit);
+    }
+    return err;
+}
+
+/**
  * test whether we should use blind or not based on an inbound packet
  *
  * @param msg a HIP control message

=== modified file 'hipd/cookie.c'
--- hipd/cookie.c       2010-04-09 15:20:38 +0000
+++ hipd/cookie.c       2010-04-13 11:33:54 +0000
@@ -12,6 +12,7 @@
 #define _BSD_SOURCE
 
 #include "config.h"
+#include "blind.h"
 #include "cookie.h"
 #include "lib/core/solve.h"
 

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-04-13 11:10:38 +0000
+++ hipd/hidb.c 2010-04-13 11:33:54 +0000
@@ -758,70 +758,6 @@
     return err;
 }
 
-//#ifdef CONFIG_HIP_BLIND
-
-/**
- * find the blinded local host identifier from the HIDB
- *
- * @param nonce the nonce used to blind the HIT
- * @param test_hit the blinded HIT
- * @param local_hit the unblinded HIT will be copied here
- * @return zero on success or negative on error
- */
-int hip_blind_find_local_hi(uint16_t *nonce,  struct in6_addr *test_hit,
-                            struct in6_addr *local_hit)
-{
-    hip_list_t *curr, *iter;
-    struct hip_host_id_entry *tmp;
-    int err                    = 0, c;
-    char *key                  = NULL;
-    unsigned int key_len       = sizeof(struct in6_addr);
-    struct in6_addr *blind_hit = NULL;
-
-    // generate key = nonce|hit_our
-    HIP_IFEL((key = HIP_MALLOC(sizeof(uint16_t) + sizeof(struct in6_addr), 0)) 
== NULL,
-             -1, "Couldn't allocate memory\n");
-
-    HIP_IFEL((blind_hit = HIP_MALLOC(sizeof(struct in6_addr), 0)) == NULL,
-             -1, "Couldn't allocate memory\n");
-
-    HIP_READ_LOCK_DB(hip_local_hostid_db);
-
-    list_for_each_safe(curr, iter, hip_local_hostid_db, c)
-    {
-        tmp = (struct hip_host_id_entry *) list_entry(curr);
-        HIP_HEXDUMP("Found HIT", &tmp->lhi.hit, 16);
-
-        // let's test the hit
-        memcpy(key, &tmp->lhi.hit, sizeof(struct in6_addr));
-        memcpy(key + sizeof(struct in6_addr), &nonce, sizeof(uint16_t));
-        HIP_IFEL(hip_do_blind(key, key_len, blind_hit), -1, "hip_do_blind 
failed \n");
-        if (blind_hit == NULL) {
-            err = -1;
-            goto out_err;
-        }
-        HIP_HEXDUMP("test HIT:", test_hit, 16);
-        if (hip_match_hit(test_hit, blind_hit)) {
-            HIP_HEXDUMP("Plain HIT found:", &tmp->lhi.hit, 16);
-            memcpy(local_hit, &tmp->lhi.hit, sizeof(struct in6_addr));
-            goto out_err;
-        }
-    }
-
-    HIP_READ_UNLOCK_DB(hip_local_hostid_db);
-
-out_err:
-    if (key) {
-        HIP_FREE(key);
-    }
-    if (blind_hit) {
-        HIP_FREE(blind_hit);
-    }
-    return err;
-}
-
-//#endif
-
 /**
  * find a host identifier from the database
  *

=== modified file 'hipd/hidb.h'
--- hipd/hidb.h 2010-03-19 08:47:02 +0000
+++ hipd/hidb.h 2010-04-13 11:33:54 +0000
@@ -12,7 +12,6 @@
 #include "lib/core/list.h"
 #include "lib/core/debug.h"
 #include "cookie.h"
-#include "blind.h"
 
 #if 0
 #define HIP_READ_LOCK_DB(db) do { \
@@ -71,8 +70,6 @@
 int hip_handle_del_local_hi(const struct hip_common *input);
 int hip_for_each_hi(int (*func)(struct hip_host_id_entry *entry, void *opaq), 
void *opaque);
 
-int hip_blind_find_local_hi(uint16_t *nonce, struct in6_addr *test_hit,
-                            struct in6_addr *local_hit);
 int hip_build_host_id_and_signature(struct hip_common *msg,  hip_hit_t *hit);
 /*lsi support*/
 int hip_hidb_exists_lsi(hip_lsi_t *lsi);

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-04-13 11:10:38 +0000
+++ hipd/input.c        2010-04-13 11:33:54 +0000
@@ -17,6 +17,7 @@
 #define _BSD_SOURCE
 
 #include "config.h"
+#include "blind.h"
 #include "input.h"
 #include "hadb.h"
 #include "oppdb.h"

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-04-13 11:17:51 +0000
+++ hipd/output.c       2010-04-13 11:33:54 +0000
@@ -18,6 +18,7 @@
 #include <netinet/icmp6.h>
 
 #include "config.h"
+#include "blind.h"
 #include "output.h"
 #include "lib/core/performance.h"

Other related posts:

  • » [hipl-commit] [trunk] Rev 4256: Move hip_blind_find_local_hi() to the only place it is used and make it static. - Diego Biurrun