xref: /onnv-gate/usr/src/uts/common/fs/sockfs/nl7cnca.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #include <sys/types.h>
31*0Sstevel@tonic-gate #include <sys/conf.h>
32*0Sstevel@tonic-gate #include <sys/modctl.h>
33*0Sstevel@tonic-gate #include <sys/stream.h>
34*0Sstevel@tonic-gate #include <sys/strsubr.h>
35*0Sstevel@tonic-gate #include <sys/stropts.h>
36*0Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
37*0Sstevel@tonic-gate #include <sys/ddi.h>
38*0Sstevel@tonic-gate #include <sys/sunddi.h>
39*0Sstevel@tonic-gate #include <sys/cmn_err.h>
40*0Sstevel@tonic-gate #include <sys/debug.h>
41*0Sstevel@tonic-gate #include <sys/vtrace.h>
42*0Sstevel@tonic-gate #include <sys/errno.h>
43*0Sstevel@tonic-gate #include <inet/common.h>
44*0Sstevel@tonic-gate #include <inet/led.h>
45*0Sstevel@tonic-gate #include <inet/mi.h>
46*0Sstevel@tonic-gate #include <inet/nd.h>
47*0Sstevel@tonic-gate #include <sys/strsun.h>
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #include <fs/sockfs/nl7c.h>
50*0Sstevel@tonic-gate #include <fs/sockfs/nl7curi.h>
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate #include <inet/nca/nca.h>
53*0Sstevel@tonic-gate #include <inet/nca/ncalogd.h>
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate /*
56*0Sstevel@tonic-gate  * This file is for NCA compatability, specifically it provides ndd
57*0Sstevel@tonic-gate  * support for existing NCA ndd ...
58*0Sstevel@tonic-gate  */
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate extern boolean_t	nl7c_logd_enabled;
61*0Sstevel@tonic-gate extern nca_fio_t	*nl7c_logd_fio;
62*0Sstevel@tonic-gate extern clock_t		nl7c_uri_ttl;
63*0Sstevel@tonic-gate extern boolean_t	nl7c_use_kmem;
64*0Sstevel@tonic-gate extern uint64_t		nl7c_file_prefetch;
65*0Sstevel@tonic-gate extern uint64_t		nl7c_uri_max;
66*0Sstevel@tonic-gate extern uint64_t		nl7c_uri_bytes;
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate extern void		nl7c_mi_report_addr(mblk_t *);
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate #define	MS	1L
71*0Sstevel@tonic-gate #define	SECONDS	(1000 * MS)
72*0Sstevel@tonic-gate #define	MINUTES	(60 * SECONDS)
73*0Sstevel@tonic-gate #define	HOURS	(60 * MINUTES)
74*0Sstevel@tonic-gate #define	DAYS	(24 * HOURS)
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate #define	PARAM_MAX UINT_MAX
77*0Sstevel@tonic-gate #define	PARAML_MAX ULONG_MAX
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate #include <inet/nca/ncandd.h>
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate uint32_t nca_major_version = 1;
82*0Sstevel@tonic-gate uint32_t nca_minor_version = 3;
83*0Sstevel@tonic-gate uint32_t nca_httpd_version = NCA_HTTP_VERSION1;
84*0Sstevel@tonic-gate uint32_t nca_logd_version = NCA_LOG_VERSION1;
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate caddr_t	nca_g_nd;	/* Head of 'named dispatch' variable list */
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * min, max, and value are int64_t's, addr is the optional address of an
90*0Sstevel@tonic-gate  * external int64_t to be updated at init/set, name is the ndd name used
91*0Sstevel@tonic-gate  * to access. Note, if min == max then only get is allowed, i.e. RO.
92*0Sstevel@tonic-gate  */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate /* BEGIN CSTYLED */
95*0Sstevel@tonic-gate ncaparam_t	nca_param_arr[] = {
96*0Sstevel@tonic-gate  /*min	max		value		name */
97*0Sstevel@tonic-gate  { 0,	1,		1,		"nca_log_cycle"},
98*0Sstevel@tonic-gate  { 0,	1,		0,		"no_caching"},
99*0Sstevel@tonic-gate  { 0,	PARAML_MAX,    	0,		"nca_log_size"},
100*0Sstevel@tonic-gate  { 0,	PARAM_MAX,     	10000000,	"nca_max_cache_size"},
101*0Sstevel@tonic-gate  { 0,	PARAM_MAX,	300*SECONDS,	"nca_http_timeout"},
102*0Sstevel@tonic-gate  { 0,	PARAM_MAX,	15*SECONDS,	"nca_http_keep_alive_timeout"},
103*0Sstevel@tonic-gate  { 0,	PARAM_MAX,	100,		"nca_http_keep_alive_max"},
104*0Sstevel@tonic-gate  { 0,	1,		1,		"nca_inq_nointr"},
105*0Sstevel@tonic-gate  { 0,	1,		1,		"nca_use_hwcksum"},
106*0Sstevel@tonic-gate  { 0,	PARAM_MAX,	0,		"nca_segmap_min_size"},
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * Obsolete ip variables, use "/dev/ip" instead.
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate ncaparam_t	nca_ip_obsolete_arr[] = {
114*0Sstevel@tonic-gate  { 0, 0, 0, "ip_forwarding"},
115*0Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_address_mask_broadcast"},
116*0Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_echo_broadcast"},
117*0Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp"},
118*0Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp_broadcast"},
119*0Sstevel@tonic-gate  { 0, 0, 0, "ip_send_redirects"},
120*0Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_directed_broadcasts"},
121*0Sstevel@tonic-gate  { 0, 0, 0, "ip_debug"},
122*0Sstevel@tonic-gate  { 0, 0, 0, "ip_mrtdebug"},
123*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_cleanup_interval" },
124*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_flush_interval" },
125*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_redirect_interval" },
126*0Sstevel@tonic-gate  { 0, 0, 0, "ip_def_ttl" },
127*0Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_src_routed"},
128*0Sstevel@tonic-gate  { 0, 0, 0, "ip_wroff_extra" },
129*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_pathmtu_interval" },
130*0Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_return_data_bytes" },
131*0Sstevel@tonic-gate  { 0, 0, 0, "ip_send_source_quench" },
132*0Sstevel@tonic-gate  { 0, 0, 0, "ip_path_mtu_discovery" },
133*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_delete_time" },
134*0Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_redirect" },
135*0Sstevel@tonic-gate  { 0, 0, 0, "ip_output_queue" },
136*0Sstevel@tonic-gate  { 0, 0, 0, "ip_broadcast_ttl" },
137*0Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_err_interval" },
138*0Sstevel@tonic-gate  { 0, 0, 0, "ip_reass_queue_bytes" },
139*0Sstevel@tonic-gate  { 0, 0, 0, "ip_strict_dst_multihoming" },
140*0Sstevel@tonic-gate  { 0, 0, 0, "ip_addrs_per_if"},
141*0Sstevel@tonic-gate };
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate /*
144*0Sstevel@tonic-gate  * Obsolete tcp variables, use "/dev/tcp" instead.
145*0Sstevel@tonic-gate  */
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate ncaparam_t	nca_tcp_obsolete_arr[] = {
148*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_time_wait_interval"},
149*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q" },
150*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q0" },
151*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_min" },
152*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_grace_period" },
153*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_cwnd_max" },
154*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_debug" },
155*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_nonpriv_port"},
156*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_cinterval"},
157*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_linterval"},
158*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_interval"},
159*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_cinterval"},
160*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_interval"},
161*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_ttl"},
162*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_keepalive_interval"},
163*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_maxpsz_multiplier" },
164*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_def"},
165*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_max"},
166*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_min"},
167*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_naglim_def"},
168*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_initial"},
169*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_max"},
170*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_min"},
171*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_wroff_xtra" },
172*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_ack_interval" },
173*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_snd_lowat_fraction" },
174*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_hiwat" },
175*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_lowat" },
176*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_dupack_fast_retransmit" },
177*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_ignore_path_mtu" },
178*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rcv_push_wait" },
179*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_anon_port"},
180*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_largest_anon_port"},
181*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_hiwat"},
182*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_lowat"},
183*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat"},
184*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat_minmss"},
185*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_fin_wait_2_flush_interval"},
186*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_co_min"},
187*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_max_buf"},
188*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_strong_iss"},
189*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rtt_updates"},
190*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_wscale_always"},
191*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_always"},
192*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_if_wscale"},
193*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_extra"},
194*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_acks_max"},
195*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_after_idle"},
196*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_initial"},
197*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_co_timer_interval"},
198*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_sack_permitted"},
199*0Sstevel@tonic-gate #ifdef DEBUG
200*0Sstevel@tonic-gate  { 0, 0, 0, "tcp_drop_oob"},
201*0Sstevel@tonic-gate #endif
202*0Sstevel@tonic-gate };
203*0Sstevel@tonic-gate 
204*0Sstevel@tonic-gate /*
205*0Sstevel@tonic-gate  * Obsolete nca variables, just warn.
206*0Sstevel@tonic-gate  */
207*0Sstevel@tonic-gate 
208*0Sstevel@tonic-gate ncaparam_t	nca_nca_obsolete_arr[] = {
209*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_bucket"},
210*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_size"},
211*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_expand"},
212*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_shrink"},
213*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ip_virtual_hosting"},
214*0Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_address"},
215*0Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_path"},
216*0Sstevel@tonic-gate  { 0, 0, 0, "httpd_downdoor_path"},
217*0Sstevel@tonic-gate  { 0, 0, 0, "nca_ppmax"},
218*0Sstevel@tonic-gate  { 0, 0, 0, "nca_vpmax"},
219*0Sstevel@tonic-gate  { 0, 0, 0, "nca_use_segmap"},
220*0Sstevel@tonic-gate  { 0, 0, 0, "nca_availrmem"},
221*0Sstevel@tonic-gate  { 0, 0, 0, "nca_maxkmem"},
222*0Sstevel@tonic-gate  { 0, 0, 0, "nca_log_file"},
223*0Sstevel@tonic-gate  { 0, 0, 0, "conn_status"},
224*0Sstevel@tonic-gate  { 0, 0, 0, "conn_status_all"},
225*0Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q"},
226*0Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q0"},
227*0Sstevel@tonic-gate  { 0, 0, 0, "cache_clear"},
228*0Sstevel@tonic-gate  { 0, 0, 0, "nca_node_hash"},
229*0Sstevel@tonic-gate  { 0, 0, 0, "node_status"},
230*0Sstevel@tonic-gate #ifdef DEBUG
231*0Sstevel@tonic-gate  { 0, 0, 0, "nca_debug_counter"},
232*0Sstevel@tonic-gate #endif
233*0Sstevel@tonic-gate };
234*0Sstevel@tonic-gate /* END CSTYLED */
235*0Sstevel@tonic-gate 
236*0Sstevel@tonic-gate static int
237*0Sstevel@tonic-gate /*ARGSUSED*/
238*0Sstevel@tonic-gate nl7c_uri_ttl_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
239*0Sstevel@tonic-gate {
240*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", nl7c_uri_ttl);
241*0Sstevel@tonic-gate 	return (0);
242*0Sstevel@tonic-gate }
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate static int
245*0Sstevel@tonic-gate /*ARGSUSED*/
246*0Sstevel@tonic-gate nl7c_uri_ttl_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
247*0Sstevel@tonic-gate {
248*0Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &nl7c_uri_ttl) != 0)
249*0Sstevel@tonic-gate 		return (EINVAL);
250*0Sstevel@tonic-gate 	return (0);
251*0Sstevel@tonic-gate }
252*0Sstevel@tonic-gate 
253*0Sstevel@tonic-gate static int
254*0Sstevel@tonic-gate /*ARGSUSED*/
255*0Sstevel@tonic-gate nca_logging_on_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
256*0Sstevel@tonic-gate {
257*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nl7c_logd_enabled);
258*0Sstevel@tonic-gate 	return (0);
259*0Sstevel@tonic-gate }
260*0Sstevel@tonic-gate 
261*0Sstevel@tonic-gate static int
262*0Sstevel@tonic-gate /*ARGSUSED*/
263*0Sstevel@tonic-gate nca_logging_on_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
264*0Sstevel@tonic-gate {
265*0Sstevel@tonic-gate 	long new_value;
266*0Sstevel@tonic-gate 
267*0Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &new_value) != 0 || new_value < 0 ||
268*0Sstevel@tonic-gate 	    new_value > 1) {
269*0Sstevel@tonic-gate 		return (EINVAL);
270*0Sstevel@tonic-gate 	}
271*0Sstevel@tonic-gate 	if (nca_fio_cnt(nl7c_logd_fio) == 0)
272*0Sstevel@tonic-gate 		return (EINVAL);
273*0Sstevel@tonic-gate 	nl7c_logd_enabled = new_value;
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate 	return (0);
276*0Sstevel@tonic-gate }
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate static int
279*0Sstevel@tonic-gate /*ARGSUSED*/
280*0Sstevel@tonic-gate nca_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
281*0Sstevel@tonic-gate {
282*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d.%d", nca_major_version, nca_minor_version);
283*0Sstevel@tonic-gate 	return (0);
284*0Sstevel@tonic-gate }
285*0Sstevel@tonic-gate 
286*0Sstevel@tonic-gate static int
287*0Sstevel@tonic-gate /*ARGSUSED*/
288*0Sstevel@tonic-gate nca_httpd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
289*0Sstevel@tonic-gate {
290*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_httpd_version);
291*0Sstevel@tonic-gate 	return (0);
292*0Sstevel@tonic-gate }
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate static int
295*0Sstevel@tonic-gate /*ARGSUSED*/
296*0Sstevel@tonic-gate nca_logd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
297*0Sstevel@tonic-gate {
298*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_logd_version);
299*0Sstevel@tonic-gate 	return (0);
300*0Sstevel@tonic-gate }
301*0Sstevel@tonic-gate 
302*0Sstevel@tonic-gate static int
303*0Sstevel@tonic-gate /*ARGSUSED*/
304*0Sstevel@tonic-gate nca_httpd_door_inst_get(queue_t *q, mblk_t *mp, caddr_t nu, cred_t *cr)
305*0Sstevel@tonic-gate {
306*0Sstevel@tonic-gate 	nl7c_mi_report_addr(mp);
307*0Sstevel@tonic-gate 	return (0);
308*0Sstevel@tonic-gate }
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate static int
311*0Sstevel@tonic-gate /*ARGSUSED*/
312*0Sstevel@tonic-gate nca_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
313*0Sstevel@tonic-gate {
314*0Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
315*0Sstevel@tonic-gate 
316*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", ncapa->param_val);
317*0Sstevel@tonic-gate 	return (0);
318*0Sstevel@tonic-gate }
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate static int
321*0Sstevel@tonic-gate /*ARGSUSED*/
322*0Sstevel@tonic-gate nca_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr)
323*0Sstevel@tonic-gate {
324*0Sstevel@tonic-gate 	ulong_t		new_value;
325*0Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate 	if (ddi_strtoul(value, NULL, 10, &new_value) != 0 ||
328*0Sstevel@tonic-gate 	    new_value < ncapa->param_min || new_value > ncapa->param_max) {
329*0Sstevel@tonic-gate 		return (EINVAL);
330*0Sstevel@tonic-gate 	}
331*0Sstevel@tonic-gate 	ncapa->param_val = new_value;
332*0Sstevel@tonic-gate 	return (0);
333*0Sstevel@tonic-gate }
334*0Sstevel@tonic-gate 
335*0Sstevel@tonic-gate static int
336*0Sstevel@tonic-gate /*ARGSUSED*/
337*0Sstevel@tonic-gate nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
338*0Sstevel@tonic-gate {
339*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete");
340*0Sstevel@tonic-gate 	return (0);
341*0Sstevel@tonic-gate }
342*0Sstevel@tonic-gate 
343*0Sstevel@tonic-gate static int
344*0Sstevel@tonic-gate /*ARGSUSED*/
345*0Sstevel@tonic-gate nca_ip_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
346*0Sstevel@tonic-gate {
347*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/ip");
348*0Sstevel@tonic-gate 	return (0);
349*0Sstevel@tonic-gate }
350*0Sstevel@tonic-gate 
351*0Sstevel@tonic-gate static int
352*0Sstevel@tonic-gate /*ARGSUSED*/
353*0Sstevel@tonic-gate nca_tcp_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
354*0Sstevel@tonic-gate {
355*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/tcp");
356*0Sstevel@tonic-gate 	return (0);
357*0Sstevel@tonic-gate }
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate static int
360*0Sstevel@tonic-gate /*ARGSUSED*/
361*0Sstevel@tonic-gate nca_nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
362*0Sstevel@tonic-gate {
363*0Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca");
364*0Sstevel@tonic-gate 	return (0);
365*0Sstevel@tonic-gate }
366*0Sstevel@tonic-gate 
367*0Sstevel@tonic-gate static boolean_t
368*0Sstevel@tonic-gate nca_param_register(ncaparam_t *ncapa, int cnt)
369*0Sstevel@tonic-gate {
370*0Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
371*0Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
372*0Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
373*0Sstevel@tonic-gate 			    nca_param_get, nca_param_set,
374*0Sstevel@tonic-gate 			    (caddr_t)ncapa)) {
375*0Sstevel@tonic-gate 				goto error;
376*0Sstevel@tonic-gate 			}
377*0Sstevel@tonic-gate 		}
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate 	}
380*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_version", nca_version_get, nil(pfi_t),
381*0Sstevel@tonic-gate 			nil(caddr_t))) {
382*0Sstevel@tonic-gate 		goto error;
383*0Sstevel@tonic-gate 	}
384*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logd_version", nca_logd_version_get,
385*0Sstevel@tonic-gate 			nil(pfi_t), nil(caddr_t))) {
386*0Sstevel@tonic-gate 		goto error;
387*0Sstevel@tonic-gate 	}
388*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logging_on", nca_logging_on_get,
389*0Sstevel@tonic-gate 	    nca_logging_on_set, nil(caddr_t))) {
390*0Sstevel@tonic-gate 		goto error;
391*0Sstevel@tonic-gate 	}
392*0Sstevel@tonic-gate 
393*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "uri_time_to_live", nl7c_uri_ttl_get,
394*0Sstevel@tonic-gate 	    nl7c_uri_ttl_set, nil(caddr_t))) {
395*0Sstevel@tonic-gate 		goto error;
396*0Sstevel@tonic-gate 	}
397*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_httpd_version", nca_httpd_version_get,
398*0Sstevel@tonic-gate 			nil(pfi_t), nil(caddr_t))) {
399*0Sstevel@tonic-gate 		goto error;
400*0Sstevel@tonic-gate 	}
401*0Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "httpd_door_instance", nca_httpd_door_inst_get,
402*0Sstevel@tonic-gate 			nil(pfi_t), nil(caddr_t))) {
403*0Sstevel@tonic-gate 		nd_free(&nca_g_nd);
404*0Sstevel@tonic-gate 		return (B_FALSE);
405*0Sstevel@tonic-gate 	}
406*0Sstevel@tonic-gate 
407*0Sstevel@tonic-gate 	ncapa = nca_ip_obsolete_arr;
408*0Sstevel@tonic-gate 	cnt = A_CNT(nca_ip_obsolete_arr);
409*0Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
410*0Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
411*0Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
412*0Sstevel@tonic-gate 			    nca_ip_obsolete, NULL, (caddr_t)ncapa)) {
413*0Sstevel@tonic-gate 				goto error;
414*0Sstevel@tonic-gate 			}
415*0Sstevel@tonic-gate 		}
416*0Sstevel@tonic-gate 
417*0Sstevel@tonic-gate 	}
418*0Sstevel@tonic-gate 
419*0Sstevel@tonic-gate 	ncapa = nca_tcp_obsolete_arr;
420*0Sstevel@tonic-gate 	cnt = A_CNT(nca_tcp_obsolete_arr);
421*0Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
422*0Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
423*0Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
424*0Sstevel@tonic-gate 			    nca_tcp_obsolete, NULL, (caddr_t)ncapa)) {
425*0Sstevel@tonic-gate 				goto error;
426*0Sstevel@tonic-gate 			}
427*0Sstevel@tonic-gate 		}
428*0Sstevel@tonic-gate 
429*0Sstevel@tonic-gate 	}
430*0Sstevel@tonic-gate 
431*0Sstevel@tonic-gate 	ncapa = nca_nca_obsolete_arr;
432*0Sstevel@tonic-gate 	cnt = A_CNT(nca_nca_obsolete_arr);
433*0Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
434*0Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
435*0Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
436*0Sstevel@tonic-gate 			    nca_nca_obsolete, NULL, (caddr_t)ncapa)) {
437*0Sstevel@tonic-gate 				goto error;
438*0Sstevel@tonic-gate 			}
439*0Sstevel@tonic-gate 		}
440*0Sstevel@tonic-gate 
441*0Sstevel@tonic-gate 	}
442*0Sstevel@tonic-gate 
443*0Sstevel@tonic-gate 	return (B_TRUE);
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate error:
446*0Sstevel@tonic-gate 	nd_free(&nca_g_nd);
447*0Sstevel@tonic-gate 	return (B_FALSE);
448*0Sstevel@tonic-gate }
449*0Sstevel@tonic-gate 
450*0Sstevel@tonic-gate void
451*0Sstevel@tonic-gate nl7c_nca_init(void)
452*0Sstevel@tonic-gate {
453*0Sstevel@tonic-gate 	if (! nca_g_nd) {
454*0Sstevel@tonic-gate 		if (! nca_param_register(nca_param_arr, A_CNT(nca_param_arr)))
455*0Sstevel@tonic-gate 			cmn_err(CE_WARN,
456*0Sstevel@tonic-gate 			    "nl7c: /dev/nca ndd initialization failed.");
457*0Sstevel@tonic-gate 	}
458*0Sstevel@tonic-gate }
459