[hipl-commit] [trunk] Rev 3639: Moved two puzzle-related functions to where they belong to.

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Mon, 15 Feb 2010 19:28:23 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Mon Feb 15 19:29:10 2010 +0200
Revision: 3639
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Moved two puzzle-related functions to where they belong to.

Modified:
  M  hipd/cookie.c
  M  hipd/cookie.h
  M  hipd/netdev.c
  M  hipd/netdev.h

=== modified file 'hipd/cookie.c'
--- hipd/cookie.c       2010-02-11 09:57:04 +0000
+++ hipd/cookie.c       2010-02-15 17:29:10 +0000
@@ -23,6 +23,59 @@
 
 int hip_cookie_difficulty = HIP_DEFAULT_COOKIE_K;
 
+//get the puzzle difficulty and return result to hipconf
+int hip_get_puzzle_difficulty_msg(struct hip_common *msg)
+{
+    int err            = 0, diff = 0;
+    hip_hit_t *dst_hit = NULL;
+    hip_hit_t all_zero_hit;
+    bzero(&all_zero_hit, sizeof(all_zero_hit));
+
+    //obtain the hit
+    dst_hit = hip_get_param_contents(msg, HIP_PARAM_HIT);
+
+#ifdef CONFIG_HIP_COOKIE
+    if (ipv6_addr_cmp(&all_zero_hit, dst_hit) != 0) {
+        diff = hip_get_cookie_difficulty(dst_hit);
+    } else {
+#endif
+    diff = hip_get_cookie_difficulty(NULL);
+#ifdef CONFIG_HIP_COOKIE
+}
+#endif
+
+    _HIP_DEBUG("Puzzle difficulty is %d\n", diff);
+    hip_build_param_contents(msg, &diff, HIP_PARAM_INT, sizeof(diff));
+
+    return err;
+}
+
+
+/* TODO: This function has no error handling at all! Check if this is right-*/
+//set the puzzle difficulty acc to msg sent by hipconf
+int hip_set_puzzle_difficulty_msg(struct hip_common *msg)
+{
+    int err            = 0, *newVal = NULL;
+    hip_hit_t *dst_hit = NULL;
+    hip_hit_t all_zero_hit;
+    bzero(&all_zero_hit, sizeof(all_zero_hit));
+
+    dst_hit = hip_get_param_contents(msg, HIP_PARAM_HIT);
+    newVal  = hip_get_param_contents(msg, HIP_PARAM_INT);
+
+#ifdef CONFIG_HIP_COOKIE
+    if (ipv6_addr_cmp(&all_zero_hit, dst_hit) != 0) {
+        hip_set_cookie_difficulty(dst_hit, *newVal);
+    } else {
+#endif
+    hip_set_cookie_difficulty(NULL, *newVal);
+#ifdef CONFIG_HIP_COOKIE
+}
+
+#endif
+    return err;
+}
+
 #ifndef CONFIG_HIP_ICOOKIE /* see also spam.c for overriding functions */
 
 #if 0

=== modified file 'hipd/cookie.h'
--- hipd/cookie.h       2010-02-10 22:32:46 +0000
+++ hipd/cookie.h       2010-02-15 17:29:10 +0000
@@ -35,4 +35,6 @@
 int hip_get_cookie_difficulty(hip_hit_t *not_used);
 int hip_inc_cookie_difficulty(hip_hit_t *not_used);
 int hip_dec_cookie_difficulty(hip_hit_t *not_used);
+int hip_get_puzzle_difficulty_msg(struct hip_common *msg);
+int hip_set_puzzle_difficulty_msg(struct hip_common *msg);
 #endif /* HIP_COOKIE_H */

=== modified file 'hipd/netdev.c'
--- hipd/netdev.c       2010-02-15 16:27:50 +0000
+++ hipd/netdev.c       2010-02-15 17:29:10 +0000
@@ -1502,67 +1502,10 @@
     return err;
 }
 
-/* get the puzzle difficulty and return result to hipconf */
-int hip_get_puzzle_difficulty_msg(struct hip_common *msg)
-{
-    int err            = 0, diff = 0;
-    hip_hit_t *dst_hit = NULL;
-    hip_hit_t all_zero_hit;
-    bzero(&all_zero_hit, sizeof(all_zero_hit));
-
-    /* obtain the hit */
-    dst_hit = hip_get_param_contents(msg, HIP_PARAM_HIT);
-
-#ifdef CONFIG_HIP_COOKIE
-    if (ipv6_addr_cmp(&all_zero_hit, dst_hit) != 0) {
-        diff = hip_get_cookie_difficulty(dst_hit);
-    } else {
-#endif
-    diff = hip_get_cookie_difficulty(NULL);
-#ifdef CONFIG_HIP_COOKIE
-}
-#endif
-
-    _HIP_DEBUG("Puzzle difficulty is %d\n", diff);
-    hip_build_param_contents(msg, &diff, HIP_PARAM_INT, sizeof(diff));
-
-    return err;
-}
-
-
-/* @todo This function has no error handling at all! Check if this is right */
-/* set the puzzle difficulty acc to msg sent by hipconf */
-int hip_set_puzzle_difficulty_msg(struct hip_common *msg)
-{
-    int err            = 0, *newVal = NULL;
-    hip_hit_t *dst_hit = NULL;
-    hip_hit_t all_zero_hit;
-    bzero(&all_zero_hit, sizeof(all_zero_hit));
-
-    dst_hit = hip_get_param_contents(msg, HIP_PARAM_HIT);
-    newVal  = hip_get_param_contents(msg, HIP_PARAM_INT);
-
-#ifdef CONFIG_HIP_COOKIE
-    if (ipv6_addr_cmp(&all_zero_hit, dst_hit) != 0) {
-        hip_set_cookie_difficulty(dst_hit, *newVal);
-    } else {
-#endif
-    hip_set_cookie_difficulty(NULL, *newVal);
-#ifdef CONFIG_HIP_COOKIE
-}
-
-#endif
-/* Disabled because error handling isn't used
- * out_err:
- */
-    return err;
-}
-
 /**
  * attach the reply we got from the dht gateway
  * to the message back to hipconf
  */
-
 #ifdef CONFIG_HIP_DHT
 static void hip_attach_locator_addresses(struct hip_common *in_msg,
                                          struct hip_common *msg)

=== modified file 'hipd/netdev.h'
--- hipd/netdev.h       2010-02-10 22:32:46 +0000
+++ hipd/netdev.h       2010-02-15 17:29:10 +0000
@@ -52,8 +52,6 @@
 int hip_get_default_hit(struct in6_addr *hit);
 int hip_get_default_hit_msg(struct hip_common *msg);
 int hip_get_default_lsi(struct in_addr *lsi);
-int hip_get_puzzle_difficulty_msg(struct hip_common *msg);
-int hip_set_puzzle_difficulty_msg(struct hip_common *msg);
 
 int hip_netdev_trigger_bex_msg(struct hip_common *msg);
 void add_address_to_list(struct sockaddr *addr, int ifindex, int flags);

Other related posts:

  • » [hipl-commit] [trunk] Rev 3639: Moved two puzzle-related functions to where they belong to. - Miika Komu