[hipl-commit] [trunk] Rev 4357: cosmetics: Move one function around to merge two CONFIG_HIP_MIDAUTH #ifdefs.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 20 Apr 2010 14:17:42 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 20/04/2010 at 14:17:42
Revision: 4357
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  cosmetics: Move one function around to merge two CONFIG_HIP_MIDAUTH #ifdefs.

Modified:
  M  lib/core/builder.c

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-04-16 01:35:28 +0000
+++ lib/core/builder.c  2010-04-20 11:17:15 +0000
@@ -2514,6 +2514,7 @@
     return err;
 }
 
+#ifdef CONFIG_HIP_MIDAUTH
 /**
  * Build and append a HIP challenge_request to the message.
  *
@@ -2530,7 +2531,6 @@
  *
  * @return zero for success, or non-zero on error
  */
-#ifdef CONFIG_HIP_MIDAUTH
 int hip_build_param_challenge_request(struct hip_common *msg,
                                       uint8_t val_K,
                                       uint8_t lifetime,
@@ -2560,45 +2560,6 @@
     return err;
 }
 
-#endif /* CONFIG_HIP_MIDAUTH */
-
-/**
- * Build and append a HIP solution into the message.
- *
- * The puzzle mechanism assumes that every value is in network byte order
- * except for the hip_birthday_cookie.cv union, where the value is in
- * host byte order. This is an exception to the normal builder rules, where
- * input arguments are normally always in host byte order.
- *
- * @param msg the message where the solution is to be appended
- * @param pz values from the corresponding puzzle copied to the solution
- * @param val_J J value for the solution (in host byte order)
- *
- * @return zero for success, or non-zero on error
- */
-int hip_build_param_solution(struct hip_common *msg, struct hip_puzzle *pz,
-                             uint64_t val_J)
-{
-    struct hip_solution cookie;
-    int err = 0;
-
-    /* note: the length cannot be calculated with calc_param_len() */
-    hip_set_param_contents_len((struct hip_tlv_common *) &cookie,
-                               sizeof(struct hip_solution) -
-                               sizeof(struct hip_tlv_common));
-    /* Type 2 (in R1) or 3 (in I2) */
-    hip_set_param_type((struct hip_tlv_common *) &cookie, HIP_PARAM_SOLUTION);
-
-    cookie.J        = hton64(val_J);
-    memcpy(&cookie.K, &pz->K, 12);     /* copy: K (1), reserved (1),
-                                        * opaque (2) and I (8 bytes). */
-    cookie.reserved = 0;
-    err = hip_build_generic_param(msg,
-                                  &cookie,
-                                  sizeof(struct hip_tlv_common),
-                                  hip_get_param_contents_direct(&cookie));
-    return err;
-}
 
 /**
  * Build and append a HIP solution into the message.
@@ -2614,7 +2575,6 @@
  *
  * @return zero for success, or non-zero on error
  */
-#ifdef CONFIG_HIP_MIDAUTH
 int hip_build_param_challenge_response(struct hip_common *msg, struct 
hip_challenge_request *pz,
                                        uint64_t val_J)
 {
@@ -2640,10 +2600,47 @@
                                   hip_get_param_contents_direct(&cookie));
     return err;
 }
-
 #endif /* CONFIG_HIP_MIDAUTH */
 
 /**
+ * Build and append a HIP solution into the message.
+ *
+ * The puzzle mechanism assumes that every value is in network byte order
+ * except for the hip_birthday_cookie.cv union, where the value is in
+ * host byte order. This is an exception to the normal builder rules, where
+ * input arguments are normally always in host byte order.
+ *
+ * @param msg the message where the solution is to be appended
+ * @param pz values from the corresponding puzzle copied to the solution
+ * @param val_J J value for the solution (in host byte order)
+ *
+ * @return zero for success, or non-zero on error
+ */
+int hip_build_param_solution(struct hip_common *msg, struct hip_puzzle *pz,
+                             uint64_t val_J)
+{
+    struct hip_solution cookie;
+    int err = 0;
+
+    /* note: the length cannot be calculated with calc_param_len() */
+    hip_set_param_contents_len((struct hip_tlv_common *) &cookie,
+                               sizeof(struct hip_solution) -
+                               sizeof(struct hip_tlv_common));
+    /* Type 2 (in R1) or 3 (in I2) */
+    hip_set_param_type((struct hip_tlv_common *) &cookie, HIP_PARAM_SOLUTION);
+
+    cookie.J        = hton64(val_J);
+    memcpy(&cookie.K, &pz->K, 12);     /* copy: K (1), reserved (1),
+                                        * opaque (2) and I (8 bytes). */
+    cookie.reserved = 0;
+    err = hip_build_generic_param(msg,
+                                  &cookie,
+                                  sizeof(struct hip_tlv_common),
+                                  hip_get_param_contents_direct(&cookie));
+    return err;
+}
+
+/**
  * Fill HIP DH contents (excludes type and length fields) with one or
  * two public values.
  *

Other related posts:

  • » [hipl-commit] [trunk] Rev 4357: cosmetics: Move one function around to merge two CONFIG_HIP_MIDAUTH #ifdefs. - Diego Biurrun