1 /*
2  * sppptun_impl.h - Internal sppptun data exposed for adb/mdb macros.
3  *
4  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
5  * Use is subject to license terms.
6  */
7 
8 #ifndef	_SPPPTUN_IMPL_H
9 #define	_SPPPTUN_IMPL_H
10 
11 #pragma ident	"%Z%%M%	%I%	%E% SMI"
12 
13 #ifdef	__cplusplus
14 extern "C" {
15 #endif
16 
17 /* For use with insque/remque (belongs in a system header!) */
18 struct qelem {
19 	struct qelem *q_forw;
20 	struct qelem *q_back;
21 };
22 
23 typedef struct tunll_s tunll_t;
24 typedef struct tuncl_s tuncl_t;
25 
26 typedef struct {
27 	kstat_named_t	lks_octrls;		/* sent control messages */
28 	kstat_named_t	lks_octrl_drop;		/* dropped control messages */
29 	kstat_named_t	lks_clients;		/* number of clients (tcls) */
30 	kstat_named_t	lks_walks;		/* PPPoE tcl walks */
31 	kstat_named_t	lks_in_nomatch;		/* input without match */
32 	kstat_named_t	lks_indata;		/* input data packets */
33 	kstat_named_t	lks_indata_drops;	/* input data packet drops */
34 	kstat_named_t	lks_inctrls;		/* input control packets */
35 	kstat_named_t	lks_inctrl_drops;	/* input control pkt drops */
36 } tll_kstats_t;
37 
38 #define	TLL_KSTATS_NAMES \
39 	"octrls", "octrl_drop", "clients", "walks", "in_nomatch", \
40 	"indata", "indata_drops", "inctrls", "inctrl_drops"
41 
42 typedef struct {
43 	kstat_named_t	cks_octrls;		/* sent control messages */
44 	kstat_named_t	cks_octrl_drop;		/* dropped control messages */
45 	kstat_named_t	cks_octrl_spec;		/* special control messages */
46 	kstat_named_t	cks_walks;		/* PPPoE tcl walks */
47 	kstat_named_t	cks_inctrls;		/* input control messages */
48 	kstat_named_t	cks_inctrl_drops;	/* input control pkt drops */
49 } tcl_kstats_t;
50 
51 #define	TCL_KSTATS_NAMES \
52 	"octrls", "octrl_drop", "octrl_spec", "walks", "inctrls", \
53 	"inctrl_drops"
54 
55 /*
56  * Tunnel lower layer structure; module open; connects to output device.
57  *
58  * Note: tll_flags member carefully aligned to match with tcl_flags in
59  * following structure so that we don't have to continually look at
60  * q_next to determine context.  Do not move these around.
61  *
62  * Note: this is also defined in uts/adb/common/tunll.dbg; if you change
63  * this structure, don't forget to change the adb/mdb macro.
64  */
65 struct tunll_s {
66 	uint32_t tll_flags;		/* See TLLF_* below */
67 	void *tll_next, *tll_prev;
68 
69 	int tll_error;
70 	queue_t *tll_wq;		/* Output data sent here */
71 	tuncl_t *tll_defcl;		/* Default client (daemon) */
72 	ppptun_atype tll_lcladdr;	/* Local address */
73 
74 	tuncl_t *tll_lastcl;		/* Silly PPPoE optimization */
75 
76 	ppptun_lname tll_name;
77 	int tll_index;
78 	int tll_muxid;
79 	int tll_style;			/* Interface type; PTS_* */
80 	int tll_alen;			/* Address length */
81 
82 	int tll_msg_pending;
83 	mblk_t *tll_msg_deferred;
84 
85 	mblk_t *tll_onclose;
86 
87 	tll_kstats_t tll_kstats;	/* current statistics */
88 	kstat_t *tll_ksp;		/* pointer to kstats allocation */
89 };
90 
91 /*
92  * Tunnel client structure; used for each device open.
93  *
94  * There is one of these for each PPP session plus (perhaps) one for
95  * each tunneling protocol server daemon.
96  *
97  * Note: this is also defined in uts/adb/common/tuncl.dbg; if you change
98  * this structure, don't forget to change the adb/mdb macro.
99  */
100 struct tuncl_s {
101 	uint32_t tcl_flags;		/* TCLF_ flags below */
102 
103 	tunll_t *tcl_data_tll;		/* Pointer to data interface */
104 	tunll_t *tcl_ctrl_tll;		/* Pointer to control */
105 
106 	queue_t *tcl_rq;		/* Received data sent here. */
107 
108 	uint32_t tcl_seq;
109 
110 	uint32_t tcl_ctlval;		/* Control distinguisher */
111 
112 	uint_t	tcl_style;		/* Saved style */
113 	uint_t	tcl_ltunid;		/* Local Tunnel ID (L2F/L2TP) */
114 	uint_t	tcl_rtunid;		/* Remote Tunnel ID (L2F/L2TP) */
115 	uint_t	tcl_lsessid;		/* Local Session ID (minor node) */
116 	uint_t	tcl_rsessid;		/* Remote Session ID */
117 	ppptun_atype	tcl_address;
118 
119 	int	tcl_unit;		/* PPP unit number (for debug) */
120 	struct pppstat64 tcl_stats;	/* Standard PPP statistics */
121 	tcl_kstats_t tcl_kstats;	/* current statistics */
122 	kstat_t *tcl_ksp;		/* pointer to kstats allocation */
123 };
124 
125 #define	TO_TLL(p) \
126 	((tunll_t *)((caddr_t)(p) - offsetof(tunll_t, tll_next)))
127 
128 #define	TLLF_NOTLOWER		0x00000001	/* never set */
129 #define	TLLF_CLOSING		0x00000002	/* driver detach initiated */
130 #define	TLLF_CLOSE_DONE		0x00000004	/* detach sent; waiting */
131 #define	TLLF_SHUTDOWN_DONE	0x00000008	/* detach done */
132 
133 #define	TCLF_ISCLIENT		0x00000001	/* always set */
134 #define	TCLF_FASTPATH		0x00000004	/* enable fast path recv */
135 #define	TCLF_DAEMON		0x00000010	/* server side; session 0 */
136 #define	TCLF_SPEER_DONE		0x00000020	/* SPEER ioctl done */
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif /* _SPPPTUN_IMPL_H */
143