xref: /onnv-gate/usr/src/uts/common/fs/sockfs/nl7cnca.c (revision 7502:da077e5d991e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7502Saruna@cs.umn.edu  * Common Development and Distribution License (the "License").
6*7502Saruna@cs.umn.edu  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*7502Saruna@cs.umn.edu  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/conf.h>
280Sstevel@tonic-gate #include <sys/modctl.h>
290Sstevel@tonic-gate #include <sys/stream.h>
300Sstevel@tonic-gate #include <sys/strsubr.h>
310Sstevel@tonic-gate #include <sys/stropts.h>
320Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
330Sstevel@tonic-gate #include <sys/ddi.h>
340Sstevel@tonic-gate #include <sys/sunddi.h>
350Sstevel@tonic-gate #include <sys/cmn_err.h>
360Sstevel@tonic-gate #include <sys/debug.h>
370Sstevel@tonic-gate #include <sys/vtrace.h>
380Sstevel@tonic-gate #include <sys/errno.h>
390Sstevel@tonic-gate #include <inet/common.h>
400Sstevel@tonic-gate #include <inet/led.h>
410Sstevel@tonic-gate #include <inet/mi.h>
420Sstevel@tonic-gate #include <inet/nd.h>
430Sstevel@tonic-gate #include <sys/strsun.h>
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #include <fs/sockfs/nl7c.h>
460Sstevel@tonic-gate #include <fs/sockfs/nl7curi.h>
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #include <inet/nca/nca.h>
490Sstevel@tonic-gate #include <inet/nca/ncalogd.h>
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * This file is for NCA compatability, specifically it provides ndd
530Sstevel@tonic-gate  * support for existing NCA ndd ...
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate 
560Sstevel@tonic-gate extern boolean_t	nl7c_logd_enabled;
570Sstevel@tonic-gate extern nca_fio_t	*nl7c_logd_fio;
580Sstevel@tonic-gate extern clock_t		nl7c_uri_ttl;
590Sstevel@tonic-gate extern boolean_t	nl7c_use_kmem;
600Sstevel@tonic-gate extern uint64_t		nl7c_file_prefetch;
610Sstevel@tonic-gate extern uint64_t		nl7c_uri_max;
620Sstevel@tonic-gate extern uint64_t		nl7c_uri_bytes;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate extern void		nl7c_mi_report_addr(mblk_t *);
650Sstevel@tonic-gate 
660Sstevel@tonic-gate #define	MS	1L
670Sstevel@tonic-gate #define	SECONDS	(1000 * MS)
680Sstevel@tonic-gate #define	MINUTES	(60 * SECONDS)
690Sstevel@tonic-gate #define	HOURS	(60 * MINUTES)
700Sstevel@tonic-gate #define	DAYS	(24 * HOURS)
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #define	PARAM_MAX UINT_MAX
730Sstevel@tonic-gate #define	PARAML_MAX ULONG_MAX
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #include <inet/nca/ncandd.h>
760Sstevel@tonic-gate 
770Sstevel@tonic-gate uint32_t nca_major_version = 1;
780Sstevel@tonic-gate uint32_t nca_minor_version = 3;
790Sstevel@tonic-gate uint32_t nca_httpd_version = NCA_HTTP_VERSION1;
800Sstevel@tonic-gate uint32_t nca_logd_version = NCA_LOG_VERSION1;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate caddr_t	nca_g_nd;	/* Head of 'named dispatch' variable list */
830Sstevel@tonic-gate 
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate  * min, max, and value are int64_t's, addr is the optional address of an
860Sstevel@tonic-gate  * external int64_t to be updated at init/set, name is the ndd name used
870Sstevel@tonic-gate  * to access. Note, if min == max then only get is allowed, i.e. RO.
880Sstevel@tonic-gate  */
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /* BEGIN CSTYLED */
910Sstevel@tonic-gate ncaparam_t	nca_param_arr[] = {
920Sstevel@tonic-gate  /*min	max		value		name */
930Sstevel@tonic-gate  { 0,	1,		1,		"nca_log_cycle"},
940Sstevel@tonic-gate  { 0,	1,		0,		"no_caching"},
950Sstevel@tonic-gate  { 0,	PARAML_MAX,    	0,		"nca_log_size"},
960Sstevel@tonic-gate  { 0,	PARAM_MAX,     	10000000,	"nca_max_cache_size"},
970Sstevel@tonic-gate  { 0,	PARAM_MAX,	300*SECONDS,	"nca_http_timeout"},
980Sstevel@tonic-gate  { 0,	PARAM_MAX,	15*SECONDS,	"nca_http_keep_alive_timeout"},
990Sstevel@tonic-gate  { 0,	PARAM_MAX,	100,		"nca_http_keep_alive_max"},
1000Sstevel@tonic-gate  { 0,	1,		1,		"nca_inq_nointr"},
1010Sstevel@tonic-gate  { 0,	1,		1,		"nca_use_hwcksum"},
1020Sstevel@tonic-gate  { 0,	PARAM_MAX,	0,		"nca_segmap_min_size"},
1030Sstevel@tonic-gate };
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate /*
1060Sstevel@tonic-gate  * Obsolete ip variables, use "/dev/ip" instead.
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate ncaparam_t	nca_ip_obsolete_arr[] = {
1100Sstevel@tonic-gate  { 0, 0, 0, "ip_forwarding"},
1110Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_address_mask_broadcast"},
1120Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_echo_broadcast"},
1130Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp"},
1140Sstevel@tonic-gate  { 0, 0, 0, "ip_respond_to_timestamp_broadcast"},
1150Sstevel@tonic-gate  { 0, 0, 0, "ip_send_redirects"},
1160Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_directed_broadcasts"},
1170Sstevel@tonic-gate  { 0, 0, 0, "ip_debug"},
1180Sstevel@tonic-gate  { 0, 0, 0, "ip_mrtdebug"},
1190Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_cleanup_interval" },
1200Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_flush_interval" },
1210Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_redirect_interval" },
1220Sstevel@tonic-gate  { 0, 0, 0, "ip_def_ttl" },
1230Sstevel@tonic-gate  { 0, 0, 0, "ip_forward_src_routed"},
1240Sstevel@tonic-gate  { 0, 0, 0, "ip_wroff_extra" },
1250Sstevel@tonic-gate  { 0, 0, 0, "ip_ire_pathmtu_interval" },
1260Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_return_data_bytes" },
1270Sstevel@tonic-gate  { 0, 0, 0, "ip_send_source_quench" },
1280Sstevel@tonic-gate  { 0, 0, 0, "ip_path_mtu_discovery" },
1290Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_delete_time" },
1300Sstevel@tonic-gate  { 0, 0, 0, "ip_ignore_redirect" },
1310Sstevel@tonic-gate  { 0, 0, 0, "ip_output_queue" },
1320Sstevel@tonic-gate  { 0, 0, 0, "ip_broadcast_ttl" },
1330Sstevel@tonic-gate  { 0, 0, 0, "ip_icmp_err_interval" },
1340Sstevel@tonic-gate  { 0, 0, 0, "ip_reass_queue_bytes" },
1350Sstevel@tonic-gate  { 0, 0, 0, "ip_strict_dst_multihoming" },
1360Sstevel@tonic-gate  { 0, 0, 0, "ip_addrs_per_if"},
1370Sstevel@tonic-gate };
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate  * Obsolete tcp variables, use "/dev/tcp" instead.
1410Sstevel@tonic-gate  */
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate ncaparam_t	nca_tcp_obsolete_arr[] = {
1440Sstevel@tonic-gate  { 0, 0, 0, "tcp_time_wait_interval"},
1450Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q" },
1460Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_max_q0" },
1470Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_req_min" },
1480Sstevel@tonic-gate  { 0, 0, 0, "tcp_conn_grace_period" },
1490Sstevel@tonic-gate  { 0, 0, 0, "tcp_cwnd_max" },
1500Sstevel@tonic-gate  { 0, 0, 0, "tcp_debug" },
1510Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_nonpriv_port"},
1520Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_cinterval"},
1530Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_linterval"},
1540Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_abort_interval"},
1550Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_cinterval"},
1560Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_notify_interval"},
1570Sstevel@tonic-gate  { 0, 0, 0, "tcp_ip_ttl"},
1580Sstevel@tonic-gate  { 0, 0, 0, "tcp_keepalive_interval"},
1590Sstevel@tonic-gate  { 0, 0, 0, "tcp_maxpsz_multiplier" },
1600Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_def"},
1610Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_max"},
1620Sstevel@tonic-gate  { 0, 0, 0, "tcp_mss_min"},
1630Sstevel@tonic-gate  { 0, 0, 0, "tcp_naglim_def"},
1640Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_initial"},
1650Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_max"},
1660Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_min"},
1670Sstevel@tonic-gate  { 0, 0, 0, "tcp_wroff_xtra" },
1680Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_ack_interval" },
1690Sstevel@tonic-gate  { 0, 0, 0, "tcp_snd_lowat_fraction" },
1700Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_hiwat" },
1710Sstevel@tonic-gate  { 0, 0, 0, "tcp_sth_rcv_lowat" },
1720Sstevel@tonic-gate  { 0, 0, 0, "tcp_dupack_fast_retransmit" },
1730Sstevel@tonic-gate  { 0, 0, 0, "tcp_ignore_path_mtu" },
1740Sstevel@tonic-gate  { 0, 0, 0, "tcp_rcv_push_wait" },
1750Sstevel@tonic-gate  { 0, 0, 0, "tcp_smallest_anon_port"},
1760Sstevel@tonic-gate  { 0, 0, 0, "tcp_largest_anon_port"},
1770Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_hiwat"},
1780Sstevel@tonic-gate  { 0, 0, 0, "tcp_xmit_lowat"},
1790Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat"},
1800Sstevel@tonic-gate  { 0, 0, 0, "tcp_recv_hiwat_minmss"},
1810Sstevel@tonic-gate  { 0, 0, 0, "tcp_fin_wait_2_flush_interval"},
1820Sstevel@tonic-gate  { 0, 0, 0, "tcp_max_buf"},
1830Sstevel@tonic-gate  { 0, 0, 0, "tcp_strong_iss"},
1840Sstevel@tonic-gate  { 0, 0, 0, "tcp_rtt_updates"},
1850Sstevel@tonic-gate  { 0, 0, 0, "tcp_wscale_always"},
1860Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_always"},
1870Sstevel@tonic-gate  { 0, 0, 0, "tcp_tstamp_if_wscale"},
1880Sstevel@tonic-gate  { 0, 0, 0, "tcp_rexmit_interval_extra"},
1890Sstevel@tonic-gate  { 0, 0, 0, "tcp_deferred_acks_max"},
1900Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_after_idle"},
1910Sstevel@tonic-gate  { 0, 0, 0, "tcp_slow_start_initial"},
1920Sstevel@tonic-gate  { 0, 0, 0, "tcp_sack_permitted"},
1930Sstevel@tonic-gate #ifdef DEBUG
1940Sstevel@tonic-gate  { 0, 0, 0, "tcp_drop_oob"},
1950Sstevel@tonic-gate #endif
1960Sstevel@tonic-gate };
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  * Obsolete nca variables, just warn.
2000Sstevel@tonic-gate  */
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate ncaparam_t	nca_nca_obsolete_arr[] = {
2030Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_bucket"},
2040Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_size"},
2050Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_expand"},
2060Sstevel@tonic-gate  { 0, 0, 0, "nca_ipport_table_shrink"},
2070Sstevel@tonic-gate  { 0, 0, 0, "nca_ip_virtual_hosting"},
2080Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_address"},
2090Sstevel@tonic-gate  { 0, 0, 0, "httpd_door_path"},
2100Sstevel@tonic-gate  { 0, 0, 0, "httpd_downdoor_path"},
2110Sstevel@tonic-gate  { 0, 0, 0, "nca_ppmax"},
2120Sstevel@tonic-gate  { 0, 0, 0, "nca_vpmax"},
2130Sstevel@tonic-gate  { 0, 0, 0, "nca_use_segmap"},
2140Sstevel@tonic-gate  { 0, 0, 0, "nca_availrmem"},
2150Sstevel@tonic-gate  { 0, 0, 0, "nca_maxkmem"},
2160Sstevel@tonic-gate  { 0, 0, 0, "nca_log_file"},
2170Sstevel@tonic-gate  { 0, 0, 0, "conn_status"},
2180Sstevel@tonic-gate  { 0, 0, 0, "conn_status_all"},
2190Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q"},
2200Sstevel@tonic-gate  { 0, 0, 0, "nca_conn_req_max_q0"},
2210Sstevel@tonic-gate  { 0, 0, 0, "cache_clear"},
2220Sstevel@tonic-gate  { 0, 0, 0, "nca_node_hash"},
2230Sstevel@tonic-gate  { 0, 0, 0, "node_status"},
2240Sstevel@tonic-gate #ifdef DEBUG
2250Sstevel@tonic-gate  { 0, 0, 0, "nca_debug_counter"},
2260Sstevel@tonic-gate #endif
2270Sstevel@tonic-gate };
2280Sstevel@tonic-gate /* END CSTYLED */
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate static int
2310Sstevel@tonic-gate /*ARGSUSED*/
nl7c_uri_ttl_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2320Sstevel@tonic-gate nl7c_uri_ttl_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2330Sstevel@tonic-gate {
2340Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", nl7c_uri_ttl);
2350Sstevel@tonic-gate 	return (0);
2360Sstevel@tonic-gate }
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate static int
2390Sstevel@tonic-gate /*ARGSUSED*/
nl7c_uri_ttl_set(queue_t * q,mblk_t * mp,char * value,caddr_t nu,cred_t * cr)2400Sstevel@tonic-gate nl7c_uri_ttl_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
2410Sstevel@tonic-gate {
2420Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &nl7c_uri_ttl) != 0)
2430Sstevel@tonic-gate 		return (EINVAL);
2440Sstevel@tonic-gate 	return (0);
2450Sstevel@tonic-gate }
2460Sstevel@tonic-gate 
2470Sstevel@tonic-gate static int
2480Sstevel@tonic-gate /*ARGSUSED*/
nca_logging_on_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2490Sstevel@tonic-gate nca_logging_on_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2500Sstevel@tonic-gate {
2510Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nl7c_logd_enabled);
2520Sstevel@tonic-gate 	return (0);
2530Sstevel@tonic-gate }
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate static int
2560Sstevel@tonic-gate /*ARGSUSED*/
nca_logging_on_set(queue_t * q,mblk_t * mp,char * value,caddr_t nu,cred_t * cr)2570Sstevel@tonic-gate nca_logging_on_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
2580Sstevel@tonic-gate {
2590Sstevel@tonic-gate 	long new_value;
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate 	if (ddi_strtol(value, NULL, 10, &new_value) != 0 || new_value < 0 ||
2620Sstevel@tonic-gate 	    new_value > 1) {
2630Sstevel@tonic-gate 		return (EINVAL);
2640Sstevel@tonic-gate 	}
2650Sstevel@tonic-gate 	if (nca_fio_cnt(nl7c_logd_fio) == 0)
2660Sstevel@tonic-gate 		return (EINVAL);
2670Sstevel@tonic-gate 	nl7c_logd_enabled = new_value;
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate 	return (0);
2700Sstevel@tonic-gate }
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate static int
2730Sstevel@tonic-gate /*ARGSUSED*/
nca_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2740Sstevel@tonic-gate nca_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2750Sstevel@tonic-gate {
2760Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d.%d", nca_major_version, nca_minor_version);
2770Sstevel@tonic-gate 	return (0);
2780Sstevel@tonic-gate }
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate static int
2810Sstevel@tonic-gate /*ARGSUSED*/
nca_httpd_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2820Sstevel@tonic-gate nca_httpd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2830Sstevel@tonic-gate {
2840Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_httpd_version);
2850Sstevel@tonic-gate 	return (0);
2860Sstevel@tonic-gate }
2870Sstevel@tonic-gate 
2880Sstevel@tonic-gate static int
2890Sstevel@tonic-gate /*ARGSUSED*/
nca_logd_version_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)2900Sstevel@tonic-gate nca_logd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
2910Sstevel@tonic-gate {
2920Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%d", nca_logd_version);
2930Sstevel@tonic-gate 	return (0);
2940Sstevel@tonic-gate }
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate static int
2970Sstevel@tonic-gate /*ARGSUSED*/
nca_httpd_door_inst_get(queue_t * q,mblk_t * mp,caddr_t nu,cred_t * cr)2980Sstevel@tonic-gate nca_httpd_door_inst_get(queue_t *q, mblk_t *mp, caddr_t nu, cred_t *cr)
2990Sstevel@tonic-gate {
3000Sstevel@tonic-gate 	nl7c_mi_report_addr(mp);
3010Sstevel@tonic-gate 	return (0);
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate static int
3050Sstevel@tonic-gate /*ARGSUSED*/
nca_param_get(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3060Sstevel@tonic-gate nca_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3070Sstevel@tonic-gate {
3080Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "%ld", ncapa->param_val);
3110Sstevel@tonic-gate 	return (0);
3120Sstevel@tonic-gate }
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate static int
3150Sstevel@tonic-gate /*ARGSUSED*/
nca_param_set(queue_t * q,mblk_t * mp,char * value,caddr_t cp,cred_t * cr)3160Sstevel@tonic-gate nca_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr)
3170Sstevel@tonic-gate {
3180Sstevel@tonic-gate 	ulong_t		new_value;
3190Sstevel@tonic-gate 	ncaparam_t	*ncapa = (ncaparam_t *)cp;
3200Sstevel@tonic-gate 
3210Sstevel@tonic-gate 	if (ddi_strtoul(value, NULL, 10, &new_value) != 0 ||
3220Sstevel@tonic-gate 	    new_value < ncapa->param_min || new_value > ncapa->param_max) {
3230Sstevel@tonic-gate 		return (EINVAL);
3240Sstevel@tonic-gate 	}
3250Sstevel@tonic-gate 	ncapa->param_val = new_value;
3260Sstevel@tonic-gate 	return (0);
3270Sstevel@tonic-gate }
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate static int
3300Sstevel@tonic-gate /*ARGSUSED*/
nca_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3310Sstevel@tonic-gate nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3320Sstevel@tonic-gate {
3330Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete");
3340Sstevel@tonic-gate 	return (0);
3350Sstevel@tonic-gate }
3360Sstevel@tonic-gate 
3370Sstevel@tonic-gate static int
3380Sstevel@tonic-gate /*ARGSUSED*/
nca_ip_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3390Sstevel@tonic-gate nca_ip_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3400Sstevel@tonic-gate {
3410Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/ip");
3420Sstevel@tonic-gate 	return (0);
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate static int
3460Sstevel@tonic-gate /*ARGSUSED*/
nca_tcp_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3470Sstevel@tonic-gate nca_tcp_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3480Sstevel@tonic-gate {
3490Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/tcp");
3500Sstevel@tonic-gate 	return (0);
3510Sstevel@tonic-gate }
3520Sstevel@tonic-gate 
3530Sstevel@tonic-gate static int
3540Sstevel@tonic-gate /*ARGSUSED*/
nca_nca_obsolete(queue_t * q,mblk_t * mp,caddr_t cp,cred_t * cr)3550Sstevel@tonic-gate nca_nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
3560Sstevel@tonic-gate {
3570Sstevel@tonic-gate 	(void) mi_mpprintf(mp, "obsolete for /dev/nca");
3580Sstevel@tonic-gate 	return (0);
3590Sstevel@tonic-gate }
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate static boolean_t
nca_param_register(ncaparam_t * ncapa,int cnt)3620Sstevel@tonic-gate nca_param_register(ncaparam_t *ncapa, int cnt)
3630Sstevel@tonic-gate {
3640Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
3650Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
3660Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
3670Sstevel@tonic-gate 			    nca_param_get, nca_param_set,
3680Sstevel@tonic-gate 			    (caddr_t)ncapa)) {
3690Sstevel@tonic-gate 				goto error;
3700Sstevel@tonic-gate 			}
3710Sstevel@tonic-gate 		}
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate 	}
3740Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_version", nca_version_get, nil(pfi_t),
375*7502Saruna@cs.umn.edu 	    nil(caddr_t))) {
3760Sstevel@tonic-gate 		goto error;
3770Sstevel@tonic-gate 	}
3780Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logd_version", nca_logd_version_get,
379*7502Saruna@cs.umn.edu 	    nil(pfi_t), nil(caddr_t))) {
3800Sstevel@tonic-gate 		goto error;
3810Sstevel@tonic-gate 	}
3820Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_logging_on", nca_logging_on_get,
3830Sstevel@tonic-gate 	    nca_logging_on_set, nil(caddr_t))) {
3840Sstevel@tonic-gate 		goto error;
3850Sstevel@tonic-gate 	}
3860Sstevel@tonic-gate 
3870Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "uri_time_to_live", nl7c_uri_ttl_get,
3880Sstevel@tonic-gate 	    nl7c_uri_ttl_set, nil(caddr_t))) {
3890Sstevel@tonic-gate 		goto error;
3900Sstevel@tonic-gate 	}
3910Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "nca_httpd_version", nca_httpd_version_get,
392*7502Saruna@cs.umn.edu 	    nil(pfi_t), nil(caddr_t))) {
3930Sstevel@tonic-gate 		goto error;
3940Sstevel@tonic-gate 	}
3950Sstevel@tonic-gate 	if (!nd_load(&nca_g_nd, "httpd_door_instance", nca_httpd_door_inst_get,
396*7502Saruna@cs.umn.edu 	    nil(pfi_t), nil(caddr_t))) {
3970Sstevel@tonic-gate 		nd_free(&nca_g_nd);
3980Sstevel@tonic-gate 		return (B_FALSE);
3990Sstevel@tonic-gate 	}
4000Sstevel@tonic-gate 
4010Sstevel@tonic-gate 	ncapa = nca_ip_obsolete_arr;
4020Sstevel@tonic-gate 	cnt = A_CNT(nca_ip_obsolete_arr);
4030Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4040Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4050Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4060Sstevel@tonic-gate 			    nca_ip_obsolete, NULL, (caddr_t)ncapa)) {
4070Sstevel@tonic-gate 				goto error;
4080Sstevel@tonic-gate 			}
4090Sstevel@tonic-gate 		}
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate 	}
4120Sstevel@tonic-gate 
4130Sstevel@tonic-gate 	ncapa = nca_tcp_obsolete_arr;
4140Sstevel@tonic-gate 	cnt = A_CNT(nca_tcp_obsolete_arr);
4150Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4160Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4170Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4180Sstevel@tonic-gate 			    nca_tcp_obsolete, NULL, (caddr_t)ncapa)) {
4190Sstevel@tonic-gate 				goto error;
4200Sstevel@tonic-gate 			}
4210Sstevel@tonic-gate 		}
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate 	}
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate 	ncapa = nca_nca_obsolete_arr;
4260Sstevel@tonic-gate 	cnt = A_CNT(nca_nca_obsolete_arr);
4270Sstevel@tonic-gate 	for (; cnt-- > 0; ncapa++) {
4280Sstevel@tonic-gate 		if (ncapa->param_name && ncapa->param_name[0]) {
4290Sstevel@tonic-gate 			if (!nd_load(&nca_g_nd, ncapa->param_name,
4300Sstevel@tonic-gate 			    nca_nca_obsolete, NULL, (caddr_t)ncapa)) {
4310Sstevel@tonic-gate 				goto error;
4320Sstevel@tonic-gate 			}
4330Sstevel@tonic-gate 		}
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate 	}
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate 	return (B_TRUE);
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate error:
4400Sstevel@tonic-gate 	nd_free(&nca_g_nd);
4410Sstevel@tonic-gate 	return (B_FALSE);
4420Sstevel@tonic-gate }
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate void
nl7c_nca_init(void)4450Sstevel@tonic-gate nl7c_nca_init(void)
4460Sstevel@tonic-gate {
4470Sstevel@tonic-gate 	if (! nca_g_nd) {
4480Sstevel@tonic-gate 		if (! nca_param_register(nca_param_arr, A_CNT(nca_param_arr)))
4490Sstevel@tonic-gate 			cmn_err(CE_WARN,
4500Sstevel@tonic-gate 			    "nl7c: /dev/nca ndd initialization failed.");
4510Sstevel@tonic-gate 	}
4520Sstevel@tonic-gate }
453