gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37714 - gnunet/src/rps


From: gnunet
Subject: [GNUnet-SVN] r37714 - gnunet/src/rps
Date: Sun, 14 Aug 2016 11:58:55 +0200

Author: grothoff
Date: 2016-08-14 11:58:55 +0200 (Sun, 14 Aug 2016)
New Revision: 37714

Modified:
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/gnunet-service-rps_peers.c
Log:
-slightly better port setup, for RPS I don't quite see a better way yet

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2016-08-14 09:49:29 UTC (rev 37713)
+++ gnunet/src/rps/gnunet-service-rps.c 2016-08-14 09:58:55 UTC (rev 37714)
@@ -24,6 +24,7 @@
  * @author Julius Bünger
  */
 #include "platform.h"
+#include "gnunet_applications.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_cadet_service.h"
 #include "gnunet_peerinfo_service.h"
@@ -2233,14 +2234,24 @@
  * @param server the initialized server
  * @param c configuration to use
  */
-  static void
+static void
 run (void *cls,
      struct GNUNET_SERVER_Handle *server,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
+  static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
+    {&handle_peer_push        , GNUNET_MESSAGE_TYPE_RPS_PP_PUSH        ,
+      sizeof (struct GNUNET_MessageHeader)},
+    {&handle_peer_pull_request, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
+      sizeof (struct GNUNET_MessageHeader)},
+    {&handle_peer_pull_reply  , GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY  , 0},
+    {NULL, 0, 0}
+  };
+
   int size;
   int out_size;
   char* fn_valid_peers;
+  struct GNUNET_HashCode port;
 
   GNUNET_log_setup ("rps", GNUNET_error_type_to_string 
(GNUNET_ERROR_TYPE_DEBUG), NULL);
   cfg = c;
@@ -2326,20 +2337,16 @@
 
 
   /* Initialise cadet */
-  static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
-    {&handle_peer_push        , GNUNET_MESSAGE_TYPE_RPS_PP_PUSH        ,
-      sizeof (struct GNUNET_MessageHeader)},
-    {&handle_peer_pull_request, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
-      sizeof (struct GNUNET_MessageHeader)},
-    {&handle_peer_pull_reply  , GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY  , 0},
-    {NULL, 0, 0}
-  };
   cadet_handle = GNUNET_CADET_connect (cfg,
                                        cls,
                                        &cleanup_destroyed_channel,
                                        cadet_handlers);
   GNUNET_assert (NULL != cadet_handle);
-  GNUNET_CADET_open_port (cadet_handle, GC_u2h (GNUNET_RPS_CADET_PORT),
+  GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS,
+                      strlen (GNUNET_APPLICATION_PORT_RPS),
+                      &port);
+  GNUNET_CADET_open_port (cadet_handle,
+                          &port,
                           &Peers_handle_inbound_channel, cls);
 
 

Modified: gnunet/src/rps/gnunet-service-rps_peers.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps_peers.c   2016-08-14 09:49:29 UTC (rev 
37713)
+++ gnunet/src/rps/gnunet-service-rps_peers.c   2016-08-14 09:58:55 UTC (rev 
37714)
@@ -24,6 +24,7 @@
  * @author Julius Bünger
  */
 #include "platform.h"
+#include "gnunet_applications.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_cadet_service.h"
 #include <inttypes.h>
@@ -271,6 +272,7 @@
   return ctx;
 }
 
+
 /**
  * @brief Create a new #PeerContext and insert it into the peer map
  *
@@ -296,6 +298,7 @@
   return ctx;
 }
 
+
 /**
  * @brief Create or get a #PeerContext
  *
@@ -313,6 +316,7 @@
   return get_peer_ctx (peer);
 }
 
+
 /**
  * @brief Check whether we have a connection to this @a peer
  *
@@ -347,6 +351,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief The closure to #get_rand_peer_iterator.
  */
@@ -365,6 +370,7 @@
   const struct GNUNET_PeerIdentity *peer;
 };
 
+
 /**
  * @brief Iterator function for #get_random_peer_from_peermap.
  *
@@ -395,6 +401,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief Get a random peer from @a peer_map
  *
@@ -420,6 +427,7 @@
   return ret;
 }
 
+
 /**
  * @brief Add a given @a peer to valid peers.
  *
@@ -448,6 +456,7 @@
   return ret;
 }
 
+
 /**
  * @brief Set the peer flag to living and
  *        call the pending operations on this peer.
@@ -485,6 +494,7 @@
   GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0);
 }
 
+
 /**
  * @brief Get the channel of a peer. If not existing, create.
  *
@@ -495,6 +505,7 @@
 get_channel (const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *peer_ctx;
+  struct GNUNET_HashCode port;
 
   peer_ctx = get_peer_ctx (peer);
   if (NULL == peer_ctx->send_channel)
@@ -502,11 +513,14 @@
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Trying to establish channel to peer %s\n",
          GNUNET_i2s (peer));
+    GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS,
+                        strlen (GNUNET_APPLICATION_PORT_RPS),
+                        &port);
     peer_ctx->send_channel =
       GNUNET_CADET_channel_create (cadet_handle,
                                    peer_ctx->send_channel_flags, /* context */
                                    peer,
-                                   GC_u2h (GNUNET_RPS_CADET_PORT),
+                                   &port,
                                    GNUNET_CADET_OPTION_RELIABLE);
   }
   GNUNET_assert (NULL != peer_ctx->send_channel);
@@ -513,6 +527,7 @@
   return peer_ctx->send_channel;
 }
 
+
 /**
  * Get the message queue (#GNUNET_MQ_Handle) of a specific peer.
  *
@@ -653,6 +668,7 @@
   return pending_msg;
 }
 
+
 /**
  * @brief Remove a pending message from the respective DLL
  *
@@ -673,6 +689,7 @@
   GNUNET_free (pending_msg);
 }
 
+
 /**
  * @brief Check whether function of type #PeerOp was already scheduled
  *
@@ -699,6 +716,7 @@
   return GNUNET_NO;
 }
 
+
 /**
  * Iterator over hash map entries. Deletes all contexts of peers.
  *
@@ -717,6 +735,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief This is called once a message is sent.
  *
@@ -734,6 +753,7 @@
   remove_pending_message (pending_msg);
 }
 
+
 /**
  * @brief Iterator function for #store_valid_peers.
  *
@@ -774,6 +794,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief Store the peers currently in #valid_peers to disk.
  */
@@ -828,6 +849,7 @@
       GNUNET_CONTAINER_multipeermap_size (valid_peers));
 }
 
+
 /**
  * @brief Convert string representation of peer id to peer id.
  *
@@ -873,6 +895,7 @@
   return peer;
 }
 
+
 /**
  * @brief Restore the peers on disk to #valid_peers.
  */
@@ -926,6 +949,7 @@
       num_peers);
 }
 
+
 /**
  * @brief Initialise storage of peers
  *
@@ -946,6 +970,7 @@
   restore_valid_peers ();
 }
 
+
 /**
  * @brief Delete storage of peers that was created with #Peers_initialise ()
  */
@@ -1014,6 +1039,7 @@
   return ret;
 }
 
+
 /**
  * @brief Add peer to known peers.
  *
@@ -1068,6 +1094,7 @@
   return ret;
 }
 
+
 /**
  * @brief Remove unecessary data
  *
@@ -1102,6 +1129,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief Remove peer
  *
@@ -1173,6 +1201,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief set flags on a given peer.
  *
@@ -1188,6 +1217,7 @@
   set_peer_flag (peer_ctx, flags);
 }
 
+
 /**
  * @brief unset flags on a given peer.
  *
@@ -1203,6 +1233,7 @@
   unset_peer_flag (peer_ctx, flags);
 }
 
+
 /**
  * @brief Check whether flags on a peer are set.
  *
@@ -1239,6 +1270,7 @@
   set_channel_flag (channel_flags, flags);
 }
 
+
 /**
  * @brief unset flags on a given channel.
  *
@@ -1251,6 +1283,7 @@
   unset_channel_flag (channel_flags, flags);
 }
 
+
 /**
  * @brief Check whether flags on a channel are set.
  *
@@ -1266,6 +1299,7 @@
   return check_channel_flag_set (channel_flags, flags);
 }
 
+
 /**
  * @brief Check whether we have information about the given peer.
  *
@@ -1282,6 +1316,7 @@
   return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
 }
 
+
 /**
  * @brief Check whether @a peer is actually a peer.
  *
@@ -1298,6 +1333,7 @@
   return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer);
 }
 
+
 /**
  * @brief Indicate that we want to send to the other peer
  *
@@ -1312,6 +1348,7 @@
   (void) get_channel (peer);
 }
 
+
 /**
  * @brief Check whether other peer has the intention to send/opened channel
  *        towars us
@@ -1334,6 +1371,7 @@
   return GNUNET_NO;
 }
 
+
 /**
  * Handle the channel a peer opens to us.
  *
@@ -1375,6 +1413,7 @@
   return peer_ctx->recv_channel_flags;
 }
 
+
 /**
  * @brief Check whether a sending channel towards the given peer exists
  *
@@ -1400,6 +1439,7 @@
   return GNUNET_YES;
 }
 
+
 /**
  * @brief check whether the given channel is the sending channel of the given
  *        peer
@@ -1437,6 +1477,7 @@
   return GNUNET_NO;
 }
 
+
 /**
  * @brief Destroy the send channel of a peer e.g. stop indicating a sending
  *        intention to another peer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]