ndr_service_t * ndr_svc_lookup_uuid(ndr_uuid_t *as_uuid, int as_vers, ndr_uuid_t *ts_uuid, int ts_vers) { ndr_service_t *svc; char abstract_syntax[UUID_PRINTABLE_STRING_LENGTH]; char transfer_syntax[UUID_PRINTABLE_STRING_LENGTH]; int i; if (as_uuid) ndr_uuid_unparse(as_uuid, abstract_syntax); if (ts_uuid) ndr_uuid_unparse(ts_uuid, transfer_syntax); for (i = 0; i < NDR_MAX_SERVICES; i++) { if ((svc = ndr_services[i]) == NULL) continue; if (as_uuid) { if (svc->abstract_syntax_uuid == 0) continue; if (svc->abstract_syntax_version != as_vers) continue; if (strcasecmp(abstract_syntax, svc->abstract_syntax_uuid)) continue; } if (ts_uuid) { if (svc->transfer_syntax_uuid == 0) continue; if (svc->transfer_syntax_version != ts_vers) continue; if (strcasecmp(transfer_syntax, svc->transfer_syntax_uuid)) continue; } ndo_printf(0, 0, "%s %s", svc->name, svc->desc); return (svc); } ndo_printf(0, 0, "ndr_svc_lookup_uuid: unknown service"); ndo_printf(0, 0, "abstract=%s v%d, transfer=%s v%d", abstract_syntax, as_vers, transfer_syntax, ts_vers); return (NULL); }
static int ndr_svc_request(ndr_xa_t *mxa) { ndr_binding_t *mbind; ndr_service_t *msvc; unsigned p_cont_id; int rc; mxa->opnum = mxa->recv_hdr.request_hdr.opnum; p_cont_id = mxa->recv_hdr.request_hdr.p_cont_id; if ((mbind = ndr_svc_find_binding(mxa, p_cont_id)) == NULL) return (NDR_DRC_FAULT_REQUEST_PCONT_INVALID); mxa->binding = mbind; msvc = mbind->service; /* * Make room for the response hdr. */ mxa->send_nds.pdu_scan_offset = NDR_RSP_HDR_SIZE; if (msvc->call_stub) rc = (*msvc->call_stub)(mxa); else rc = ndr_generic_call_stub(mxa); if (NDR_DRC_IS_FAULT(rc)) { ndo_printf(0, 0, "%s[0x%02x]: 0x%04x", msvc->name, mxa->opnum, rc); } return (rc); }
/* * The transaction and the two nds streams use the same heap, which * should already exist at this point. The heap will also be available * to the stub. */ int ndr_generic_call_stub(ndr_xa_t *mxa) { ndr_binding_t *mbind = mxa->binding; ndr_service_t *msvc = mbind->service; ndr_typeinfo_t *intf_ti = msvc->interface_ti; ndr_stub_table_t *ste; int opnum = mxa->opnum; unsigned p_len = intf_ti->c_size_fixed_part; char *param; int rc; if (mxa->heap == NULL) { ndo_printf(0, 0, "%s[0x%02x]: no heap", msvc->name, opnum); return (NDR_DRC_FAULT_OUT_OF_MEMORY); } if ((ste = ndr_svc_find_stub(msvc, opnum)) == NULL) { ndo_printf(0, 0, "%s[0x%02x]: invalid opnum", msvc->name, opnum); return (NDR_DRC_FAULT_REQUEST_OPNUM_INVALID); } if ((param = ndr_heap_malloc(mxa->heap, p_len)) == NULL) return (NDR_DRC_FAULT_OUT_OF_MEMORY); bzero(param, p_len); rc = ndr_decode_call(mxa, param); if (!NDR_DRC_IS_OK(rc)) return (rc); rc = (*ste->func)(param, mxa); if (rc == NDR_DRC_OK) rc = ndr_encode_return(mxa, param); return (rc); }
ndr_service_t * ndr_svc_lookup_name(const char *name) { ndr_service_t *svc; int i; for (i = 0; i < NDR_MAX_SERVICES; i++) { if ((svc = ndr_services[i]) == NULL) continue; if (strcasecmp(name, svc->name) != 0) continue; ndo_printf(0, 0, "%s %s", svc->name, svc->desc); return (svc); } return (NULL); }