Move all source code to src/.
[oweals/tinc.git] / src / vnd.h
1 /*
2     vnd.c -- virtual network device management
3
4     Copyright (C) 2003-2004 Guus Sliepen <guus@tinc-vpn.org>,
5                   2003-2004 Ivo Timmermans <ivo@tinc-vpn.org>
6
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21     $Id$
22 */
23
24 #ifndef __VND_H__
25 #define __VND_H__
26
27 typedef enum vnd_mode{
28         VND_MODE_TUN,
29         VND_MODE_TAP,
30 } vnd_mode_t;
31
32 struct vnd;
33
34 typedef bool (*vnd_handler_t)(struct vnd *vnd, const void *buf, int len);
35
36 typedef struct vnd {
37         char *device;
38         char *interface;
39         enum vnd_mode mode;
40         int mtu;
41
42         vnd_handler_t recv;
43         vnd_handler_t send;
44
45         /* Private data */
46
47         struct fd fd;
48         char *description;
49 } vnd_t;
50
51 extern bool vnd_init(void);
52 extern bool vnd_exit(void);
53 extern struct vnd *vnd_new(void);
54 extern void vnd_free(struct vnd *vnd);
55 extern void vnd_set(struct vnd *vnd, char *device, char *interface, vnd_mode_t mode, vnd_handler_t recv);
56 extern bool vnd_open(struct vnd *vnd);
57 extern bool vnd_close(struct vnd *vnd);
58
59 #endif /* __VND_H__ */