version 0.9.6
[rofl0r-htun.git] / include / tun.h
blob6b2ea7e76cfc31eb07b126f00d1ebdad1d1e8bd4
1 /*
2 * Universal TUN/TAP device driver.
3 * Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 * Modified for use with htun by Moshe Jacobson <moshe@runslinux.net>
18 * and Ola Nordström <ola@triblock.com>
20 * $Id: tun.h,v 2.15 2002/04/28 05:29:07 jehsom Exp $
23 #ifndef __IF_TUN_H
24 #define __IF_TUN_H
26 #include <net/if.h>
27 #include <netinet/in.h>
28 #include "clidata.h"
30 /* Read queue size */
31 #define TUN_READQ_SIZE 10
33 /* TUN device flags */
34 #define TUN_TUN_DEV 0x0001
35 #define TUN_TAP_DEV 0x0002
36 #define TUN_TYPE_MASK 0x000f
38 #define TUN_FASYNC 0x0010
39 #define TUN_NOCHECKSUM 0x0020
40 #define TUN_NO_PI 0x0040
41 #define TUN_ONE_QUEUE 0x0080
42 #define TUN_PERSIST 0x0100
44 /* Ioctl defines */
45 #define TUNSETNOCSUM _IOW('T', 200, int)
46 #define TUNSETDEBUG _IOW('T', 201, int)
47 #define TUNSETIFF _IOW('T', 202, int)
48 #define TUNSETPERSIST _IOW('T', 203, int)
49 #define TUNSETOWNER _IOW('T', 204, int)
51 /* TUNSETIFF ifr flags */
52 #define IFF_TUN 0x0001
53 #define IFF_TAP 0x0002
54 #define IFF_NO_PI 0x1000
55 #define IFF_ONE_QUEUE 0x2000
57 struct tun_pi {
58 unsigned short flags;
59 unsigned short proto;
61 #define TUN_PKT_STRIP 0x0001
63 /*
64 * * Allocates a tun device based on the input set of acceptable ip ranges.
65 * Simply attempts to bring up the interface with successive IPs until it
66 * succeeds. Then attempts to assign peer addresses with successive IPs until
67 * that succeeds. On success, returns 0 and sets the following variables:
68 * clidata->tunfd
69 * clidata->cliaddr
70 * clidata->srvaddr
71 * On failure, returns -1
73 int srv_tun_alloc( clidata_t *clidata, clidata_list_t *clients );
76 * Stores the default gateway information for later undoing by
77 * restore_default_gw().
79 int store_default_gw(void);
82 * sets routing table's default gateway to the sock peer addrress
84 int set_default_gw( int sockfd );
87 * Restores the default route to what it was before set_default_gw() was
88 * called.
90 int restore_default_gw(void);
93 * fetches the mac addr
94 * returns a pointer to a static buffer of the mac addr
96 char *get_mac( char *ifname );
99 * sets up the tun dev according to the specidied
100 * local and peer ip
102 int cli_tun_alloc(struct in_addr local, struct in_addr peer);
105 #endif /* __IF_TUN_H */