GNUnet  0.10.x
gnunet-service-testbed.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008--2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
27 #include "platform.h"
28 #include "gnunet_util_lib.h"
29 #include "gnunet_testbed_service.h"
31 #include "gnunet_core_service.h"
32 
33 #include "testbed.h"
34 #include "testbed_api.h"
35 #include "testbed_api_operations.h"
36 #include "testbed_api_hosts.h"
37 #include "gnunet_testing_lib.h"
39 
40 
44 #define LOG(kind, ...) \
45  GNUNET_log(kind, __VA_ARGS__)
46 
50 #define LOG_DEBUG(...) \
51  LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
52 
56 #define LIST_GROW_STEP 10
57 
58 
62 struct Route {
66  uint32_t dest;
67 
71  uint32_t thru;
72 };
73 
74 
83 
88 
93 
98 
102  void *cls;
103 
108 
112  uint64_t operation_id;
113 
118 };
119 
120 
129 
134 
139 
143  void *cb_cls;
144 
149 };
150 
151 
160 
164  uint64_t operation_id;
165 };
166 
167 
171 struct Peer {
172  union {
173  struct {
178 
184 
189  } local;
190 
191  struct {
195  struct Slave *slave;
196 
200  uint32_t remote_host_id;
201  } remote;
202  } details;
203 
208 
212  uint32_t id;
213 
221  uint32_t reference_cnt;
222 
230  uint32_t destroy_flag;
231 };
232 
233 
237 struct Context {
242 
246  char *master_ip;
247 
252 
256  uint32_t host_id;
257 };
258 
259 
267  char *name;
268 
272  uint32_t num_shared;
273 
277  uint32_t num_sharing;
278 };
279 
280 
281 struct RegisteredHostContext;
282 
283 
293 
298 
303 
308 
313 
317  uint64_t operation_id;
318 
322  uint32_t peer1;
323 
327  uint32_t peer2;
328 
332  uint32_t peer2_host_id;
333 };
334 
335 
345 
350 
355 
360 
364  enum RHCState {
368  RHC_INIT = 0,
369 
373  RHC_DONE
374  } state;
375 };
376 
377 
386  unsigned int nslaves;
387 
392  int timeout;
393 };
394 
395 
400 
404 extern struct Context *GST_context;
405 
410 
415 
419 extern struct Peer **GST_peer_list;
420 
424 extern struct GNUNET_TESTBED_Host **GST_host_list;
425 
429 extern struct OperationQueue *GST_opq_openfds;
430 
434 extern struct GNUNET_TIME_Relative GST_timeout;
435 
439 extern unsigned int GST_peer_list_size;
440 
444 extern unsigned int GST_num_local_peers;
445 
449 extern unsigned int GST_host_list_size;
450 
454 extern char *GST_stats_dir;
455 
459 #define VALID_HOST_ID(id) \
460  (((id) < GST_host_list_size) && (NULL != GST_host_list[id]))
461 
465 #define VALID_PEER_ID(id) \
466  (((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]))
467 
468 
480 #define GST_array_grow_large_enough(ptr, size, accommodate_size) \
481  do \
482  { \
483  unsigned int growth_size; \
484  GNUNET_assert(size <= accommodate_size); \
485  growth_size = size; \
486  while (growth_size <= accommodate_size) \
487  growth_size += LIST_GROW_STEP; \
488  GNUNET_array_grow (ptr, size, growth_size); \
489  GNUNET_assert(size > accommodate_size); \
490  } while (0)
491 
492 
498 void
499 GST_destroy_peer(struct Peer *peer);
500 
501 
505 void
506 GST_destroy_peers(void);
507 
508 
517 struct Route *
518 GST_find_dest_route(uint32_t host_id);
519 
520 
527 void
528 handle_overlay_connect(void *cls,
530 
531 
541 void
542 GST_queue_host_registration(struct Slave *slave,
544  void *cb_cls, struct GNUNET_TESTBED_Host *host);
545 
546 
553 void
555  const struct GNUNET_MessageHeader *msg);
556 
557 
564 void
566 
567 
571 void
572 GST_clear_fopcq(void);
573 
574 
582 void
584  uint64_t operation_id,
585  const char *emsg);
586 
587 
593 void
595 
596 
602 void
604 
605 
612 void
614  uint64_t operation_id);
615 
616 
624 int
627 
628 
635 void
638 
639 
647 int
648 check_peer_create(void *cls,
649  const struct GNUNET_TESTBED_PeerCreateMessage *msg);
650 
651 
658 void
659 handle_peer_create(void *cls,
660  const struct GNUNET_TESTBED_PeerCreateMessage *msg);
661 
662 
669 void
670 handle_peer_destroy(void *cls,
671  const struct GNUNET_TESTBED_PeerDestroyMessage *msg);
672 
673 
680 void
681 handle_peer_start(void *cls,
682  const struct GNUNET_TESTBED_PeerStartMessage *msg);
683 
684 
691 void
692 handle_peer_stop(void *cls,
693  const struct GNUNET_TESTBED_PeerStopMessage *msg);
694 
695 
702 void
703 handle_peer_get_config(void *cls,
705 
706 
713 void
714 handle_shutdown_peers(void *cls,
716 
717 
725 int
726 check_manage_peer_service(void *cls,
728 
729 
736 void
739 
740 
741 
742 
750 int
751 check_peer_reconfigure(void *cls,
753 
754 
763 void
764 handle_peer_reconfigure(void *cls,
766 
767 
771 void
772 GST_free_mctxq(void);
773 
774 
778 void
779 GST_free_lcf(void);
780 
781 
785 void
787 
788 
794 void
796 
797 
803 void
805 
806 
810 void
811 GST_free_occq(void);
812 
813 
817 void
818 GST_free_roccq(void);
819 
820 
824 void
825 GST_free_prcq(void);
826 
827 
833 void
834 GST_cache_init(unsigned int size);
835 
836 
840 void
841 GST_cache_clear(void);
842 
843 
850 const struct GNUNET_MessageHeader *
851 GST_cache_lookup_hello(const unsigned int peer_id);
852 
853 
861 void
862 GST_cache_add_hello(const unsigned int peer_id,
863  const struct GNUNET_MessageHeader *hello);
864 
865 
871 void
873 
874 
878 void
879 GST_stats_destroy(void);
880 
881 /* End of gnunet-service-testbed.h */
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
struct ForwardedOperationContext * prev
The prev pointer for DLL.
unsigned int GST_host_list_size
The size of the host list.
Context to hold data of peer.
This context information will be created for each host that is registered at slave controllers during...
int is_remote
Is this peer locally created?
int check_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:396
void GST_route_list_clear(void)
Cleans up the route list.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
internal API to access the &#39;operations&#39; subsystem
The structure for identifying a shared service.
uint32_t thru
The destination host is reachable thru.
void GST_notify_client_disconnect_oc(struct GNUNET_SERVICE_Client *client)
Notify OC subsystem that client disconnected.
Message sent from client to testing service to reconfigure a (stopped) a peer.
Definition: testbed.h:234
int timeout
Did we observe a timeout with respect to this operation at any of the slaves.
Message sent from client to testing service to stop a peer.
Definition: testbed.h:286
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
Handle for a GNUnet peer controlled by testing.
Definition: testing.c:167
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:563
struct GNUNET_SERVICE_Client * client
The client handle.
void GST_stats_destroy(void)
Shutdown the status calls module.
int is_running
Is the peer running.
Shutdown peers message.
Definition: testbed.h:666
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:308
void handle_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
uint32_t id
Our local reference id for this peer.
char * master_ip
The network address of the master controller.
struct OperationContext * opc
The generated operation context.
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
struct Peer ** GST_peer_list
A list of peers we know about.
IPC messages between testing API and service ("controller")
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
int check_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.
void GST_queue_host_registration(struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
Adds a host registration&#39;s request to a slave&#39;s registration queue.
void(* GNUNET_TESTBED_HostRegistrationCompletion)(void *cls, const char *emsg)
Callback which will be called to after a host registration succeeded or failed.
Structure representing a connected(directly-linked) controller.
void GST_send_operation_success_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
Function to send generic operation success message to given client.
Opaque handle to a host running experiments managed by the testing framework.
struct GNUNET_TESTBED_Host * host
The host of the controller which has to connect to the above rhost.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
void GST_free_mctxq(void)
Frees the ManageServiceContext queue.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timedout.
struct GNUNET_CONFIGURATION_Handle * GST_config
Our configuration.
Context information used while linking controllers.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
int check_remote_overlay_connect(void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.
Message sent from client to testing service to start a peer.
Definition: testbed.h:264
void handle_peer_destroy(void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
Handle to a client that is connected to a service.
Definition: service.c:246
uint32_t peer2
The id of peer 2.
unsigned int GST_peer_list_size
The size of the peer list.
void GST_cleanup_focc(struct ForwardedOverlayConnectContext *focc)
Cleans up ForwardedOverlayConnectContext.
void handle_peer_stop(void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
GNUNET_TESTBED_HostRegistrationCompletion cb
The callback to call after this registration&#39;s status is available.
enum State state
current state of profiling
struct Slave * slave
The slave this peer is started through.
uint32_t remote_host_id
The id of the remote host this peer is running on.
void GST_clear_fopcq(void)
Clears the forwarded operations queue.
uint32_t host_id
Our host id according to this context.
uint64_t operation_id
The id of the operation which created this context information.
Context information to used during operations which forward the overlay connect message.
A DLL of host registrations to be made.
struct GNUNET_CONFIGURATION_Handle * cfg
The modified (by GNUNET_TESTING_peer_configure) configuration this peer is configured with...
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
A routing entry.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TESTING_Peer * peer
The peer handle from testing API.
struct ForwardedOverlayConnectContext * prev
previous ForwardedOverlayConnectContext in the DLL
const struct GNUNET_MessageHeader * GST_cache_lookup_hello(const unsigned int peer_id)
Looks up in the hello cache and returns the HELLO of the given peer.
void GST_cache_clear(void)
Clear cache.
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
void GST_cache_init(unsigned int size)
Initializes the cache.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
uint32_t num_sharing
Number of peers currently sharing the service.
void * cls
Closure pointer.
Message sent from client to testing service to create (configure, but not start) a peer...
Definition: testbed.h:199
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
uint32_t peer2_host_id
Id of the host where peer2 is running.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
static unsigned int size
Size of the "table".
Definition: peer.c:66
uint64_t operation_id
The ID of the operation.
struct Context * GST_context
The master context; generated with the first INIT message.
void handle_peer_get_config(void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:95
void handle_shutdown_peers(void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.
struct GNUNET_TESTBED_Host * host
The host that has to be registered.
struct HostRegistration * next
next registration in the DLL
struct GNUNET_TESTBED_Host * reg_host
The host which is being registered.
RHCState
Enumeration of states for this context.
Interface for functions internally exported from testbed_api.c.
Message sent from client to testing service to connect two peers.
Definition: testbed.h:364
char * GST_stats_dir
The directory where to store load statistics data.
Queue of operations where we can only support a certain number of concurrent operations of a particul...
struct ForwardedOverlayConnectContext * next
next ForwardedOverlayConnectContext in the DLL
void GST_notify_client_disconnect_peers(struct GNUNET_SERVICE_Client *client)
Notify peers subsystem that client disconnected.
char * name
The name of the shared service.
struct HostRegistration * prev
previous registration in the DLL
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
configuration data
Definition: configuration.c:83
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
Message to start/stop services of a peer.
Definition: testbed.h:682
void GST_free_prcq(void)
Cleans up the Peer reconfigure context list.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
void GST_process_next_focc(struct RegisteredHostContext *rhc)
Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.
Entry in list of pending tasks.
Definition: scheduler.c:131
struct ForwardedOperationContext * next
The next pointer for DLL.
void handle_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
uint64_t operation_id
The id of the operation that has been forwarded.
void GST_stats_init(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize logging CPU and IO statisticfs.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Header for all communications.
uint32_t num_shared
Number of shared peers per instance of the shared service.
void * cb_cls
The closure for the above callback.
void GST_free_lcf(void)
Cleans up the queue used for forwarding link controllers requests.
internal API to access the &#39;hosts&#39; subsystem
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
void handle_peer_start(void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
void handle_overlay_connect(void *cls, const struct GNUNET_TESTBED_OverlayConnectMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages.
int check_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
struct OperationQueue * GST_opq_openfds
Operation queue for open file descriptors.
Context information for operations forwarded to subcontrollers.
void handle_remote_overlay_connect(void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.
uint32_t dest
destination host
void handle_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.
Context information for GNUNET_TESTBED_Operation.
Definition: testbed_api.h:135
Time for relative time used by GNUnet, in microseconds.
void GST_destroy_peers(void)
Stops and destroys all peers.
struct GNUNET_SERVICE_Client * client
The client which initiated the link controller operation.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void GST_cache_add_hello(const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
Caches the HELLO of the given peer.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.