Added support for multiple overlays to the copy-on-write filesystem.
[strongswan.git] / src / dumm / iface.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 IFACE_H
17 #define IFACE_H
18
19 #include <library.h>
20 #include <utils/enumerator.h>
21 #include <utils/host.h>
22
23 #define TAP_DEVICE "/dev/net/tun"
24
25 typedef struct iface_t iface_t;
26
27 #include "mconsole.h"
28 #include "bridge.h"
29 #include "guest.h"
30
31 /**
32 * Interface in a guest, connected to a tap device on the host.
33 */
34 struct iface_t {
35
36 /**
37 * Get the interface name in the guest (e.g. eth0).
38 *
39 * @return guest interface name
40 */
41 char* (*get_guestif)(iface_t *this);
42
43 /**
44 * Get the interface name at the host (e.g. tap0).
45 *
46 * @return host interface (tap device) name
47 */
48 char* (*get_hostif)(iface_t *this);
49
50 /**
51 * Add an address to the interface.
52 *
53 * @param addr address to add to interface
54 * @return TRUE if address added
55 */
56 bool (*add_address)(iface_t *this, host_t *addr);
57
58 /**
59 * Create an enumerator over all installed addresses.
60 *
61 * @return enumerator over host_t*
62 */
63 enumerator_t* (*create_address_enumerator)(iface_t *this);
64
65 /**
66 * Remove an address from an interface.
67 *
68 * @param addr address to remove
69 * @return TRUE if address removed
70 */
71 bool (*delete_address)(iface_t *this, host_t *addr);
72
73 /**
74 * Set the bridge this interface is attached to.
75 *
76 * @param bridge assigned bridge, or NULL for none
77 */
78 void (*set_bridge)(iface_t *this, bridge_t *bridge);
79
80 /**
81 * Get the bridge this iface is connected, or NULL.
82 *
83 * @return connected bridge, or NULL
84 */
85 bridge_t* (*get_bridge)(iface_t *this);
86
87 /**
88 * Get the guest this iface belongs to.
89 *
90 * @return guest of this iface
91 */
92 guest_t* (*get_guest)(iface_t *this);
93
94 /**
95 * Destroy an interface
96 */
97 void (*destroy) (iface_t *this);
98 };
99
100 /**
101 * Create a new interface for a guest
102 *
103 * @param name name of the interface in the guest
104 * @param guest guest this iface is connecting
105 * @param mconsole mconsole of guest
106 * @return interface descriptor, or NULL if failed
107 */
108 iface_t *iface_create(char *name, guest_t *guest, mconsole_t *mconsole);
109
110 #endif /* IFACE_H */
111