880a4486482e5c9f6f4f376e68c95c383150e2ef
[oweals/gnunet.git] / src / testbed / testbed.h
1 /*
2       This file is part of GNUnet
3       (C) 2012 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   /* Followed by 0-terminated hostname of the controller */
59 };
60
61
62 /**
63  * Notify the service about a host that we intend to use.
64  */
65 struct GNUNET_TESTBED_AddHostMessage
66 {
67
68   /**
69    * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
70    */
71   struct GNUNET_MessageHeader header;
72
73   /**
74    * Unique ID for the host (in NBO).
75    */
76   uint32_t host_id GNUNET_PACKED;
77
78   /**
79    * SSH port to use, 0 for default (in NBO).
80    */
81   uint16_t ssh_port GNUNET_PACKED;
82
83   /**
84    * Number of bytes in the user name that follows;
85    * 0 to use no user name; otherwise 'strlen (username)',
86    * excluding 0-termination!
87    */
88   uint16_t user_name_length GNUNET_PACKED;
89
90   /**
91    * Number of bytes in the host name (excluding 0-termination) that follows the
92    * user name; cannot be 0
93    */
94   uint16_t hostname_length 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  * Message to testing service: configure service sharing
133  * at a host.
134  */
135 struct GNUNET_TESTBED_ConfigureSharedServiceMessage
136 {
137
138   /**
139    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHARE_SERVICE
140    */
141   struct GNUNET_MessageHeader header;
142
143   /**
144    * Host that is being configured.
145    */
146   uint32_t host_id GNUNET_PACKED;
147
148   /**
149    * Number of peers that should share a service instance;
150    * 1 for no sharing, 0 to forcefully disable the service.
151    */
152   uint32_t num_peers GNUNET_PACKED;
153
154   /* followed by 0-terminated name of the service */
155
156 };
157
158
159 /**
160  * Client notifies controller that it should delegate
161  * requests for a particular client to a particular
162  * sub-controller.
163  */
164 struct GNUNET_TESTBED_ControllerLinkMessage
165 {
166
167   /**
168    * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
169    */
170   struct GNUNET_MessageHeader header;
171
172   /**
173    * For which host should requests be delegated? NBO.
174    */
175   uint32_t delegated_host_id GNUNET_PACKED;
176
177   /**
178    * The id of the operation which created this message
179    */
180   uint64_t operation_id GNUNET_PACKED;
181
182   /**
183    * Which host is responsible for managing the delegation? NBO
184    */
185   uint32_t slave_host_id GNUNET_PACKED;
186
187   /**
188    * The size of the uncompressed configuration
189    */
190   uint16_t config_size GNUNET_PACKED;
191
192   /**
193    * Set to 1 if the receiving controller is the master controller for
194    * the slave host (and thus responsible for starting it?). 0 if not
195    */
196   uint8_t is_subordinate;
197
198   /* followed by serialized slave configuration;
199    * gzip'ed configuration file in INI format */
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    * Unique operation id
218    */
219   uint64_t operation_id GNUNET_PACKED;
220
221   /**
222    * On which host should the peer be started?
223    */
224   uint32_t host_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   uint32_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_TYPDE_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   /* followed by serialized peer configuration;
265    * gzip'ed configuration file in INI format */
266
267 };
268
269
270 /**
271  * Message sent from client to testing service to
272  * start a peer.
273  */
274 struct GNUNET_TESTBED_PeerStartMessage
275 {
276
277   /**
278    * Type is GNUNET_MESSAGE_TYPE_TESTBED_START_PEER
279    */
280   struct GNUNET_MessageHeader header;
281
282   /**
283    * Unique ID for the peer.
284    */
285   uint32_t peer_id GNUNET_PACKED;
286
287   /**
288    * Operation ID that is used to identify this operation.
289    */
290   uint64_t operation_id GNUNET_PACKED;
291
292 };
293
294
295 /**
296  * Message sent from client to testing service to
297  * stop a peer.
298  */
299 struct GNUNET_TESTBED_PeerStopMessage
300 {
301
302   /**
303    * Type is GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER
304    */
305   struct GNUNET_MessageHeader header;
306
307   /**
308    * Unique ID for the peer.
309    */
310   uint32_t peer_id GNUNET_PACKED;
311
312   /**
313    * Operation ID that is used to identify this operation.
314    */
315   uint64_t operation_id GNUNET_PACKED;
316
317 };
318
319
320 /**
321  * Message sent from client to testing service to
322  * destroy a (stopped) peer.
323  */
324 struct GNUNET_TESTBED_PeerDestroyMessage
325 {
326
327   /**
328    * Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER
329    */
330   struct GNUNET_MessageHeader header;
331
332   /**
333    * Unique ID for the peer.
334    */
335   uint32_t peer_id GNUNET_PACKED;
336
337   /**
338    * Operation ID that is used to identify this operation.
339    */
340   uint64_t operation_id GNUNET_PACKED;
341
342 };
343
344
345 /**
346  * Message sent from client to testing service to
347  * (re)configure a "physical" link between two peers.
348  */
349 struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
350 {
351
352   /**
353    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CONFIGURE_UNDERLAY_LINK
354    */
355   struct GNUNET_MessageHeader header;
356
357   /**
358    * 'enum GNUNET_TESTBED_ConnectOption' of the option to change
359    */
360   int32_t connect_option GNUNET_PACKED;
361
362   /**
363    * Unique ID for the first peer.
364    */
365   uint32_t peer1 GNUNET_PACKED;
366
367   /**
368    * Unique ID for the second peer.
369    */
370   uint32_t peer2 GNUNET_PACKED;
371
372   /**
373    * Operation ID that is used to identify this operation.
374    */
375   uint64_t operation_id GNUNET_PACKED;
376
377   /* followed by option-dependent variable-size values */
378
379 };
380
381
382 /**
383  * Message sent from client to testing service to
384  * connect two peers.
385  */
386 struct GNUNET_TESTBED_OverlayConnectMessage
387 {
388
389   /**
390    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT
391    */
392   struct GNUNET_MessageHeader header;
393
394   /**
395    * Unique ID for the first peer.
396    */
397   uint32_t peer1 GNUNET_PACKED;
398
399   /**
400    * Operation ID that is used to identify this operation.
401    */
402   uint64_t operation_id GNUNET_PACKED;
403
404   /**
405    * Unique ID for the second peer.
406    */
407   uint32_t peer2 GNUNET_PACKED;
408
409   /**
410    * The ID of the host which runs peer2
411    */
412   uint32_t peer2_host_id GNUNET_PACKED;
413
414 };
415
416
417 /**
418  * Message sent from host controller of a peer(A) to the host controller of
419  * another peer(B) to request B to connect to A
420  */
421 struct GNUNET_TESTBED_RemoteOverlayConnectMessage
422 {
423   /**
424    * Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT
425    */
426   struct GNUNET_MessageHeader header;
427
428   /**
429    * The Unique ID of B
430    */
431   uint32_t peer GNUNET_PACKED;
432
433   /**
434    * The Operation ID that is used to identify this operation
435    */
436   uint64_t operation_id GNUNET_PACKED;
437
438   /**
439    * Identity of A
440    */
441   struct GNUNET_PeerIdentity peer_identity;
442
443   /**
444    * To be followed by the HELLO message of A
445    */
446   struct GNUNET_MessageHeader hello[0];
447
448 };
449
450
451 /**
452  * Event notification from a controller to a client.
453  */
454 struct GNUNET_TESTBED_PeerEventMessage
455 {
456
457   /**
458    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
459    */
460   struct GNUNET_MessageHeader header;
461
462   /**
463    * 'enum GNUNET_TESTBED_EventType' (in NBO);
464    * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
465    */
466   int32_t event_type GNUNET_PACKED;
467
468   /**
469    * Host where the peer is running.
470    */
471   uint32_t host_id GNUNET_PACKED;
472
473   /**
474    * Peer that was started or stopped.
475    */
476   uint32_t peer_id GNUNET_PACKED;
477
478   /**
479    * Operation ID that is used to identify this operation.
480    */
481   uint64_t operation_id GNUNET_PACKED;
482
483 };
484
485
486 /**
487  * Event notification from a controller to a client.
488  */
489 struct GNUNET_TESTBED_ConnectionEventMessage
490 {
491
492   /**
493    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
494    */
495   struct GNUNET_MessageHeader header;
496
497   /**
498    * 'enum GNUNET_TESTBED_EventType' (in NBO);
499    * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT.
500    */
501   int32_t event_type GNUNET_PACKED;
502
503   /**
504    * First peer.
505    */
506   uint32_t peer1 GNUNET_PACKED;
507
508   /**
509    * Second peer.
510    */
511   uint32_t peer2 GNUNET_PACKED;
512
513   /**
514    * Operation ID that is used to identify this operation.
515    */
516   uint64_t operation_id GNUNET_PACKED;
517
518 };
519
520
521 /**
522  * Event notification from a controller to a client.
523  */
524 struct GNUNET_TESTBED_OperationFailureEventMessage
525 {
526
527   /**
528    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
529    */
530   struct GNUNET_MessageHeader header;
531
532   /**
533    * 'enum GNUNET_TESTBED_EventType' (in NBO);
534    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
535    */
536   int32_t event_type GNUNET_PACKED;
537
538   /**
539    * Operation ID of the operation that created this event.
540    */
541   uint64_t operation_id GNUNET_PACKED;
542
543   /* followed by 0-terminated error message */
544
545 };
546
547
548 /**
549  * Event notification from a controller to a client.
550  */
551 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
552 {
553
554   /**
555    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
556    */
557   struct GNUNET_MessageHeader header;
558
559   /**
560    * Peer identity of the peer that was created.
561    */
562   uint32_t peer_id GNUNET_PACKED;
563
564   /**
565    * Operation ID of the operation that created this event.
566    */
567   uint64_t operation_id GNUNET_PACKED;
568
569 };
570
571
572 /**
573  * Event notification from a controller to a client for
574  * a generic operational success where the operation does
575  * not return any data.
576  */
577 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
578 {
579
580   /**
581    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
582    */
583   struct GNUNET_MessageHeader header;
584
585   /**
586    * 'enum GNUNET_TESTBED_EventType' (in NBO);
587    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
588    */
589   int32_t event_type GNUNET_PACKED;
590
591   /**
592    * Operation ID of the operation that created this event.
593    */
594   uint64_t operation_id GNUNET_PACKED;
595
596 };
597
598
599 /**
600  * Message sent from client to testing service to
601  * obtain the configuration of a peer.
602  */
603 struct GNUNET_TESTBED_PeerGetConfigurationMessage
604 {
605
606   /**
607    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_CONFIGURATION
608    */
609   struct GNUNET_MessageHeader header;
610
611   /**
612    * Unique ID for the peer.
613    */
614   uint32_t peer_id GNUNET_PACKED;
615
616   /**
617    * Operation ID that is used to identify this operation.
618    */
619   uint64_t operation_id GNUNET_PACKED;
620
621 };
622
623
624 /**
625  * Peer configuration and identity reply from controller to a client.
626  */
627 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
628 {
629
630   /**
631    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION
632    */
633   struct GNUNET_MessageHeader header;
634
635   /**
636    * The id of the peer relevant to this information
637    */
638   uint32_t peer_id GNUNET_PACKED;
639
640   /**
641    * Operation ID of the operation that created this event.
642    */
643   uint64_t operation_id GNUNET_PACKED;
644
645   /**
646    * Identity of the peer.
647    */
648   struct GNUNET_PeerIdentity peer_identity;
649
650   /**
651    * The size of configuration when uncompressed
652    */
653   uint16_t config_size GNUNET_PACKED;
654
655   /* followed by gzip-compressed configuration of the peer */
656
657 };
658
659
660 /**
661  * Message to request configuration of a slave controller
662  */
663 struct GNUNET_TESTBED_SlaveGetConfigurationMessage
664 {
665   /**
666    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
667    */
668   struct GNUNET_MessageHeader header;
669
670   /**
671    * The id of the slave host
672    */
673   uint32_t slave_id GNUNET_PACKED;
674
675   /**
676    * Operation ID
677    */
678   uint64_t operation_id GNUNET_PACKED;
679
680 };
681
682
683 /**
684  * Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIG message
685  */
686 struct GNUNET_TESTBED_SlaveConfiguration
687 {
688   /**
689    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
690    */
691   struct GNUNET_MessageHeader header;
692
693   /**
694    * The id of the host where the slave is running
695    */
696   uint32_t slave_id GNUNET_PACKED;
697
698   /**
699    * Operation ID
700    */
701   uint64_t operation_id GNUNET_PACKED;
702
703   /**
704    * The size of the configuration when uncompressed
705    */
706   uint16_t config_size GNUNET_PACKED;
707
708   /* followed by gzip-compressed configuration of the peer */
709
710 };
711
712
713 GNUNET_NETWORK_STRUCT_END
714 #endif
715 /* end of testbed.h */