- unify testbed operation handlers, avoid pointer arithmetic
[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   /* 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 username_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   /**
97    * The length of the uncompressed configuration
98    */
99   uint16_t config_size GNUNET_PACKED;
100
101   /* followed by non 0-terminated user name */
102
103   /* followed by non 0-terminated host name */
104
105   /* followed by gzip compressed configuration to start or connect to a
106      controller on this host.  While starting the controller this configration
107      is used as a template */
108
109 };
110
111
112 /**
113  * Confirmation from the service that adding a host
114  * worked (or failed).
115  * FIXME: Where is this required?
116  */
117 struct GNUNET_TESTBED_HostConfirmedMessage
118 {
119
120   /**
121    * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
122    */
123   struct GNUNET_MessageHeader header;
124
125   /**
126    * Unique ID for the host (in NBO).
127    */
128   uint32_t host_id GNUNET_PACKED;
129
130   /* followed by the 0-terminated error message (on failure)
131    * (typical errors include host-id already in use) */
132
133 };
134
135
136 /**
137  * Client notifies controller that it should delegate
138  * requests for a particular client to a particular
139  * sub-controller.
140  */
141 struct GNUNET_TESTBED_ControllerLinkRequest
142 {
143
144   /**
145    * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
146    */
147   struct GNUNET_MessageHeader header;
148
149   /**
150    * For which host should requests be delegated? NBO.
151    */
152   uint32_t delegated_host_id GNUNET_PACKED;
153
154   /**
155    * The id of the operation which created this message
156    */
157   uint64_t operation_id GNUNET_PACKED;
158
159   /**
160    * Which host is responsible for managing the delegation? NBO
161    */
162   uint32_t slave_host_id GNUNET_PACKED;
163
164   /**
165    * Set to 1 if the receiving controller is the master controller for
166    * the slave host (and thus responsible for starting it?). 0 if not
167    */
168   uint8_t is_subordinate;
169
170 };
171
172
173 /**
174  * Response message for ControllerLinkRequest message
175  */
176 struct GNUNET_TESTBED_ControllerLinkResponse
177 {
178   
179   /**
180    * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
181    */
182   struct GNUNET_MessageHeader header;
183
184   /**
185    * The size of the compressed configuration. Can be ZERO if the controller is
186    * not started (depends on the ControllerLinkRequest). NBO.
187    */
188   uint16_t config_size GNUNET_PACKED;
189
190   /**
191    * Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure
192    */
193   uint16_t success GNUNET_PACKED;
194
195   /**
196    * The id of the operation which created this message. NBO
197    */
198   uint64_t operation_id GNUNET_PACKED;
199
200   /* If controller linking is successful and configuration is present, then here
201    * comes the serialized gzip configuration with which the controller is
202    * running at the delegate host */
203
204   /* In case of failure, here comes the error message (without \0 termination)*/
205
206 };
207
208
209 /**
210  * Message sent from client to testing service to
211  * create (configure, but not start) a peer.
212  */
213 struct GNUNET_TESTBED_PeerCreateMessage
214 {
215
216   /**
217    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
218    */
219   struct GNUNET_MessageHeader header;
220
221   /**
222    * Unique operation id
223    */
224   uint64_t operation_id GNUNET_PACKED;
225
226   /**
227    * On which host should the peer be started?
228    */
229   uint32_t host_id GNUNET_PACKED;
230
231   /**
232    * Unique ID for the peer.
233    */
234   uint32_t peer_id GNUNET_PACKED;
235
236   /**
237    * Size of the uncompressed configuration
238    */
239   uint32_t config_size GNUNET_PACKED;
240
241   /* followed by serialized peer configuration;
242    * gzip'ed configuration file in INI format */
243
244 };
245
246
247 /**
248  * Message sent from client to testing service to
249  * reconfigure a (stopped) a peer.
250  */
251 struct GNUNET_TESTBED_PeerReconfigureMessage
252 {
253
254   /**
255    * Type is GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER
256    */
257   struct GNUNET_MessageHeader header;
258
259   /**
260    * Unique ID for the peer.
261    */
262   uint32_t peer_id GNUNET_PACKED;
263
264   /**
265    * Operation ID that is used to identify this operation.
266    */
267   uint64_t operation_id 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
453 };
454
455
456 /**
457  * Event notification from a controller to a client.
458  */
459 struct GNUNET_TESTBED_PeerEventMessage
460 {
461
462   /**
463    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
464    */
465   struct GNUNET_MessageHeader header;
466
467   /**
468    * 'enum GNUNET_TESTBED_EventType' (in NBO);
469    * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
470    */
471   int32_t event_type GNUNET_PACKED;
472
473   /**
474    * Host where the peer is running.
475    */
476   uint32_t host_id GNUNET_PACKED;
477
478   /**
479    * Peer that was started or stopped.
480    */
481   uint32_t peer_id 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 /**
492  * Event notification from a controller to a client.
493  */
494 struct GNUNET_TESTBED_ConnectionEventMessage
495 {
496
497   /**
498    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
499    */
500   struct GNUNET_MessageHeader header;
501
502   /**
503    * 'enum GNUNET_TESTBED_EventType' (in NBO);
504    * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT.
505    */
506   int32_t event_type GNUNET_PACKED;
507
508   /**
509    * First peer.
510    */
511   uint32_t peer1 GNUNET_PACKED;
512
513   /**
514    * Second peer.
515    */
516   uint32_t peer2 GNUNET_PACKED;
517
518   /**
519    * Operation ID that is used to identify this operation.
520    */
521   uint64_t operation_id GNUNET_PACKED;
522
523 };
524
525
526 /**
527  * Event notification from a controller to a client.
528  */
529 struct GNUNET_TESTBED_OperationFailureEventMessage
530 {
531
532   /**
533    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
534    */
535   struct GNUNET_MessageHeader header;
536
537   /**
538    * 'enum GNUNET_TESTBED_EventType' (in NBO);
539    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
540    */
541   int32_t event_type GNUNET_PACKED;
542
543   /**
544    * Operation ID of the operation that created this event.
545    */
546   uint64_t operation_id GNUNET_PACKED;
547
548   /* followed by 0-terminated error message */
549
550 };
551
552
553 /**
554  * Event notification from a controller to a client.
555  */
556 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
557 {
558
559   /**
560    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
561    */
562   struct GNUNET_MessageHeader header;
563
564   /**
565    * Peer identity of the peer that was created.
566    */
567   uint32_t peer_id GNUNET_PACKED;
568
569   /**
570    * Operation ID of the operation that created this event.
571    */
572   uint64_t operation_id GNUNET_PACKED;
573
574 };
575
576
577 /**
578  * Event notification from a controller to a client for
579  * a generic operational success where the operation does
580  * not return any data.
581  */
582 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
583 {
584
585   /**
586    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
587    */
588   struct GNUNET_MessageHeader header;
589
590   /**
591    * 'enum GNUNET_TESTBED_EventType' (in NBO);
592    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
593    */
594   int32_t event_type GNUNET_PACKED;
595
596   /**
597    * Operation ID of the operation that created this event.
598    */
599   uint64_t operation_id GNUNET_PACKED;
600
601 };
602
603
604 /**
605  * Message sent from client to testing service to
606  * obtain the configuration of a peer.
607  */
608 struct GNUNET_TESTBED_PeerGetConfigurationMessage
609 {
610
611   /**
612    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_CONFIGURATION
613    */
614   struct GNUNET_MessageHeader header;
615
616   /**
617    * Unique ID for the peer.
618    */
619   uint32_t peer_id GNUNET_PACKED;
620
621   /**
622    * Operation ID that is used to identify this operation.
623    */
624   uint64_t operation_id GNUNET_PACKED;
625
626 };
627
628
629 /**
630  * Peer configuration and identity reply from controller to a client.
631  */
632 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
633 {
634
635   /**
636    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION
637    */
638   struct GNUNET_MessageHeader header;
639
640   /**
641    * The id of the peer relevant to this information
642    */
643   uint32_t peer_id GNUNET_PACKED;
644
645   /**
646    * Operation ID of the operation that created this event.
647    */
648   uint64_t operation_id GNUNET_PACKED;
649
650   /**
651    * Identity of the peer.
652    */
653   struct GNUNET_PeerIdentity peer_identity;
654
655   /**
656    * The size of configuration when uncompressed
657    */
658   uint16_t config_size GNUNET_PACKED;
659
660   /* followed by gzip-compressed configuration of the peer */
661
662 };
663
664
665 /**
666  * Message to request configuration of a slave controller
667  */
668 struct GNUNET_TESTBED_SlaveGetConfigurationMessage
669 {
670   /**
671    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
672    */
673   struct GNUNET_MessageHeader header;
674
675   /**
676    * The id of the slave host
677    */
678   uint32_t slave_id GNUNET_PACKED;
679
680   /**
681    * Operation ID
682    */
683   uint64_t operation_id GNUNET_PACKED;
684
685 };
686
687
688 /**
689  * Reply to GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIG message
690  */
691 struct GNUNET_TESTBED_SlaveConfiguration
692 {
693   /**
694    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
695    */
696   struct GNUNET_MessageHeader header;
697
698   /**
699    * The id of the host where the slave is running
700    */
701   uint32_t slave_id GNUNET_PACKED;
702
703   /**
704    * Operation ID
705    */
706   uint64_t operation_id GNUNET_PACKED;
707
708   /**
709    * The size of the configuration when uncompressed
710    */
711   uint16_t config_size GNUNET_PACKED;
712
713   /* followed by gzip-compressed configuration of the peer */
714
715 };
716
717
718 /**
719  * Shutdown peers message
720  */
721 struct GNUNET_TESTBED_ShutdownPeersMessage
722 {
723   /**
724    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
725    */
726   struct GNUNET_MessageHeader header;
727
728   /**
729    * Operation ID
730    */
731   uint64_t operation_id GNUNET_PACKED;
732 };
733
734
735 /**
736  * Message to start/stop services of a peer
737  */
738 struct GNUNET_TESTBED_ManagePeerServiceMessage
739 {
740   /**
741    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
742    */
743   struct GNUNET_MessageHeader header;
744
745   /**
746    * Unique ID of the peer whose service has to be managed.
747    */
748   uint32_t peer_id GNUNET_PACKED;
749
750   /**
751    * Operation ID
752    */
753   uint64_t operation_id GNUNET_PACKED;
754
755   /**
756    * set this to 1 to start the service; 0 to stop the service
757    */
758   uint8_t start;
759   
760   /**
761    * The NULL-terminated name of the service to start/stop follows here
762    */
763 };
764
765
766 GNUNET_NETWORK_STRUCT_END
767 #endif
768 /* end of testbed.h */