- make sure all flow control values are updated correctly
[oweals/gnunet.git] / src / testbed / testbed.h
1 /*
2       This file is part of GNUnet
3       (C) 2008--2013 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       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       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
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   /**
40    * Type is GNUNET_MESSAGE_TYPE_TESTBED_INIT
41    */
42   struct GNUNET_MessageHeader header;
43
44   /**
45    * Host ID that the controller is either given (if this is the
46    * dominating client) or assumed to have (for peer-connections
47    * between controllers).  A controller must check that all
48    * connections make consistent claims...
49    */
50   uint32_t host_id GNUNET_PACKED;
51
52   /**
53    * Event mask that specifies which events this client
54    * is interested in.  In NBO.
55    */
56   uint64_t event_mask GNUNET_PACKED;
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 configration
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
456 };
457
458
459 /**
460  * Event notification from a controller to a client.
461  */
462 struct GNUNET_TESTBED_PeerEventMessage
463 {
464
465   /**
466    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
467    */
468   struct GNUNET_MessageHeader header;
469
470   /**
471    * 'enum GNUNET_TESTBED_EventType' (in NBO);
472    * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
473    */
474   int32_t event_type GNUNET_PACKED;
475
476   /**
477    * Host where the peer is running.
478    */
479   uint32_t host_id GNUNET_PACKED;
480
481   /**
482    * Peer that was started or stopped.
483    */
484   uint32_t peer_id GNUNET_PACKED;
485
486   /**
487    * Operation ID that is used to identify this operation.
488    */
489   uint64_t operation_id GNUNET_PACKED;
490
491 };
492
493
494 /**
495  * Event notification from a controller to a client.
496  */
497 struct GNUNET_TESTBED_ConnectionEventMessage
498 {
499
500   /**
501    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
502    */
503   struct GNUNET_MessageHeader header;
504
505   /**
506    * 'enum GNUNET_TESTBED_EventType' (in NBO);
507    * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT.
508    */
509   int32_t event_type GNUNET_PACKED;
510
511   /**
512    * First peer.
513    */
514   uint32_t peer1 GNUNET_PACKED;
515
516   /**
517    * Second peer.
518    */
519   uint32_t peer2 GNUNET_PACKED;
520
521   /**
522    * Operation ID that is used to identify this operation.
523    */
524   uint64_t operation_id GNUNET_PACKED;
525
526 };
527
528
529 /**
530  * Event notification from a controller to a client.
531  */
532 struct GNUNET_TESTBED_OperationFailureEventMessage
533 {
534
535   /**
536    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
537    */
538   struct GNUNET_MessageHeader header;
539
540   /**
541    * 'enum GNUNET_TESTBED_EventType' (in NBO);
542    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
543    */
544   int32_t event_type GNUNET_PACKED;
545
546   /**
547    * Operation ID of the operation that created this event.
548    */
549   uint64_t operation_id GNUNET_PACKED;
550
551   /* followed by 0-terminated error message */
552
553 };
554
555
556 /**
557  * Event notification from a controller to a client.
558  */
559 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
560 {
561
562   /**
563    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
564    */
565   struct GNUNET_MessageHeader header;
566
567   /**
568    * Peer identity of the peer that was created.
569    */
570   uint32_t peer_id GNUNET_PACKED;
571
572   /**
573    * Operation ID of the operation that created this event.
574    */
575   uint64_t operation_id GNUNET_PACKED;
576
577 };
578
579
580 /**
581  * Event notification from a controller to a client for
582  * a generic operational success where the operation does
583  * not return any data.
584  */
585 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
586 {
587
588   /**
589    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
590    */
591   struct GNUNET_MessageHeader header;
592
593   /**
594    * 'enum GNUNET_TESTBED_EventType' (in NBO);
595    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
596    */
597   int32_t event_type GNUNET_PACKED;
598
599   /**
600    * Operation ID of the operation that created this event.
601    */
602   uint64_t operation_id GNUNET_PACKED;
603
604 };
605
606
607 /**
608  * Message sent from client to testing service to
609  * obtain the configuration of a peer.
610  */
611 struct GNUNET_TESTBED_PeerGetConfigurationMessage
612 {
613
614   /**
615    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_CONFIGURATION
616    */
617   struct GNUNET_MessageHeader header;
618
619   /**
620    * Unique ID for the peer.
621    */
622   uint32_t peer_id GNUNET_PACKED;
623
624   /**
625    * Operation ID that is used to identify this operation.
626    */
627   uint64_t operation_id GNUNET_PACKED;
628
629 };
630
631
632 /**
633  * Peer configuration and identity reply from controller to a client.
634  */
635 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
636 {
637
638   /**
639    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION
640    */
641   struct GNUNET_MessageHeader header;
642
643   /**
644    * The id of the peer relevant to this information
645    */
646   uint32_t peer_id GNUNET_PACKED;
647
648   /**
649    * Operation ID of the operation that created this event.
650    */
651   uint64_t operation_id GNUNET_PACKED;
652
653   /**
654    * Identity of the peer.
655    */
656   struct GNUNET_PeerIdentity peer_identity;
657
658   /**
659    * The size of configuration when uncompressed
660    */
661   uint16_t config_size GNUNET_PACKED;
662
663   /* followed by gzip-compressed configuration of the peer */
664
665 };
666
667
668 /**
669  * Message to request configuration of a slave controller
670  */
671 struct GNUNET_TESTBED_SlaveGetConfigurationMessage
672 {
673   /**
674    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
675    */
676   struct GNUNET_MessageHeader header;
677
678   /**
679    * The id of the slave host
680    */
681   uint32_t slave_id GNUNET_PACKED;
682
683   /**
684    * Operation ID
685    */
686   uint64_t operation_id GNUNET_PACKED;
687
688 };
689
690
691 /**
692  * Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIG message
693  */
694 struct GNUNET_TESTBED_SlaveConfiguration
695 {
696   /**
697    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
698    */
699   struct GNUNET_MessageHeader header;
700
701   /**
702    * The id of the host where the slave is running
703    */
704   uint32_t slave_id GNUNET_PACKED;
705
706   /**
707    * Operation ID
708    */
709   uint64_t operation_id GNUNET_PACKED;
710
711   /**
712    * The size of the configuration when uncompressed
713    */
714   uint16_t config_size GNUNET_PACKED;
715
716   /* followed by gzip-compressed configuration of the peer */
717
718 };
719
720
721 /**
722  * Shutdown peers message
723  */
724 struct GNUNET_TESTBED_ShutdownPeersMessage
725 {
726   /**
727    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
728    */
729   struct GNUNET_MessageHeader header;
730
731   /**
732    * Operation ID
733    */
734   uint64_t operation_id GNUNET_PACKED;
735 };
736
737
738 /**
739  * Message to start/stop services of a peer
740  */
741 struct GNUNET_TESTBED_ManagePeerServiceMessage
742 {
743   /**
744    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
745    */
746   struct GNUNET_MessageHeader header;
747
748   /**
749    * Unique ID of the peer whose service has to be managed.
750    */
751   uint32_t peer_id GNUNET_PACKED;
752
753   /**
754    * Operation ID
755    */
756   uint64_t operation_id GNUNET_PACKED;
757
758   /**
759    * set this to 1 to start the service; 0 to stop the service
760    */
761   uint8_t start;
762   
763   /**
764    * The NULL-terminated name of the service to start/stop follows here
765    */
766 };
767
768
769 GNUNET_NETWORK_STRUCT_END
770 #endif
771 /* end of testbed.h */