prototype of irdumm - interactive ruby shell for dumm
[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
22 #define TAP_DEVICE "/dev/net/tun"
23
24 typedef struct iface_t iface_t;
25
26 #include "mconsole.h"
27 #include "bridge.h"
28 #include "guest.h"
29
30 /**
31 * @brief Interface in a guest, connected to a tap device on the host.
32 */
33 struct iface_t {
34
35 /**
36 * @brief Get the interface name in the guest (e.g. eth0).
37 *
38 * @return guest interface name
39 */
40 char* (*get_guestif)(iface_t *this);
41
42 /**
43 * @brief Get the interface name at the host (e.g. tap0).
44 *
45 * @return host interface (tap device) name
46 */
47 char* (*get_hostif)(iface_t *this);
48
49 /**
50 * @brief Set the bridge this interface is attached to.
51 *
52 * @param bridge assigned bridge, or NULL for none
53 */
54 void (*set_bridge)(iface_t *this, bridge_t *bridge);
55
56 /**
57 * @brief Get the bridge this iface is connected, or NULL.
58 *
59 * @return connected bridge, or NULL
60 */
61 bridge_t* (*get_bridge)(iface_t *this);
62
63 /**
64 * @brief Get the guest this iface belongs to.
65 *
66 * @return guest of this iface
67 */
68 guest_t* (*get_guest)(iface_t *this);
69
70 /**
71 * @brief Destroy an interface
72 */
73 void (*destroy) (iface_t *this);
74 };
75
76 /**
77 * @brief Create a new interface for a guest
78 *
79 * @param name name of the interface in the guest
80 * @param guest guest this iface is connecting
81 * @param mconsole mconsole of guest
82 * @return interface descriptor, or NULL if failed
83 */
84 iface_t *iface_create(char *name, guest_t *guest, mconsole_t *mconsole);
85
86 #endif /* IFACE_H */
87