if_tun.h revision 1.21 1 1.21 riastrad /* $NetBSD: if_tun.h,v 1.21 2022/03/13 21:31:58 riastradh Exp $ */
2 1.5 cgd
3 1.1 deraadt /*
4 1.2 deraadt * Copyright (c) 1988, Julian Onions <jpo (at) cs.nott.ac.uk>
5 1.2 deraadt * Nottingham University 1987.
6 1.1 deraadt *
7 1.1 deraadt * This source may be freely distributed, however I would be interested
8 1.1 deraadt * in any changes that are made.
9 1.1 deraadt *
10 1.2 deraadt * This driver takes packets off the IP i/f and hands them up to a
11 1.18 snj * user process to have its wicked way with. This driver has its
12 1.2 deraadt * roots in a similar driver written by Phil Cockcroft (formerly) at
13 1.2 deraadt * UCL. This driver is based much more on read/write/select mode of
14 1.2 deraadt * operation though.
15 1.12 perry *
16 1.7 perry * from: Header: if_tnreg.h,v 1.1.2.1 1992/07/16 22:39:16 friedl Exp
17 1.1 deraadt */
18 1.1 deraadt
19 1.1 deraadt #ifndef _NET_IF_TUN_H_
20 1.1 deraadt #define _NET_IF_TUN_H_
21 1.1 deraadt
22 1.19 dholland #include <sys/ioccom.h>
23 1.19 dholland
24 1.8 tv #ifdef _KERNEL
25 1.21 riastrad
26 1.21 riastrad #include <sys/types.h>
27 1.21 riastrad
28 1.21 riastrad #include <sys/condvar.h>
29 1.21 riastrad #include <sys/mutex.h>
30 1.21 riastrad #include <sys/queue.h>
31 1.21 riastrad #include <sys/select.h>
32 1.21 riastrad
33 1.21 riastrad #include <net/if.h>
34 1.21 riastrad
35 1.1 deraadt struct tun_softc {
36 1.10 atatat struct ifnet tun_if; /* the interface */
37 1.10 atatat
38 1.1 deraadt u_short tun_flags; /* misc flags */
39 1.1 deraadt #define TUN_OPEN 0x0001
40 1.1 deraadt #define TUN_INITED 0x0002
41 1.1 deraadt #define TUN_RCOLL 0x0004
42 1.1 deraadt #define TUN_IASET 0x0008
43 1.1 deraadt #define TUN_DSTADDR 0x0010
44 1.1 deraadt #define TUN_RWAIT 0x0040
45 1.1 deraadt #define TUN_ASYNC 0x0080
46 1.1 deraadt #define TUN_NBIO 0x0100
47 1.6 pk #define TUN_PREPADDR 0x0200
48 1.14 rpaulo #define TUN_IFHEAD 0x0400
49 1.4 deraadt
50 1.4 deraadt #define TUN_READY (TUN_OPEN | TUN_INITED | TUN_IASET)
51 1.4 deraadt
52 1.11 jdolecek pid_t tun_pgid; /* PID or process group ID */
53 1.1 deraadt struct selinfo tun_rsel; /* read select */
54 1.1 deraadt struct selinfo tun_wsel; /* write select (not used) */
55 1.10 atatat int tun_unit; /* the tunnel unit number */
56 1.17 rmind kmutex_t tun_lock; /* lock for this tunnel */
57 1.20 skrll kcondvar_t tun_cv; /* condition variable for tunnel */
58 1.10 atatat LIST_ENTRY(tun_softc) tun_list; /* list of all tuns */
59 1.16 ad void *tun_osih; /* soft interrupt handle */
60 1.16 ad void *tun_isih; /* soft interrupt handle */
61 1.1 deraadt };
62 1.8 tv #endif /* _KERNEL */
63 1.1 deraadt
64 1.1 deraadt /* Maximum packet size */
65 1.3 deraadt #define TUNMTU 1500
66 1.1 deraadt
67 1.1 deraadt /* ioctl's for get/set debug */
68 1.1 deraadt #define TUNSDEBUG _IOW('t', 90, int)
69 1.1 deraadt #define TUNGDEBUG _IOR('t', 89, int)
70 1.6 pk #define TUNSIFMODE _IOW('t', 88, int)
71 1.6 pk #define TUNSLMODE _IOW('t', 87, int)
72 1.15 rpaulo #define TUNSIFHEAD _IOW('t', 66, int)
73 1.15 rpaulo #define TUNGIFHEAD _IOR('t', 65, int)
74 1.1 deraadt
75 1.1 deraadt #endif /* !_NET_IF_TUN_H_ */
76