Add a new header file for functions in lib/util/util.c.
[obnox/samba/samba-obnox.git] / librpc / rpc / rpc_common.h
index 4dfc46a98db94978842b81f74dc963c3c1f712db..b03b9ffc81432c4e7f402cce166a59841cc0f616 100644 (file)
@@ -22,6 +22,9 @@
 #ifndef __DEFAULT_LIBRPC_RPCCOMMON_H__
 #define __DEFAULT_LIBRPC_RPCCOMMON_H__
 
+#include "gen_ndr/dcerpc.h"
+#include "lib/util/attr.h"
+
 struct dcerpc_binding_handle;
 struct GUID;
 struct ndr_interface_table;
@@ -40,18 +43,7 @@ enum dcerpc_transport_t {
        NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX, NCACN_INTERNAL };
 
 /** this describes a binding to a particular transport/pipe */
-struct dcerpc_binding {
-       enum dcerpc_transport_t transport;
-       struct ndr_syntax_id object;
-       const char *object_string;
-       const char *host;
-       const char *target_hostname;
-       const char *target_principal;
-       const char *endpoint;
-       const char **options;
-       uint32_t flags;
-       uint32_t assoc_group_id;
-};
+struct dcerpc_binding;
 
 /* dcerpc pipe flags */
 #define DCERPC_DEBUG_PRINT_IN          (1<<0)
@@ -117,6 +109,7 @@ struct dcerpc_binding {
 
 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
 NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code);
+uint32_t dcerpc_fault_from_nt_status(NTSTATUS nt_status);
 
 /* The following definitions come from ../librpc/rpc/binding.c  */
 
@@ -145,6 +138,9 @@ void dcerpc_binding_get_auth_info(const struct dcerpc_binding *b,
 uint32_t dcerpc_binding_get_assoc_group_id(const struct dcerpc_binding *b);
 NTSTATUS dcerpc_binding_set_assoc_group_id(struct dcerpc_binding *b,
                                           uint32_t assoc_group_id);
+struct ndr_syntax_id dcerpc_binding_get_abstract_syntax(const struct dcerpc_binding *b);
+NTSTATUS dcerpc_binding_set_abstract_syntax(struct dcerpc_binding *b,
+                                           const struct ndr_syntax_id *syntax);
 const char *dcerpc_binding_get_string_option(const struct dcerpc_binding *b,
                                             const char *name);
 char *dcerpc_binding_copy_string_option(TALLOC_CTX *mem_ctx,
@@ -378,4 +374,39 @@ bool dcerpc_sec_verification_trailer_check(
                const struct dcerpc_sec_vt_pcontext *pcontext,
                const struct dcerpc_sec_vt_header2 *header2);
 
+/**
+ * @brief check and optionally extract the Bind Time Features from
+ * the given ndr_syntax_id.
+ *
+ * <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
+ *
+ * @param[in]  s the syntax that should be checked.
+ *
+ * @param[out] features This is optional, it will be filled with the extracted
+ *                      features the on success, otherwise it's filled with 0.
+ *
+ * @return true if the syntax matches the 6CB71C2C-9812-4540 prefix with version 1, false otherwise.
+ *
+ * @see dcerpc_construct_bind_time_features
+ */
+bool dcerpc_extract_bind_time_features(struct ndr_syntax_id syntax, uint64_t *features);
+
+/**
+ * @brief Construct a ndr_syntax_id used for Bind Time Features Negotiation.
+ *
+ * <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
+ *
+ * @param[in] features The supported features.
+ *
+ * @return The ndr_syntax_id with the given features.
+ *
+ * @see dcerpc_extract_bind_time_features
+ */
+struct ndr_syntax_id dcerpc_construct_bind_time_features(uint64_t features);
+
+#define DCERPC_AUTH_PAD_LENGTH(stub_length) (\
+       (((stub_length) % DCERPC_AUTH_PAD_ALIGNMENT) > 0)?\
+       (DCERPC_AUTH_PAD_ALIGNMENT - (stub_length) % DCERPC_AUTH_PAD_ALIGNMENT):\
+       0)
+
 #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */