[hipl-commit] [trunk] Rev 4267: Move hip_fw_proxy_set_peer_hit() to where it is used and make it static.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 13 Apr 2010 19:40:50 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 13/04/2010 at 19:40:50
Revision: 4267
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Move hip_fw_proxy_set_peer_hit() to where it is used and make it static.

Modified:
  M  firewall/firewall_control.c
  M  firewall/proxy.c
  M  firewall/proxy.h

=== modified file 'firewall/firewall_control.c'
--- firewall/firewall_control.c 2010-04-09 15:20:38 +0000
+++ firewall/firewall_control.c 2010-04-13 16:39:45 +0000
@@ -65,6 +65,105 @@
 }
 
 /**
+ * Set the peer HIT into the HIP Proxy Database
+ *
+ * @param msg the received message for the HIT request of the peer host
+ * @return zero on success, non-zero on error
+ */
+static int hip_fw_proxy_set_peer_hit(hip_common_t *msg)
+{
+    int fallback               = 1, reject = 0, addr_found = 0, err = 0;
+    hip_hit_t local_hit, peer_hit;
+    struct in6_addr local_addr, peer_addr;
+    hip_hit_t *ptr             = NULL;
+    struct in6_addr *proxy_hit = NULL;
+
+    HIP_IFEL( !(proxy_hit = hip_fw_get_default_hit()), 0,
+              "Error while getting the default HIT!\n");
+
+    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_HIT_PEER);
+    if (ptr) {
+        memcpy(&peer_hit, ptr, sizeof(hip_hit_t));
+        HIP_DEBUG_HIT("peer_hit", &peer_hit);
+        fallback = 0;
+    }
+
+    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_HIT_LOCAL);
+    if (ptr) {
+        memcpy(&local_hit, ptr, sizeof(hip_hit_t));
+        HIP_DEBUG_HIT("local_hit", &local_hit);
+    }
+
+    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_IPV6_ADDR_PEER);
+    if (ptr) {
+        memcpy(&peer_addr, ptr, sizeof(struct in6_addr));
+        HIP_DEBUG_IN6ADDR("peer_addr", &peer_addr);
+        addr_found++;
+    }
+
+    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_IPV6_ADDR_LOCAL);
+    if (ptr) {
+        memcpy(&local_addr, ptr, sizeof(hip_hit_t));
+        HIP_DEBUG_IN6ADDR("local_addr", &local_addr);
+        addr_found++;
+    }
+
+    if (addr_found != 2) {
+        HIP_ERROR("Internal error: two addr not found\n");
+        err = -1;
+    }
+
+    ptr = hip_get_param(msg, HIP_PARAM_AGENT_REJECT);
+    if (ptr) {
+        HIP_DEBUG("Connection is to be rejected\n");
+        reject = 1;
+    }
+
+    if (reject) {
+        HIP_DEBUG("Connection should be rejected\n");
+        err = -1;
+        goto out_err;
+    }
+
+    if (fallback) {
+        HIP_DEBUG("Peer does not support HIP, fallback\n");
+        //update the state of the ip pair
+        if (hip_proxy_update_state(NULL, &peer_addr, NULL, NULL, NULL,
+                                   HIP_PROXY_PASSTHROUGH)) {
+            HIP_ERROR("Proxy update Failed!\n");
+        }
+
+        //let the packet pass
+        err = -1;
+    } else {
+        if (hip_proxy_update_state(NULL, &peer_addr, &local_addr, proxy_hit,
+                                   &peer_hit, HIP_PROXY_TRANSLATE)) {
+            HIP_ERROR("Proxy update Failed!\n");
+        }
+
+#if 0
+        if (hip_proxy_conn_add_entry(&local_addr,
+                                     &peer_addr,
+                                     proxy_hit,
+                                     &peer_hit,
+                                     protocol,
+                                     port_client,
+                                     port_peer,
+                                     HIP_PROXY_TRANSLATE)) {
+            HIP_ERROR("ConnDB add entry Failed!\n");
+        }
+#endif
+
+        /* Drop packet. Firewall translates further retransmissions correctly 
*/
+        err = 0;
+    }
+
+out_err:
+
+    return err;
+}
+
+/**
  * distribute a message from hipd to the respective extension handler
  *
  * @param   msg pointer to the received user message

=== modified file 'firewall/proxy.c'
--- firewall/proxy.c    2010-04-13 15:49:15 +0000
+++ firewall/proxy.c    2010-04-13 16:39:45 +0000
@@ -104,133 +104,6 @@
 }
 
 /**
- * Get the local HIT from HIP Daemon
- *
- * @param hit the pointer used to store the local HIT
- * @return zero on success, non-zero on error
- */
-int hip_get_local_hit_wrapper(hip_hit_t *hit)
-{
-    int err                = 0;
-    char *param            = 0;
-    struct hip_common *msg = NULL;
-
-    HIP_IFEL(!(msg = hip_msg_alloc()), -1, "malloc failed\n");
-    HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_DEFAULT_HIT, 0),
-             -1, "Fail to get hits");
-    HIP_IFEL(hip_send_recv_daemon_info(msg, 0, hip_fw_sock), -1, 
"send/recv\n");
-    HIP_IFEL(!(param = hip_get_param(msg, HIP_PARAM_HIT)), -1,
-             "No HIT received\n");
-    ipv6_addr_copy(hit, hip_get_param_contents_direct(param));
-    _HIP_DEBUG_HIT("hit", hit);
-
-out_err:
-    if (msg) {
-        free(msg);
-    }
-    return err;
-}
-
-/**
- * Set the peer HIT into the HIP Proxy Database
- *
- * @param msg the received message for the HIT request of the peer host
- * @return zero on success, non-zero on error
- */
-int hip_fw_proxy_set_peer_hit(hip_common_t *msg)
-{
-    int fallback               = 1, reject = 0, addr_found = 0, err = 0;
-    hip_hit_t local_hit, peer_hit;
-    struct in6_addr local_addr, peer_addr;
-    hip_hit_t *ptr             = NULL;
-    struct in6_addr *proxy_hit = NULL;
-
-    HIP_IFEL( !(proxy_hit = hip_fw_get_default_hit()), 0,
-              "Error while getting the default HIT!\n");
-
-    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_HIT_PEER);
-    if (ptr) {
-        memcpy(&peer_hit, ptr, sizeof(hip_hit_t));
-        HIP_DEBUG_HIT("peer_hit", &peer_hit);
-        fallback = 0;
-    }
-
-    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_HIT_LOCAL);
-    if (ptr) {
-        memcpy(&local_hit, ptr, sizeof(hip_hit_t));
-        HIP_DEBUG_HIT("local_hit", &local_hit);
-    }
-
-    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_IPV6_ADDR_PEER);
-    if (ptr) {
-        memcpy(&peer_addr, ptr, sizeof(struct in6_addr));
-        HIP_DEBUG_IN6ADDR("peer_addr", &peer_addr);
-        addr_found++;
-    }
-
-    ptr = (hip_hit_t *) hip_get_param_contents(msg, HIP_PARAM_IPV6_ADDR_LOCAL);
-    if (ptr) {
-        memcpy(&local_addr, ptr, sizeof(hip_hit_t));
-        HIP_DEBUG_IN6ADDR("local_addr", &local_addr);
-        addr_found++;
-    }
-
-    if (addr_found != 2) {
-        HIP_ERROR("Internal error: two addr not found\n");
-        err = -1;
-    }
-
-    ptr = hip_get_param(msg, HIP_PARAM_AGENT_REJECT);
-    if (ptr) {
-        HIP_DEBUG("Connection is to be rejected\n");
-        reject = 1;
-    }
-
-    if (reject) {
-        HIP_DEBUG("Connection should be rejected\n");
-        err = -1;
-        goto out_err;
-    }
-
-    if (fallback) {
-        HIP_DEBUG("Peer does not support HIP, fallback\n");
-        //update the state of the ip pair
-        if (hip_proxy_update_state(NULL, &peer_addr, NULL, NULL, NULL,
-                                   HIP_PROXY_PASSTHROUGH)) {
-            HIP_ERROR("Proxy update Failed!\n");
-        }
-
-        //let the packet pass
-        err = -1;
-    } else {
-        if (hip_proxy_update_state(NULL, &peer_addr, &local_addr, proxy_hit,
-                                   &peer_hit, HIP_PROXY_TRANSLATE)) {
-            HIP_ERROR("Proxy update Failed!\n");
-        }
-
-#if 0
-        if (hip_proxy_conn_add_entry(&local_addr,
-                                     &peer_addr,
-                                     proxy_hit,
-                                     &peer_hit,
-                                     protocol,
-                                     port_client,
-                                     port_peer,
-                                     HIP_PROXY_TRANSLATE)) {
-            HIP_ERROR("ConnDB add entry Failed!\n");
-        }
-#endif
-
-        /* Drop packet. Firewall translates further retransmissions correctly 
*/
-        err = 0;
-    }
-
-out_err:
-
-    return err;
-}
-
-/**
  * Initialize the IPv6 socket for TCP connection
  *
  * @param hip_raw_sock_v6 the socket pointer used for TCP connection in IPv6

=== modified file 'firewall/proxy.h'
--- firewall/proxy.h    2010-04-09 21:10:27 +0000
+++ firewall/proxy.h    2010-04-13 16:39:45 +0000
@@ -18,7 +18,6 @@
 
 int init_proxy(void);
 int uninit_proxy(void);
-int hip_fw_proxy_set_peer_hit(hip_common_t *msg);
 int handle_proxy_outbound_traffic(const ipq_packet_msg_t *m,
                                   const struct in6_addr *src_addr,
                                   const struct in6_addr *dst_addr,

Other related posts:

  • » [hipl-commit] [trunk] Rev 4267: Move hip_fw_proxy_set_peer_hit() to where it is used and make it static. - Diego Biurrun