xref: /titanic_41/usr/src/uts/common/fs/sockfs/nl7cnca.c (revision fab254e2b865295c3dd79c791650a3161d99e196)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*fab254e2SAruna Ramakrishna  * Common Development and Distribution License (the "License").
6*fab254e2SAruna Ramakrishna  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*fab254e2SAruna Ramakrishna  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/conf.h>
287c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
297c478bd9Sstevel@tonic-gate #include <sys/stream.h>
307c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
317c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
327c478bd9Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
337c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
347c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
357c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
367c478bd9Sstevel@tonic-gate #include <sys/debug.h>
377c478bd9Sstevel@tonic-gate #include <sys/vtrace.h>
387c478bd9Sstevel@tonic-gate #include <sys/errno.h>
397c478bd9Sstevel@tonic-gate #include <inet/common.h>
407c478bd9Sstevel@tonic-gate #include <inet/led.h>
417c478bd9Sstevel@tonic-gate #include <inet/mi.h>
427c478bd9Sstevel@tonic-gate #include <inet/nd.h>
437c478bd9Sstevel@tonic-gate #include <sys/strsun.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #include <fs/sockfs/nl7c.h>
467c478bd9Sstevel@tonic-gate #include <fs/sockfs/nl7curi.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #include <inet/nca/nca.h>
497c478bd9Sstevel@tonic-gate #include <inet/nca/ncalogd.h>
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate  * This file is for NCA compatability, specifically it provides ndd
537c478bd9Sstevel@tonic-gate  * support for existing NCA ndd ...
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate extern boolean_t	nl7c_logd_enabled;
577c478bd9Sstevel@tonic-gate extern nca_fio_t	*nl7c_logd_fio;
587c478bd9Sstevel@tonic-gate extern clock_t		nl7c_uri_ttl;
597c478bd9Sstevel@tonic-gate extern boolean_t	nl7c_use_kmem;
607c478bd9Sstevel@tonic-gate extern uint64_t		nl7c_file_prefetch;
617c478bd9Sstevel@tonic-gate extern uint64_t		nl7c_uri_max;
627c478bd9Sstevel@tonic-gate extern uint64_t		nl7c_uri_bytes;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate extern void		nl7c_mi_report_addr(mblk_t *);
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate #define	MS	1L
677c478bd9Sstevel@tonic-gate #define	SECONDS	(1000 * MS)
687c478bd9Sstevel@tonic-gate #define	MINUTES	(60 * SECONDS)
697c478bd9Sstevel@tonic-gate #define	HOURS	(60 * MINUTES)
707c478bd9Sstevel@tonic-gate #define	DAYS	(24 * HOURS)
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	PARAM_MAX UINT_MAX
737c478bd9Sstevel@tonic-gate #define	PARAML_MAX ULONG_MAX
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate #include <inet/nca/ncandd.h>
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate uint32_t nca_major_version = 1;
787c478bd9Sstevel@tonic-gate uint32_t nca_minor_version = 3;
797c478bd9Sstevel@tonic-gate uint32_t nca_httpd_version = NCA_HTTP_VERSION1;
807c478bd9Sstevel@tonic-gate uint32_t nca_logd_version = NCA_LOG_VERSION1;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate caddr_t	nca_g_nd;	/* Head of 'named dispatch' variable list */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * min, max, and value are int64_t's, addr is the optional address of an
867c478bd9Sstevel@tonic-gate  * external int64_t to be updated at init/set, name is the ndd name used
877c478bd9Sstevel@tonic-gate  * to access. Note, if min == max then only get is allowed, i.e. RO.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /* BEGIN CSTYLED */
917c478bd9Sstevel@tonic-gate ncaparam_t	nca_param_arr[] = {
927c478bd9Sstevel@tonic-gate  /*min	max		value		name */
937c478bd9Sstevel@tonic-gate  { 0,	1,		1,		"nca_log_cycle"},
947c478bd9Sstevel@tonic-gate  { 0,	1,		0,		"no_caching"},
957c478bd9Sstevel@tonic-gate  { 0,	PARAML_MAX,    	0,		"nca_log_size"},
967c478bd9Sstevel@tonic-gate  { 0,	PARAM_MAX,     	10000000,	"nca_max_cache_size"},
977c478bd9Sstevel@tonic-gate  { 0,	PARAM_MAX,	300*SECONDS,	"nca_http_timeout"},
987c478bd9Sstevel@tonic-gate  { 0,	PARAM_MAX,	15*SECONDS,	"nca_http_keep_alive_timeout"},
997c478bd9Sstevel@tonic-gate  { 0,	PARAM_MAX,	100,		"nca_http_keep_alive_max"},
1007c478bd9Sstevel@tonic-gate  { 0,	1,		1,		"nca_inq_nointr"},
1017c478bd9Sstevel@tonic-gate  { 0,	1,		1,		"nca_use_hwcksum"},
1027c478bd9Sstevel@tonic-gate  { 0,	PARAM_MAX,	0,		"nca_segmap_min_size"},
1037c478bd9Sstevel@tonic-gate };
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Obsolete ip variables, use "/dev/ip" instead.
1077c478bd9Sstevel@tonic-gate  */
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate ncaparam_t	nca_ip_obsolete_arr[] = {
1107c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_forwarding"},
1117c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_address_mask_broadcast"},
1127c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_echo_broadcast"},
1137c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp"},
1147c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp_broadcast"},
1157c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_send_redirects"},
1167c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_directed_broadcasts"},
1177c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_debug"},
1187c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_mrtdebug"},
1197c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_cleanup_interval" },
1207c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_flush_interval" },
1217c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_redirect_interval" },
1227c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_def_ttl" },
1237c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_src_routed"},
1247c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_wroff_extra" },
1257c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_pathmtu_interval" },
1267c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_return_data_bytes" },
1277c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_send_source_quench" },
1287c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_path_mtu_discovery" },
1297c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_delete_time" },
1307c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_redirect" },
1317c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_output_queue" },
1327c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_broadcast_ttl" },
1337c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_err_interval" },
1347c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_reass_queue_bytes" },
1357c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_strict_dst_multihoming" },
1367c478bd9Sstevel@tonic-gate  { 0, 0, 0, "ip_addrs_per_if"},
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate /*
1407c478bd9Sstevel@tonic-gate  * Obsolete tcp variables, use "/dev/tcp" instead.
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate ncaparam_t	nca_tcp_obsolete_arr[] = {
1447c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_time_wait_interval"},
1457c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q" },
1467c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q0" },
1477c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_min" },
1487c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_grace_period" },
1497c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_cwnd_max" },
1507c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_debug" },
1517c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_nonpriv_port"},
1527c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_cinterval"},
1537c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_linterval"},
1547c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_interval"},
1557c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_cinterval"},
1567c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_interval"},
1577c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_ttl"},
1587c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_keepalive_interval"},
1597c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_maxpsz_multiplier" },
1607c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_def"},
1617c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_max"},
1627c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_min"},
1637c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_naglim_def"},
1647c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_initial"},
1657c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_max"},
1667c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_min"},
1677c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_wroff_xtra" },
1687c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_ack_interval" },
1697c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_snd_lowat_fraction" },
1707c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_hiwat" },
1717c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_lowat" },
1727c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_dupack_fast_retransmit" },
1737c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_ignore_path_mtu" },
1747c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rcv_push_wait" },
1757c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_anon_port"},
1767c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_largest_anon_port"},
1777c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_hiwat"},
1787c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_lowat"},
1797c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat"},
1807c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat_minmss"},
1817c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_fin_wait_2_flush_interval"},
1827c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_max_buf"},
1837c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_strong_iss"},
1847c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rtt_updates"},
1857c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_wscale_always"},
1867c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_always"},
1877c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_if_wscale"},
1887c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_extra"},
1897c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_acks_max"},
1907c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_after_idle"},
1917c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_initial"},
1927c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_sack_permitted"},
1937c478bd9Sstevel@tonic-gate #ifdef DEBUG
1947c478bd9Sstevel@tonic-gate  { 0, 0, 0, "tcp_drop_oob"},
1957c478bd9Sstevel@tonic-gate #endif
1967c478bd9Sstevel@tonic-gate };
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * Obsolete nca variables, just warn.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate ncaparam_t	nca_nca_obsolete_arr[] = {
2037c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_bucket"},
2047c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_size"},
2057c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_expand"},
2067c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_shrink"},
2077c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ip_virtual_hosting"},
2087c478bd9Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_address"},
2097c478bd9Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_path"},
2107c478bd9Sstevel@tonic-gate  { 0, 0, 0, "httpd_downdoor_path"},
2117c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_ppmax"},
2127c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_vpmax"},
2137c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_use_segmap"},
2147c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_availrmem"},
2157c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_maxkmem"},
2167c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_log_file"},
2177c478bd9Sstevel@tonic-gate  { 0, 0, 0, "conn_status"},
2187c478bd9Sstevel@tonic-gate  { 0, 0, 0, "conn_status_all"},
2197c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q"},
2207c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q0"},
2217c478bd9Sstevel@tonic-gate  { 0, 0, 0, "cache_clear"},
2227c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_node_hash"},
2237c478bd9Sstevel@tonic-gate  { 0, 0, 0, "node_status"},
2247c478bd9Sstevel@tonic-gate #ifdef DEBUG
2257c478bd9Sstevel@tonic-gate  { 0, 0, 0, "nca_debug_counter"},
2267c478bd9Sstevel@tonic-gate #endif
2277c478bd9Sstevel@tonic-gate };
2287c478bd9Sstevel@tonic-gate /* END CSTYLED */
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate static int
2317c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nl7c_uri_ttl_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2327c478bd9Sstevel@tonic-gate nl7c_uri_ttl_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2337c478bd9Sstevel@tonic-gate {
2347c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", nl7c_uri_ttl);
2357c478bd9Sstevel@tonic-gate 	return (0);
2367c478bd9Sstevel@tonic-gate }
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate static int
2397c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nl7c_uri_ttl_set(queue_t * q,mblk_t * mp,char * value,caddr_t nu,cred_t * cr)2407c478bd9Sstevel@tonic-gate nl7c_uri_ttl_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
2417c478bd9Sstevel@tonic-gate {
2427c478bd9Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &nl7c_uri_ttl) != 0)
2437c478bd9Sstevel@tonic-gate 		return (EINVAL);
2447c478bd9Sstevel@tonic-gate 	return (0);
2457c478bd9Sstevel@tonic-gate }
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate static int
2487c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_logging_on_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2497c478bd9Sstevel@tonic-gate nca_logging_on_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2507c478bd9Sstevel@tonic-gate {
2517c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nl7c_logd_enabled);
2527c478bd9Sstevel@tonic-gate 	return (0);
2537c478bd9Sstevel@tonic-gate }
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate static int
2567c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_logging_on_set(queue_t * q,mblk_t * mp,char * value,caddr_t nu,cred_t * cr)2577c478bd9Sstevel@tonic-gate nca_logging_on_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
2587c478bd9Sstevel@tonic-gate {
2597c478bd9Sstevel@tonic-gate 	long new_value;
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &new_value) != 0 || new_value < 0 ||
2627c478bd9Sstevel@tonic-gate 	    new_value > 1) {
2637c478bd9Sstevel@tonic-gate 		return (EINVAL);
2647c478bd9Sstevel@tonic-gate 	}
2657c478bd9Sstevel@tonic-gate 	if (nca_fio_cnt(nl7c_logd_fio) == 0)
2667c478bd9Sstevel@tonic-gate 		return (EINVAL);
2677c478bd9Sstevel@tonic-gate 	nl7c_logd_enabled = new_value;
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	return (0);
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate static int
2737c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2747c478bd9Sstevel@tonic-gate nca_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2757c478bd9Sstevel@tonic-gate {
2767c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d.%d", nca_major_version, nca_minor_version);
2777c478bd9Sstevel@tonic-gate 	return (0);
2787c478bd9Sstevel@tonic-gate }
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate static int
2817c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_httpd_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2827c478bd9Sstevel@tonic-gate nca_httpd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2837c478bd9Sstevel@tonic-gate {
2847c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_httpd_version);
2857c478bd9Sstevel@tonic-gate 	return (0);
2867c478bd9Sstevel@tonic-gate }
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate static int
2897c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_logd_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2907c478bd9Sstevel@tonic-gate nca_logd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2917c478bd9Sstevel@tonic-gate {
2927c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_logd_version);
2937c478bd9Sstevel@tonic-gate 	return (0);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate static int
2977c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_httpd_door_inst_get(queue_t * q,mblk_t * mp,caddr_t nu,cred_t * cr)2987c478bd9Sstevel@tonic-gate nca_httpd_door_inst_get(queue_t *q, mblk_t *mp, caddr_t nu, cred_t *cr)
2997c478bd9Sstevel@tonic-gate {
3007c478bd9Sstevel@tonic-gate 	nl7c_mi_report_addr(mp);
3017c478bd9Sstevel@tonic-gate 	return (0);
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate static int
3057c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_param_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3067c478bd9Sstevel@tonic-gate nca_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3077c478bd9Sstevel@tonic-gate {
3087c478bd9Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", ncapa->param_val);
3117c478bd9Sstevel@tonic-gate 	return (0);
3127c478bd9Sstevel@tonic-gate }
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate static int
3157c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_param_set(queue_t * q,mblk_t * mp,char * value,caddr_t cp,cred_t * cr)3167c478bd9Sstevel@tonic-gate nca_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr)
3177c478bd9Sstevel@tonic-gate {
3187c478bd9Sstevel@tonic-gate 	ulong_t		new_value;
3197c478bd9Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate 	if (ddi_strtoul(value, NULL, 10, &new_value) != 0 ||
3227c478bd9Sstevel@tonic-gate 	    new_value < ncapa->param_min || new_value > ncapa->param_max) {
3237c478bd9Sstevel@tonic-gate 		return (EINVAL);
3247c478bd9Sstevel@tonic-gate 	}
3257c478bd9Sstevel@tonic-gate 	ncapa->param_val = new_value;
3267c478bd9Sstevel@tonic-gate 	return (0);
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate static int
3307c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3317c478bd9Sstevel@tonic-gate nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3327c478bd9Sstevel@tonic-gate {
3337c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete");
3347c478bd9Sstevel@tonic-gate 	return (0);
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate static int
3387c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_ip_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3397c478bd9Sstevel@tonic-gate nca_ip_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3407c478bd9Sstevel@tonic-gate {
3417c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/ip");
3427c478bd9Sstevel@tonic-gate 	return (0);
3437c478bd9Sstevel@tonic-gate }
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate static int
3467c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_tcp_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3477c478bd9Sstevel@tonic-gate nca_tcp_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3487c478bd9Sstevel@tonic-gate {
3497c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/tcp");
3507c478bd9Sstevel@tonic-gate 	return (0);
3517c478bd9Sstevel@tonic-gate }
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate static int
3547c478bd9Sstevel@tonic-gate /*ARGSUSED*/
nca_nca_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3557c478bd9Sstevel@tonic-gate nca_nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3567c478bd9Sstevel@tonic-gate {
3577c478bd9Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca");
3587c478bd9Sstevel@tonic-gate 	return (0);
3597c478bd9Sstevel@tonic-gate }
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate static boolean_t
nca_param_register(ncaparam_t * ncapa,int cnt)3627c478bd9Sstevel@tonic-gate nca_param_register(ncaparam_t *ncapa, int cnt)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
3657c478bd9Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
3667c478bd9Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
3677c478bd9Sstevel@tonic-gate 			    nca_param_get, nca_param_set,
3687c478bd9Sstevel@tonic-gate 			    (caddr_t)ncapa)) {
3697c478bd9Sstevel@tonic-gate 				goto error;
3707c478bd9Sstevel@tonic-gate 			}
3717c478bd9Sstevel@tonic-gate 		}
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate 	}
3747c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_version", nca_version_get, nil(pfi_t),
3757c478bd9Sstevel@tonic-gate 	    nil(caddr_t))) {
3767c478bd9Sstevel@tonic-gate 		goto error;
3777c478bd9Sstevel@tonic-gate 	}
3787c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logd_version", nca_logd_version_get,
3797c478bd9Sstevel@tonic-gate 	    nil(pfi_t), nil(caddr_t))) {
3807c478bd9Sstevel@tonic-gate 		goto error;
3817c478bd9Sstevel@tonic-gate 	}
3827c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logging_on", nca_logging_on_get,
3837c478bd9Sstevel@tonic-gate 	    nca_logging_on_set, nil(caddr_t))) {
3847c478bd9Sstevel@tonic-gate 		goto error;
3857c478bd9Sstevel@tonic-gate 	}
3867c478bd9Sstevel@tonic-gate 
3877c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "uri_time_to_live", nl7c_uri_ttl_get,
3887c478bd9Sstevel@tonic-gate 	    nl7c_uri_ttl_set, nil(caddr_t))) {
3897c478bd9Sstevel@tonic-gate 		goto error;
3907c478bd9Sstevel@tonic-gate 	}
3917c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_httpd_version", nca_httpd_version_get,
3927c478bd9Sstevel@tonic-gate 	    nil(pfi_t), nil(caddr_t))) {
3937c478bd9Sstevel@tonic-gate 		goto error;
3947c478bd9Sstevel@tonic-gate 	}
3957c478bd9Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "httpd_door_instance", nca_httpd_door_inst_get,
3967c478bd9Sstevel@tonic-gate 	    nil(pfi_t), nil(caddr_t))) {
3977c478bd9Sstevel@tonic-gate 		nd_free(&nca_g_nd);
3987c478bd9Sstevel@tonic-gate 		return (B_FALSE);
3997c478bd9Sstevel@tonic-gate 	}
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate 	ncapa = nca_ip_obsolete_arr;
4027c478bd9Sstevel@tonic-gate 	cnt = A_CNT(nca_ip_obsolete_arr);
4037c478bd9Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4047c478bd9Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4057c478bd9Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4067c478bd9Sstevel@tonic-gate 			    nca_ip_obsolete, NULL, (caddr_t)ncapa)) {
4077c478bd9Sstevel@tonic-gate 				goto error;
4087c478bd9Sstevel@tonic-gate 			}
4097c478bd9Sstevel@tonic-gate 		}
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate 	}
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate 	ncapa = nca_tcp_obsolete_arr;
4147c478bd9Sstevel@tonic-gate 	cnt = A_CNT(nca_tcp_obsolete_arr);
4157c478bd9Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4167c478bd9Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4177c478bd9Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4187c478bd9Sstevel@tonic-gate 			    nca_tcp_obsolete, NULL, (caddr_t)ncapa)) {
4197c478bd9Sstevel@tonic-gate 				goto error;
4207c478bd9Sstevel@tonic-gate 			}
4217c478bd9Sstevel@tonic-gate 		}
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate 	}
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate 	ncapa = nca_nca_obsolete_arr;
4267c478bd9Sstevel@tonic-gate 	cnt = A_CNT(nca_nca_obsolete_arr);
4277c478bd9Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4287c478bd9Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4297c478bd9Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4307c478bd9Sstevel@tonic-gate 			    nca_nca_obsolete, NULL, (caddr_t)ncapa)) {
4317c478bd9Sstevel@tonic-gate 				goto error;
4327c478bd9Sstevel@tonic-gate 			}
4337c478bd9Sstevel@tonic-gate 		}
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate 	}
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate 	return (B_TRUE);
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate error:
4407c478bd9Sstevel@tonic-gate 	nd_free(&nca_g_nd);
4417c478bd9Sstevel@tonic-gate 	return (B_FALSE);
4427c478bd9Sstevel@tonic-gate }
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate void
nl7c_nca_init(void)4457c478bd9Sstevel@tonic-gate nl7c_nca_init(void)
4467c478bd9Sstevel@tonic-gate {
4477c478bd9Sstevel@tonic-gate 	if (! nca_g_nd) {
4487c478bd9Sstevel@tonic-gate 		if (! nca_param_register(nca_param_arr, A_CNT(nca_param_arr)))
4497c478bd9Sstevel@tonic-gate 			cmn_err(CE_WARN,
4507c478bd9Sstevel@tonic-gate 			    "nl7c: /dev/nca ndd initialization failed.");
4517c478bd9Sstevel@tonic-gate 	}
4527c478bd9Sstevel@tonic-gate }
453