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