2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
20 #include <utils/enumerator.h>
21 #include <utils/host.h>
23 #define TAP_DEVICE "/dev/net/tun"
25 typedef struct iface_t iface_t
;
32 * @brief Interface in a guest, connected to a tap device on the host.
37 * @brief Get the interface name in the guest (e.g. eth0).
39 * @return guest interface name
41 char* (*get_guestif
)(iface_t
*this);
44 * @brief Get the interface name at the host (e.g. tap0).
46 * @return host interface (tap device) name
48 char* (*get_hostif
)(iface_t
*this);
51 * Add an address to the interface.
53 * @param addr address to add to interface
54 * @return TRUE if address added
56 bool (*add_address
)(iface_t
*this, host_t
*addr
);
59 * Create an enumerator over all installed addresses.
61 * @return enumerator over host_t*
63 enumerator_t
* (*create_address_enumerator
)(iface_t
*this);
66 * Remove an address from an interface.
68 * @param addr address to remove
69 * @return TRUE if address removed
71 bool (*delete_address
)(iface_t
*this, host_t
*addr
);
74 * @brief Set the bridge this interface is attached to.
76 * @param bridge assigned bridge, or NULL for none
78 void (*set_bridge
)(iface_t
*this, bridge_t
*bridge
);
81 * @brief Get the bridge this iface is connected, or NULL.
83 * @return connected bridge, or NULL
85 bridge_t
* (*get_bridge
)(iface_t
*this);
88 * @brief Get the guest this iface belongs to.
90 * @return guest of this iface
92 guest_t
* (*get_guest
)(iface_t
*this);
95 * @brief Destroy an interface
97 void (*destroy
) (iface_t
*this);
101 * @brief Create a new interface for a guest
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
108 iface_t
*iface_create(char *name
, guest_t
*guest
, mconsole_t
*mconsole
);