Esempio n. 1
0
/*
 * Walk through the param array specified registering each element with the
 * named dispatch handler.
 */
boolean_t
sctp_param_register(sctpparam_t *sctppa, int cnt)
{

	if (sctp_g_nd != NULL) {
		return (B_TRUE);
	}

	for (; cnt-- > 0; sctppa++) {
		if (sctppa->sctp_param_name && sctppa->sctp_param_name[0]) {
			if (!nd_load(&sctp_g_nd, sctppa->sctp_param_name,
			    sctp_param_get, sctp_param_set,
			    (caddr_t)sctppa)) {
				nd_free(&sctp_g_nd);
				return (B_FALSE);
			}
		}
	}
	if (!nd_load(&sctp_g_nd, sctp_wroff_xtra_param.sctp_param_name,
	    sctp_param_get, sctp_wroff_xtra_set,
	    (caddr_t)&sctp_wroff_xtra_param)) {
		nd_free(&sctp_g_nd);
		return (B_FALSE);
	}
	if (!nd_load(&sctp_g_nd, "sctp_extra_priv_ports",
	    sctp_extra_priv_ports_get, NULL, NULL)) {
		nd_free(&sctp_g_nd);
		return (B_FALSE);
	}
	if (!nd_load(&sctp_g_nd, "sctp_extra_priv_ports_add",
	    NULL, sctp_extra_priv_ports_add, NULL)) {
		nd_free(&sctp_g_nd);
		return (B_FALSE);
	}
	if (!nd_load(&sctp_g_nd, "sctp_extra_priv_ports_del",
	    NULL, sctp_extra_priv_ports_del, NULL)) {
		nd_free(&sctp_g_nd);
		return (B_FALSE);
	}
	return (B_TRUE);
}
Esempio n. 2
0
/*
 * Initialise the per-instance parameter array from the global prototype,
 * and register each element with the named dispatch handler using nd_load()
 */
static int
unm_param_register(unm_adapter *adapter)
{
	const nd_param_t *tmplp;
	dev_info_t *dip;
	nd_param_t *ndp;
	caddr_t *nddpp;
	pfi_t setfn;
	char *nm;
	int pval;

	dip = adapter->dip;
	nddpp = &adapter->nd_data_p;
	ASSERT(*nddpp == NULL);

	if (adapter->ahw.board_type == UNM_NIC_XGBE)
		tmplp = nd_template_10000;
	else
		tmplp = nd_template_1000;

	for (; tmplp->ndp_name != NULL; ++tmplp) {
		/*
		 * Copy the template from nd_template[] into the
		 * proper slot in the per-instance parameters,
		 * then register the parameter with nd_load()
		 */
		ndp = &adapter->nd_params[tmplp->ndp_info];
		*ndp = *tmplp;
		nm = &ndp->ndp_name[0];
		setfn = unm_param_set;

		switch (*nm) {
		default:
		case '!':
			continue;

		case '+':
			break;

		case '-':
			setfn = NULL;
			break;
		}

		if (!nd_load(nddpp, ++nm, unm_param_get, setfn, (caddr_t)ndp))
			goto nd_fail;

		/*
		 * If the parameter is writable, and there's a property
		 * with the same name, and its value is in range, we use
		 * it to initialise the parameter.  If it exists but is
		 * out of range, it's ignored.
		 */
		if (setfn && UNM_PROP_EXISTS(dip, nm)) {
			pval = UNM_PROP_GET_INT(dip, nm);
			if (pval >= ndp->ndp_min && pval <= ndp->ndp_max)
				ndp->ndp_val = pval;
		}
	}

	DPRINTF(1, (CE_WARN, "unm_param_register: OK"));
	return (DDI_SUCCESS);

nd_fail:
	if (adapter->ahw.board_type == UNM_NIC_XGBE) {
		cmn_err(CE_WARN,
		    "unm_param_register: FAILED at index %d [info %d]",
		    (int)(tmplp-nd_template_10000), tmplp->ndp_info);
	} else {
		cmn_err(CE_WARN,
		    "unm_param_register: FAILED at index %d [info %d]",
		    (int)(tmplp-nd_template_1000), tmplp->ndp_info);
	}
	nd_free(nddpp);
	return (DDI_FAILURE);
}
Esempio n. 3
0
static boolean_t
nca_param_register(ncaparam_t *ncapa, int cnt)
{
	for (; cnt-- > 0; ncapa++) {
		if (ncapa->param_name && ncapa->param_name[0]) {
			if (!nd_load(&nca_g_nd, ncapa->param_name,
			    nca_param_get, nca_param_set,
			    (caddr_t)ncapa)) {
				goto error;
			}
		}

	}
	if (!nd_load(&nca_g_nd, "nca_version", nca_version_get, nil(pfi_t),
	    nil(caddr_t))) {
		goto error;
	}
	if (!nd_load(&nca_g_nd, "nca_logd_version", nca_logd_version_get,
	    nil(pfi_t), nil(caddr_t))) {
		goto error;
	}
	if (!nd_load(&nca_g_nd, "nca_logging_on", nca_logging_on_get,
	    nca_logging_on_set, nil(caddr_t))) {
		goto error;
	}

	if (!nd_load(&nca_g_nd, "uri_time_to_live", nl7c_uri_ttl_get,
	    nl7c_uri_ttl_set, nil(caddr_t))) {
		goto error;
	}
	if (!nd_load(&nca_g_nd, "nca_httpd_version", nca_httpd_version_get,
	    nil(pfi_t), nil(caddr_t))) {
		goto error;
	}
	if (!nd_load(&nca_g_nd, "httpd_door_instance", nca_httpd_door_inst_get,
	    nil(pfi_t), nil(caddr_t))) {
		nd_free(&nca_g_nd);
		return (B_FALSE);
	}

	ncapa = nca_ip_obsolete_arr;
	cnt = A_CNT(nca_ip_obsolete_arr);
	for (; cnt-- > 0; ncapa++) {
		if (ncapa->param_name && ncapa->param_name[0]) {
			if (!nd_load(&nca_g_nd, ncapa->param_name,
			    nca_ip_obsolete, NULL, (caddr_t)ncapa)) {
				goto error;
			}
		}

	}

	ncapa = nca_tcp_obsolete_arr;
	cnt = A_CNT(nca_tcp_obsolete_arr);
	for (; cnt-- > 0; ncapa++) {
		if (ncapa->param_name && ncapa->param_name[0]) {
			if (!nd_load(&nca_g_nd, ncapa->param_name,
			    nca_tcp_obsolete, NULL, (caddr_t)ncapa)) {
				goto error;
			}
		}

	}

	ncapa = nca_nca_obsolete_arr;
	cnt = A_CNT(nca_nca_obsolete_arr);
	for (; cnt-- > 0; ncapa++) {
		if (ncapa->param_name && ncapa->param_name[0]) {
			if (!nd_load(&nca_g_nd, ncapa->param_name,
			    nca_nca_obsolete, NULL, (caddr_t)ncapa)) {
				goto error;
			}
		}

	}

	return (B_TRUE);

error:
	nd_free(&nca_g_nd);
	return (B_FALSE);
}
Esempio n. 4
0
/*
 * Initialise the per-instance parameter array from the global prototype,
 * and register each element with the named dispatch handler using nd_load()
 */
static int
rge_param_register(rge_t *rgep)
{
	const nd_param_t *tmplp;
	dev_info_t *dip;
	nd_param_t *ndp;
	caddr_t *nddpp;
	pfi_t setfn;
	char *nm;
	int pval;

	dip = rgep->devinfo;
	nddpp = &rgep->nd_data_p;
	ASSERT(*nddpp == NULL);

	if (rgep->chipid.mac_ver == MAC_VER_8101E)
		tmplp = nd_template_100;
	else
		tmplp = nd_template_1000;

	for (; tmplp->ndp_name != NULL; ++tmplp) {
		/*
		 * Copy the template from nd_template[] into the
		 * proper slot in the per-instance parameters,
		 * then register the parameter with nd_load()
		 */
		ndp = &rgep->nd_params[tmplp->ndp_info];
		*ndp = *tmplp;
		nm = &ndp->ndp_name[0];
		setfn = rge_param_set;

		switch (*nm) {
		default:
		case '!':
			continue;

		case '+':
			break;

		case '-':
			setfn = NULL;
			break;
		}

		if (!nd_load(nddpp, ++nm, rge_param_get, setfn, (caddr_t)ndp))
			goto nd_fail;

		/*
		 * If the parameter is writable, and there's a property
		 * with the same name, and its value is in range, we use
		 * it to initialise the parameter.  If it exists but is
		 * out of range, it's ignored.
		 */
		if (setfn && RGE_PROP_EXISTS(dip, nm)) {
			pval = RGE_PROP_GET_INT(dip, nm);
			if (pval >= ndp->ndp_min && pval <= ndp->ndp_max)
				ndp->ndp_val = pval;
		}
	}

	RGE_DEBUG(("rge_param_register: OK"));
	return (DDI_SUCCESS);

nd_fail:
	if (rgep->chipid.mac_ver == MAC_VER_8101E) {
		RGE_DEBUG(("rge_param_register: FAILED at index %d [info %d]",
		    tmplp-nd_template_100, tmplp->ndp_info));
	} else {
		RGE_DEBUG(("rge_param_register: FAILED at index %d [info %d]",
		    tmplp-nd_template_1000, tmplp->ndp_info));
	}
	nd_free(nddpp);
	return (DDI_FAILURE);
}