peer destroy with new operations handling
[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
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_ADDHOST
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 user_name_length GNUNET_PACKED;
87
88   /* followed by 0-terminated user name */
89
90   /* followed by 0-terminated host name */
91
92 };
93
94
95 /**
96  * Confirmation from the service that adding a host
97  * worked (or failed).
98  * FIXME: Where is this required?
99  */
100 struct GNUNET_TESTBED_HostConfirmedMessage
101 {
102
103   /**
104    * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTSUCCESS
105    */
106   struct GNUNET_MessageHeader header;
107
108   /**
109    * Unique ID for the host (in NBO).
110    */
111   uint32_t host_id GNUNET_PACKED;
112
113   /* followed by the 0-terminated error message (on failure) 
114    (typical errors include failure to login and 
115    host-id already in use) */
116
117 };
118
119
120 /**
121  * Message to testing service: configure service sharing
122  * at a host.
123  */
124 struct GNUNET_TESTBED_ConfigureSharedServiceMessage
125 {
126
127   /**
128    * Type is GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE
129    */
130   struct GNUNET_MessageHeader header;
131
132   /**
133    * Host that is being configured.
134    */
135   uint32_t host_id GNUNET_PACKED;
136
137   /**
138    * Number of peers that should share a service instance;
139    * 1 for no sharing, 0 to forcefully disable the service.
140    */
141   uint32_t num_peers GNUNET_PACKED;
142
143   /* followed by 0-terminated name of the service */
144
145 };
146
147
148 /**
149  * Client notifies controller that it should delegate
150  * requests for a particular client to a particular
151  * sub-controller.
152  */
153 struct GNUNET_TESTBED_ControllerLinkMessage
154 {
155
156   /**
157    * Type is GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS
158    */
159   struct GNUNET_MessageHeader header;
160
161   /**
162    * For which host should requests be delegated? NBO.
163    */
164   uint32_t delegated_host_id GNUNET_PACKED;
165
166   /**
167    * Which host is responsible for managing the delegation? NBO
168    */
169   uint32_t slave_host_id GNUNET_PACKED;
170
171   /**
172    * The size of the uncompressed configuration
173    */
174   uint16_t config_size GNUNET_PACKED;
175
176   /**
177    * Set to 1 if the receiving controller is the master controller for
178    * the slave host (and thus responsible for starting it?). 0 if not
179    */
180   uint8_t is_subordinate;
181
182   /* followed by serialized slave configuration;
183      gzip'ed configuration file in INI format */
184
185 };
186
187
188 /**
189  * Message sent from client to testing service to 
190  * create (configure, but not start) a peer.
191  */
192 struct GNUNET_TESTBED_PeerCreateMessage
193 {
194
195   /**
196    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER
197    */
198   struct GNUNET_MessageHeader header;
199
200   /**
201    * Unique operation id
202    */
203   uint64_t operation_id GNUNET_PACKED;
204
205   /**
206    * On which host should the peer be started?
207    */
208   uint32_t host_id GNUNET_PACKED;
209
210   /**
211    * Unique ID for the peer.
212    */
213   uint32_t peer_id GNUNET_PACKED;
214
215   /**
216    * Size of the uncompressed configuration
217    */
218   uint32_t config_size GNUNET_PACKED;
219
220   /* followed by serialized peer configuration;
221      gzip'ed configuration file in INI format */
222   
223 };
224
225
226 /**
227  * Message sent from client to testing service to 
228  * reconfigure a (stopped) a peer.
229  */
230 struct GNUNET_TESTBED_PeerReconfigureMessage
231 {
232
233   /**
234    * Type is GNUNET_MESSAGE_TYPDE_TESTBED_PEERRECONF
235    */
236   struct GNUNET_MessageHeader header;
237
238   /**
239    * Unique ID for the peer.
240    */
241   uint32_t peer_id GNUNET_PACKED;
242
243   /**
244    * Operation ID that is used to identify this operation.
245    */
246   uint64_t operation_id GNUNET_PACKED;
247
248   /* followed by serialized peer configuration;
249      gzip'ed configuration file in INI format */
250   
251 };
252
253
254 /**
255  * Message sent from client to testing service to
256  * start a peer.
257  */
258 struct GNUNET_TESTBED_PeerStartMessage
259 {
260
261   /**
262    * Type is GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER
263    */
264   struct GNUNET_MessageHeader header;
265
266   /**
267    * Unique ID for the peer.
268    */
269   uint32_t peer_id GNUNET_PACKED;
270
271   /**
272    * Operation ID that is used to identify this operation.
273    */
274   uint64_t operation_id GNUNET_PACKED;
275
276 };
277
278
279 /**
280  * Message sent from client to testing service to
281  * stop a peer.
282  */
283 struct GNUNET_TESTBED_PeerStopMessage
284 {
285
286   /**
287    * Type is GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER
288    */
289   struct GNUNET_MessageHeader header;
290
291   /**
292    * Unique ID for the peer.
293    */
294   uint32_t peer_id GNUNET_PACKED;
295
296   /**
297    * Operation ID that is used to identify this operation.
298    */
299   uint64_t operation_id GNUNET_PACKED;
300
301 };
302
303
304 /**
305  * Message sent from client to testing service to
306  * destroy a (stopped) peer.
307  */
308 struct GNUNET_TESTBED_PeerDestroyMessage
309 {
310
311   /**
312    * Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER
313    */
314   struct GNUNET_MessageHeader header;
315
316   /**
317    * Unique ID for the peer.
318    */
319   uint32_t peer_id GNUNET_PACKED;
320
321   /**
322    * Operation ID that is used to identify this operation.
323    */
324   uint64_t operation_id GNUNET_PACKED;
325
326 };
327
328
329 /**
330  * Message sent from client to testing service to
331  * (re)configure a "physical" link between two peers.
332  */
333 struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
334 {
335
336   /**
337    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CONFIGULLINK
338    */
339   struct GNUNET_MessageHeader header;
340
341   /**
342    * 'enum GNUNET_TESTBED_ConnectOption' of the option to change
343    */
344   int32_t connect_option GNUNET_PACKED;
345
346   /**
347    * Unique ID for the first peer.
348    */
349   uint32_t peer1 GNUNET_PACKED;
350
351   /**
352    * Unique ID for the second peer.
353    */
354   uint32_t peer2 GNUNET_PACKED;
355
356   /**
357    * Operation ID that is used to identify this operation.
358    */
359   uint64_t operation_id GNUNET_PACKED;
360
361   /* followed by option-dependent variable-size values */
362
363 };
364
365
366 /**
367  * Message sent from client to testing service to
368  * connect two peers.
369  */
370 struct GNUNET_TESTBED_OverlayConnectMessage
371 {
372
373   /**
374    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT
375    */
376   struct GNUNET_MessageHeader header;
377
378   /**
379    * Unique ID for the first peer.
380    */
381   uint32_t peer1 GNUNET_PACKED;
382
383   /**
384    * Operation ID that is used to identify this operation.
385    */
386   uint64_t operation_id GNUNET_PACKED;
387
388   /**
389    * Unique ID for the second peer.
390    */
391   uint32_t peer2 GNUNET_PACKED;
392
393 };
394
395
396 /**
397  * Event notification from a controller to a client.
398  */
399 struct GNUNET_TESTBED_PeerEventMessage
400 {
401
402   /**
403    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT
404    */
405   struct GNUNET_MessageHeader header;
406
407   /**
408    * 'enum GNUNET_TESTBED_EventType' (in NBO);
409    * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
410    */
411   int32_t event_type GNUNET_PACKED;
412   
413   /**
414    * Host where the peer is running.
415    */
416   uint32_t host_id GNUNET_PACKED;
417
418   /**
419    * Peer that was started or stopped.
420    */
421   uint32_t peer_id GNUNET_PACKED;
422
423   /**
424    * Operation ID that is used to identify this operation.
425    */
426   uint64_t operation_id GNUNET_PACKED;
427
428 };
429
430
431 /**
432  * Event notification from a controller to a client.
433  */
434 struct GNUNET_TESTBED_ConnectionEventMessage
435 {
436
437   /**
438    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT
439    */
440   struct GNUNET_MessageHeader header;
441
442   /**
443    * 'enum GNUNET_TESTBED_EventType' (in NBO);
444    * either GNUNET_TESTBED_ET_PEER_CONNECT or GNUNET_TESTBED_ET_PEER_DISCONNECT.
445    */
446   int32_t event_type GNUNET_PACKED;
447   
448   /**
449    * First peer.
450    */
451   uint32_t peer1 GNUNET_PACKED;
452
453   /**
454    * Second peer.
455    */
456   uint32_t peer2 GNUNET_PACKED;
457
458   /**
459    * Operation ID that is used to identify this operation.
460    */
461   uint64_t operation_id GNUNET_PACKED;
462
463 };
464
465
466 /**
467  * Event notification from a controller to a client.
468  */
469 struct GNUNET_TESTBED_OperationFailureEventMessage
470 {
471
472   /**
473    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONEVENT
474    */
475   struct GNUNET_MessageHeader header;
476
477   /**
478    * 'enum GNUNET_TESTBED_EventType' (in NBO);
479    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
480    */
481   int32_t event_type GNUNET_PACKED;
482   
483   /**
484    * Operation ID of the operation that created this event.
485    */
486   uint64_t operation_id GNUNET_PACKED;
487
488   /* followed by 0-terminated error message */
489
490 };
491
492
493 /**
494  * Event notification from a controller to a client.
495  */
496 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
497 {
498
499   /**
500    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS
501    */
502   struct GNUNET_MessageHeader header;
503
504   /**
505    * Peer identity of the peer that was created.
506    */
507   uint32_t peer_id GNUNET_PACKED;
508   
509   /**
510    * Operation ID of the operation that created this event.
511    */
512   uint64_t operation_id GNUNET_PACKED;
513
514 };
515
516
517 /**
518  * Event notification from a controller to a client for
519  * a generic operational success where the operation does
520  * not return any data.
521  */
522 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
523 {
524
525   /**
526    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS
527    */
528   struct GNUNET_MessageHeader header;
529
530   /**
531    * 'enum GNUNET_TESTBED_EventType' (in NBO);
532    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
533    */
534   int32_t event_type GNUNET_PACKED;
535   
536   /**
537    * Operation ID of the operation that created this event.
538    */
539   uint64_t operation_id GNUNET_PACKED;
540
541 };
542
543
544
545
546 /**
547  * Message sent from client to testing service to 
548  * obtain the configuration of a peer.
549  */
550 struct GNUNET_TESTBED_PeerGetConfigurationMessage
551 {
552
553   /**
554    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG
555    */
556   struct GNUNET_MessageHeader header;
557
558   /**
559    * Unique ID for the peer.
560    */
561   uint32_t peer_id GNUNET_PACKED;
562
563   /**
564    * Operation ID that is used to identify this operation.
565    */
566   uint64_t operation_id GNUNET_PACKED;
567
568 };
569
570
571
572 /**
573  * Event notification from a controller to a client.
574  */
575 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
576 {
577
578   /**
579    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG
580    */
581   struct GNUNET_MessageHeader header;
582
583   /**
584    * The id of the peer relevant to this information
585    */
586   uint32_t peer_id GNUNET_PACKED;
587   
588   /**
589    * Operation ID of the operation that created this event.
590    */
591   uint64_t operation_id GNUNET_PACKED;
592
593   /**
594    * Identity of the peer.
595    */
596   struct GNUNET_PeerIdentity peer_identity;
597
598   /**
599    * The size of configuration when uncompressed
600    */
601   uint16_t config_size;
602
603   /* followed by gzip-compressed configuration of the peer */
604
605 };
606
607 #endif