add $(GN_LIBINTL) to Makefile.am (fixes 0005902)
[oweals/gnunet.git] / src / testbed / testbed.h
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
21 /**
22  * @file testbed/testbed.h
23  * @brief IPC messages between testing API and service ("controller")
24  * @author Christian Grothoff
25  */
26
27 #ifndef TESTBED_H
28 #define TESTBED_H
29
30 #include "gnunet_util_lib.h"
31
32 GNUNET_NETWORK_STRUCT_BEGIN
33 /**
34  * Initial message from a client to a testing control service.
35  */
36 struct GNUNET_TESTBED_InitMessage
37 {
38   /**
39    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_INIT
40    */
41   struct GNUNET_MessageHeader header;
42
43   /**
44    * Host ID that the controller is either given (if this is the
45    * dominating client) or assumed to have (for peer-connections
46    * between controllers).  A controller must check that all
47    * connections make consistent claims...
48    */
49   uint32_t host_id GNUNET_PACKED;
50
51   /**
52    * Event mask that specifies which events this client
53    * is interested in.  In NBO.
54    */
55   uint64_t event_mask GNUNET_PACKED;
56
57   /* Followed by 0-terminated hostname of the controller */
58 };
59
60
61 /**
62  * Notify the service about a host that we intend to use.
63  */
64 struct GNUNET_TESTBED_AddHostMessage
65 {
66   /**
67    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
68    */
69   struct GNUNET_MessageHeader header;
70
71   /**
72    * Unique ID for the host (in NBO).
73    */
74   uint32_t host_id GNUNET_PACKED;
75
76   /**
77    * SSH port to use, 0 for default (in NBO).
78    */
79   uint16_t ssh_port GNUNET_PACKED;
80
81   /**
82    * Number of bytes in the user name that follows;
83    * 0 to use no user name; otherwise 'strlen (username)',
84    * excluding 0-termination!
85    */
86   uint16_t username_length GNUNET_PACKED;
87
88   /**
89    * Number of bytes in the host name (excluding 0-termination) that follows the
90    * user name; cannot be 0
91    */
92   uint16_t hostname_length GNUNET_PACKED;
93
94   /**
95    * The length of the uncompressed configuration
96    */
97   uint16_t config_size GNUNET_PACKED;
98
99   /* followed by non 0-terminated user name */
100
101   /* followed by non 0-terminated host name */
102
103   /* followed by gzip compressed configuration to start or connect to a
104      controller on this host.  While starting the controller this configuration
105      is used as a template */
106 };
107
108
109 /**
110  * Confirmation from the service that adding a host
111  * worked (or failed).
112  * FIXME: Where is this required?
113  */
114 struct GNUNET_TESTBED_HostConfirmedMessage
115 {
116   /**
117    * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
118    */
119   struct GNUNET_MessageHeader header;
120
121   /**
122    * Unique ID for the host (in NBO).
123    */
124   uint32_t host_id GNUNET_PACKED;
125
126   /* followed by the 0-terminated error message (on failure)
127    * (typical errors include host-id already in use) */
128 };
129
130
131 /**
132  * Client notifies controller that it should delegate
133  * requests for a particular client to a particular
134  * sub-controller.
135  */
136 struct GNUNET_TESTBED_ControllerLinkRequest
137 {
138   /**
139    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
140    */
141   struct GNUNET_MessageHeader header;
142
143   /**
144    * For which host should requests be delegated? NBO.
145    */
146   uint32_t delegated_host_id GNUNET_PACKED;
147
148   /**
149    * The id of the operation which created this message
150    */
151   uint64_t operation_id GNUNET_PACKED;
152
153   /**
154    * Which host is responsible for managing the delegation? NBO
155    */
156   uint32_t slave_host_id GNUNET_PACKED;
157
158   /**
159    * Set to 1 if the receiving controller is the master controller for
160    * the slave host (and thus responsible for starting it?). 0 if not
161    */
162   uint8_t is_subordinate;
163 };
164
165
166 /**
167  * Response message for ControllerLinkRequest message
168  */
169 struct GNUNET_TESTBED_ControllerLinkResponse
170 {
171   /**
172    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
173    */
174   struct GNUNET_MessageHeader header;
175
176   /**
177    * The size of the compressed configuration. Can be ZERO if the controller is
178    * not started (depends on the ControllerLinkRequest). NBO.
179    */
180   uint16_t config_size GNUNET_PACKED;
181
182   /**
183    * Set to #GNUNET_YES to signify SUCCESS; #GNUNET_NO to signify failure
184    */
185   uint16_t success GNUNET_PACKED;
186
187   /**
188    * The id of the operation which created this message. NBO
189    */
190   uint64_t operation_id GNUNET_PACKED;
191
192   /* If controller linking is successful and configuration is present, then here
193    * comes the serialized gzip configuration with which the controller is
194    * running at the delegate host */
195
196   /* In case of failure, here comes the error message (without \0 termination)*/
197 };
198
199
200 /**
201  * Message sent from client to testing service to
202  * create (configure, but not start) a peer.
203  */
204 struct GNUNET_TESTBED_PeerCreateMessage
205 {
206   /**
207    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
208    */
209   struct GNUNET_MessageHeader header;
210
211   /**
212    * On which host should the peer be started?
213    */
214   uint32_t host_id GNUNET_PACKED;
215
216   /**
217    * Unique operation id
218    */
219   uint64_t operation_id GNUNET_PACKED;
220
221   /**
222    * Unique ID for the peer.
223    */
224   uint32_t peer_id GNUNET_PACKED;
225
226   /**
227    * Size of the uncompressed configuration
228    */
229   uint16_t config_size GNUNET_PACKED;
230
231   /* followed by serialized peer configuration;
232   * gzip'ed configuration file in INI format */
233 };
234
235
236 /**
237  * Message sent from client to testing service to
238  * reconfigure a (stopped) a peer.
239  */
240 struct GNUNET_TESTBED_PeerReconfigureMessage
241 {
242   /**
243    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER
244    */
245   struct GNUNET_MessageHeader header;
246
247   /**
248    * Unique ID for the peer.
249    */
250   uint32_t peer_id GNUNET_PACKED;
251
252   /**
253    * Operation ID that is used to identify this operation.
254    */
255   uint64_t operation_id GNUNET_PACKED;
256
257   /**
258    * The length of the serialized configuration when uncompressed
259    */
260   uint16_t config_size GNUNET_PACKED;
261
262   /* followed by serialized peer configuration;
263   * gzip'ed configuration file in INI format */
264 };
265
266
267 /**
268  * Message sent from client to testing service to
269  * start a peer.
270  */
271 struct GNUNET_TESTBED_PeerStartMessage
272 {
273   /**
274    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_START_PEER
275    */
276   struct GNUNET_MessageHeader header;
277
278   /**
279    * Unique ID for the peer.
280    */
281   uint32_t peer_id GNUNET_PACKED;
282
283   /**
284    * Operation ID that is used to identify this operation.
285    */
286   uint64_t operation_id GNUNET_PACKED;
287 };
288
289
290 /**
291  * Message sent from client to testing service to
292  * stop a peer.
293  */
294 struct GNUNET_TESTBED_PeerStopMessage
295 {
296   /**
297    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER
298    */
299   struct GNUNET_MessageHeader header;
300
301   /**
302    * Unique ID for the peer.
303    */
304   uint32_t peer_id GNUNET_PACKED;
305
306   /**
307    * Operation ID that is used to identify this operation.
308    */
309   uint64_t operation_id GNUNET_PACKED;
310 };
311
312
313 /**
314  * Message sent from client to testing service to
315  * destroy a (stopped) peer.
316  */
317 struct GNUNET_TESTBED_PeerDestroyMessage
318 {
319   /**
320    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER
321    */
322   struct GNUNET_MessageHeader header;
323
324   /**
325    * Unique ID for the peer.
326    */
327   uint32_t peer_id GNUNET_PACKED;
328
329   /**
330    * Operation ID that is used to identify this operation.
331    */
332   uint64_t operation_id GNUNET_PACKED;
333 };
334
335
336 /**
337  * Message sent from client to testing service to
338  * (re)configure a "physical" link between two peers.
339  */
340 struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
341 {
342   /**
343    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_CONFIGURE_UNDERLAY_LINK
344    */
345   struct GNUNET_MessageHeader header;
346
347   /**
348    * 'enum GNUNET_TESTBED_ConnectOption' of the option to change
349    */
350   int32_t connect_option GNUNET_PACKED;
351
352   /**
353    * Unique ID for the first peer.
354    */
355   uint32_t peer1 GNUNET_PACKED;
356
357   /**
358    * Unique ID for the second peer.
359    */
360   uint32_t peer2 GNUNET_PACKED;
361
362   /**
363    * Operation ID that is used to identify this operation.
364    */
365   uint64_t operation_id GNUNET_PACKED;
366
367   /* followed by option-dependent variable-size values */
368 };
369
370
371 /**
372  * Message sent from client to testing service to
373  * connect two peers.
374  */
375 struct GNUNET_TESTBED_OverlayConnectMessage
376 {
377   /**
378    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT
379    */
380   struct GNUNET_MessageHeader header;
381
382   /**
383    * Unique ID for the first peer.
384    */
385   uint32_t peer1 GNUNET_PACKED;
386
387   /**
388    * Operation ID that is used to identify this operation.
389    */
390   uint64_t operation_id GNUNET_PACKED;
391
392   /**
393    * Unique ID for the second peer.
394    */
395   uint32_t peer2 GNUNET_PACKED;
396
397   /**
398    * The ID of the host which runs peer2
399    */
400   uint32_t peer2_host_id GNUNET_PACKED;
401 };
402
403
404 /**
405  * Message sent from host controller of a peer(A) to the host controller of
406  * another peer(B) to request B to connect to A
407  */
408 struct GNUNET_TESTBED_RemoteOverlayConnectMessage
409 {
410   /**
411    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT
412    */
413   struct GNUNET_MessageHeader header;
414
415   /**
416    * The Unique ID of B
417    */
418   uint32_t peer GNUNET_PACKED;
419
420   /**
421    * The Operation ID that is used to identify this operation
422    */
423   uint64_t operation_id GNUNET_PACKED;
424
425   /**
426    * Identity of A
427    */
428   struct GNUNET_PeerIdentity peer_identity;
429
430   /**
431    * To be followed by the HELLO message of A
432    */
433   struct GNUNET_MessageHeader hello[0];
434   // FIXME: we usually do not use this gcc-hack as some
435   // compilers / tools really get messed up by it...
436 };
437
438
439 /**
440  * Event notification from a controller to a client.
441  */
442 struct GNUNET_TESTBED_PeerEventMessage
443 {
444   /**
445    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
446    */
447   struct GNUNET_MessageHeader header;
448
449   /**
450    * `enum GNUNET_TESTBED_EventType` (in NBO);
451    * either #GNUNET_TESTBED_ET_PEER_START or #GNUNET_TESTBED_ET_PEER_STOP.
452    */
453   int32_t event_type GNUNET_PACKED;
454
455   /**
456    * Host where the peer is running.
457    */
458   uint32_t host_id GNUNET_PACKED;
459
460   /**
461    * Peer that was started or stopped.
462    */
463   uint32_t peer_id GNUNET_PACKED;
464
465   /**
466    * Operation ID that is used to identify this operation.
467    */
468   uint64_t operation_id GNUNET_PACKED;
469 };
470
471
472 /**
473  * Event notification from a controller to a client.
474  */
475 struct GNUNET_TESTBED_ConnectionEventMessage
476 {
477   /**
478    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
479    */
480   struct GNUNET_MessageHeader header;
481
482   /**
483    * 'enum GNUNET_TESTBED_EventType' (in NBO);
484    * either #GNUNET_TESTBED_ET_CONNECT or #GNUNET_TESTBED_ET_DISCONNECT.
485    */
486   int32_t event_type GNUNET_PACKED;
487
488   /**
489    * First peer.
490    */
491   uint32_t peer1 GNUNET_PACKED;
492
493   /**
494    * Second peer.
495    */
496   uint32_t peer2 GNUNET_PACKED;
497
498   /**
499    * Operation ID that is used to identify this operation.
500    */
501   uint64_t operation_id GNUNET_PACKED;
502 };
503
504
505 /**
506  * Event notification from a controller to a client.
507  */
508 struct GNUNET_TESTBED_OperationFailureEventMessage
509 {
510   /**
511    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
512    */
513   struct GNUNET_MessageHeader header;
514
515   /**
516    * 'enum GNUNET_TESTBED_EventType' (in NBO);
517    * #GNUNET_TESTBED_ET_OPERATION_FINISHED.
518    */
519   int32_t event_type GNUNET_PACKED;
520
521   /**
522    * Operation ID of the operation that created this event.
523    */
524   uint64_t operation_id GNUNET_PACKED;
525
526   /* followed by 0-terminated error message */
527 };
528
529
530 /**
531  * Event notification from a controller to a client.
532  */
533 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
534 {
535   /**
536    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
537    */
538   struct GNUNET_MessageHeader header;
539
540   /**
541    * Peer identity of the peer that was created.
542    */
543   uint32_t peer_id GNUNET_PACKED;
544
545   /**
546    * Operation ID of the operation that created this event.
547    */
548   uint64_t operation_id GNUNET_PACKED;
549 };
550
551
552 /**
553  * Event notification from a controller to a client for
554  * a generic operational success where the operation does
555  * not return any data.
556  */
557 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
558 {
559   /**
560    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
561    */
562   struct GNUNET_MessageHeader header;
563
564   /**
565    * 'enum GNUNET_TESTBED_EventType' (in NBO);
566    * #GNUNET_TESTBED_ET_OPERATION_FINISHED.
567    */
568   int32_t event_type GNUNET_PACKED;
569
570   /**
571    * Operation ID of the operation that created this event.
572    */
573   uint64_t operation_id GNUNET_PACKED;
574 };
575
576
577 /**
578  * Message sent from client to testing service to
579  * obtain the configuration of a peer.
580  */
581 struct GNUNET_TESTBED_PeerGetConfigurationMessage
582 {
583   /**
584    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
585    */
586   struct GNUNET_MessageHeader header;
587
588   /**
589    * Unique ID for the peer.
590    */
591   uint32_t peer_id GNUNET_PACKED;
592
593   /**
594    * Operation ID that is used to identify this operation.
595    */
596   uint64_t operation_id GNUNET_PACKED;
597 };
598
599
600 /**
601  * Peer configuration and identity reply from controller to a client.
602  */
603 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
604 {
605   /**
606    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
607    */
608   struct GNUNET_MessageHeader header;
609
610   /**
611    * The id of the peer relevant to this information
612    */
613   uint32_t peer_id GNUNET_PACKED;
614
615   /**
616    * Operation ID of the operation that created this event.
617    */
618   uint64_t operation_id GNUNET_PACKED;
619
620   /**
621    * Identity of the peer.
622    */
623   struct GNUNET_PeerIdentity peer_identity;
624
625   /**
626    * The size of configuration when uncompressed
627    */
628   uint16_t config_size GNUNET_PACKED;
629
630   /* followed by gzip-compressed configuration of the peer */
631 };
632
633
634 /**
635  * Message to request configuration of a slave controller
636  */
637 struct GNUNET_TESTBED_SlaveGetConfigurationMessage
638 {
639   /**
640    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
641    */
642   struct GNUNET_MessageHeader header;
643
644   /**
645    * The id of the slave host
646    */
647   uint32_t slave_id GNUNET_PACKED;
648
649   /**
650    * Operation ID
651    */
652   uint64_t operation_id GNUNET_PACKED;
653 };
654
655
656 /**
657  * Reply to #GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION message
658  */
659 struct GNUNET_TESTBED_SlaveConfiguration
660 {
661   /**
662    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
663    */
664   struct GNUNET_MessageHeader header;
665
666   /**
667    * The id of the host where the slave is running
668    */
669   uint32_t slave_id GNUNET_PACKED;
670
671   /**
672    * Operation ID
673    */
674   uint64_t operation_id GNUNET_PACKED;
675
676   /**
677    * The size of the configuration when uncompressed
678    */
679   uint16_t config_size GNUNET_PACKED;
680
681   /* followed by gzip-compressed configuration of the peer */
682 };
683
684
685 /**
686  * Shutdown peers message
687  */
688 struct GNUNET_TESTBED_ShutdownPeersMessage
689 {
690   /**
691    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
692    */
693   struct GNUNET_MessageHeader header;
694
695   /**
696    * Operation ID
697    */
698   uint64_t operation_id GNUNET_PACKED;
699 };
700
701
702 /**
703  * Message to start/stop services of a peer
704  */
705 struct GNUNET_TESTBED_ManagePeerServiceMessage
706 {
707   /**
708    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
709    */
710   struct GNUNET_MessageHeader header;
711
712   /**
713    * Unique ID of the peer whose service has to be managed.
714    */
715   uint32_t peer_id GNUNET_PACKED;
716
717   /**
718    * Operation ID
719    */
720   uint64_t operation_id GNUNET_PACKED;
721
722   /**
723    * set this to 1 to start the service; 0 to stop the service
724    */
725   uint8_t start;
726
727   /**
728    * The NULL-terminated name of the service to start/stop follows here
729    */
730 };
731
732
733 /**
734  * Message to send underlay link model of a peer.  This message will be
735  * forwarded to the controller running the peer.
736  */
737 struct GNUNET_TESTBED_UnderlayLinkModelMsg
738 {
739   /**
740    * Type is #GNUNET_MESSAGE_TYPE_UNDERLAYLINKMODELMSG
741    */
742   struct GNUNET_MessageHeader header;
743
744   /**
745    * The number of peer entries contained in this message
746    */
747   uint32_t nentries GNUNET_PACKED;
748
749   /**
750    * The number of link properties contained in this message
751    */
752   uint32_t nprops GNUNET_PACKED;
753
754   /**
755    * Array of ids of peers to be in the blacklist/whitelist.  Each id is of type
756    * uint32_t.  Number of ids should be equal to nentries.
757    */
758
759   /**
760    * Array of link properties.  Each link property is to be arraged in a
761    * sequence of four integers of type uint32_t: peer_id, latency, loss and
762    * bandwidth.
763    */
764 };
765
766
767 /**************************************/
768 /* Barriers IPC messages and protocol */
769 /**************************************/
770
771
772 /**
773  * The environmental variable which when available refers to the configuration
774  * file the local testbed controller is using
775  */
776 #define ENV_TESTBED_CONFIG "GNUNET_TESTBED_CONTROLLER_CONFIG"
777
778
779 /**
780  * Message to initialise a barrier
781  */
782 struct GNUNET_TESTBED_BarrierInit
783 {
784   /**
785    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT
786    */
787   struct GNUNET_MessageHeader header;
788
789   /**
790    * The quorum percentage needed for crossing the barrier
791    */
792   uint8_t quorum;
793
794   /**
795    * name of the barrier.  Non NULL-terminated.
796    */
797   char name[0];
798 };
799
800
801 /**
802  * Message to cancel a barrier
803  */
804 struct GNUNET_TESTBED_BarrierCancel
805 {
806   /**
807    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL
808    */
809   struct GNUNET_MessageHeader header;
810
811   /**
812    * The barrier name.  Non NULL terminated
813    */
814   char name[0];
815 };
816
817
818 /**
819  * Message for signalling status changes of a barrier
820  */
821 struct GNUNET_TESTBED_BarrierStatusMsg
822 {
823   /**
824    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS
825    */
826   struct GNUNET_MessageHeader header;
827
828   /**
829    * status.  Use enumerated values of enum BarrierStatus
830    */
831   uint16_t status GNUNET_PACKED;
832
833   /**
834    * strlen of the barrier name
835    */
836   uint16_t name_len GNUNET_PACKED;
837
838   /**
839    * the barrier name (0-terminated) concatenated with an error message
840    * (0-terminated) if the status were to indicate an error
841    */
842   char data[0];
843 };
844
845
846 /**
847  * Message sent from peers to the testbed-barrier service to indicate that they
848  * have reached a barrier and are waiting for it to be crossed
849  */
850 struct GNUNET_TESTBED_BarrierWait
851 {
852   /**
853    * Type is #GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT
854    */
855   struct GNUNET_MessageHeader header;
856
857   /**
858    * The name of the barrier they have reached.  Non-NULL terminated.
859    */
860   char name[0];
861 };
862
863
864 GNUNET_NETWORK_STRUCT_END
865 #endif
866 /* end of testbed.h */