support for killing guests properly
[strongswan.git] / src / dumm / dumm.h
1 /*
2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #ifndef DUMM_H
17 #define DUMM_H
18
19 #include <signal.h>
20
21 #include <library.h>
22 #include <utils/linked_list.h>
23
24 #include "guest.h"
25
26 #define HOST_DIR "host"
27 #define MOUNT_DIR "mount"
28 #define RUN_DIR "run"
29
30
31 typedef struct dumm_t dumm_t;
32
33 /**
34 * @brief dumm - Dynamic Uml Mesh Modeler
35 *
36 * Controls a group of UML guests and their networks.
37 */
38 struct dumm_t {
39
40 /**
41 * @brief Starts a new UML guest
42 *
43 * @param name name of the guest
44 * @param master mounted read only master filesystem
45 * @param mem amount of memory for guest, in MB
46 * @return guest if started, NULL if failed
47 */
48 guest_t* (*create_guest) (dumm_t *this, char *name, char *master, int mem);
49
50 /**
51 * @brief Create an iterator over all guests.
52 *
53 * @return iteraotor over guest_t's
54 */
55 iterator_t* (*create_guest_iterator) (dumm_t *this);
56
57 /**
58 * @brief Handler for received SIG_CHILD signals.
59 *
60 * Dumm spans children, UML kernels. To track and cleanup these kernel
61 * processes, it is required that this method is called whenever a SIG_CHILD
62 * is received. The user is responsible to call sigchild_handler on each
63 * dumm_t instance with the signals siginfo_t.
64 *
65 * @param info siginfo associated to the SIG_CHILD signal
66 */
67 void (*sigchild_handler)(dumm_t *this, siginfo_t *info);
68
69 /**
70 * @brief stop all guests and destroy the modeler
71 */
72 void (*destroy) (dumm_t *this);
73 };
74
75 /**
76 * @brief Create a new group of UML hosts and networks.
77 *
78 * Dumm uses its working dir to create folders and files it works with.
79 *
80 * @return created UML group, or NULL if failed.
81 */
82 dumm_t *dumm_create();
83
84 #endif /* DUMM_H */
85