added dynamic interface manipulation for guests
[strongswan.git] / src / dumm / guest.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 GUEST_H
17 #define GUEST_H
18
19 #include <library.h>
20 #include <utils/iterator.h>
21
22 #include "iface.h"
23
24 typedef struct guest_t guest_t;
25
26 /**
27 * @brief A guest is a UML instance running on the host.
28 **/
29 struct guest_t {
30
31 /**
32 * @brief Get the name of this guest.
33 *
34 * @return name of the guest
35 */
36 char* (*get_name) (guest_t *this);
37
38 /**
39 * @brief Start the guest.
40 *
41 * @return TRUE if guest successfully started
42 */
43 bool (*start) (guest_t *this);
44
45 /**
46 * @brief Kill the guest.
47 *
48 * @return TRUE if guest was running and killed
49 */
50 bool (*stop) (guest_t *this);
51
52 /**
53 * @brief Create a new interface for that host.
54 *
55 * @param name name of the interface in the guest
56 * @return created interface, or NULL if failed
57 */
58 iface_t* (*create_iface)(guest_t *this, char *name);
59
60 /**
61 * @brief Create an iterator over all guest interfaces.
62 *
63 * @return iterator over iface_t's
64 */
65 iterator_t* (*create_iface_iterator)(guest_t *this);
66
67 /**
68 * @brief Close and destroy a guest with all interfaces
69 */
70 void (*destroy) (guest_t *this);
71 };
72
73 /**
74 * @brief Create a new, unstarted guest.
75 *
76 * @param name name of the guest
77 * @param kernel kernel to boot for this guest
78 * @param master read-only master filesystem for guest
79 * @param mem amount of memory to give the guest
80 */
81 guest_t *guest_create(char *name, char *kernel, char *master, int mem);
82
83 #endif /* GUEST_H */
84