Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  *  Universal TUN/TAP device driver.
0004  *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>
0005  *
0006  *  This program is free software; you can redistribute it and/or modify
0007  *  it under the terms of the GNU General Public License as published by
0008  *  the Free Software Foundation; either version 2 of the License, or
0009  *  (at your option) any later version.
0010  *
0011  *  This program is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0014  *  GNU General Public License for more details.
0015  */
0016 
0017 #ifndef _UAPI__IF_TUN_H
0018 #define _UAPI__IF_TUN_H
0019 
0020 #include <linux/types.h>
0021 #include <linux/if_ether.h>
0022 #include <linux/filter.h>
0023 
0024 /* Read queue size */
0025 #define TUN_READQ_SIZE  500
0026 /* TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. */
0027 #define TUN_TUN_DEV     IFF_TUN
0028 #define TUN_TAP_DEV IFF_TAP
0029 #define TUN_TYPE_MASK   0x000f
0030 
0031 /* Ioctl defines */
0032 #define TUNSETNOCSUM  _IOW('T', 200, int) 
0033 #define TUNSETDEBUG   _IOW('T', 201, int) 
0034 #define TUNSETIFF     _IOW('T', 202, int) 
0035 #define TUNSETPERSIST _IOW('T', 203, int) 
0036 #define TUNSETOWNER   _IOW('T', 204, int)
0037 #define TUNSETLINK    _IOW('T', 205, int)
0038 #define TUNSETGROUP   _IOW('T', 206, int)
0039 #define TUNGETFEATURES _IOR('T', 207, unsigned int)
0040 #define TUNSETOFFLOAD  _IOW('T', 208, unsigned int)
0041 #define TUNSETTXFILTER _IOW('T', 209, unsigned int)
0042 #define TUNGETIFF      _IOR('T', 210, unsigned int)
0043 #define TUNGETSNDBUF   _IOR('T', 211, int)
0044 #define TUNSETSNDBUF   _IOW('T', 212, int)
0045 #define TUNATTACHFILTER _IOW('T', 213, struct sock_fprog)
0046 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
0047 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
0048 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
0049 #define TUNSETQUEUE  _IOW('T', 217, int)
0050 #define TUNSETIFINDEX   _IOW('T', 218, unsigned int)
0051 #define TUNGETFILTER _IOR('T', 219, struct sock_fprog)
0052 #define TUNSETVNETLE _IOW('T', 220, int)
0053 #define TUNGETVNETLE _IOR('T', 221, int)
0054 /* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on
0055  * little-endian hosts. Not all kernel configurations support them, but all
0056  * configurations that support SET also support GET.
0057  */
0058 #define TUNSETVNETBE _IOW('T', 222, int)
0059 #define TUNGETVNETBE _IOR('T', 223, int)
0060 #define TUNSETSTEERINGEBPF _IOR('T', 224, int)
0061 #define TUNSETFILTEREBPF _IOR('T', 225, int)
0062 #define TUNSETCARRIER _IOW('T', 226, int)
0063 #define TUNGETDEVNETNS _IO('T', 227)
0064 
0065 /* TUNSETIFF ifr flags */
0066 #define IFF_TUN     0x0001
0067 #define IFF_TAP     0x0002
0068 #define IFF_NAPI    0x0010
0069 #define IFF_NAPI_FRAGS  0x0020
0070 #define IFF_NO_PI   0x1000
0071 /* This flag has no real effect */
0072 #define IFF_ONE_QUEUE   0x2000
0073 #define IFF_VNET_HDR    0x4000
0074 #define IFF_TUN_EXCL    0x8000
0075 #define IFF_MULTI_QUEUE 0x0100
0076 #define IFF_ATTACH_QUEUE 0x0200
0077 #define IFF_DETACH_QUEUE 0x0400
0078 /* read-only flag */
0079 #define IFF_PERSIST 0x0800
0080 #define IFF_NOFILTER    0x1000
0081 
0082 /* Socket options */
0083 #define TUN_TX_TIMESTAMP 1
0084 
0085 /* Features for GSO (TUNSETOFFLOAD). */
0086 #define TUN_F_CSUM  0x01    /* You can hand me unchecksummed packets. */
0087 #define TUN_F_TSO4  0x02    /* I can handle TSO for IPv4 packets */
0088 #define TUN_F_TSO6  0x04    /* I can handle TSO for IPv6 packets */
0089 #define TUN_F_TSO_ECN   0x08    /* I can handle TSO with ECN bits. */
0090 #define TUN_F_UFO   0x10    /* I can handle UFO packets */
0091 
0092 /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
0093 #define TUN_PKT_STRIP   0x0001
0094 struct tun_pi {
0095     __u16  flags;
0096     __be16 proto;
0097 };
0098 
0099 /*
0100  * Filter spec (used for SETXXFILTER ioctls)
0101  * This stuff is applicable only to the TAP (Ethernet) devices.
0102  * If the count is zero the filter is disabled and the driver accepts
0103  * all packets (promisc mode).
0104  * If the filter is enabled in order to accept broadcast packets
0105  * broadcast addr must be explicitly included in the addr list.
0106  */
0107 #define TUN_FLT_ALLMULTI 0x0001 /* Accept all multicast packets */
0108 struct tun_filter {
0109     __u16  flags; /* TUN_FLT_ flags see above */
0110     __u16  count; /* Number of addresses */
0111     __u8   addr[][ETH_ALEN];
0112 };
0113 
0114 #endif /* _UAPI__IF_TUN_H */