11a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/*
21a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  Universal TUN/TAP device driver.
31a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  Copyright (C) 1999-2000 Maxim Krasnyansky <max_mk@yahoo.com>
41a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *
51a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  This program is free software; you can redistribute it and/or modify
61a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  it under the terms of the GNU General Public License as published by
71a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  the Free Software Foundation; either version 2 of the License, or
81a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  (at your option) any later version.
91a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *
101a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  This program is distributed in the hope that it will be useful,
111a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  but WITHOUT ANY WARRANTY; without even the implied warranty of
121a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt *  GNU General Public License for more details.
141a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt */
151a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
161a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#ifndef __IF_TUN_H
171a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define __IF_TUN_H
181a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
191a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#include <linux/types.h>
201a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#include <linux/if_ether.h>
211a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#include <linux/filter.h>
221a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
231a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* Read queue size */
241a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_READQ_SIZE	500
251a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
261a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* TUN device flags */
271a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_TUN_DEV 	0x0001
281a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_TAP_DEV	0x0002
291a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_TYPE_MASK   0x000f
301a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
311a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_FASYNC	0x0010
321a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_NOCHECKSUM	0x0020
331a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_NO_PI	0x0040
341a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_ONE_QUEUE	0x0080
351a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_PERSIST 	0x0100
361a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_VNET_HDR 	0x0200
371a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
381a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* Ioctl defines */
391a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETNOCSUM  _IOW('T', 200, int)
401a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETDEBUG   _IOW('T', 201, int)
411a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETIFF     _IOW('T', 202, int)
421a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETPERSIST _IOW('T', 203, int)
431a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETOWNER   _IOW('T', 204, int)
441a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETLINK    _IOW('T', 205, int)
451a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETGROUP   _IOW('T', 206, int)
461a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNGETFEATURES _IOR('T', 207, unsigned int)
471a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETOFFLOAD  _IOW('T', 208, unsigned int)
481a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETTXFILTER _IOW('T', 209, unsigned int)
491a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNGETIFF      _IOR('T', 210, unsigned int)
501a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNGETSNDBUF   _IOR('T', 211, int)
511a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETSNDBUF   _IOW('T', 212, int)
521a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNATTACHFILTER _IOW('T', 213, struct sock_fprog)
531a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
541a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNGETVNETHDRSZ _IOR('T', 215, int)
551a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUNSETVNETHDRSZ _IOW('T', 216, int)
561a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
571a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* TUNSETIFF ifr flags */
581a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_TUN		0x0001
591a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_TAP		0x0002
601a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_NO_PI	0x1000
611a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_ONE_QUEUE	0x2000
621a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_VNET_HDR	0x4000
631a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define IFF_TUN_EXCL	0x8000
641a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
651a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* Features for GSO (TUNSETOFFLOAD). */
661a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_F_CSUM	0x01	/* You can hand me unchecksummed packets. */
671a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_F_TSO4	0x02	/* I can handle TSO for IPv4 packets */
681a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */
691a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */
701a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_F_UFO	0x10	/* I can handle UFO packets */
711a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
721a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
731a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_PKT_STRIP	0x0001
741a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidtstruct tun_pi {
751a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt	__u16  flags;
761a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt	__be16 proto;
771a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt};
781a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
791a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt/*
801a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * Filter spec (used for SETXXFILTER ioctls)
811a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * This stuff is applicable only to the TAP (Ethernet) devices.
821a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * If the count is zero the filter is disabled and the driver accepts
831a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * all packets (promisc mode).
841a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * If the filter is enabled in order to accept broadcast packets
851a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt * broadcast addr must be explicitly included in the addr list.
861a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt */
871a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#define TUN_FLT_ALLMULTI 0x0001 /* Accept all multicast packets */
881a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidtstruct tun_filter {
891a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt	__u16  flags; /* TUN_FLT_ flags see above */
901a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt	__u16  count; /* Number of addresses */
911a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt	__u8   addr[0][ETH_ALEN];
921a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt};
931a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt
941a441f49ec87ef74b978d7ae17da2a9b2ca6e811Dmitry Shmidt#endif /* __IF_TUN_H */
95