gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r35366 - in gnunet: . src/rps


From: gnunet
Subject: [GNUnet-SVN] r35366 - in gnunet: . src/rps
Date: Tue, 10 Mar 2015 13:20:25 +0100

Author: ch3
Date: 2015-03-10 13:20:25 +0100 (Tue, 10 Mar 2015)
New Revision: 35366

Modified:
   gnunet/.gitignore
   gnunet/src/rps/gnunet-service-rps.c
   gnunet/src/rps/rps.h
   gnunet/src/rps/rps_api.c
   gnunet/src/rps/test_rps.conf
   gnunet/src/rps/test_rps_malicious_1.c
Log:
- several minor fixes

Modified: gnunet/.gitignore
===================================================================
--- gnunet/.gitignore   2015-03-09 11:59:33 UTC (rev 35365)
+++ gnunet/.gitignore   2015-03-10 12:20:25 UTC (rev 35366)
@@ -1004,6 +1004,7 @@
 # /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

Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-03-09 11:59:33 UTC (rev 35365)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-03-10 12:20:25 UTC (rev 35366)
@@ -379,7 +379,7 @@
 /**
  * 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 @@
   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 @@
         || 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 @@
                            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 @@
     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 @@
     memcpy (mal_peers, peers, num_mal_peers);
     attacked_peer = peers[num_mal_peers];
   }
+
+  return GNUNET_OK;
 }
 #endif /* ENABLE_MALICIOUS */
 

Modified: gnunet/src/rps/rps.h
===================================================================
--- gnunet/src/rps/rps.h        2015-03-09 11:59:33 UTC (rev 35365)
+++ gnunet/src/rps/rps.h        2015-03-10 12:20:25 UTC (rev 35366)
@@ -24,6 +24,7 @@
  */
 
 #include "gnunet_rps_service.h"
+//#define ENABLE_MALICIOUS 1
 
 /**
  * Mesh port used by RPS.
@@ -72,15 +73,14 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * Number of random peer requested
+   * Identifyer of the message.
    */
-  uint32_t num_peers GNUNET_PACKED; 
+  uint64_t n GNUNET_PACKED;
 
   /**
-   * Identifyer of the message.
+   * Number of random peer requested
    */
-  uint64_t n GNUNET_PACKED;
-
+  uint32_t num_peers GNUNET_PACKED;
 };
 
 /**
@@ -101,7 +101,7 @@
   /**
    * 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 @@
   /**
    * 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 @@
   /**
    * Number of peers
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
 
   /* Followed by num_peers * GNUNET_PeerIdentity */
 };

Modified: gnunet/src/rps/rps_api.c
===================================================================
--- gnunet/src/rps/rps_api.c    2015-03-09 11:59:33 UTC (rev 35365)
+++ gnunet/src/rps/rps_api.c    2015-03-10 12:20:25 UTC (rev 35366)
@@ -128,18 +128,14 @@
               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 @@
   {
     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);
 

Modified: gnunet/src/rps/test_rps.conf
===================================================================
--- gnunet/src/rps/test_rps.conf        2015-03-09 11:59:33 UTC (rev 35365)
+++ gnunet/src/rps/test_rps.conf        2015-03-10 12:20:25 UTC (rev 35366)
@@ -23,7 +23,8 @@
 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

Modified: gnunet/src/rps/test_rps_malicious_1.c
===================================================================
--- gnunet/src/rps/test_rps_malicious_1.c       2015-03-09 11:59:33 UTC (rev 
35365)
+++ gnunet/src/rps/test_rps_malicious_1.c       2015-03-10 12:20:25 UTC (rev 
35366)
@@ -242,8 +242,11 @@
   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;




reply via email to

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