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