diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-09-16 05:48:29 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-09-16 05:48:29 +0200 |
commit | db872cfe3713315a5163bf0db8e9644019c9c664 (patch) | |
tree | f9b2fadb67515ab1f0dc12d67953caeff4773336 /source4/librpc | |
parent | e970efc721abafb9d0a30579454d18b1d502a272 (diff) | |
download | samba-db872cfe3713315a5163bf0db8e9644019c9c664.tar.gz samba-db872cfe3713315a5163bf0db8e9644019c9c664.tar.bz2 samba-db872cfe3713315a5163bf0db8e9644019c9c664.zip |
Remove more hand-written marshallers.
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/idl/wmi.idl | 294 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_wmi.c | 759 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_wmi.h | 3 |
3 files changed, 103 insertions, 953 deletions
diff --git a/source4/librpc/idl/wmi.idl b/source4/librpc/idl/wmi.idl index 8d2e31b6f0..3a65345c72 100644 --- a/source4/librpc/idl/wmi.idl +++ b/source4/librpc/idl/wmi.idl @@ -24,7 +24,7 @@ import "misc.idl"; interface IWbemClassObject : IUnknown { - typedef struct { + typedef [noprint] struct { [value(0x72657355)] uint32 flags; [string, charset(UTF16)] uint16 data[]; } BSTR; @@ -205,27 +205,24 @@ coclass WbemClassObject typedef [public,noprint] enum { - WBEM_FLAG_RETURN_IMMEDIATELY = 0x10, - WBEM_FLAG_RETURN_WBEM_COMPLETE = 0, - WBEM_FLAG_BIDIRECTIONAL = 0, - WBEM_FLAG_FORWARD_ONLY = 0x20, - WBEM_FLAG_NO_ERROR_OBJECT = 0x40, - WBEM_FLAG_RETURN_ERROR_OBJECT = 0, - WBEM_FLAG_SEND_STATUS = 0x80, - WBEM_FLAG_DONT_SEND_STATUS = 0, - WBEM_FLAG_ENSURE_LOCATABLE = 0x100, - WBEM_FLAG_DIRECT_READ = 0x200, - WBEM_FLAG_SEND_ONLY_SELECTED = 0, - - WBEM_RETURN_WHEN_COMPLETE = 0, - WBEM_RETURN_IMMEDIATELY = 0x10, - - WBEM_MASK_RESERVED_FLAGS = 0x1F000, - - WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000, - - WBEM_FLAG_STRONG_VALIDATION = 0x100000 - + WBEM_FLAG_RETURN_WBEM_COMPLETE = 0, + WBEM_FLAG_BIDIRECTIONAL = 0, + WBEM_FLAG_RETURN_IMMEDIATELY = 0x000010, + WBEM_FLAG_FORWARD_ONLY = 0x000020, + WBEM_FLAG_NO_ERROR_OBJECT = 0x000040, + WBEM_FLAG_SEND_STATUS = 0x000080, + WBEM_FLAG_ENSURE_LOCATABLE = 0x000100, + WBEM_FLAG_DIRECT_READ = 0x000200, + WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x020000, + WBEM_FLAG_STRONG_VALIDATION = 0x100000, + WBEM_FLAG_RETURN_ERROR_OBJECT = 0, + WBEM_FLAG_DONT_SEND_STATUS = 0, + WBEM_FLAG_SEND_ONLY_SELECTED = 0, + + WBEM_RETURN_WHEN_COMPLETE = 0, + WBEM_RETURN_IMMEDIATELY = WBEM_FLAG_RETURN_IMMEDIATELY, + + WBEM_MASK_RESERVED_FLAGS = 0x001F000 } WBEM_GENERIC_FLAG_TYPE; typedef [public,noprint,v1_enum] enum tag_WBEM_TIMEOUT_TYPE @@ -236,26 +233,28 @@ coclass WbemClassObject typedef [public,v1_enum] enum { - CIM_EMPTY = 0, - - CIM_SINT8 = 16, - CIM_UINT8 = 17, - CIM_SINT16 = 2, - CIM_UINT16 = 18, - CIM_SINT32 = 3, - CIM_UINT32 = 19, - CIM_SINT64 = 20, - CIM_UINT64 = 21, - CIM_REAL32 = 4, - CIM_REAL64 = 5, - CIM_BOOLEAN = 11, - CIM_STRING = 8, - CIM_DATETIME = 101, - CIM_REFERENCE = 102, - CIM_CHAR16 = 103, - CIM_OBJECT = 13, - - CIM_FLAG_ARRAY = 0x2000, + CIM_EMPTY = 0, + CIM_SINT16 = 2, + CIM_SINT32 = 3, + CIM_REAL32 = 4, + CIM_REAL64 = 5, + CIM_STRING = 8, + + CIM_BOOLEAN = 11, + CIM_OBJECT = 13, + CIM_SINT8 = 16, + CIM_UINT8 = 17, + CIM_UINT16 = 18, + CIM_UINT32 = 19, + CIM_SINT64 = 20, + CIM_UINT64 = 21, + CIM_DATETIME = 101, + CIM_REFERENCE = 102, + CIM_CHAR16 = 103, + + CIM_FLAG_ARRAY = 0x2000, + CIM_ILLEGAL = 0x0fff, + CIM_TYPEMASK = 0x2fff, CIM_ARR_SINT8 = CIM_FLAG_ARRAY | CIM_SINT8, CIM_ARR_UINT8 = CIM_FLAG_ARRAY | CIM_UINT8, @@ -272,98 +271,10 @@ coclass WbemClassObject CIM_ARR_DATETIME = CIM_FLAG_ARRAY | CIM_DATETIME, CIM_ARR_REFERENCE = CIM_FLAG_ARRAY | CIM_REFERENCE, CIM_ARR_CHAR16 = CIM_FLAG_ARRAY | CIM_CHAR16, - CIM_ARR_OBJECT = CIM_FLAG_ARRAY | CIM_OBJECT, + CIM_ARR_OBJECT = CIM_FLAG_ARRAY | CIM_OBJECT - CIM_ILLEGAL = 0xfff, - CIM_TYPEMASK = 0x2FFF } CIMTYPE_ENUMERATION; - typedef [public] struct { - uint32 count; - int8 item[count]; - } arr_int8; - - typedef [public] struct { - uint32 count; - uint8 item[count]; - } arr_uint8; - - typedef [public] struct { - uint32 count; - int16 item[count]; - } arr_int16; - - typedef [public] struct { - uint32 count; - uint16 item[count]; - } arr_uint16; - - typedef [public] struct { - uint32 count; - int32 item[count]; - } arr_int32; - - typedef [public] struct { - uint32 count; - uint32 item[count]; - } arr_uint32; - - typedef [public] struct { - uint32 count; - dlong item[count]; - } arr_dlong; - - typedef [public] struct { - uint32 count; - udlong item[count]; - } arr_udlong; - - typedef [public] struct { - uint32 count; - [relative,charset(UTF16)] uint16 *item[count]; - } arr_CIMSTRING; - - typedef [public] struct { - uint32 count; - [relative,subcontext(4)] WbemClassObject *item[count]; - } arr_WbemClassObject; - -// FIXME:avg implement rest of types - typedef [public,nodiscriminant] union - { - [case(CIM_SINT8)] int8 v_sint8; - [case(CIM_UINT8)] uint8 v_uint8; - [case(CIM_SINT16)] int16 v_sint16; - [case(CIM_UINT16)] uint16 v_uint16; - [case(CIM_SINT32)] int32 v_sint32; - [case(CIM_UINT32)] uint32 v_uint32; - [case(CIM_SINT64)] dlong v_sint64; - [case(CIM_UINT64)] udlong v_uint64; - [case(CIM_REAL32)] uint32 v_real32; - [case(CIM_REAL64)] udlong v_real64; - [case(CIM_BOOLEAN)] uint16 v_boolean; - [case(CIM_STRING),relative,charset(UTF16)] uint16 *v_string; - [case(CIM_DATETIME),relative,charset(UTF16)] uint16 *v_datetime; - [case(CIM_REFERENCE),relative,charset(UTF16)] uint16 *v_reference; - [case(CIM_OBJECT),subcontext(4),relative] WbemClassObject *v_object; - - [case(CIM_ARR_SINT8),relative] arr_int8 *a_sint8; - [case(CIM_ARR_UINT8),relative] arr_uint8 *a_uint8; - [case(CIM_ARR_SINT16),relative] arr_int16 *a_sint16; - [case(CIM_ARR_UINT16),relative] arr_uint16 *a_uint16; - [case(CIM_ARR_SINT32),relative] arr_int32 *a_sint32; - [case(CIM_ARR_UINT32),relative] arr_uint32 *a_uint32; - [case(CIM_ARR_SINT64),relative] arr_dlong *a_sint64; - [case(CIM_ARR_UINT64),relative] arr_udlong *a_uint64; - [case(CIM_ARR_REAL32),relative] arr_uint32 *a_real32; - [case(CIM_ARR_REAL64),relative] arr_udlong *a_real64; - [case(CIM_ARR_BOOLEAN),relative] arr_uint16 *a_boolean; - [case(CIM_ARR_STRING),relative] arr_CIMSTRING *a_string; - [case(CIM_ARR_DATETIME),relative] arr_CIMSTRING *a_datetime; - [case(CIM_ARR_REFERENCE),relative] arr_CIMSTRING *a_reference; - [case(CIM_ARR_OBJECT),relative] arr_WbemClassObject *a_object; - } CIMVAR; - typedef [public,bitmap8bit] bitmap { WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE = 0x1, @@ -384,17 +295,17 @@ coclass WbemClassObject typedef [public,bitmap8bit] bitmap { - WCF_DECORATIONS = 1, - WCF_INSTANCE = 2, - WCF_CLASS = 4, - WCF_CLASS_PART_INTERNAL = 8 -// WCF_CLASS_PART_SHARED = 0x104 + WCF_DECORATIONS = 1, + WCF_INSTANCE = 2, + WCF_CLASS = 4, + WCF_CLASS_PART_INTERNAL = 8 + // WCF_CLASS_PART_SHARED = 0x104 } WCO_FLAGS; typedef [public,nopull,nopush] struct { - uint32 count; - [ref,charset(UTF16)] uint16 *item[count]; + uint32 count; + [ref,charset(UTF16)] uint16 *item[count]; } CIMSTRINGS; typedef [public,bitmap8bit] bitmap { @@ -403,26 +314,29 @@ coclass WbemClassObject } DEFAULT_FLAGS; WERROR OpenNamespace( - [in] BSTR strNamespace, - [in] long lFlags, - [in] IWbemContext* pCtx, - [out, in, unique] IWbemServices** ppWorkingNamespace, - [out, in, unique] IWbemCallResult** ppResult - ); + [in] BSTR strNamespace, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemServices** ppWorkingNamespace, + [out, in, unique] IWbemCallResult** ppResult + ); + WERROR CancelAsyncCall( - [in] IWbemObjectSink* pSink - ); + [in] IWbemObjectSink* pSink + ); + WERROR QueryObjectSink( - [in] long lFlags, - [out] IWbemObjectSink** ppResponseHandler - ); + [in] long lFlags, + [out] IWbemObjectSink** ppResponseHandler + ); + WERROR GetObject( - [in] BSTR strObjectPath, - [in] long lFlags, - [in] IWbemContext* pCtx, - [out, in, unique] IWbemClassObject** ppObject, - [out, in, unique] IWbemCallResult** ppCallResult - ); + [in] BSTR strObjectPath, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out, in, unique] IWbemClassObject** ppObject, + [out, in, unique] IWbemCallResult** ppCallResult + ); WERROR GetObjectAsync( @@ -431,6 +345,7 @@ coclass WbemClassObject [in] IWbemContext* pCtx, [in] IWbemObjectSink* pResponseHandler ); + WERROR PutClass( [in] IWbemClassObject* pObject, [in] long lFlags, @@ -581,9 +496,8 @@ coclass WbemClassObject [call_as(Next)] WERROR IEnumWbemClassObject_Next( [in] int32 lTimeout, [in] uint32 uCount, - [out, size_is(uCount), length_is(*puReturned)] - IWbemClassObject** apObjects, - [out] uint32* puReturned + [out, size_is(uCount), length_is(*puReturned)] IWbemClassObject** apObjects, + [out] uint32* puReturned ); WERROR NextAsync( @@ -653,32 +567,31 @@ coclass WbemClassObject ] interface IWbemLevel1Login : IUnknown { WERROR EstablishPosition( - [in, unique, string, charset(UTF16)] uint16* wszLocaleList, - [in] DWORD dwNumLocales, - [out] DWORD* reserved - ); + [in, unique, string, charset(UTF16)] uint16* wszLocaleList, + [in] DWORD dwNumLocales, + [out] DWORD* reserved + ); WERROR RequestChallenge( - [in, unique, string, charset(UTF16)] uint16* wszNetworkResource, - [in, unique, string, charset(UTF16)] uint16* wszUser, - [out, size_is(16), length_is(16)] unsigned char* Nonce - ); + [in, unique, string, charset(UTF16)] uint16* wszNetworkResource, + [in, unique, string, charset(UTF16)] uint16* wszUser, + [out, size_is(16), length_is(16)] uint8 * Nonce + ); WERROR WBEMLogin( - [in, unique, string, charset(UTF16)] uint16* wszPreferredLocale, - [in, size_is(16), length_is(16), unique] - unsigned char* AccessToken, - [in] long lFlags, - [in] IWbemContext* pCtx, - [out] IWbemServices** ppNamespace - ); + [in, unique, string, charset(UTF16)] uint16* wszPreferredLocale, + [in, size_is(16), length_is(16), unique] uint8 * AccessToken, + [in] long lFlags, + [in] IWbemContext* pCtx, + [out] IWbemServices** ppNamespace + ); WERROR NTLMLogin( - [in,unique,string,charset(UTF16)] uint16 *wszNetworkResource, - [in,unique,string,charset(UTF16)] uint16 *wszPreferredLocale, - [in] long lFlags, - [in,unique] IWbemContext* pCtx, - [out,ref] IWbemServices** ppNamespace - ); + [in,unique,string,charset(UTF16)] uint16 *wszNetworkResource, + [in,unique,string,charset(UTF16)] uint16 *wszPreferredLocale, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out,ref] IWbemServices** ppNamespace + ); } @@ -733,16 +646,16 @@ coclass WbemClassObject } WBEMDATA0; WERROR IWbemWCOSmartEnum_Next( - [in,ref] GUID *gEWCO, - [in] uint32 lTimeOut, - [in] uint32 uCount, - // [in] uint32 unknown, - // [in,ref] GUID *gWCO, - [out,ref] uint32 *puReturned, - [out,ref] uint32 *pSize, - // [out,ref] WBEMDATA0 **pData - [out,ref,noprint,size_is(,*pSize)] uint8 **pData - ); + [in,ref] GUID *gEWCO, + [in] uint32 lTimeOut, + [in] uint32 uCount, + // [in] uint32 unknown, + // [in,ref] GUID *gWCO, + [out,ref] uint32 *puReturned, + [out,ref] uint32 *pSize, + // [out,ref] WBEMDATA0 **pData + [out,ref,noprint,size_is(,*pSize)] uint8 **pData + ); } [ @@ -752,7 +665,7 @@ coclass WbemClassObject ] interface IWbemFetchSmartEnum : IUnknown { WERROR Fetch([out] IWbemWCOSmartEnum** ppEnum); - WERROR Test([out] WbemClassObject** ppEnum); + WERROR Test([out] IWbemClassObject** ppEnum); } [ @@ -763,7 +676,6 @@ coclass WbemClassObject { WERROR GetResultObject( [in] long lTimeout, - [out] IUnknown** ppResultObject, [out] IWbemClassObject** ppResultObject ); diff --git a/source4/librpc/ndr/ndr_wmi.c b/source4/librpc/ndr/ndr_wmi.c index 69cbe95f40..6cf42471f8 100644 --- a/source4/librpc/ndr/ndr_wmi.c +++ b/source4/librpc/ndr/ndr_wmi.c @@ -88,762 +88,3 @@ void ndr_print_BSTR(struct ndr_print *ndr, const char *name, const struct BSTR * { ndr->print(ndr, "%-25s: BSTR(\"%s\")", name, r->data); } - -enum ndr_err_code ndr_push_CIMSTRING(struct ndr_push *ndr, int ndr_flags, const CIMSTRING *r) -{ - uint8_t u; - enum ndr_err_code status; - - if (!(ndr_flags & NDR_SCALARS)) return NDR_ERR_SUCCESS; - - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, 0)); - u = ndr->flags; - ndr->flags |= LIBNDR_FLAG_STR_ASCII | LIBNDR_FLAG_STR_NULLTERM; - status = ndr_push_string(ndr, NDR_SCALARS, *r); - DEBUG(9, ("%08X: Push string: %s\n", ndr->offset, *r)); - ndr->flags = u; - return status; -} - -enum ndr_err_code ndr_pull_CIMSTRING(struct ndr_pull *ndr, int ndr_flags, CIMSTRING *r) -{ - uint8_t u; - enum ndr_err_code status; - - if (!(ndr_flags & NDR_SCALARS)) return NDR_ERR_SUCCESS; - - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u)); - switch (u) { - case 0: - u = ndr->flags; - ndr->flags |= LIBNDR_FLAG_STR_ASCII | LIBNDR_FLAG_STR_NULLTERM; - status = ndr_pull_string(ndr, NDR_SCALARS, r); - DEBUG(10, ("%08X: Pull string: %s\n", ndr->offset, *r)); - ndr->flags = u; - return status; - case 1: - u = ndr->flags; - ndr->flags |= LIBNDR_FLAG_STR_NULLTERM; - status = ndr_pull_string(ndr, NDR_SCALARS, r); - DEBUG(10, ("%08X: Pull string: %s\n", ndr->offset, *r)); - ndr->flags = u; - return status; - default: return NDR_ERR_BAD_SWITCH; - } -} - -void ndr_print_CIMSTRING(struct ndr_print *ndr, const char *name, const CIMSTRING *r) -{ - ndr->print(ndr, "%-25s: \"%s\"", name, *r); -} - -enum ndr_err_code ndr_push_CIMSTRINGS(struct ndr_push *ndr, int ndr_flags, const struct CIMSTRINGS *r) -{ - uint32_t ofs_size, ofs, i; - - if (!(ndr_flags & NDR_SCALARS)) return NDR_ERR_SUCCESS; - - ofs_size = ndr->offset; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - - for (i = 0; i < r->count; ++i) { - ofs = ndr->offset; - NDR_CHECK(ndr_push_CIMSTRING(ndr, ndr_flags, &r->item[i])); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr->offset - ofs)); - } - ofs = ndr->offset; - ndr->offset = ofs_size; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs - ofs_size)); - ndr->offset = ofs; - - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_CIMSTRINGS(struct ndr_pull *ndr, int ndr_flags, struct CIMSTRINGS *r) -{ - uint32_t endofs; - uint32_t len; - TALLOC_CTX *mem_ctx; - uint32_t u; - - if (!(ndr_flags & NDR_SCALARS)) return NDR_ERR_SUCCESS; - - mem_ctx = ndr->current_mem_ctx; - - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &endofs)); - endofs += ndr->offset - sizeof(endofs); - - r->count = 0; - len = 5; - r->item = talloc_array(mem_ctx, CIMSTRING, len); - ndr->current_mem_ctx = r->item; - while (ndr->offset < endofs) { - if (r->count >= len) { - len += 3; - r->item = talloc_realloc(mem_ctx, r->item, CIMSTRING, len); - } - NDR_CHECK(ndr_pull_CIMSTRING(ndr, ndr_flags, &r->item[r->count])); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); - ++r->count; - } - - r->item = talloc_realloc(mem_ctx, r->item, CIMSTRING, r->count); - - ndr->current_mem_ctx = mem_ctx; - - return NDR_ERR_SUCCESS; -} - -static const char *qualifier_keys[] = {[1] = "key", [3] = "read", [6] = "provider", [7] = "dynamic", [10] = "CIMTYPE" }; -#define arr_sizeof(a) (sizeof(a)/sizeof(a[0])) -static const char *qn_unknown = "Unknown_qualifier_name"; - -_PUBLIC_ enum ndr_err_code ndr_push_WbemQualifier(struct ndr_push *ndr, int ndr_flags, const struct WbemQualifier *r) -{ - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->name)); - NDR_CHECK(ndr_push_WBEM_FLAVOR_TYPE(ndr, NDR_SCALARS, r->flavors)); - NDR_CHECK(ndr_push_CIMTYPE_ENUMERATION(ndr, NDR_SCALARS, r->cimtype)); - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->value, r->cimtype & CIM_TYPEMASK)); - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_SCALARS, &r->value)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->name) { - uint32_t ofs; - int32_t i; - for (i = 0; i < arr_sizeof(qualifier_keys); ++i) - if (qualifier_keys[i] && !strcmp(r->name, qualifier_keys[i])) break; - if (i == arr_sizeof(qualifier_keys)) { - if (!strncmp(qn_unknown, r->name, sizeof(qn_unknown) - 1)) - i = atoi(r->name + sizeof(qn_unknown) - 1); - else - i = -1; - } - if (i >= 0) { - ofs = ndr->offset; - NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, r->name, &ndr->offset)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x80000000 | i)); - ndr->offset = ofs; - } else { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->name)); - NDR_CHECK(ndr_push_CIMSTRING(ndr, NDR_SCALARS, &r->name)); - } - } - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_BUFFERS, &r->value)); - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_WbemQualifier(struct ndr_pull *ndr, int ndr_flags, struct WbemQualifier *r) -{ - uint32_t _ptr_name; - TALLOC_CTX *_mem_save_name_0; - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name)); - if (_ptr_name != 0xFFFFFFFF) { - NDR_PULL_ALLOC(ndr, r->name); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->name, _ptr_name)); - } else { - r->name = NULL; - } - NDR_CHECK(ndr_pull_WBEM_FLAVOR_TYPE(ndr, NDR_SCALARS, &r->flavors)); - NDR_CHECK(ndr_pull_CIMTYPE_ENUMERATION(ndr, NDR_SCALARS, &r->cimtype)); - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->value, r->cimtype & CIM_TYPEMASK)); - NDR_CHECK(ndr_pull_CIMVAR(ndr, NDR_SCALARS, &r->value)); - } - if (ndr_flags & NDR_BUFFERS) { - uint32_t relofs; - relofs = ndr_token_peek(&ndr->relative_list, r->name); - if (relofs & 0x80000000) { - relofs &= 0xFF; - if ((relofs < sizeof(qualifier_keys)/sizeof(qualifier_keys[0])) && qualifier_keys[relofs]) { - r->name = talloc_strdup(ndr->current_mem_ctx, qualifier_keys[relofs]); - } else { - r->name = talloc_asprintf(ndr->current_mem_ctx, "%s%d", qn_unknown, relofs); - } - } else if (r->name) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->name)); - _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->name, 0); - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->name)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0); - ndr->offset = _relative_save_offset; - } - NDR_CHECK(ndr_pull_CIMVAR(ndr, NDR_BUFFERS, &r->value)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_WbemQualifiers(struct ndr_push *ndr, int ndr_flags, const struct WbemQualifiers *r) -{ - uint32_t i, ofs, ofs_size; - - if (ndr_flags & NDR_SCALARS) { - ofs_size = ndr->offset; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - for (i = 0; i < r->count; ++i) - NDR_CHECK(ndr_push_WbemQualifier(ndr, NDR_SCALARS, r->item[i])); - ofs = ndr->offset; - ndr->offset = ofs_size; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs - ofs_size)); - ndr->offset = ofs; - } - if (ndr_flags & NDR_BUFFERS) { - for (i = 0; i < r->count; ++i) - NDR_CHECK(ndr_push_WbemQualifier(ndr, NDR_BUFFERS, r->item[i])); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_WbemQualifiers(struct ndr_pull *ndr, int ndr_flags, struct WbemQualifiers *r) -{ - uint32_t endofs; - uint32_t len; - TALLOC_CTX *mem_ctx; - - mem_ctx = ndr->current_mem_ctx; - - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &endofs)); - endofs += ndr->offset - 4; - - r->count = 0; - len = 10; - r->item = talloc_array(mem_ctx, struct WbemQualifier*, len); - ndr->current_mem_ctx = r->item; - while (ndr->offset < endofs) { - if (r->count >= len) { - len += 3; - r->item = talloc_realloc(mem_ctx, r->item, struct WbemQualifier*, len); - } - NDR_PULL_ALLOC(ndr, r->item[r->count]); - NDR_CHECK(ndr_pull_WbemQualifier(ndr, NDR_SCALARS, r->item[r->count])); - ++r->count; - } - r->item = talloc_realloc(mem_ctx, r->item, struct WbemQualifier*, r->count); - } - if (ndr_flags & NDR_BUFFERS) { - uint32_t i; - ndr->current_mem_ctx = r->item; - for (i = 0; i < r->count; ++i) { - NDR_CHECK(ndr_pull_WbemQualifier(ndr, NDR_BUFFERS, r->item[i])); - } - } - - ndr->current_mem_ctx = mem_ctx; - - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_DataWithStack(struct ndr_push *ndr, ndr_push_flags_fn_t fn, const void *r) -{ - uint32_t ofs, ofs_size, ofs_ssize; - - ofs_size = ndr->offset; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - - NDR_CHECK(fn(ndr, NDR_SCALARS, r)); - - ofs_ssize = ndr->offset; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - ndr->relative_base_offset = ndr->offset; - - NDR_CHECK(fn(ndr, NDR_BUFFERS, r)); - - ofs = ndr->offset; - ndr->offset = ofs_size; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs-ofs_size)); - ndr->offset = ofs_ssize; - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, (ofs-ofs_ssize-4) | 0x80000000)); - ndr->offset = ofs; - - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_DataWithStack(struct ndr_pull *ndr, ndr_pull_flags_fn_t fn, void *r) -{ - uint32_t end, size, ssize, ndrend; - - end = ndr->offset; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &size)); - NDR_PULL_NEED_BYTES(ndr, size - 4); - end += size; - ndrend = ndr->data_size; - ndr->data_size = end; - - NDR_CHECK(fn(ndr, NDR_SCALARS, r)); - - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ssize)); - if (!(ssize & 0x80000000)) - return ndr_pull_error(ndr, NDR_ERR_VALIDATE, "ndr_pull_DataWithStack(%08X): Stack size without 31th bit set: 0x%08X", ndr->offset - 4, ssize); - ssize &= 0x7FFFFFFF; - NDR_PULL_NEED_BYTES(ndr, ssize); - ndr->data_size = ndr->offset + ssize; - - ndr->relative_base_offset = ndr->offset; - - NDR_CHECK(fn(ndr, NDR_BUFFERS, r)); - - ndr->data_size = ndrend; - ndr->offset = end; - - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_push_uint32_flags(struct ndr_push *ndr, int ndr_flags, uint32_t v) -{ - if (ndr_flags & NDR_SCALARS) - return ndr_push_uint32(ndr, NDR_SCALARS, v); - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_uint32_flags(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) -{ - if (ndr_flags & NDR_SCALARS) - return ndr_pull_uint32(ndr, NDR_SCALARS, v); - return NDR_ERR_SUCCESS; -} - -void copy_bits(const uint8_t *src, uint32_t bsrc, uint8_t *dst, uint32_t bdst, uint32_t count) -{ - uint8_t mask; - - src += bsrc >> 3; - bsrc &= 7; - dst += bdst >> 3; - bdst &= 7; - mask = ((1 << count) - 1); - *dst &= ~(mask << bdst); - *dst |= ((*src >> bsrc) & mask) << bdst; -} - -#define IS_CIMTYPE_PTR(t) (((t) & CIM_FLAG_ARRAY) || ((t) == CIM_STRING) || ((t) == CIM_DATETIME) || ((t) == CIM_REFERENCE)) -enum ndr_err_code ndr_push_WbemInstance_priv(struct ndr_push *ndr, int ndr_flags, const struct WbemClassObject *r) -{ - int i; - if (ndr_flags & NDR_SCALARS) { - uint32_t ofs, vofs; - - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->instance->u1_0)); - - if (r->instance->__CLASS) { - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->instance->__CLASS)); - } else { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xFFFFFFFF)); - } - - ofs = ndr->offset; - NDR_PUSH_NEED_BYTES(ndr, r->obj_class->data_size); - - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - copy_bits(&r->instance->properties[i].default_flags, 0, ndr->data + ndr->offset, 2*r->obj_class->properties[i].property.desc->nr, 2); - } - i = 0xFF; - copy_bits((uint8_t *)&i, 0, ndr->data + ndr->offset, 2*r->obj_class->__PROPERTY_COUNT, (8 - 2*r->obj_class->__PROPERTY_COUNT) % 7); - vofs = ofs + ((r->obj_class->__PROPERTY_COUNT + 3) >> 2); - - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->instance->data[i], r->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK)); - ndr->offset = vofs + r->obj_class->properties[i].property.desc->offset; - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_SCALARS, &r->instance->data[i])); - } - ndr->offset = ofs + r->obj_class->data_size; - - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->instance->u2_4)); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->instance->u3_1)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->instance->__CLASS) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->instance->__CLASS)); - NDR_CHECK(ndr_push_CIMSTRING(ndr, NDR_SCALARS, &r->instance->__CLASS)); - } - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_BUFFERS, &r->instance->data[i])); - } - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_WbemInstance_priv(struct ndr_pull *ndr, int ndr_flags, const struct WbemClassObject *r) -{ - int i; - - if (!r->obj_class) { -DEBUG(1,("ndr_pull_WbemInstance_priv: There is no class for given instance\n")); - return NDR_ERR_VALIDATE; - } - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - if (ndr_flags & NDR_SCALARS) { - uint32_t ofs, vofs; - uint32_t _ptr___CLASS; - - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->instance->u1_0)); - - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr___CLASS)); - if (_ptr___CLASS != 0xFFFFFFFF) { - NDR_PULL_ALLOC(ndr, r->instance->__CLASS); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->instance->__CLASS, _ptr___CLASS)); - } else { - r->instance->__CLASS = NULL; - } - - ofs = ndr->offset; - NDR_PULL_NEED_BYTES(ndr, r->obj_class->data_size); - NDR_PULL_ALLOC_N(ndr, r->instance->default_flags, r->obj_class->__PROPERTY_COUNT); - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - r->instance->default_flags[i] = 0; - copy_bits(ndr->data + ndr->offset, 2*r->obj_class->properties[i].property.desc->nr, &r->instance->properties[i].default_flags, 0, 2); - } - vofs = ofs + ((r->obj_class->__PROPERTY_COUNT + 3) >> 2); - - NDR_PULL_ALLOC_N(ndr, r->instance->data, r->obj_class->__PROPERTY_COUNT); - memset(r->instance->data, 0, sizeof(*r->instance->data) * r->obj_class->__PROPERTY_COUNT); - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->instance->data[i], r->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK)); - ndr->offset = vofs + r->obj_class->properties[i].property.desc->offset; - NDR_CHECK(ndr_pull_CIMVAR(ndr, NDR_SCALARS, &r->instance->data[i])); - } - ndr->offset = ofs + r->obj_class->data_size; - - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->instance->u2_4)); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->instance->u3_1)); - } - if (ndr_flags & NDR_BUFFERS) { - if (r->instance->__CLASS) { - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->instance->__CLASS)); - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->instance->__CLASS)); - ndr->offset = _relative_save_offset; - } - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - NDR_CHECK(ndr_pull_CIMVAR(ndr, NDR_BUFFERS, &r->instance->data[i])); - } - } - return NDR_ERR_SUCCESS; -} - -void ndr_print_WbemInstance_priv(struct ndr_print *ndr, const char *name, const struct WbemClassObject *r) -{ - int i; - - ndr_print_array_uint8(ndr, "default_flags", r->instance->default_flags, r->obj_class->__PROPERTY_COUNT); - - ndr->print(ndr, "%s: ARRAY(%d)", "data", r->obj_class->__PROPERTY_COUNT); - ndr->depth++; - for (i = 0; i < r->obj_class->__PROPERTY_COUNT; ++i) { - ndr->print(ndr, "%s[%d]", "data", i); - ndr->depth++; - ndr_print_set_switch_value(ndr, &r->instance->data[i], r->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK); - ndr_print_CIMVAR(ndr, r->obj_class->properties[i].property.name, &r->instance->data[i]); - ndr->depth--; - } - ndr->depth--; -} - -enum ndr_err_code ndr_push_WbemClassObject(struct ndr_push *ndr, int ndr_flags, const struct WbemClassObject *r) -{ - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->flags)); - if (r->flags & WCF_CLASS) { - NDR_CHECK(ndr_push_CIMSTRING(ndr, NDR_SCALARS, &r->__SERVER)); - NDR_CHECK(ndr_push_CIMSTRING(ndr, NDR_SCALARS, &r->__NAMESPACE)); - } - if (r->flags & WCF_DECORATIONS) { - NDR_CHECK(ndr_push_DataWithStack(ndr, (ndr_push_flags_fn_t)ndr_push_WbemClass, r->sup_class)); - NDR_CHECK(ndr_push_DataWithStack(ndr, (ndr_push_flags_fn_t)ndr_push_WbemMethods, r->sup_methods)); - } - if (r->flags & (WCF_CLASS | WCF_INSTANCE)) { - NDR_CHECK(ndr_push_DataWithStack(ndr, (ndr_push_flags_fn_t)ndr_push_WbemClass, r->obj_class)); - } - if (r->flags & WCF_DECORATIONS) { - NDR_CHECK(ndr_push_DataWithStack(ndr, (ndr_push_flags_fn_t)ndr_push_WbemMethods, r->obj_methods)); - } - if (r->flags & WCF_INSTANCE) { - NDR_CHECK(ndr_push_DataWithStack(ndr, (ndr_push_flags_fn_t)ndr_push_WbemInstance_priv, r)); - } - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_WbemClassObject(struct ndr_pull *ndr, int ndr_flags, struct WbemClassObject *r) -{ - TALLOC_CTX *tc; - - tc = NDR_PULL_GET_MEM_CTX(ndr); - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->flags)); - if (r->flags & WCF_CLASS) { - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->__SERVER)); - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->__NAMESPACE)); - } - if (r->flags & WCF_DECORATIONS) { - r->sup_class = talloc_zero(r, struct WbemClass); - NDR_PULL_SET_MEM_CTX(ndr, r->sup_class, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemClass, r->sup_class)); - r->sup_methods = talloc_zero(r, struct WbemMethods); - NDR_PULL_SET_MEM_CTX(ndr, r->sup_methods, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemMethods, r->sup_methods)); - NDR_PULL_SET_MEM_CTX(ndr, tc, 0); - } else - r->sup_class = NULL; - if (r->flags & (WCF_CLASS | WCF_INSTANCE)) { - r->obj_class = talloc_zero(r, struct WbemClass); - NDR_PULL_SET_MEM_CTX(ndr, r->obj_class, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemClass, r->obj_class)); - NDR_PULL_SET_MEM_CTX(ndr, tc, 0); - } - if (r->flags & WCF_DECORATIONS) { - r->obj_methods = talloc_zero(r, struct WbemMethods); - NDR_PULL_SET_MEM_CTX(ndr, r->obj_methods, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemMethods, r->obj_methods)); - NDR_PULL_SET_MEM_CTX(ndr, tc, 0); - } - if (r->flags & WCF_INSTANCE) { - r->instance = talloc_zero(r, struct WbemInstance); - NDR_PULL_SET_MEM_CTX(ndr, r->instance, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemInstance_priv, r)); - NDR_PULL_SET_MEM_CTX(ndr, tc, 0); - } else - r->instance = NULL; - return NDR_ERR_SUCCESS; -} - -enum ndr_err_code ndr_pull_WbemClassObject_Object(struct ndr_pull *ndr, int ndr_flags, struct WbemClassObject *r) -{ - TALLOC_CTX *tc; - - tc = NDR_PULL_GET_MEM_CTX(ndr); - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->flags)); - if (r->flags & WCF_CLASS) { - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->__SERVER)); - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->__NAMESPACE)); - } - if (r->flags & WCF_INSTANCE) { - r->instance = talloc_zero(r, struct WbemInstance); - NDR_PULL_SET_MEM_CTX(ndr, r->instance, 0); - NDR_CHECK(ndr_pull_DataWithStack(ndr, (ndr_pull_flags_fn_t)ndr_pull_WbemInstance_priv, r)); - NDR_PULL_SET_MEM_CTX(ndr, tc, 0); - } else - r->instance = NULL; - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ void ndr_print_WbemClassObject(struct ndr_print *ndr, const char *name, const struct WbemClassObject *r) -{ - ndr_print_struct(ndr, name, "WbemClassObject"); - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - ndr->depth++; - ndr_print_WCO_FLAGS(ndr, "flags", r->flags); - if (r->flags & WCF_CLASS) { - ndr_print_ptr(ndr, "__SERVER", r->__SERVER); - ndr->depth++; - ndr_print_CIMSTRING(ndr, "__SERVER", &r->__SERVER); - ndr->depth--; - ndr_print_ptr(ndr, "__NAMESPACE", r->__NAMESPACE); - ndr->depth++; - ndr_print_CIMSTRING(ndr, "__NAMESPACE", &r->__NAMESPACE); - ndr->depth--; - } - if (r->flags & WCF_DECORATIONS) { - ndr_print_ptr(ndr, "sup_class", r->sup_class); - ndr->depth++; - if (r->sup_class) { - ndr_print_WbemClass(ndr, "sup_class", r->sup_class); - } - ndr->depth--; - ndr_print_ptr(ndr, "sup_methods", r->sup_methods); - ndr->depth++; - if (r->sup_methods) { - ndr_print_WbemMethods(ndr, "sup_methods", r->sup_methods); - } - ndr->depth--; - } - if (r->flags & (WCF_CLASS | WCF_INSTANCE)) { - ndr_print_ptr(ndr, "obj_class", r->obj_class); - ndr->depth++; - if (r->obj_class) { - ndr_print_WbemClass(ndr, "obj_class", r->obj_class); - } - ndr->depth--; - } - if (r->flags & WCF_DECORATIONS) { - ndr_print_ptr(ndr, "obj_methods", r->obj_methods); - ndr->depth++; - if (r->obj_methods) { - ndr_print_WbemMethods(ndr, "obj_methods", r->obj_methods); - } - ndr->depth--; - } - if (r->flags & WCF_INSTANCE) { - ndr_print_ptr(ndr, "instance", r->instance); - ndr->depth++; - if (r->instance) { - ndr_print_WbemInstance_priv(ndr, "instance", r); - } - ndr->depth--; - } - ndr->depth--; - ndr->flags = _flags_save_STRUCT; - } -} - -_PUBLIC_ enum ndr_err_code ndr_push_WbemClass(struct ndr_push *ndr, int ndr_flags, const struct WbemClass *r) -{ - uint32_t cntr_properties_0; - uint32_t i, ofs, vofs; - { - uint32_t _flags_save_STRUCT = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->u_0)); - if (r->__CLASS) { - NDR_CHECK(ndr_push_relative_ptr1(ndr, r->__CLASS)); - } else { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xFFFFFFFF)); - } - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->data_size)); - NDR_CHECK(ndr_push_CIMSTRINGS(ndr, NDR_SCALARS, &r->__DERIVATION)); - NDR_CHECK(ndr_push_WbemQualifiers(ndr, NDR_SCALARS, &r->qualifiers)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->__PROPERTY_COUNT)); - for (cntr_properties_0 = 0; cntr_properties_0 < r->__PROPERTY_COUNT; cntr_properties_0++) { - NDR_CHECK(ndr_push_WbemProperty(ndr, NDR_SCALARS, &r->properties[cntr_properties_0].property)); - } - - ofs = ndr->offset; - NDR_PUSH_NEED_BYTES(ndr, r->data_size); - - for (i = 0; i < r->__PROPERTY_COUNT; ++i) { - copy_bits(&r->properties[i].default_flags, 0, ndr->data + ndr->offset, 2*r->properties[i].property.desc->nr, 2); - } - i = 0xFF; - copy_bits((uint8_t *)&i, 0, ndr->data + ndr->offset, 2*r->__PROPERTY_COUNT, (8 - 2*r->__PROPERTY_COUNT) % 7); - vofs = ofs + ((r->__PROPERTY_COUNT + 3) >> 2); - for (i = 0; i < r->__PROPERTY_COUNT; ++i) { - NDR_CHECK(ndr_push_set_switch_value(ndr, &r->properties[i].default_values, r->properties[i].property.desc->cimtype & CIM_TYPEMASK)); - ndr->offset = vofs + r->properties[i].property.desc->offset; - if ((r->properties[i].default_flags & DEFAULT_FLAG_EMPTY) && IS_CIMTYPE_PTR(r->properties[i].property.desc->cimtype & CIM_TYPEMASK)) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0xFFFFFFFF)); - } else { - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_SCALARS, &r->properties[i].default_values)); - } - } - ndr->offset = ofs + r->data_size; - } - if (ndr_flags & NDR_BUFFERS) { - if (r->__CLASS) { - NDR_CHECK(ndr_push_relative_ptr2(ndr, r->__CLASS)); - NDR_CHECK(ndr_push_CIMSTRING(ndr, NDR_SCALARS, &r->__CLASS)); - } - NDR_CHECK(ndr_push_CIMSTRINGS(ndr, NDR_BUFFERS, &r->__DERIVATION)); - NDR_CHECK(ndr_push_WbemQualifiers(ndr, NDR_BUFFERS, &r->qualifiers)); - for (cntr_properties_0 = 0; cntr_properties_0 < r->__PROPERTY_COUNT; cntr_properties_0++) { - NDR_CHECK(ndr_push_WbemProperty(ndr, NDR_BUFFERS, &r->properties[cntr_properties_0].property)); - } - for (i = 0; i < r->__PROPERTY_COUNT; ++i) { - if (r->properties[i].default_flags & DEFAULT_FLAG_EMPTY) continue; - NDR_CHECK(ndr_push_CIMVAR(ndr, NDR_BUFFERS, &r->properties[i].default_values)); - } - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} - -_PUBLIC_ enum ndr_err_code ndr_pull_WbemClass(struct ndr_pull *ndr, int ndr_flags, struct WbemClass *r) -{ - uint32_t _ptr___CLASS; - uint32_t cntr_properties_0; - TALLOC_CTX *_mem_save_properties_0; - uint32_t i; - - { - uint32_t _flags_save_STRUCT = ndr->flags; - - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); - if (ndr_flags & NDR_SCALARS) { - NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->u_0)); - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr___CLASS)); - if (_ptr___CLASS != 0xFFFFFFFF) { - NDR_PULL_ALLOC(ndr, r->__CLASS); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->__CLASS, _ptr___CLASS)); - } else { - r->__CLASS = NULL; - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->data_size)); - NDR_CHECK(ndr_pull_CIMSTRINGS(ndr, NDR_SCALARS, &r->__DERIVATION)); - NDR_CHECK(ndr_pull_WbemQualifiers(ndr, NDR_SCALARS, &r->qualifiers)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->__PROPERTY_COUNT)); - NDR_PULL_ALLOC_N(ndr, r->properties, r->__PROPERTY_COUNT); - _mem_save_properties_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->properties, 0); - for (cntr_properties_0 = 0; cntr_properties_0 < r->__PROPERTY_COUNT; cntr_properties_0++) { - NDR_CHECK(ndr_pull_WbemProperty(ndr, NDR_SCALARS, &(r->properties)[cntr_properties_0])); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_properties_0, 0); - - NDR_PULL_NEED_BYTES(ndr, r->data_size); - - NDR_PULL_ALLOC_N(ndr, r->default_flags, r->__PROPERTY_COUNT); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_flags, ndr->offset)); - - NDR_PULL_ALLOC_N(ndr, r->default_values, r->__PROPERTY_COUNT); - memset(r->default_values, 0, sizeof(*r->default_values) * r->__PROPERTY_COUNT); - NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_values, ndr->offset + ((r->__PROPERTY_COUNT + 3) >> 2))); - - ndr->offset += r->data_size; - } - if (ndr_flags & NDR_BUFFERS) { - if (r->__CLASS) { - TALLOC_CTX *_mem_save___CLASS_0; - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->__CLASS)); - _mem_save___CLASS_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->__CLASS, 0); - NDR_CHECK(ndr_pull_CIMSTRING(ndr, NDR_SCALARS, &r->__CLASS)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save___CLASS_0, 0); - ndr->offset = _relative_save_offset; - } - NDR_CHECK(ndr_pull_CIMSTRINGS(ndr, NDR_BUFFERS, &r->__DERIVATION)); - NDR_CHECK(ndr_pull_WbemQualifiers(ndr, NDR_BUFFERS, &r->qualifiers)); - _mem_save_properties_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->properties, 0); - for (cntr_properties_0 = 0; cntr_properties_0 < r->__PROPERTY_COUNT; cntr_properties_0++) { - NDR_CHECK(ndr_pull_WbemProperty(ndr, NDR_BUFFERS, &(r->properties)[cntr_properties_0].property)); - } - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_properties_0, 0); - { - uint32_t ofs; - NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, r->default_flags, &ofs)); - for (i = 0; i < r->__PROPERTY_COUNT; ++i) { - r->properties[i].default_flags = 0; - copy_bits(ndr->data + ofs, 2*r->properties[i].property.desc->nr, &r->properties[i].default_flags, 0, 2); - } - } - { - uint32_t ofs; - uint32_t _relative_save_offset; - _relative_save_offset = ndr->offset; - NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, r->default_values, &ofs)); - for (i=0; i < r->__PROPERTY_COUNT; ++i) { - if (r->properties[i].default_flags & DEFAULT_FLAG_EMPTY) continue; - NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->properties[i].default_values, r->properties[i].property.desc->cimtype & CIM_TYPEMASK)); - ndr->offset = ofs + r->properties[i].property.desc->offset; - NDR_CHECK(ndr_pull_CIMVAR(ndr, NDR_SCALARS|NDR_BUFFERS, &r->properties[i].default_values)); - } - ndr->offset = _relative_save_offset; - } - } - ndr->flags = _flags_save_STRUCT; - } - return NDR_ERR_SUCCESS; -} diff --git a/source4/librpc/ndr/ndr_wmi.h b/source4/librpc/ndr/ndr_wmi.h index 0dbf3844ba..539b9e882b 100644 --- a/source4/librpc/ndr/ndr_wmi.h +++ b/source4/librpc/ndr/ndr_wmi.h @@ -1,6 +1,3 @@ typedef const char *CIMSTRING; -enum ndr_err_code ndr_pull_WbemClassObject_Object(struct ndr_pull *ndr, int ndr_flags, struct WbemClassObject *r); -enum ndr_err_code ndr_pull_WbemClassObject(struct ndr_pull *ndr, int ndr_flags, struct WbemClassObject *r); -enum ndr_err_code ndr_push_WbemClassObject(struct ndr_push *ndr, int ndr_flags, const struct WbemClassObject *r); enum ndr_err_code ndr_pull_CIMSTRING(struct ndr_pull *ndr, int ndr_flags, CIMSTRING *r); enum ndr_err_code ndr_push_CIMSTRING(struct ndr_push *ndr, int ndr_flags, const CIMSTRING *r); |