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