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
63 {
67  uint32_t dest;
68 
72  uint32_t thru;
73 };
74 
75 
80 {
85 
90 
95 
100 
104  void *cls;
105 
110 
114  uint64_t operation_id;
115 
120 
121 };
122 
123 
128 {
133 
138 
143 
147  void *cb_cls;
148 
153 };
154 
155 
160 {
165 
169  uint64_t operation_id;
170 
171 };
172 
173 
177 struct Peer
178 {
179 
180  union
181  {
182  struct
183  {
188 
194 
199 
200  } local;
201 
202  struct
203  {
207  struct Slave *slave;
208 
212  uint32_t remote_host_id;
213 
214  } remote;
215 
216  } details;
217 
222 
226  uint32_t id;
227 
235  uint32_t reference_cnt;
236 
244  uint32_t destroy_flag;
245 
246 };
247 
248 
252 struct Context
253 {
258 
262  char *master_ip;
263 
268 
272  uint32_t host_id;
273 };
274 
275 
280 {
284  char *name;
285 
289  uint32_t num_shared;
290 
294  uint32_t num_sharing;
295 };
296 
297 
298 struct RegisteredHostContext;
299 
300 
306 {
311 
316 
321 
326 
331 
335  uint64_t operation_id;
336 
340  uint32_t peer1;
341 
345  uint32_t peer2;
346 
350  uint32_t peer2_host_id;
351 };
352 
353 
359 {
364 
369 
374 
379 
383  enum RHCState
384  {
385 
389  RHC_INIT = 0,
390 
394  RHC_DONE
395  } state;
396 
397 };
398 
399 
404 {
409  unsigned int nslaves;
410 
415  int timeout;
416 };
417 
418 
423 
427 extern struct Context *GST_context;
428 
433 
438 
442 extern struct Peer **GST_peer_list;
443 
447 extern struct GNUNET_TESTBED_Host **GST_host_list;
448 
452 extern struct OperationQueue *GST_opq_openfds;
453 
457 const extern struct GNUNET_TIME_Relative GST_timeout;
458 
462 extern unsigned int GST_peer_list_size;
463 
467 extern unsigned int GST_num_local_peers;
468 
472 extern unsigned int GST_host_list_size;
473 
477 extern char *GST_stats_dir;
478 
482 #define VALID_HOST_ID(id) \
483  ( ((id) < GST_host_list_size) && (NULL != GST_host_list[id]) )
484 
488 #define VALID_PEER_ID(id) \
489  ( ((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]) )
490 
491 
503 #define GST_array_grow_large_enough(ptr, size, accommodate_size) \
504  do \
505  { \
506  unsigned int growth_size; \
507  GNUNET_assert (size <= accommodate_size); \
508  growth_size = size; \
509  while (growth_size <= accommodate_size) \
510  growth_size += LIST_GROW_STEP; \
511  GNUNET_array_grow (ptr, size, growth_size); \
512  GNUNET_assert (size > accommodate_size); \
513  } while (0)
514 
515 
521 void
522 GST_destroy_peer (struct Peer *peer);
523 
524 
528 void
529 GST_destroy_peers (void);
530 
531 
540 struct Route *
541 GST_find_dest_route (uint32_t host_id);
542 
543 
550 void
551 handle_overlay_connect (void *cls,
553 
554 
564 void
565 GST_queue_host_registration (struct Slave *slave,
567  void *cb_cls, struct GNUNET_TESTBED_Host *host);
568 
569 
576 void
578  const struct GNUNET_MessageHeader *msg);
579 
580 
587 void
589 
590 
594 void
595 GST_clear_fopcq (void);
596 
597 
605 void
607  uint64_t operation_id,
608  const char *emsg);
609 
610 
616 void
618 
619 
625 void
627 
628 
635 void
637  uint64_t operation_id);
638 
639 
647 int
650 
651 
658 void
661 
662 
670 int
671 check_peer_create (void *cls,
672  const struct GNUNET_TESTBED_PeerCreateMessage *msg);
673 
674 
681 void
682 handle_peer_create (void *cls,
683  const struct GNUNET_TESTBED_PeerCreateMessage *msg);
684 
685 
692 void
693 handle_peer_destroy (void *cls,
694  const struct GNUNET_TESTBED_PeerDestroyMessage *msg);
695 
696 
703 void
704 handle_peer_start (void *cls,
705  const struct GNUNET_TESTBED_PeerStartMessage *msg);
706 
707 
714 void
715 handle_peer_stop (void *cls,
716  const struct GNUNET_TESTBED_PeerStopMessage *msg);
717 
718 
725 void
726 handle_peer_get_config (void *cls,
728 
729 
736 void
737 handle_shutdown_peers (void *cls,
739 
740 
748 int
749 check_manage_peer_service (void *cls,
751 
752 
759 void
760 handle_manage_peer_service (void *cls,
762 
763 
764 
765 
773 int
774 check_peer_reconfigure (void *cls,
776 
777 
786 void
787 handle_peer_reconfigure (void *cls,
789 
790 
794 void
795 GST_free_mctxq (void);
796 
797 
801 void
802 GST_free_lcf (void);
803 
804 
808 void
809 GST_route_list_clear (void);
810 
811 
817 void
819 
820 
826 void
828 
829 
833 void
834 GST_free_occq (void);
835 
836 
840 void
841 GST_free_roccq (void);
842 
843 
847 void
848 GST_free_prcq (void);
849 
850 
856 void
857 GST_cache_init (unsigned int size);
858 
859 
863 void
864 GST_cache_clear (void);
865 
866 
873 const struct GNUNET_MessageHeader *
874 GST_cache_lookup_hello (const unsigned int peer_id);
875 
876 
884 void
885 GST_cache_add_hello (const unsigned int peer_id,
886  const struct GNUNET_MessageHeader *hello);
887 
888 
894 void
896 
897 
901 void
902 GST_stats_destroy (void);
903 
904 /* 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:431
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:251
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:309
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:175
Message sent from client to testing service to obtain the configuration of a peer.
Definition: testbed.h:615
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:728
Message sent from client to testing service to destroy a (stopped) peer.
Definition: testbed.h:334
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:284
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:249
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:213
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:67
GUID host
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:102
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:396
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:85
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:745
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
void GST_free_prcq(void)
Cleans up the Peer reconfigure context list.
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:134
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:137
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.