[hipl-commit] [trunk] Rev 3953: Moved some accessor functions from hipd.c to accessor.c

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 16 Mar 2010 14:48:20 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: 16/03/2010 at 14:48:20
Revision: 3953
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Moved some accessor functions from hipd.c to accessor.c

Modified:
  M  hipd/accessor.c
  M  hipd/accessor.h
  M  hipd/hipd.c
  M  hipd/hipd.h

=== modified file 'hipd/accessor.c'
--- hipd/accessor.c     2010-03-09 18:26:22 +0000
+++ hipd/accessor.c     2010-03-16 12:48:19 +0000
@@ -15,13 +15,12 @@
 #include "config.h"
 #include "accessor.h"
 
-
 unsigned int hipd_state         = HIPD_STATE_CLOSED;
 #ifdef CONFIG_HIP_OPPORTUNISTIC
 unsigned int opportunistic_mode = 1;
+extern int hip_use_opptcp;
 #endif // CONFIG_HIP_OPPORTUNISTIC
 
-
 /**
  * Set global daemon state.
  * @param state @see daemon_states
@@ -75,6 +74,67 @@
 
 #ifdef CONFIG_HIP_OPPORTUNISTIC
 /**
+ * Set opportunistic TCP status on or off
+ *
+ * @param msg a message with message type as SO_HIP_SET_OPPTCP_ON
+ *            or SO_HIP_SET_OPPTCP_OFF
+ */
+void hip_set_opportunistic_tcp_status(struct hip_common *msg)
+{
+    struct sockaddr_in6 sock_addr;
+    int retry, type, n;
+
+    type = hip_get_msg_type(msg);
+
+    _HIP_DEBUG("type=%d\n", type);
+
+    memset(&sock_addr, 0, sizeof(sock_addr));
+    sock_addr.sin6_family = AF_INET6;
+    sock_addr.sin6_port   = htons(HIP_FIREWALL_PORT);
+    sock_addr.sin6_addr   = in6addr_loopback;
+
+    for (retry = 0; retry < 3; retry++) {
+        /* Switched from hip_sendto() to hip_sendto_user() due to
+         * namespace collision. Both message.h and user.c had functions
+         * hip_sendto(). Introducing a prototype hip_sendto() to user.h
+         * led to compiler errors --> user.c hip_sendto() renamed to
+         * hip_sendto_user().
+         *
+         * Lesson learned: use function prototypes unless functions are
+         * ment only for local (inside the same file where defined) use.
+         * -Lauri 11.07.2008 */
+        n = hip_sendto_user(msg, (struct sockaddr *) &sock_addr);
+        if (n <= 0) {
+            HIP_ERROR("hipconf opptcp failed (round %d)\n", retry);
+            HIP_DEBUG("Sleeping few seconds to wait for fw\n");
+            sleep(2);
+        } else {
+            HIP_DEBUG("hipconf opptcp ok (sent %d bytes)\n", n);
+            break;
+        }
+    }
+
+    if (type == SO_HIP_SET_OPPTCP_ON) {
+        hip_use_opptcp = 1;
+    } else {
+        hip_use_opptcp = 0;
+    }
+
+    HIP_DEBUG("Opportunistic tcp set %s\n",
+              (hip_use_opptcp ? "on" : "off"));
+}
+
+/**
+ * query status for the opportunistic TCP extensions
+ *
+ * @return 1 if it is enabled or 0 otherwise
+ */
+int hip_get_opportunistic_tcp_status()
+{
+    return hip_use_opptcp;
+}
+
+/**
  * Set opportunistic mode
  *
  * @param msg A message containing a HIP_PARAM_UINT parameter.
@@ -142,6 +202,65 @@
     return err;
 }
 
+
+#ifdef CONFIG_HIP_I3
+/**
+ * turn hi3 support on or off
+ *
+ * @param msg a message with type SO_HIP_SET_HI3_ON or SO_HIP_SET_HI3_OFF
+ */
+void hip_set_hi3_status(struct hip_common *msg)
+{
+    struct sockaddr_in6 sock_addr;
+    int retry, type, n;
+
+    type = hip_get_msg_type(msg);
+
+    _HIP_DEBUG("type=%d\n", type);
+
+    bzero(&sock_addr, sizeof(sock_addr));
+    sock_addr.sin6_family = AF_INET6;
+    sock_addr.sin6_port   = htons(HIP_FIREWALL_PORT);
+    sock_addr.sin6_addr   = in6addr_loopback;
+
+    for (retry = 0; retry < 3; retry++) {
+        n = hip_sendto_user(msg, (struct sockaddr *) &sock_addr);
+        if (n <= 0) {
+            HIP_ERROR("hipconf hi3 failed (round %d)\n", retry);
+            HIP_DEBUG("Sleeping few seconds to wait for fw\n");
+            sleep(2);
+        } else {
+            HIP_DEBUG("hipconf hi3 ok (sent %d bytes)\n", n);
+            break;
+        }
+    }
+
+    if (type == SO_HIP_SET_HI3_ON) {
+        hip_i3_init();
+        hip_use_hi3        = 1;
+        hip_locator_status = SO_HIP_SET_LOCATOR_ON;
+    } else {
+        hip_locator_status = SO_HIP_SET_LOCATOR_OFF;
+        hip_hi3_clean();
+        hip_use_hi3        = 0;
+    }
+
+    HIP_DEBUG("hi3 set %s\n",
+              (hip_use_hi3 ? "on" : "off"));
+}
+
+/**
+ * query if Hi3 is enabled or not
+ *
+ * @return 1 if it is enabled or 0 otherwise
+ */
+int hip_get_hi3_status()
+{
+    return hip_use_hi3;
+}
+
+#endif
+
 /**
  * Query if a pseudo HIT is stored in the host association
  * data base.

=== modified file 'hipd/accessor.h'
--- hipd/accessor.h     2010-03-07 11:20:52 +0000
+++ hipd/accessor.h     2010-03-16 12:48:19 +0000
@@ -46,6 +46,12 @@
 int hip_get_hip_proxy_status(void);
 int hip_set_hip_proxy_on(void);
 int hip_set_hip_proxy_off(void);
+int hip_get_opportunistic_tcp_status(void);
+
+#ifdef CONFIG_HIP_I3
+int hip_get_hi3_status( void );
+void hip_set_hi3_status(struct hip_common *msg);
+#endif /* CONFIG_HIP_I3 */
 
 /** Specifies the NAT status of the daemon. This value indicates if the current
  *  machine is behind a NAT. Defined in hipd.c */

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-03-16 12:37:27 +0000
+++ hipd/hipd.c 2010-03-16 12:48:19 +0000
@@ -171,124 +171,6 @@
 
 HIP_HASHTABLE *bex_timestamp_db = NULL;
 
-/**
- * Set opportunistic TCP status on or off
- *
- * @param msg a message with message type as SO_HIP_SET_OPPTCP_ON
- *            or SO_HIP_SET_OPPTCP_OFF
- */
-void hip_set_opportunistic_tcp_status(struct hip_common *msg)
-{
-    struct sockaddr_in6 sock_addr;
-    int retry, type, n;
-
-    type = hip_get_msg_type(msg);
-
-    _HIP_DEBUG("type=%d\n", type);
-
-    memset(&sock_addr, 0, sizeof(sock_addr));
-    sock_addr.sin6_family = AF_INET6;
-    sock_addr.sin6_port   = htons(HIP_FIREWALL_PORT);
-    sock_addr.sin6_addr   = in6addr_loopback;
-
-    for (retry = 0; retry < 3; retry++) {
-        /* Switched from hip_sendto() to hip_sendto_user() due to
-         * namespace collision. Both message.h and user.c had functions
-         * hip_sendto(). Introducing a prototype hip_sendto() to user.h
-         * led to compiler errors --> user.c hip_sendto() renamed to
-         * hip_sendto_user().
-         *
-         * Lesson learned: use function prototypes unless functions are
-         * ment only for local (inside the same file where defined) use.
-         * -Lauri 11.07.2008 */
-        n = hip_sendto_user(msg, (struct sockaddr *) &sock_addr);
-        if (n <= 0) {
-            HIP_ERROR("hipconf opptcp failed (round %d)\n", retry);
-            HIP_DEBUG("Sleeping few seconds to wait for fw\n");
-            sleep(2);
-        } else {
-            HIP_DEBUG("hipconf opptcp ok (sent %d bytes)\n", n);
-            break;
-        }
-    }
-
-    if (type == SO_HIP_SET_OPPTCP_ON) {
-        hip_use_opptcp = 1;
-    } else {
-        hip_use_opptcp = 0;
-    }
-
-    HIP_DEBUG("Opportunistic tcp set %s\n",
-              (hip_use_opptcp ? "on" : "off"));
-}
-
-/**
- * query status for the opportunistic TCP extensions
- *
- * @return 1 if it is enabled or 0 otherwise
- */
-int hip_get_opportunistic_tcp_status()
-{
-    return hip_use_opptcp;
-}
-
-#ifdef CONFIG_HIP_I3
-/**
- * turn hi3 support on or off
- *
- * @param msg a message with type SO_HIP_SET_HI3_ON or SO_HIP_SET_HI3_OFF
- */
-void hip_set_hi3_status(struct hip_common *msg)
-{
-    struct sockaddr_in6 sock_addr;
-    int retry, type, n;
-
-    type = hip_get_msg_type(msg);
-
-    _HIP_DEBUG("type=%d\n", type);
-
-    bzero(&sock_addr, sizeof(sock_addr));
-    sock_addr.sin6_family = AF_INET6;
-    sock_addr.sin6_port   = htons(HIP_FIREWALL_PORT);
-    sock_addr.sin6_addr   = in6addr_loopback;
-
-    for (retry = 0; retry < 3; retry++) {
-        n = hip_sendto_user(msg, (struct sockaddr *) &sock_addr);
-        if (n <= 0) {
-            HIP_ERROR("hipconf hi3 failed (round %d)\n", retry);
-            HIP_DEBUG("Sleeping few seconds to wait for fw\n");
-            sleep(2);
-        } else {
-            HIP_DEBUG("hipconf hi3 ok (sent %d bytes)\n", n);
-            break;
-        }
-    }
-
-    if (type == SO_HIP_SET_HI3_ON) {
-        hip_i3_init();
-        hip_use_hi3        = 1;
-        hip_locator_status = SO_HIP_SET_LOCATOR_ON;
-    } else {
-        hip_locator_status = SO_HIP_SET_LOCATOR_OFF;
-        hip_hi3_clean();
-        hip_use_hi3        = 0;
-    }
-
-    HIP_DEBUG("hi3 set %s\n",
-              (hip_use_hi3 ? "on" : "off"));
-}
-
-/**
- * query if Hi3 is enabled or not
- *
- * @return 1 if it is enabled or 0 otherwise
- */
-int hip_get_hi3_status()
-{
-    return hip_use_hi3;
-}
-
-#endif
 
 /**
  * print hipd usage instructions on stderr

=== modified file 'hipd/hipd.h'
--- hipd/hipd.h 2010-03-10 17:44:36 +0000
+++ hipd/hipd.h 2010-03-16 12:48:19 +0000
@@ -175,13 +175,6 @@
 
 //int hip_sendto(const struct hip_common *msg, const struct sockaddr_in6 *dst);
 
-#ifdef CONFIG_HIP_I3
-int hip_get_hi3_status( void );
-void hip_set_hi3_status(struct hip_common *msg);
-#endif /* CONFIG_HIP_I3 */
-
-void hip_set_opportunistic_tcp_status(struct hip_common *msg);
-int hip_get_opportunistic_tcp_status(void);
 int hip_send_agent(struct hip_common *msg);
 int hip_recv_agent(struct hip_common *msg);

Other related posts:

  • » [hipl-commit] [trunk] Rev 3953: Moved some accessor functions from hipd.c to accessor.c - Miika Komu