WvStreams
if_tun.h
00001 /*
00002  *  Universal TUN/TAP device driver.
00003  *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *
00015  */
00016 
00017 #ifndef __IF_TUN_H
00018 #define __IF_TUN_H
00019 
00020 /* Uncomment to enable debugging */
00021 /* #define TUN_DEBUG 1 */
00022 
00023 #ifdef __KERNEL__
00024 
00025 #ifdef TUN_DEBUG
00026 #define DBG  if(tun->debug)printk
00027 #define DBG1 if(debug==2)printk
00028 #else
00029 #define DBG( a... )
00030 #define DBG1( a... )
00031 #endif
00032 
00033 struct tun_struct {
00034         char                    *name;
00035         unsigned long           flags;
00036         int                     attached;
00037         uid_t                   owner;
00038 
00039         wait_queue_head_t       read_wait;
00040         struct sk_buff_head     readq;
00041 
00042         struct net_device       dev;
00043         struct net_device_stats stats;
00044 
00045         struct fasync_struct    *fasync;
00046 
00047 #ifdef TUN_DEBUG        
00048         int debug;
00049 #endif  
00050 };
00051 
00052 #ifndef MIN
00053 #define MIN(a,b) ( (a)<(b) ? (a):(b) ) 
00054 #endif
00055 
00056 #endif /* __KERNEL__ */
00057 
00058 /* Read queue size */
00059 #define TUN_READQ_SIZE  10
00060 
00061 /* TUN device flags */
00062 #define TUN_TUN_DEV     0x0001  
00063 #define TUN_TAP_DEV     0x0002
00064 #define TUN_TYPE_MASK   0x000f
00065 
00066 #define TUN_FASYNC      0x0010
00067 #define TUN_NOCHECKSUM  0x0020
00068 #define TUN_NO_PI       0x0040
00069 #define TUN_ONE_QUEUE   0x0080
00070 #define TUN_PERSIST     0x0100  
00071 
00072 /* Ioctl defines */
00073 #define TUNSETNOCSUM  _IOW('T', 200, int) 
00074 #define TUNSETDEBUG   _IOW('T', 201, int) 
00075 #define TUNSETIFF     _IOW('T', 202, int) 
00076 #define TUNSETPERSIST _IOW('T', 203, int) 
00077 #define TUNSETOWNER   _IOW('T', 204, int)
00078 
00079 /* TUNSETIFF ifr flags */
00080 #define IFF_TUN         0x0001
00081 #define IFF_TAP         0x0002
00082 #define IFF_NO_PI       0x1000
00083 #define IFF_ONE_QUEUE   0x2000
00084 
00085 struct tun_pi {
00086         unsigned short flags;
00087         unsigned short proto;
00088 };
00089 #define TUN_PKT_STRIP   0x0001
00090 
00091 #endif /* __IF_TUN_H */