/* * 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); }
/* Free the Named Dispatch Table by calling nd_free */ void unm_nd_cleanup(unm_adapter *adapter) { nd_free(&adapter->nd_data_p); }
/* * 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); }
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); }
void gm2s_test() { int size = 128; delim_str* ds1 = NULL; char* str = "I wish I were a jellyfish that cannot fall down stairs.";; char* name = "jellyfish_string"; #if 0 //delim_str testing stuff ds_print(ds1); ds_resize(&ds1,size); ds_print(ds1); memcpy(ds1->str,str,strlen(str)); ds_print(ds1); ds_free(&ds1); printf("ds1 has been free'd\n"); ds_print(ds1); #endif #if 0 //named_data testing stuff (print) named_data* nd1 = NULL; nd_print(nd1); nd_resize_name(&nd1,128); nd_print(nd1); memcpy(nd1->name,str,strlen(str)); nd_print(nd1); nd_resize_data(&nd1,128); nd_print(nd1); memcpy(nd1->data,name,strlen(name)); nd_print(nd1); nd_free(&nd1); printf("nd1 is free'd\n"); nd_print(nd1); #endif #if 0 //test named data list stuff int count = 1024; named_data* nda[count]; named_data* list = NULL; for (int i=0; i<count; i++) { nda[i] = NULL; nd_resize_data(&nda[i],strlen(str)+1); memcpy(nda[i]->data,str,strlen(str)); nd_resize_name(&nda[i],strlen(name)+1); memcpy(nda[i]->name,name,strlen(name)); nda[i]->order = (int)(((double)rand()/RAND_MAX)*100.0); nd_add_sorted(&list,&nda[i]); //nd_print_all(list); } nd_print_all(list); nd_free_all(&list); #endif #if 0 //test subtitle stuff (printing, list op) int count = 110; subtitle* sa[count]; subtitle* list = NULL; for (int i=0; i<count; i++) { sa[i] = NULL; sub_resize(&sa[i],128); memcpy(sa[i]->txt->str,str,strlen(str)); sa[i]->txt_color = 0x11223344; sa[i]->bord_color = 0x66778899; sa[i]->start_frame = (int)(((double)rand()/RAND_MAX)*100.0); sa[i]->end_frame = 123; sa[i]->x = 40; sa[i]->y = 80; sub_add_sorted(&list,&sa[i]); sub_print_all(list); } sub_free_all(&list); #endif }
void sctp_nd_free() { nd_free(&sctp_g_nd); }
/* Free the Named Dispatch Table by calling nd_free */ void rge_nd_cleanup(rge_t *rgep) { nd_free(&rgep->nd_data_p); }
/* * 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); }