- several minor fixes
authorJulius Bünger <buenger@mytum.de>
Tue, 10 Mar 2015 12:20:25 +0000 (12:20 +0000)
committerJulius Bünger <buenger@mytum.de>
Tue, 10 Mar 2015 12:20:25 +0000 (12:20 +0000)
.gitignore
src/rps/gnunet-service-rps.c
src/rps/rps.h
src/rps/rps_api.c
src/rps/test_rps.conf
src/rps/test_rps_malicious_1.c

index 9755bb9a71fa3ad8e6cce1f47c195b965a5ceac9..1f09415690279e24ffc7e7f9d3b9c8c58a3ede65 100644 (file)
 # /src/rps/
 /src/rps/rps.conf
 /src/rps/test_rps_multipeer
+/src/rps/test_rps_malicious*
 /src/rps/Makefile.in
 /src/rps/Makefile
 /src/rps/.deps
index 923540db0e979cccfbe47e7b3d931ec64cf4db6e..4e9f795c321abc24624c02d962b6d42a91303f0a 100644 (file)
@@ -379,7 +379,7 @@ static uint32_t num_mal_peers;
 /**
  * If type is 2 this is the attacked peer
  */
-struct struct GNUNET_PeerIdentity attacked_peer;
+static struct GNUNET_PeerIdentity attacked_peer;
 #endif /* ENABLE_MALICIOUS */
 
 
@@ -1057,7 +1057,7 @@ handle_client_request (void *cls,
   msg = (struct GNUNET_RPS_CS_RequestMessage *) message;
 
   num_peers = ntohl (msg->num_peers);
-  size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) +
+  size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) +
                 num_peers * sizeof (struct GNUNET_PeerIdentity);
 
   if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
@@ -1303,7 +1303,7 @@ handle_peer_pull_reply (void *cls,
         || NULL != peer_ctx->recv_channel)
     {
       if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])
-          && GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i]))
+          && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i]))
         GNUNET_array_append (pull_list, pull_list_size, peers[i]);
     }
     else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx))
@@ -1339,12 +1339,13 @@ handle_peer_act_malicious (void *cls,
                            void **channel_ctx,
                            const struct GNUNET_MessageHeader *msg)
 {
+  struct GNUNET_RPS_CS_ActMaliciousMessage *in_msg;
+  struct GNUNET_PeerIdentity *sender;
+  struct PeerContext *sender_ctx;
   struct GNUNET_PeerIdentity *peers;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "PULL REPLY received\n");
-
   /* Check for protocol violation */
-  if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size))
+  if (sizeof (struct GNUNET_RPS_CS_ActMaliciousMessage) > ntohs (msg->size))
   {
     GNUNET_break_op (0);
     return GNUNET_SYSERR;
@@ -1375,11 +1376,16 @@ handle_peer_act_malicious (void *cls,
     return GNUNET_OK;
   }
 
+
   /* Do actual logic */
   peers = (struct GNUNET_PeerIdentity *) &msg[1];
-  num_peers = ntohl (in_msg->num_peers);
+  num_mal_peers = ntohl (in_msg->num_peers);
   mal_type = ntohl (in_msg->type);
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Now acting malicious type %" PRIX32 "\n",
+       mal_type);
+
   if (1 == mal_type)
   { /* Try to maximise representation */
     num_mal_peers = ntohl (in_msg->num_peers);
@@ -1395,6 +1401,8 @@ handle_peer_act_malicious (void *cls,
     memcpy (mal_peers, peers, num_mal_peers);
     attacked_peer = peers[num_mal_peers];
   }
+
+  return GNUNET_OK;
 }
 #endif /* ENABLE_MALICIOUS */
 
index eace8d5f15fb6d9783416d4ee66753ffc1a57890..0fbd2fb60462c6473d617b4198fa1431a50d6287 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "gnunet_rps_service.h"
+//#define ENABLE_MALICIOUS 1
 
 /**
  * Mesh port used by RPS.
@@ -71,16 +72,15 @@ struct GNUNET_RPS_CS_RequestMessage
    */
   struct GNUNET_MessageHeader header;
 
-  /**
-   * Number of random peer requested
-   */
-  uint32_t num_peers GNUNET_PACKED; 
-
   /**
    * Identifyer of the message.
    */
   uint64_t n GNUNET_PACKED;
 
+  /**
+   * Number of random peer requested
+   */
+  uint32_t num_peers GNUNET_PACKED;
 };
 
 /**
@@ -101,7 +101,7 @@ struct GNUNET_RPS_CS_ReplyMessage
   /**
    * Number of random peer replied
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
 
   /* Followed by num_peers * GNUNET_PeerIdentity */
 };
@@ -119,7 +119,7 @@ struct GNUNET_RPS_CS_SeedMessage
   /**
    * Number of peers
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
 
   /* Followed by num_peers * GNUNET_PeerIdentity */
 };
@@ -147,7 +147,7 @@ struct GNUNET_RPS_CS_ActMaliciousMessage
   /**
    * Number of peers
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
 
   /* Followed by num_peers * GNUNET_PeerIdentity */
 };
index 30f0a75c55a909bce9cf8b614d79ba037e2abe88..91612c2f7ccffb04db50e088d49e004eec51e0be 100644 (file)
@@ -128,18 +128,14 @@ handle_reply (void *cls,
               const struct GNUNET_MessageHeader *message)
 {
   struct GNUNET_RPS_CS_ReplyMessage *msg;
-  //struct cb_cls_pack *pack;
-  //struct GNUNET_RPS_Handle *h;
   struct GNUNET_PeerIdentity *peers;
   struct GNUNET_RPS_Request_Handle *rh;
 
   /* Give the peers back */
   msg = (struct GNUNET_RPS_CS_ReplyMessage *) message;
-  //pack = (struct cb_cls_pack *) cls;
-  //h = (struct GNUNET_RPS_Handle *) cls;
   peers = (struct GNUNET_PeerIdentity *) &msg[1];
   rh = &req_handlers[msg->n];
-  rh->ready_cb((rh)->ready_cb_cls, msg->num_peers, peers);
+  rh->ready_cb((rh)->ready_cb_cls, msg->num_peers, peers); // FIXME? ntohl ()
 
   /* Disconnect */
   //GNUNET_CLIENT_disconnect(pack->service_conn);
@@ -270,7 +266,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h,
   {
     ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity),
         GNUNET_MESSAGE_TYPE_RPS_CS_SEED);
-    msg->num_peers = ntohl (num_peers_max);
+    msg->num_peers = htonl (num_peers_max);
     memcpy (&msg[1], tmp_peer_pointer, num_peers_max * sizeof (struct GNUNET_PeerIdentity));
     GNUNET_MQ_send (h->mq, ev);
 
index 9db6711eae98eb84010864f04038f65cb7383705..45f62133a02dae3db2c9c05f9d43da49d75b8bf0 100644 (file)
@@ -23,7 +23,8 @@ HOSTNAME = localhost
 OPERATION_TIMEOUT = 60 s
 
 MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1
-OVERLAY_TOPOLOGY = CLIQUE
+#OVERLAY_TOPOLOGY = CLIQUE
+OVERLAY_TOPOLOGY = SMALL_WORLD
 SCALE_FREE_TOPOLOGY_CAP = 
 
 OVERLAY_RANDOM_LINKS = 5
index 304e46973a071091965838e53b376d47402b545e..a30607d8787af5b3b01568ce813717e96e77cdad 100644 (file)
@@ -242,8 +242,11 @@ rps_connect_adapter (void *cls,
   h = GNUNET_RPS_connect (cfg);
 
   #if ENABLE_MALICIOUS
+  GNUNET_assert (1 >= portion
+                 && 0 <  portion);
+
   num_mal_peers = round (portion * NUM_PEERS);
-  GNUNET_RPS_act_malicious (h, htonl (1), htonl (num_mal_peers), rps_peer_ids);
+  GNUNET_RPS_act_malicious (h, htonl (1), num_mal_peers, rps_peer_ids);
   #endif /* ENABLE_MALICIOUS */
 
   return h;