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