aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-27 13:42:08 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-27 13:42:08 +0000
commit8d9e724fe53ec6ddb0a02c2c981ea8ff1379f727 (patch)
tree00a66c4d85b0a9c640af29b3f303b341bebed5d7 /src
parent3d3109aa4c8c25d9292e9e94d878121af0084d07 (diff)
downloadgnunet-8d9e724fe53ec6ddb0a02c2c981ea8ff1379f727.tar.gz
gnunet-8d9e724fe53ec6ddb0a02c2c981ea8ff1379f727.zip
-indentation, doxygen, etc.
Diffstat (limited to 'src')
-rw-r--r--src/testbed/gnunet-service-testbed_connectionpool.c24
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c180
-rw-r--r--src/testbed/testbed_api.c39
-rw-r--r--src/testbed/testbed_api_topology.c98
4 files changed, 208 insertions, 133 deletions
diff --git a/src/testbed/gnunet-service-testbed_connectionpool.c b/src/testbed/gnunet-service-testbed_connectionpool.c
index 1067bc00e..0f65edf15 100644
--- a/src/testbed/gnunet-service-testbed_connectionpool.c
+++ b/src/testbed/gnunet-service-testbed_connectionpool.c
@@ -568,12 +568,12 @@ core_peer_connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
568 568
569 569
570/** 570/**
571 * Function called after GNUNET_CORE_connect has succeeded (or failed 571 * Function called after #GNUNET_CORE_connect() has succeeded (or failed
572 * for good). Note that the private key of the peer is intentionally 572 * for good). Note that the private key of the peer is intentionally
573 * not exposed here; if you need it, your process should try to read 573 * not exposed here; if you need it, your process should try to read
574 * the private key file directly (which should work if you are 574 * the private key file directly (which should work if you are
575 * authorized...). Implementations of this function must not call 575 * authorized...). Implementations of this function must not call
576 * GNUNET_CORE_disconnect (other than by scheduling a new task to 576 * #GNUNET_CORE_disconnect() (other than by scheduling a new task to
577 * do this later). 577 * do this later).
578 * 578 *
579 * @param cls the #PooledConnection object 579 * @param cls the #PooledConnection object
@@ -816,7 +816,9 @@ GST_connection_pool_get_handle (unsigned int peer_id,
816 } 816 }
817 else 817 else
818 { 818 {
819 GNUNET_CONTAINER_DLL_insert_tail (head_not_pooled, tail_not_pooled, entry); 819 GNUNET_CONTAINER_DLL_insert_tail (head_not_pooled,
820 tail_not_pooled,
821 entry);
820 } 822 }
821 entry->cfg = GNUNET_CONFIGURATION_dup (cfg); 823 entry->cfg = GNUNET_CONFIGURATION_dup (cfg);
822 } 824 }
@@ -829,13 +831,16 @@ GST_connection_pool_get_handle (unsigned int peer_id,
829 gh->connect_notify_cb = connect_notify_cb; 831 gh->connect_notify_cb = connect_notify_cb;
830 gh->connect_notify_cb_cls = connect_notify_cb_cls; 832 gh->connect_notify_cb_cls = connect_notify_cb_cls;
831 gh->service = service; 833 gh->service = service;
832 GNUNET_CONTAINER_DLL_insert (entry->head_waiting, entry->tail_waiting, gh); 834 GNUNET_CONTAINER_DLL_insert (entry->head_waiting,
835 entry->tail_waiting,
836 gh);
833 if (NULL != handle) 837 if (NULL != handle)
834 { 838 {
835 if (NULL == entry->notify_task) 839 if (NULL == entry->notify_task)
836 { 840 {
837 if (NULL != search_waiting (entry, entry->head_waiting)) 841 if (NULL != search_waiting (entry, entry->head_waiting))
838 entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready, entry); 842 entry->notify_task = GNUNET_SCHEDULER_add_now (&connection_ready,
843 entry);
839 } 844 }
840 return gh; 845 return gh;
841 } 846 }
@@ -845,19 +850,22 @@ GST_connection_pool_get_handle (unsigned int peer_id,
845 case GST_CONNECTIONPOOL_SERVICE_TRANSPORT: 850 case GST_CONNECTIONPOOL_SERVICE_TRANSPORT:
846 if (NULL != entry->op_transport) 851 if (NULL != entry->op_transport)
847 return gh; /* Operation pending */ 852 return gh; /* Operation pending */
848 op = GNUNET_TESTBED_operation_create_ (entry, &opstart_get_handle_transport, 853 op = GNUNET_TESTBED_operation_create_ (entry,
854 &opstart_get_handle_transport,
849 &oprelease_get_handle_transport); 855 &oprelease_get_handle_transport);
850 entry->op_transport = op; 856 entry->op_transport = op;
851 break; 857 break;
852 case GST_CONNECTIONPOOL_SERVICE_CORE: 858 case GST_CONNECTIONPOOL_SERVICE_CORE:
853 if (NULL != entry->op_core) 859 if (NULL != entry->op_core)
854 return gh; /* Operation pending */ 860 return gh; /* Operation pending */
855 op = GNUNET_TESTBED_operation_create_ (entry, &opstart_get_handle_core, 861 op = GNUNET_TESTBED_operation_create_ (entry,
862 &opstart_get_handle_core,
856 &oprelease_get_handle_core); 863 &oprelease_get_handle_core);
857 entry->op_core = op; 864 entry->op_core = op;
858 break; 865 break;
859 } 866 }
860 GNUNET_TESTBED_operation_queue_insert_ (GST_opq_openfds, op); 867 GNUNET_TESTBED_operation_queue_insert_ (GST_opq_openfds,
868 op);
861 GNUNET_TESTBED_operation_begin_wait_ (op); 869 GNUNET_TESTBED_operation_begin_wait_ (op);
862 return gh; 870 return gh;
863} 871}
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index 1d57499f7..bb3a04e93 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -65,7 +65,7 @@ struct TryConnectContext
65 /** 65 /**
66 * The task handle 66 * The task handle
67 */ 67 */
68 struct GNUNET_SCHEDULER_Task * task; 68 struct GNUNET_SCHEDULER_Task *task;
69 69
70 /** 70 /**
71 * The id of the operation which is resposible for this context 71 * The id of the operation which is resposible for this context
@@ -131,7 +131,7 @@ struct LocalPeer2Context
131struct RemotePeer2Context 131struct RemotePeer2Context
132{ 132{
133 /** 133 /**
134 * Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay 134 * Controller of peer 2; If #OCC_TYPE_REMOTE_LATERAL is the type of overlay
135 * connection then this can be NULL until the connection to the controller is 135 * connection then this can be NULL until the connection to the controller is
136 * established 136 * established
137 */ 137 */
@@ -145,7 +145,7 @@ struct RemotePeer2Context
145 145
146 /** 146 /**
147 * Notification handle acquire to connect to a remote controller. Only used 147 * Notification handle acquire to connect to a remote controller. Only used
148 * if the type of overlay connection is OCC_TYPE_REMOTE_LATERAL. 148 * if the type of overlay connection is #OCC_TYPE_REMOTE_LATERAL.
149 */ 149 */
150 struct NeighbourConnectNotification *ncn; 150 struct NeighbourConnectNotification *ncn;
151 151
@@ -250,17 +250,17 @@ struct OverlayConnectContext
250 * The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to 250 * The id of the task for sending HELLO of peer 2 to peer 1 and ask peer 1 to
251 * connect to peer 2 251 * connect to peer 2
252 */ 252 */
253 struct GNUNET_SCHEDULER_Task * send_hello_task; 253 struct GNUNET_SCHEDULER_Task *send_hello_task;
254 254
255 /** 255 /**
256 * The id of the overlay connect timeout task 256 * The id of the overlay connect timeout task
257 */ 257 */
258 struct GNUNET_SCHEDULER_Task * timeout_task; 258 struct GNUNET_SCHEDULER_Task *timeout_task;
259 259
260 /** 260 /**
261 * The id of the cleanup task 261 * The id of the cleanup task
262 */ 262 */
263 struct GNUNET_SCHEDULER_Task * cleanup_task; 263 struct GNUNET_SCHEDULER_Task *cleanup_task;
264 264
265 /** 265 /**
266 * The type of this context information 266 * The type of this context information
@@ -321,12 +321,12 @@ struct RemoteOverlayConnectCtx
321 /** 321 /**
322 * Task for offering HELLO of A to B and doing try_connect 322 * Task for offering HELLO of A to B and doing try_connect
323 */ 323 */
324 struct GNUNET_SCHEDULER_Task * attempt_connect_task_id; 324 struct GNUNET_SCHEDULER_Task *attempt_connect_task_id;
325 325
326 /** 326 /**
327 * Task to timeout RequestOverlayConnect 327 * Task to timeout RequestOverlayConnect
328 */ 328 */
329 struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id; 329 struct GNUNET_SCHEDULER_Task *timeout_rocc_task_id;
330 330
331 /** 331 /**
332 * The id of the operation responsible for creating this context 332 * The id of the operation responsible for creating this context
@@ -833,7 +833,8 @@ send_hello_thru_rocc (struct OverlayConnectContext *occ)
833 * @param tc the TaskContext from scheduler 833 * @param tc the TaskContext from scheduler
834 */ 834 */
835static void 835static void
836send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 836send_hello (void *cls,
837 const struct GNUNET_SCHEDULER_TaskContext *tc)
837{ 838{
838 struct OverlayConnectContext *occ = cls; 839 struct OverlayConnectContext *occ = cls;
839 struct LocalPeer2Context *lp2c; 840 struct LocalPeer2Context *lp2c;
@@ -879,7 +880,8 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
879 * @param ignore_ peer identity which is ignored in this callback 880 * @param ignore_ peer identity which is ignored in this callback
880 */ 881 */
881static void 882static void
882p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch, 883p2_transport_connect_cache_callback (void *cls,
884 struct GNUNET_CORE_Handle *ch,
883 struct GNUNET_TRANSPORT_Handle *th, 885 struct GNUNET_TRANSPORT_Handle *th,
884 const struct GNUNET_PeerIdentity *ignore_) 886 const struct GNUNET_PeerIdentity *ignore_)
885{ 887{
@@ -888,7 +890,8 @@ p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
888 GNUNET_assert (OCC_TYPE_LOCAL == occ->type); 890 GNUNET_assert (OCC_TYPE_LOCAL == occ->type);
889 if (NULL == th) 891 if (NULL == th)
890 { 892 {
891 GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s", 893 GNUNET_asprintf (&occ->emsg,
894 "0x%llx: Cannot connect to TRANSPORT of %s",
892 occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); 895 occ->op_id, GNUNET_i2s (&occ->other_peer_identity));
893 GNUNET_SCHEDULER_cancel (occ->timeout_task); 896 GNUNET_SCHEDULER_cancel (occ->timeout_task);
894 occ->timeout_task = 897 occ->timeout_task =
@@ -896,8 +899,10 @@ p2_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
896 return; 899 return;
897 } 900 }
898 occ->p2ctx.local.tcc.th_ = th; 901 occ->p2ctx.local.tcc.th_ = th;
899 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s", 902 GNUNET_asprintf (&occ->emsg,
900 occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); 903 "0x%llx: Timeout while offering HELLO to %s",
904 occ->op_id,
905 GNUNET_i2s (&occ->other_peer_identity));
901 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); 906 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ);
902} 907}
903 908
@@ -929,8 +934,10 @@ p2_transport_connect (struct OverlayConnectContext *occ)
929 occ, NULL, NULL, NULL); 934 occ, NULL, NULL, NULL);
930 return; 935 return;
931 } 936 }
932 GNUNET_asprintf (&occ->emsg, "0x%llx: Timeout while offering HELLO to %s", 937 GNUNET_asprintf (&occ->emsg,
933 occ->op_id, GNUNET_i2s (&occ->other_peer_identity)); 938 "0x%llx: Timeout while offering HELLO to %s",
939 occ->op_id,
940 GNUNET_i2s (&occ->other_peer_identity));
934 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); 941 occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ);
935} 942}
936 943
@@ -944,7 +951,8 @@ p2_transport_connect (struct OverlayConnectContext *occ)
944 * @return 951 * @return
945 */ 952 */
946static int 953static int
947test_address (void *cls, const struct GNUNET_HELLO_Address *address, 954test_address (void *cls,
955 const struct GNUNET_HELLO_Address *address,
948 struct GNUNET_TIME_Absolute expiration) 956 struct GNUNET_TIME_Absolute expiration)
949{ 957{
950 int *empty = cls; 958 int *empty = cls;
@@ -963,7 +971,8 @@ test_address (void *cls, const struct GNUNET_HELLO_Address *address,
963 * @param hello our updated HELLO 971 * @param hello our updated HELLO
964 */ 972 */
965static void 973static void
966hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) 974hello_update_cb (void *cls,
975 const struct GNUNET_MessageHeader *hello)
967{ 976{
968 struct OverlayConnectContext *occ = cls; 977 struct OverlayConnectContext *occ = cls;
969 int empty; 978 int empty;
@@ -972,15 +981,18 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello)
972 msize = ntohs (hello->size); 981 msize = ntohs (hello->size);
973 empty = GNUNET_YES; 982 empty = GNUNET_YES;
974 (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) 983 (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *)
975 hello, GNUNET_NO, &test_address, 984 hello, GNUNET_NO,
985 &test_address,
976 &empty); 986 &empty);
977 if (GNUNET_YES == empty) 987 if (GNUNET_YES == empty)
978 { 988 {
979 LOG_DEBUG ("0x%llx: HELLO of %s is empty\n", occ->op_id, 989 LOG_DEBUG ("0x%llx: HELLO of %s is empty\n",
990 occ->op_id,
980 GNUNET_i2s (&occ->peer_identity)); 991 GNUNET_i2s (&occ->peer_identity));
981 return; 992 return;
982 } 993 }
983 LOG_DEBUG ("0x%llx: Received HELLO of %s\n", occ->op_id, 994 LOG_DEBUG ("0x%llx: Received HELLO of %s\n",
995 occ->op_id,
984 GNUNET_i2s (&occ->peer_identity)); 996 GNUNET_i2s (&occ->peer_identity));
985 occ->hello = GNUNET_malloc (msize); 997 occ->hello = GNUNET_malloc (msize);
986 GST_cache_add_hello (occ->peer->id, hello); 998 GST_cache_add_hello (occ->peer->id, hello);
@@ -1015,8 +1027,10 @@ p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
1015 occ->emsg = NULL; 1027 occ->emsg = NULL;
1016 if (NULL == th) 1028 if (NULL == th)
1017 { 1029 {
1018 GNUNET_asprintf (&occ->emsg, "0x%llx: Cannot connect to TRANSPORT of %s", 1030 GNUNET_asprintf (&occ->emsg,
1019 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 1031 "0x%llx: Cannot connect to TRANSPORT of %s",
1032 occ->op_id,
1033 GNUNET_i2s (&occ->peer_identity));
1020 GNUNET_SCHEDULER_cancel (occ->timeout_task); 1034 GNUNET_SCHEDULER_cancel (occ->timeout_task);
1021 occ->timeout_task = 1035 occ->timeout_task =
1022 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 1036 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
@@ -1026,9 +1040,12 @@ p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
1026 GNUNET_assert (NULL != occ->cgh_p1th); 1040 GNUNET_assert (NULL != occ->cgh_p1th);
1027 occ->p1th_ = th; 1041 occ->p1th_ = th;
1028 GNUNET_asprintf (&occ->emsg, 1042 GNUNET_asprintf (&occ->emsg,
1029 "0x%llx: Timeout while acquiring HELLO of peer %4s", 1043 "0x%llx: Timeout while acquiring HELLO of peer %s",
1030 occ->op_id, GNUNET_i2s (&occ->peer_identity)); 1044 occ->op_id,
1031 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th_, &hello_update_cb, occ); 1045 GNUNET_i2s (&occ->peer_identity));
1046 occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p1th_,
1047 &hello_update_cb,
1048 occ);
1032} 1049}
1033 1050
1034 1051
@@ -1041,7 +1058,8 @@ p1_transport_connect_cache_callback (void *cls, struct GNUNET_CORE_Handle *ch,
1041 * @param my_identity the identity of our peer 1058 * @param my_identity the identity of our peer
1042 */ 1059 */
1043static void 1060static void
1044occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch, 1061occ_cache_get_handle_core_cb (void *cls,
1062 struct GNUNET_CORE_Handle *ch,
1045 struct GNUNET_TRANSPORT_Handle *th, 1063 struct GNUNET_TRANSPORT_Handle *th,
1046 const struct GNUNET_PeerIdentity *my_identity) 1064 const struct GNUNET_PeerIdentity *my_identity)
1047{ 1065{
@@ -1054,7 +1072,9 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1054 { 1072 {
1055 GNUNET_asprintf (&occ->emsg, 1073 GNUNET_asprintf (&occ->emsg,
1056 "0x%llx: Failed to connect to CORE of peer with " 1074 "0x%llx: Failed to connect to CORE of peer with "
1057 "id: %u", occ->op_id, occ->peer->id); 1075 "id: %u",
1076 occ->op_id,
1077 occ->peer->id);
1058 GNUNET_SCHEDULER_cancel (occ->timeout_task); 1078 GNUNET_SCHEDULER_cancel (occ->timeout_task);
1059 occ->timeout_task = 1079 occ->timeout_task =
1060 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); 1080 GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ);
@@ -1073,7 +1093,8 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1073 } 1093 }
1074 memcpy (&occ->peer_identity, my_identity, 1094 memcpy (&occ->peer_identity, my_identity,
1075 sizeof (struct GNUNET_PeerIdentity)); 1095 sizeof (struct GNUNET_PeerIdentity));
1076 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n", occ->op_id, 1096 LOG_DEBUG ("0x%llx: Acquiring HELLO of peer %s\n",
1097 occ->op_id,
1077 GNUNET_i2s (&occ->peer_identity)); 1098 GNUNET_i2s (&occ->peer_identity));
1078 /* Lookup for HELLO in hello cache */ 1099 /* Lookup for HELLO in hello cache */
1079 if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id))) 1100 if (NULL != (hello = GST_cache_lookup_hello (occ->peer->id)))
@@ -1105,7 +1126,8 @@ occ_cache_get_handle_core_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1105 * @param msg the peer create success message 1126 * @param msg the peer create success message
1106 */ 1127 */
1107static void 1128static void
1108overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) 1129overlay_connect_get_config (void *cls,
1130 const struct GNUNET_MessageHeader *msg)
1109{ 1131{
1110 struct OverlayConnectContext *occ = cls; 1132 struct OverlayConnectContext *occ = cls;
1111 struct RemotePeer2Context *rp2c; 1133 struct RemotePeer2Context *rp2c;
@@ -1123,19 +1145,22 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg)
1123 } 1145 }
1124 cmsg = 1146 cmsg =
1125 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; 1147 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
1126 memcpy (&occ->other_peer_identity, &cmsg->peer_identity, 1148 occ->other_peer_identity = cmsg->peer_identity;
1127 sizeof (struct GNUNET_PeerIdentity));
1128 GNUNET_free_non_null (occ->emsg); 1149 GNUNET_free_non_null (occ->emsg);
1129 GNUNET_asprintf (&occ->emsg, 1150 GNUNET_asprintf (&occ->emsg,
1130 "0x%llx: Timeout while connecting to CORE of peer with " 1151 "0x%llx: Timeout while connecting to CORE of peer with "
1131 "id: %u", occ->op_id, occ->peer->id); 1152 "id: %u",
1153 occ->op_id,
1154 occ->peer->id);
1132 occ->cgh_ch = 1155 occ->cgh_ch =
1133 GST_connection_pool_get_handle (occ->peer->id, 1156 GST_connection_pool_get_handle (occ->peer->id,
1134 occ->peer->details.local.cfg, 1157 occ->peer->details.local.cfg,
1135 GST_CONNECTIONPOOL_SERVICE_CORE, 1158 GST_CONNECTIONPOOL_SERVICE_CORE,
1136 occ_cache_get_handle_core_cb, occ, 1159 occ_cache_get_handle_core_cb,
1160 occ,
1137 &occ->other_peer_identity, 1161 &occ->other_peer_identity,
1138 &overlay_connect_notify, occ); 1162 &overlay_connect_notify,
1163 occ);
1139 return; 1164 return;
1140} 1165}
1141 1166
@@ -1162,12 +1187,13 @@ host_registration_comp (void *cls, const char *emsg)
1162 * @param cls pointer 2 pointer of RegisteredHostContext 1187 * @param cls pointer 2 pointer of RegisteredHostContext
1163 * @param key current key code 1188 * @param key current key code
1164 * @param value value in the hash map 1189 * @param value value in the hash map
1165 * @return GNUNET_YES if we should continue to 1190 * @return #GNUNET_YES if we should continue to
1166 * iterate, 1191 * iterate,
1167 * GNUNET_NO if not. 1192 * #GNUNET_NO if not.
1168 */ 1193 */
1169static int 1194static int
1170reghost_match_iterator (void *cls, const struct GNUNET_HashCode *key, 1195reghost_match_iterator (void *cls,
1196 const struct GNUNET_HashCode *key,
1171 void *value) 1197 void *value)
1172{ 1198{
1173 struct RegisteredHostContext **rh = cls; 1199 struct RegisteredHostContext **rh = cls;
@@ -1345,7 +1371,8 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg,
1345 * @param c handle to the controller connection 1371 * @param c handle to the controller connection
1346 */ 1372 */
1347static void 1373static void
1348p2_controller_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c) 1374p2_controller_connect_cb (void *cls,
1375 struct GNUNET_TESTBED_Controller *c)
1349{ 1376{
1350 struct OverlayConnectContext *occ = cls; 1377 struct OverlayConnectContext *occ = cls;
1351 struct RemotePeer2Context *rp2c; 1378 struct RemotePeer2Context *rp2c;
@@ -1369,19 +1396,22 @@ p2_controller_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c)
1369 GNUNET_free_non_null (occ->emsg); 1396 GNUNET_free_non_null (occ->emsg);
1370 GNUNET_asprintf (&occ->emsg, 1397 GNUNET_asprintf (&occ->emsg,
1371 "0x%llx: Timeout while getting peer identity of peer " 1398 "0x%llx: Timeout while getting peer identity of peer "
1372 "with id: %u", occ->op_id, occ->other_peer_id); 1399 "with id: %u",
1400 occ->op_id,
1401 occ->other_peer_id);
1373} 1402}
1374 1403
1375 1404
1376/** 1405/**
1377 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT messages 1406 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT messages
1378 * 1407 *
1379 * @param cls NULL 1408 * @param cls NULL
1380 * @param client identification of the client 1409 * @param client identification of the client
1381 * @param message the actual message 1410 * @param message the actual message
1382 */ 1411 */
1383void 1412void
1384GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, 1413GST_handle_overlay_connect (void *cls,
1414 struct GNUNET_SERVER_Client *client,
1385 const struct GNUNET_MessageHeader *message) 1415 const struct GNUNET_MessageHeader *message)
1386{ 1416{
1387 const struct GNUNET_TESTBED_OverlayConnectMessage *msg; 1417 const struct GNUNET_TESTBED_OverlayConnectMessage *msg;
@@ -1413,19 +1443,23 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1413 peer = GST_peer_list[p1]; 1443 peer = GST_peer_list[p1];
1414 operation_id = GNUNET_ntohll (msg->operation_id); 1444 operation_id = GNUNET_ntohll (msg->operation_id);
1415 LOG_DEBUG 1445 LOG_DEBUG
1416 ("Received overlay connect for peers %u and %u with op id: 0x%llx\n", p1, 1446 ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1417 p2, operation_id); 1447 p1,
1448 p2,
1449 operation_id);
1418 peer2_host_id = ntohl (msg->peer2_host_id); 1450 peer2_host_id = ntohl (msg->peer2_host_id);
1419 if (GNUNET_YES == peer->is_remote) 1451 if (GNUNET_YES == peer->is_remote)
1420 { 1452 {
1421 if (!VALID_HOST_ID (peer2_host_id)) 1453 if (! VALID_HOST_ID (peer2_host_id))
1422 { 1454 {
1423 GNUNET_break (0); 1455 GNUNET_break (0);
1424 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1456 GNUNET_SERVER_receive_done (client,
1457 GNUNET_SYSERR);
1425 return; 1458 return;
1426 } 1459 }
1427 forward_overlay_connect (msg, client); 1460 forward_overlay_connect (msg, client);
1428 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1461 GNUNET_SERVER_receive_done (client,
1462 GNUNET_OK);
1429 return; 1463 return;
1430 } 1464 }
1431 p2n = NULL; 1465 p2n = NULL;
@@ -1441,7 +1475,8 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1441 LOG (GNUNET_ERROR_TYPE_WARNING, 1475 LOG (GNUNET_ERROR_TYPE_WARNING,
1442 "0x%llx: Peer %u's host not in our neighbours list\n", 1476 "0x%llx: Peer %u's host not in our neighbours list\n",
1443 operation_id, p2); 1477 operation_id, p2);
1444 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1478 GNUNET_SERVER_receive_done (client,
1479 GNUNET_SYSERR);
1445 GNUNET_free (occ); 1480 GNUNET_free (occ);
1446 return; 1481 return;
1447 } 1482 }
@@ -1455,7 +1490,9 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1455 occ->type = OCC_TYPE_REMOTE_SLAVE; 1490 occ->type = OCC_TYPE_REMOTE_SLAVE;
1456 occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller; 1491 occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1457 } 1492 }
1458 GNUNET_CONTAINER_DLL_insert_tail (occq_head, occq_tail, occ); 1493 GNUNET_CONTAINER_DLL_insert_tail (occq_head,
1494 occq_tail,
1495 occ);
1459 GNUNET_SERVER_client_keep (client); 1496 GNUNET_SERVER_client_keep (client);
1460 occ->client = client; 1497 occ->client = client;
1461 occ->other_peer_id = p2; 1498 occ->other_peer_id = p2;
@@ -1464,13 +1501,18 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1464 occ->op_id = operation_id; 1501 occ->op_id = operation_id;
1465 GNUNET_assert (NULL == occ->timeout_task); 1502 GNUNET_assert (NULL == occ->timeout_task);
1466 occ->timeout_task = 1503 occ->timeout_task =
1467 GNUNET_SCHEDULER_add_delayed (GST_timeout, &timeout_overlay_connect, occ); 1504 GNUNET_SCHEDULER_add_delayed (GST_timeout,
1505 &timeout_overlay_connect,
1506 occ);
1468 switch (occ->type) 1507 switch (occ->type)
1469 { 1508 {
1470 case OCC_TYPE_REMOTE_LATERAL: 1509 case OCC_TYPE_REMOTE_LATERAL:
1471 GNUNET_asprintf (&occ->emsg, 1510 GNUNET_asprintf (&occ->emsg,
1472 "0x%llx: Timeout while acquiring connection to peer %u's " 1511 "0x%llx: Timeout while acquiring connection to peer %u's "
1473 "host: %u\n", occ->op_id, occ->other_peer_id, peer2_host_id); 1512 "host: %u\n",
1513 occ->op_id,
1514 occ->other_peer_id,
1515 peer2_host_id);
1474 occ->p2ctx.remote.ncn = 1516 occ->p2ctx.remote.ncn =
1475 GST_neighbour_get_connection (p2n, &p2_controller_connect_cb, occ); 1517 GST_neighbour_get_connection (p2n, &p2_controller_connect_cb, occ);
1476 break; 1518 break;
@@ -1484,7 +1526,9 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
1484 &occ->other_peer_identity); 1526 &occ->other_peer_identity);
1485 GNUNET_asprintf (&occ->emsg, 1527 GNUNET_asprintf (&occ->emsg,
1486 "0x%llx: Timeout while connecting to CORE of peer with " 1528 "0x%llx: Timeout while connecting to CORE of peer with "
1487 "id: %u", occ->op_id, occ->peer->id); 1529 "id: %u",
1530 occ->op_id,
1531 occ->peer->id);
1488 occ->cgh_ch = 1532 occ->cgh_ch =
1489 GST_connection_pool_get_handle (occ->peer->id, 1533 GST_connection_pool_get_handle (occ->peer->id,
1490 occ->peer->details.local.cfg, 1534 occ->peer->details.local.cfg,
@@ -1537,13 +1581,15 @@ cleanup_rocc (struct RemoteOverlayConnectCtx *rocc)
1537 * @param tc the TaskContext from scheduler 1581 * @param tc the TaskContext from scheduler
1538 */ 1582 */
1539static void 1583static void
1540timeout_rocc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1584timeout_rocc_task (void *cls,
1585 const struct GNUNET_SCHEDULER_TaskContext *tc)
1541{ 1586{
1542 struct RemoteOverlayConnectCtx *rocc = cls; 1587 struct RemoteOverlayConnectCtx *rocc = cls;
1543 1588
1544 GNUNET_assert (rocc->timeout_rocc_task_id != NULL); 1589 GNUNET_assert (rocc->timeout_rocc_task_id != NULL);
1545 rocc->timeout_rocc_task_id = NULL; 1590 rocc->timeout_rocc_task_id = NULL;
1546 LOG_DEBUG ("0x%llx: rocc timed out\n", rocc->op_id); 1591 LOG_DEBUG ("0x%llx: rocc timed out\n",
1592 rocc->op_id);
1547 cleanup_rocc (rocc); 1593 cleanup_rocc (rocc);
1548} 1594}
1549 1595
@@ -1561,11 +1607,13 @@ cache_transport_peer_connect_notify (void *cls,
1561{ 1607{
1562 struct RemoteOverlayConnectCtx *rocc = cls; 1608 struct RemoteOverlayConnectCtx *rocc = cls;
1563 1609
1564 LOG_DEBUG ("0x%llx: Request Overlay connect notify\n", rocc->op_id); 1610 LOG_DEBUG ("0x%llx: Request Overlay connect notify\n",
1611 rocc->op_id);
1565 GNUNET_assert (0 == 1612 GNUNET_assert (0 ==
1566 memcmp (new_peer, &rocc->a_id, 1613 memcmp (new_peer, &rocc->a_id,
1567 sizeof (struct GNUNET_PeerIdentity))); 1614 sizeof (struct GNUNET_PeerIdentity)));
1568 LOG_DEBUG ("0x%llx: Peer %4s connected\n", rocc->op_id, 1615 LOG_DEBUG ("0x%llx: Peer %4s connected\n",
1616 rocc->op_id,
1569 GNUNET_i2s (&rocc->a_id)); 1617 GNUNET_i2s (&rocc->a_id));
1570 cleanup_rocc (rocc); 1618 cleanup_rocc (rocc);
1571} 1619}
@@ -1579,7 +1627,8 @@ cache_transport_peer_connect_notify (void *cls,
1579 * @param tc the TaskContext from scheduler 1627 * @param tc the TaskContext from scheduler
1580 */ 1628 */
1581static void 1629static void
1582attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 1630attempt_connect_task (void *cls,
1631 const struct GNUNET_SCHEDULER_TaskContext *tc);
1583 1632
1584 1633
1585/** 1634/**
@@ -1587,8 +1636,8 @@ attempt_connect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
1587 * 1636 *
1588 * @param cls the overlay connect context 1637 * @param cls the overlay connect context
1589 * @param tc the scheduler task context; if tc->reason = 1638 * @param tc the scheduler task context; if tc->reason =
1590 * GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if 1639 * #GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if
1591 * GNUNET_SCHEDULER_REASON_READ_READY is succeeded 1640 * #GNUNET_SCHEDULER_REASON_READ_READY is succeeded
1592 */ 1641 */
1593static void 1642static void
1594rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1643rocc_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -1672,7 +1721,9 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1672 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_, rocc->tcc.pid)) 1721 GNUNET_TRANSPORT_check_peer_connected (rocc->tcc.th_, rocc->tcc.pid))
1673 { 1722 {
1674 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n", 1723 LOG_DEBUG ("0x%llx: Target peer %4s already connected to local peer: %u\n",
1675 rocc->op_id, GNUNET_i2s (&rocc->a_id), rocc->peer->id); 1724 rocc->op_id,
1725 GNUNET_i2s (&rocc->a_id),
1726 rocc->peer->id);
1676 cleanup_rocc (rocc); 1727 cleanup_rocc (rocc);
1677 return; 1728 return;
1678 } 1729 }
@@ -1682,7 +1733,7 @@ rocc_cache_get_handle_transport_cb (void *cls, struct GNUNET_CORE_Handle *ch,
1682 1733
1683 1734
1684/** 1735/**
1685 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_REQUESTCONNECT messages 1736 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_REQUEST_CONNECT messages
1686 * 1737 *
1687 * @param cls NULL 1738 * @param cls NULL
1688 * @param client identification of the client 1739 * @param client identification of the client
@@ -1751,7 +1802,10 @@ GST_handle_remote_overlay_connect (void *cls,
1751 GNUNET_TESTING_peer_get_identity (peer->details.local.peer, &pid); 1802 GNUNET_TESTING_peer_get_identity (peer->details.local.peer, &pid);
1752 (void) strncpy (pid_str, GNUNET_i2s (&pid), 15); 1803 (void) strncpy (pid_str, GNUNET_i2s (&pid), 15);
1753 LOG_DEBUG ("0x%llx: Remote overlay connect %4s to peer %4s with hello size: %u\n", 1804 LOG_DEBUG ("0x%llx: Remote overlay connect %4s to peer %4s with hello size: %u\n",
1754 rocc->op_id, pid_str, GNUNET_i2s (&rocc->a_id), hsize); 1805 rocc->op_id,
1806 pid_str,
1807 GNUNET_i2s (&rocc->a_id),
1808 hsize);
1755 rocc->peer = peer; 1809 rocc->peer = peer;
1756 rocc->peer->reference_cnt++; 1810 rocc->peer->reference_cnt++;
1757 rocc->hello = GNUNET_malloc (hsize); 1811 rocc->hello = GNUNET_malloc (hsize);
@@ -1767,7 +1821,9 @@ GST_handle_remote_overlay_connect (void *cls,
1767 &cache_transport_peer_connect_notify, 1821 &cache_transport_peer_connect_notify,
1768 rocc); 1822 rocc);
1769 rocc->timeout_rocc_task_id = 1823 rocc->timeout_rocc_task_id =
1770 GNUNET_SCHEDULER_add_delayed (GST_timeout, &timeout_rocc_task, rocc); 1824 GNUNET_SCHEDULER_add_delayed (GST_timeout,
1825 &timeout_rocc_task,
1826 rocc);
1771 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1827 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1772} 1828}
1773 1829
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index a3bb3777e..ab9afd83e 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -484,12 +484,12 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
484 484
485 485
486/** 486/**
487 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS message from 487 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS message from
488 * controller (testbed service) 488 * controller (testbed service)
489 * 489 *
490 * @param c the controller handle 490 * @param c the controller handle
491 * @param msg message received 491 * @param msg message received
492 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 492 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
493 * not 493 * not
494 */ 494 */
495static int 495static int
@@ -543,12 +543,12 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c,
543 543
544 544
545/** 545/**
546 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT message from 546 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT message from
547 * controller (testbed service) 547 * controller (testbed service)
548 * 548 *
549 * @param c the controller handler 549 * @param c the controller handler
550 * @param msg message received 550 * @param msg message received
551 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 551 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
552 * not 552 * not
553 */ 553 */
554static int 554static int
@@ -624,12 +624,12 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c,
624 624
625 625
626/** 626/**
627 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT message from 627 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT message from
628 * controller (testbed service) 628 * controller (testbed service)
629 * 629 *
630 * @param c the controller handler 630 * @param c the controller handler
631 * @param msg message received 631 * @param msg message received
632 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 632 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
633 * not 633 * not
634 */ 634 */
635static int 635static int
@@ -699,7 +699,7 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c,
699 699
700 700
701/** 701/**
702 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG message from 702 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG message from
703 * controller (testbed service) 703 * controller (testbed service)
704 * 704 *
705 * @param c the controller handler 705 * @param c the controller handler
@@ -771,12 +771,12 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c,
771 771
772 772
773/** 773/**
774 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT message from 774 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT message from
775 * controller (testbed service) 775 * controller (testbed service)
776 * 776 *
777 * @param c the controller handler 777 * @param c the controller handler
778 * @param msg message received 778 * @param msg message received
779 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 779 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
780 * not 780 * not
781 */ 781 */
782static int 782static int
@@ -931,12 +931,12 @@ GNUNET_TESTBED_generate_slavegetconfig_msg_ (uint64_t op_id, uint32_t slave_id)
931 931
932 932
933/** 933/**
934 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller 934 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller
935 * (testbed service) 935 * (testbed service)
936 * 936 *
937 * @param c the controller handler 937 * @param c the controller handler
938 * @param msg message received 938 * @param msg message received
939 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 939 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
940 * not 940 * not
941 */ 941 */
942static int 942static int
@@ -978,12 +978,12 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c,
978 978
979 979
980/** 980/**
981 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller 981 * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller
982 * (testbed service) 982 * (testbed service)
983 * 983 *
984 * @param c the controller handler 984 * @param c the controller handler
985 * @param msg message received 985 * @param msg message received
986 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if 986 * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
987 * not 987 * not
988 */ 988 */
989static int 989static int
@@ -1558,8 +1558,7 @@ opc_free_iterator (void *cls, uint32_t key, void *value)
1558 * @param c handle to controller to stop 1558 * @param c handle to controller to stop
1559 */ 1559 */
1560void 1560void
1561GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller 1561GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c)
1562 *c)
1563{ 1562{
1564 struct MessageQueue *mq_entry; 1563 struct MessageQueue *mq_entry;
1565 1564
@@ -1899,11 +1898,11 @@ GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
1899/** 1898/**
1900 * Generates configuration by uncompressing configuration in given message. The 1899 * Generates configuration by uncompressing configuration in given message. The
1901 * given message should be of the following types: 1900 * given message should be of the following types:
1902 * GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, 1901 * #GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION,
1903 * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, 1902 * #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
1904 * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, 1903 * #GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST,
1905 * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, 1904 * #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS,
1906 * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, 1905 * #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
1907 * 1906 *
1908 * @param msg the message containing compressed configuration 1907 * @param msg the message containing compressed configuration
1909 * @return handle to the parsed configuration; NULL upon error while parsing the message 1908 * @return handle to the parsed configuration; NULL upon error while parsing the message
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index 1bfc9955d..1f67176cd 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -217,12 +217,12 @@ struct TopologyContext
217 * The type of this context 217 * The type of this context
218 */ 218 */
219 enum { 219 enum {
220 220
221 /** 221 /**
222 * Type for underlay topology 222 * Type for underlay topology
223 */ 223 */
224 TOPOLOGYCONTEXT_TYPE_UNDERLAY = 0, 224 TOPOLOGYCONTEXT_TYPE_UNDERLAY = 0,
225 225
226 /** 226 /**
227 * Type for overlay topology 227 * Type for overlay topology
228 */ 228 */
@@ -475,7 +475,7 @@ make_link (unsigned int offset, uint32_t A, uint32_t B,
475 { 475 {
476 struct TopologyContextOverlay *overlay; 476 struct TopologyContextOverlay *overlay;
477 struct OverlayLink *olink; 477 struct OverlayLink *olink;
478 478
479 overlay = &tc->u.overlay; 479 overlay = &tc->u.overlay;
480 GNUNET_assert (offset < tc->link_array_size); 480 GNUNET_assert (offset < tc->link_array_size);
481 olink = &overlay->link_array[offset]; 481 olink = &overlay->link_array[offset];
@@ -490,7 +490,7 @@ make_link (unsigned int offset, uint32_t A, uint32_t B,
490 { 490 {
491 struct TopologyContextUnderlay *underlay; 491 struct TopologyContextUnderlay *underlay;
492 struct UnderlayLink *ulink; 492 struct UnderlayLink *ulink;
493 493
494 underlay = &tc->u.underlay; 494 underlay = &tc->u.underlay;
495 GNUNET_assert (offset < tc->link_array_size); 495 GNUNET_assert (offset < tc->link_array_size);
496 ulink = &underlay->link_array[offset]; 496 ulink = &underlay->link_array[offset];
@@ -518,7 +518,7 @@ gen_topo_line (struct TopologyContext *tc)
518 case TOPOLOGYCONTEXT_TYPE_OVERLAY: 518 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
519 { 519 {
520 struct TopologyContextOverlay *overlay; 520 struct TopologyContextOverlay *overlay;
521 521
522 overlay = &tc->u.overlay; 522 overlay = &tc->u.overlay;
523 overlay->link_array = 523 overlay->link_array =
524 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size); 524 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
@@ -527,7 +527,7 @@ gen_topo_line (struct TopologyContext *tc)
527 case TOPOLOGYCONTEXT_TYPE_UNDERLAY: 527 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
528 { 528 {
529 struct TopologyContextUnderlay *underlay; 529 struct TopologyContextUnderlay *underlay;
530 530
531 underlay = &tc->u.underlay; 531 underlay = &tc->u.underlay;
532 underlay->link_array = 532 underlay->link_array =
533 GNUNET_malloc (sizeof (struct UnderlayLink) * tc->link_array_size); 533 GNUNET_malloc (sizeof (struct UnderlayLink) * tc->link_array_size);
@@ -564,7 +564,7 @@ gen_topo_ring (struct TopologyContext *tc)
564 case TOPOLOGYCONTEXT_TYPE_UNDERLAY: 564 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
565 { 565 {
566 struct TopologyContextUnderlay *underlay; 566 struct TopologyContextUnderlay *underlay;
567 567
568 underlay = &tc->u.underlay; 568 underlay = &tc->u.underlay;
569 underlay->link_array = 569 underlay->link_array =
570 GNUNET_realloc (underlay->link_array, sizeof (struct UnderlayLink) * 570 GNUNET_realloc (underlay->link_array, sizeof (struct UnderlayLink) *
@@ -656,7 +656,7 @@ gen_topo_2dtorus (struct TopologyContext *tc)
656 case TOPOLOGYCONTEXT_TYPE_OVERLAY: 656 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
657 { 657 {
658 struct TopologyContextOverlay *overlay; 658 struct TopologyContextOverlay *overlay;
659 659
660 overlay = &tc->u.overlay; 660 overlay = &tc->u.overlay;
661 overlay->link_array = 661 overlay->link_array =
662 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size); 662 GNUNET_malloc (sizeof (struct OverlayLink) * tc->link_array_size);
@@ -714,11 +714,13 @@ gen_topo_2dtorus (struct TopologyContext *tc)
714 * 714 *
715 * @param tc the topology context 715 * @param tc the topology context
716 * @param links the number of random links to establish 716 * @param links the number of random links to establish
717 * @param append GNUNET_YES to add links to existing link array; GNUNET_NO to 717 * @param append #GNUNET_YES to add links to existing link array; #GNUNET_NO to
718 * create a new link array 718 * create a new link array
719 */ 719 */
720static void 720static void
721gen_topo_random (struct TopologyContext *tc, unsigned int links, int append) 721gen_topo_random (struct TopologyContext *tc,
722 unsigned int links,
723 int append)
722{ 724{
723 unsigned int cnt; 725 unsigned int cnt;
724 unsigned int index; 726 unsigned int index;
@@ -802,7 +804,9 @@ gen_topo_random (struct TopologyContext *tc, unsigned int links, int append)
802 * network 804 * network
803 */ 805 */
804static void 806static void
805gen_topo_scale_free (struct TopologyContext *tc, uint16_t cap, uint8_t m) 807gen_topo_scale_free (struct TopologyContext *tc,
808 uint16_t cap,
809 uint8_t m)
806{ 810{
807 unsigned int *deg; 811 unsigned int *deg;
808 unsigned int *etab; 812 unsigned int *etab;
@@ -903,9 +907,9 @@ gen_topo_scale_free (struct TopologyContext *tc, uint16_t cap, uint8_t m)
903 case TOPOLOGYCONTEXT_TYPE_OVERLAY: 907 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
904 { 908 {
905 struct TopologyContextOverlay *overlay; 909 struct TopologyContextOverlay *overlay;
906 910
907 overlay = &tc->u.overlay; 911 overlay = &tc->u.overlay;
908 overlay->link_array = 912 overlay->link_array =
909 GNUNET_realloc (overlay->link_array, sizeof (struct OverlayLink) * tc->link_array_size); 913 GNUNET_realloc (overlay->link_array, sizeof (struct OverlayLink) * tc->link_array_size);
910 } 914 }
911 break; 915 break;
@@ -929,7 +933,8 @@ gen_topo_scale_free (struct TopologyContext *tc, uint16_t cap, uint8_t m)
929 * @param filename the filename of the file containing topology data 933 * @param filename the filename of the file containing topology data
930 */ 934 */
931static void 935static void
932gen_topo_from_file (struct TopologyContext *tc, const char *filename) 936gen_topo_from_file (struct TopologyContext *tc,
937 const char *filename)
933{ 938{
934 char *data; 939 char *data;
935 char *end; 940 char *end;
@@ -957,20 +962,24 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
957 status = GNUNET_SYSERR; 962 status = GNUNET_SYSERR;
958 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 963 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
959 { 964 {
960 LOG (GNUNET_ERROR_TYPE_ERROR, _("Topology file %s not found\n"), filename); 965 LOG (GNUNET_ERROR_TYPE_ERROR,
966 _("Topology file %s not found\n"),
967 filename);
961 return; 968 return;
962 } 969 }
963 if (GNUNET_OK != 970 if (GNUNET_OK !=
964 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) 971 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
965 { 972 {
966 LOG (GNUNET_ERROR_TYPE_ERROR, _("Topology file %s has no data\n"), 973 LOG (GNUNET_ERROR_TYPE_ERROR,
974 _("Topology file %s has no data\n"),
967 filename); 975 filename);
968 return; 976 return;
969 } 977 }
970 data = GNUNET_malloc (fs); 978 data = GNUNET_malloc (fs);
971 if (fs != GNUNET_DISK_fn_read (filename, data, fs)) 979 if (fs != GNUNET_DISK_fn_read (filename, data, fs))
972 { 980 {
973 LOG (GNUNET_ERROR_TYPE_ERROR, _("Topology file %s cannot be read\n"), 981 LOG (GNUNET_ERROR_TYPE_ERROR,
982 _("Topology file %s cannot be read\n"),
974 filename); 983 filename);
975 goto _exit; 984 goto _exit;
976 } 985 }
@@ -1048,9 +1057,9 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
1048 case TOPOLOGYCONTEXT_TYPE_OVERLAY: 1057 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
1049 { 1058 {
1050 struct TopologyContextOverlay *overlay; 1059 struct TopologyContextOverlay *overlay;
1051 1060
1052 overlay = &tc->u.overlay; 1061 overlay = &tc->u.overlay;
1053 overlay->link_array = 1062 overlay->link_array =
1054 GNUNET_realloc (overlay->link_array, 1063 GNUNET_realloc (overlay->link_array,
1055 sizeof (struct OverlayLink) * tc->link_array_size); 1064 sizeof (struct OverlayLink) * tc->link_array_size);
1056 } 1065 }
@@ -1058,7 +1067,7 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
1058 case TOPOLOGYCONTEXT_TYPE_UNDERLAY: 1067 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1059 { 1068 {
1060 struct TopologyContextUnderlay *underlay; 1069 struct TopologyContextUnderlay *underlay;
1061 1070
1062 underlay = &tc->u.underlay; 1071 underlay = &tc->u.underlay;
1063 underlay->link_array = 1072 underlay->link_array =
1064 GNUNET_realloc (underlay->link_array, 1073 GNUNET_realloc (underlay->link_array,
@@ -1071,7 +1080,8 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
1071 } 1080 }
1072 else 1081 else
1073 LOG (GNUNET_ERROR_TYPE_WARNING, 1082 LOG (GNUNET_ERROR_TYPE_WARNING,
1074 _("Ignoring to connect peer %u to peer %u\n"), peer_id, 1083 _("Ignoring to connect peer %u to peer %u\n"),
1084 peer_id,
1075 other_peer_id); 1085 other_peer_id);
1076 while (('\n' != data[offset]) && ('|' != data[offset]) && (offset < fs)) 1086 while (('\n' != data[offset]) && ('|' != data[offset]) && (offset < fs))
1077 offset++; 1087 offset++;
@@ -1091,14 +1101,15 @@ _exit:
1091 GNUNET_free (data); 1101 GNUNET_free (data);
1092 if (GNUNET_OK != status) 1102 if (GNUNET_OK != status)
1093 { 1103 {
1094 LOG (GNUNET_ERROR_TYPE_WARNING, "Removing link data read from the file\n"); 1104 LOG (GNUNET_ERROR_TYPE_WARNING,
1105 "Removing link data read from the file\n");
1095 tc->link_array_size = 0; 1106 tc->link_array_size = 0;
1096 switch (tc->type) 1107 switch (tc->type)
1097 { 1108 {
1098 case TOPOLOGYCONTEXT_TYPE_OVERLAY: 1109 case TOPOLOGYCONTEXT_TYPE_OVERLAY:
1099 { 1110 {
1100 struct TopologyContextOverlay *overlay; 1111 struct TopologyContextOverlay *overlay;
1101 1112
1102 overlay = &tc->u.overlay; 1113 overlay = &tc->u.overlay;
1103 GNUNET_free_non_null (overlay->link_array); 1114 GNUNET_free_non_null (overlay->link_array);
1104 overlay->link_array = NULL; 1115 overlay->link_array = NULL;
@@ -1107,7 +1118,7 @@ _exit:
1107 case TOPOLOGYCONTEXT_TYPE_UNDERLAY: 1118 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
1108 { 1119 {
1109 struct TopologyContextUnderlay *underlay; 1120 struct TopologyContextUnderlay *underlay;
1110 1121
1111 underlay = &tc->u.underlay; 1122 underlay = &tc->u.underlay;
1112 GNUNET_free_non_null (underlay->link_array); 1123 GNUNET_free_non_null (underlay->link_array);
1113 underlay->link_array = NULL; 1124 underlay->link_array = NULL;
@@ -1129,7 +1140,7 @@ gen_topo_clique (struct TopologyContext *tc)
1129 unsigned int cnt; 1140 unsigned int cnt;
1130 unsigned int offset; 1141 unsigned int offset;
1131 unsigned int neighbour; 1142 unsigned int neighbour;
1132 1143
1133 tc->link_array_size = tc->num_peers * (tc->num_peers - 1); 1144 tc->link_array_size = tc->num_peers * (tc->num_peers - 1);
1134 switch (tc->type) 1145 switch (tc->type)
1135 { 1146 {
@@ -1138,8 +1149,8 @@ gen_topo_clique (struct TopologyContext *tc)
1138 struct TopologyContextOverlay *overlay; 1149 struct TopologyContextOverlay *overlay;
1139 1150
1140 overlay = &tc->u.overlay; 1151 overlay = &tc->u.overlay;
1141 overlay->link_array = GNUNET_malloc (sizeof (struct OverlayLink) * 1152 overlay->link_array = GNUNET_new_array (tc->link_array_size,
1142 tc->link_array_size); 1153 struct OverlayLink);
1143 } 1154 }
1144 break; 1155 break;
1145 case TOPOLOGYCONTEXT_TYPE_UNDERLAY: 1156 case TOPOLOGYCONTEXT_TYPE_UNDERLAY:
@@ -1147,8 +1158,8 @@ gen_topo_clique (struct TopologyContext *tc)
1147 struct TopologyContextUnderlay *underlay; 1158 struct TopologyContextUnderlay *underlay;
1148 1159
1149 underlay = &tc->u.underlay; 1160 underlay = &tc->u.underlay;
1150 underlay->link_array = GNUNET_malloc (sizeof (struct UnderlayLink) * 1161 underlay->link_array = GNUNET_new_array (tc->link_array_size,
1151 tc->link_array_size); 1162 struct UnderlayLink);
1152 } 1163 }
1153 } 1164 }
1154 offset = 0; 1165 offset = 0;
@@ -1169,8 +1180,8 @@ gen_topo_clique (struct TopologyContext *tc)
1169 * Configure overall network topology to have a particular shape. 1180 * Configure overall network topology to have a particular shape.
1170 * 1181 *
1171 * @param op_cls closure argument to give with the operation event 1182 * @param op_cls closure argument to give with the operation event
1172 * @param num_peers number of peers in 'peers' 1183 * @param num_peers number of peers in @a peers
1173 * @param peers array of 'num_peers' with the peers to configure 1184 * @param peers array of @a num_peers with the peers to configure
1174 * @param topo desired underlay topology to use 1185 * @param topo desired underlay topology to use
1175 * @param ap topology-specific options 1186 * @param ap topology-specific options
1176 * @return handle to the operation, NULL if configuring the topology 1187 * @return handle to the operation, NULL if configuring the topology
@@ -1194,8 +1205,8 @@ GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls,
1194 * Configure overall network topology to have a particular shape. 1205 * Configure overall network topology to have a particular shape.
1195 * 1206 *
1196 * @param op_cls closure argument to give with the operation event 1207 * @param op_cls closure argument to give with the operation event
1197 * @param num_peers number of peers in 'peers' 1208 * @param num_peers number of peers in @a peers
1198 * @param peers array of 'num_peers' with the peers to configure 1209 * @param peers array of @a num_peers with the peers to configure
1199 * @param topo desired underlay topology to use 1210 * @param topo desired underlay topology to use
1200 * @param ... topology-specific options 1211 * @param ... topology-specific options
1201 * @return handle to the operation, NULL if configuring the topology 1212 * @return handle to the operation, NULL if configuring the topology
@@ -1220,8 +1231,8 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
1220 * 1231 *
1221 * @param op_cls closure argument to give with the peer connect operation events 1232 * @param op_cls closure argument to give with the peer connect operation events
1222 * generated through this function 1233 * generated through this function
1223 * @param num_peers number of peers in 'peers' 1234 * @param num_peers number of peers in @a peers
1224 * @param peers array of 'num_peers' with the peers to configure 1235 * @param peers array of @a num_peers with the peers to configure
1225 * @param max_connections the maximums number of overlay connections that will 1236 * @param max_connections the maximums number of overlay connections that will
1226 * be made to achieve the given topology 1237 * be made to achieve the given topology
1227 * @param comp_cb the completion callback to call when the topology generation 1238 * @param comp_cb the completion callback to call when the topology generation
@@ -1339,7 +1350,8 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
1339 GNUNET_TESTBED_operation_queue_insert_ 1350 GNUNET_TESTBED_operation_queue_insert_
1340 (c->opq_parallel_topology_config_operations, op); 1351 (c->opq_parallel_topology_config_operations, op);
1341 GNUNET_TESTBED_operation_begin_wait_ (op); 1352 GNUNET_TESTBED_operation_begin_wait_ (op);
1342 LOG (GNUNET_ERROR_TYPE_DEBUG, "Generated %u connections\n", 1353 LOG (GNUNET_ERROR_TYPE_DEBUG,
1354 "Generated %u connections\n",
1343 tc->link_array_size); 1355 tc->link_array_size);
1344 if (NULL != max_connections) 1356 if (NULL != max_connections)
1345 *max_connections = tc->link_array_size; 1357 *max_connections = tc->link_array_size;
@@ -1399,8 +1411,8 @@ GNUNET_TESTBED_overlay_configure_topology (void *op_cls,
1399 * @param topology where to write the retrieved topology 1411 * @param topology where to write the retrieved topology
1400 * @param topology_string The string to attempt to 1412 * @param topology_string The string to attempt to
1401 * get a configuration value from 1413 * get a configuration value from
1402 * @return GNUNET_YES if topology string matched a 1414 * @return #GNUNET_YES if topology string matched a
1403 * known topology, GNUNET_NO if not 1415 * known topology, #GNUNET_NO if not
1404 */ 1416 */
1405int 1417int
1406GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology, 1418GNUNET_TESTBED_topology_get_ (enum GNUNET_TESTBED_TopologyOption *topology,
@@ -1444,14 +1456,14 @@ GNUNET_TESTBED_topology_to_str_ (enum GNUNET_TESTBED_TopologyOption topology)
1444 * generated 1456 * generated
1445 * @param proc the underlay link processor callback. Will be called for each 1457 * @param proc the underlay link processor callback. Will be called for each
1446 * underlay link generated unless a previous call to this callback 1458 * underlay link generated unless a previous call to this callback
1447 * returned GNUNET_SYSERR. Cannot be NULL. 1459 * returned #GNUNET_SYSERR. Cannot be NULL.
1448 * @param cls closure for proc 1460 * @param cls closure for @a proc
1449 * @param ... variable arguments denoting the topology and its parameters. They 1461 * @param ... variable arguments denoting the topology and its parameters. They
1450 * should start with the type of topology to generate followed by their 1462 * should start with the type of topology to generate followed by their
1451 * options. 1463 * options.
1452 * @return GNUNET_OK if underlay link generation is successful; GNUNET_SYSERR 1464 * @return #GNUNET_OK if underlay link generation is successful; #GNUNET_SYSERR
1453 * upon error in generating the underlay or if any calls to the 1465 * upon error in generating the underlay or if any calls to the
1454 * underlay link processor returned GNUNET_SYSERR 1466 * underlay link processor returned #GNUNET_SYSERR
1455 */ 1467 */
1456int 1468int
1457GNUNET_TESTBED_underlay_construct_ (int num_peers, 1469GNUNET_TESTBED_underlay_construct_ (int num_peers,
@@ -1466,7 +1478,7 @@ GNUNET_TESTBED_underlay_construct_ (int num_peers,
1466 enum GNUNET_TESTBED_TopologyOption topology; 1478 enum GNUNET_TESTBED_TopologyOption topology;
1467 unsigned int cnt; 1479 unsigned int cnt;
1468 int ret; 1480 int ret;
1469 1481
1470 GNUNET_assert (NULL != proc); 1482 GNUNET_assert (NULL != proc);
1471 ret = GNUNET_OK; 1483 ret = GNUNET_OK;
1472 memset (&tc, 0, sizeof (tc)); 1484 memset (&tc, 0, sizeof (tc));