link controller handler
[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 NEW_TESTING_H
28 #define NEW_TESTING_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    * On which host should the peer be started?
202    */
203   uint32_t host_id GNUNET_PACKED;
204
205   /**
206    * Unique ID for the peer.
207    */
208   uint32_t peer_id GNUNET_PACKED;
209
210   /* followed by serialized peer configuration;
211      gzip'ed configuration file in INI format */
212   
213 };
214
215
216 /**
217  * Message sent from client to testing service to 
218  * reconfigure a (stopped) a peer.
219  */
220 struct GNUNET_TESTBED_PeerReconfigureMessage
221 {
222
223   /**
224    * Type is GNUNET_MESSAGE_TYPDE_TESTBED_PEERRECONF
225    */
226   struct GNUNET_MessageHeader header;
227
228   /**
229    * Unique ID for the peer.
230    */
231   uint32_t peer_id GNUNET_PACKED;
232
233   /**
234    * Operation ID that is used to identify this operation.
235    */
236   uint64_t operation_id GNUNET_PACKED;
237
238   /* followed by serialized peer configuration;
239      gzip'ed configuration file in INI format */
240   
241 };
242
243
244 /**
245  * Message sent from client to testing service to
246  * start a peer.
247  */
248 struct GNUNET_TESTBED_PeerStartMessage
249 {
250
251   /**
252    * Type is GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER
253    */
254   struct GNUNET_MessageHeader header;
255
256   /**
257    * Unique ID for the peer.
258    */
259   uint32_t peer_id GNUNET_PACKED;
260
261   /**
262    * Operation ID that is used to identify this operation.
263    */
264   uint64_t operation_id GNUNET_PACKED;
265
266 };
267
268
269 /**
270  * Message sent from client to testing service to
271  * stop a peer.
272  */
273 struct GNUNET_TESTBED_PeerStopMessage
274 {
275
276   /**
277    * Type is GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER
278    */
279   struct GNUNET_MessageHeader header;
280
281   /**
282    * Unique ID for the peer.
283    */
284   uint32_t peer_id GNUNET_PACKED;
285
286   /**
287    * Operation ID that is used to identify this operation.
288    */
289   uint64_t operation_id GNUNET_PACKED;
290
291 };
292
293
294 /**
295  * Message sent from client to testing service to
296  * destroy a (stopped) peer.
297  */
298 struct GNUNET_TESTBED_PeerDestroyMessage
299 {
300
301   /**
302    * Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER
303    */
304   struct GNUNET_MessageHeader header;
305
306   /**
307    * Unique ID for the peer.
308    */
309   uint32_t peer_id GNUNET_PACKED;
310
311   /**
312    * Operation ID that is used to identify this operation.
313    */
314   uint64_t operation_id GNUNET_PACKED;
315
316 };
317
318
319 /**
320  * Message sent from client to testing service to
321  * (re)configure a "physical" link between two peers.
322  */
323 struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
324 {
325
326   /**
327    * Type is GNUNET_MESSAGE_TYPE_TESTBED_CONFIGULLINK
328    */
329   struct GNUNET_MessageHeader header;
330
331   /**
332    * 'enum GNUNET_TESTBED_ConnectOption' of the option to change
333    */
334   int32_t connect_option GNUNET_PACKED;
335
336   /**
337    * Unique ID for the first peer.
338    */
339   uint32_t peer1 GNUNET_PACKED;
340
341   /**
342    * Unique ID for the second peer.
343    */
344   uint32_t peer2 GNUNET_PACKED;
345
346   /**
347    * Operation ID that is used to identify this operation.
348    */
349   uint64_t operation_id GNUNET_PACKED;
350
351   /* followed by option-dependent variable-size values */
352
353 };
354
355
356 /**
357  * Message sent from client to testing service to
358  * connect two peers.
359  */
360 struct GNUNET_TESTBED_OverlayConnectMessage
361 {
362
363   /**
364    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT
365    */
366   struct GNUNET_MessageHeader header;
367
368   /**
369    * Unique ID for the first peer.
370    */
371   uint32_t peer1 GNUNET_PACKED;
372
373   /**
374    * Operation ID that is used to identify this operation.
375    */
376   uint64_t operation_id GNUNET_PACKED;
377
378   /**
379    * Unique ID for the second peer.
380    */
381   uint32_t peer2 GNUNET_PACKED;
382
383 };
384
385
386 /**
387  * Event notification from a controller to a client.
388  */
389 struct GNUNET_TESTBED_PeerEventMessage
390 {
391
392   /**
393    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT
394    */
395   struct GNUNET_MessageHeader header;
396
397   /**
398    * 'enum GNUNET_TESTBED_EventType' (in NBO);
399    * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
400    */
401   int32_t event_type GNUNET_PACKED;
402   
403   /**
404    * Host where the peer is running.
405    */
406   uint32_t host_id GNUNET_PACKED;
407
408   /**
409    * Peer that was started or stopped.
410    */
411   uint32_t peer_id GNUNET_PACKED;
412
413   /**
414    * Operation ID that is used to identify this operation.
415    */
416   uint64_t operation_id GNUNET_PACKED;
417
418 };
419
420
421 /**
422  * Event notification from a controller to a client.
423  */
424 struct GNUNET_TESTBED_ConnectionEventMessage
425 {
426
427   /**
428    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT
429    */
430   struct GNUNET_MessageHeader header;
431
432   /**
433    * 'enum GNUNET_TESTBED_EventType' (in NBO);
434    * either GNUNET_TESTBED_ET_PEER_CONNECT or GNUNET_TESTBED_ET_PEER_DISCONNECT.
435    */
436   int32_t event_type GNUNET_PACKED;
437   
438   /**
439    * First peer.
440    */
441   uint32_t peer1 GNUNET_PACKED;
442
443   /**
444    * Second peer.
445    */
446   uint32_t peer2 GNUNET_PACKED;
447
448   /**
449    * Operation ID that is used to identify this operation.
450    */
451   uint64_t operation_id GNUNET_PACKED;
452
453 };
454
455
456 /**
457  * Event notification from a controller to a client.
458  */
459 struct GNUNET_TESTBED_OperationFailureEventMessage
460 {
461
462   /**
463    * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONEVENT
464    */
465   struct GNUNET_MessageHeader header;
466
467   /**
468    * 'enum GNUNET_TESTBED_EventType' (in NBO);
469    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
470    */
471   int32_t event_type GNUNET_PACKED;
472   
473   /**
474    * Operation ID of the operation that created this event.
475    */
476   uint64_t operation_id GNUNET_PACKED;
477
478   /* followed by 0-terminated error message */
479
480 };
481
482
483 /**
484  * Event notification from a controller to a client.
485  */
486 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
487 {
488
489   /**
490    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS
491    */
492   struct GNUNET_MessageHeader header;
493
494   /**
495    * Peer identity of the peer that was created.
496    */
497   uint32_t peer_id GNUNET_PACKED;
498   
499   /**
500    * Operation ID of the operation that created this event.
501    */
502   uint64_t operation_id GNUNET_PACKED;
503
504 };
505
506
507 /**
508  * Event notification from a controller to a client for
509  * a generic operational success where the operation does
510  * not return any data.
511  */
512 struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
513 {
514
515   /**
516    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS
517    */
518   struct GNUNET_MessageHeader header;
519
520   /**
521    * 'enum GNUNET_TESTBED_EventType' (in NBO);
522    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
523    */
524   int32_t event_type GNUNET_PACKED;
525   
526   /**
527    * Operation ID of the operation that created this event.
528    */
529   uint64_t operation_id GNUNET_PACKED;
530
531 };
532
533
534
535
536 /**
537  * Message sent from client to testing service to 
538  * obtain the configuration of a peer.
539  */
540 struct GNUNET_TESTBED_PeerGetConfigurationMessage
541 {
542
543   /**
544    * Type is GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG
545    */
546   struct GNUNET_MessageHeader header;
547
548   /**
549    * Unique ID for the peer.
550    */
551   uint32_t peer_id GNUNET_PACKED;
552
553   /**
554    * Operation ID that is used to identify this operation.
555    */
556   uint64_t operation_id GNUNET_PACKED;
557
558 };
559
560
561
562 /**
563  * Event notification from a controller to a client.
564  */
565 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
566 {
567
568   /**
569    * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG
570    */
571   struct GNUNET_MessageHeader header;
572
573   /**
574    * Peer number of the peer that was created.
575    */
576   uint32_t peer_number GNUNET_PACKED;
577   
578   /**
579    * Operation ID of the operation that created this event.
580    */
581   uint64_t operation_id GNUNET_PACKED;
582
583   /**
584    * Identity of the peer.
585    */
586   struct GNUNET_PeerIdentity peer_id;
587
588   /* followed by gzip-compressed configuration of the peer */
589
590 };
591
592 #endif