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