librpc/rpc: add dcerpc_sec_vt_header2_[from_ncacn_packet|equal]()
[sfrench/samba-autobuild/.git] / librpc / rpc / rpc_common.h
index fae303f630e3e64bd018a6adb520d72390fbf79a..aab7c1001d2994c769af61a9822fb59a0d2a36ed 100644 (file)
@@ -30,6 +30,7 @@ struct ndr_push;
 struct ndr_pull;
 struct ncacn_packet;
 struct epm_floor;
+struct epm_tower;
 struct tevent_context;
 struct tstream_context;
 
@@ -97,7 +98,7 @@ struct dcerpc_binding {
 /* this triggers the DCERPC_PFC_FLAG_CONC_MPX flag in the bind request */
 #define DCERPC_CONCURRENT_MULTIPLEX     (1<<19)
 
-/* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */
+/* this indicates DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag was negotiated */
 #define DCERPC_HEADER_SIGNING          (1<<20)
 
 /* use NDR64 transport */
@@ -106,6 +107,15 @@ struct dcerpc_binding {
 /* specify binding interface */
 #define        DCERPC_LOCALADDRESS            (1<<22)
 
+/* handle upgrades or downgrades automatically */
+#define DCERPC_SCHANNEL_AUTO           (1<<23)
+
+/* use aes schannel with hmac-sh256 session key */
+#define DCERPC_SCHANNEL_AES            (1<<24)
+
+/* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */
+#define DCERPC_PROPOSE_HEADER_SIGNING          (1<<25)
+
 /* The following definitions come from ../librpc/rpc/dcerpc_error.c  */
 
 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
@@ -116,6 +126,19 @@ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code);
 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
 const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor);
 enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot);
+struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx,
+                                         const struct dcerpc_binding *b);
+NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx,
+                                   const struct dcerpc_binding *binding,
+                                   struct epm_tower *tower);
+NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
+                                  struct epm_tower *tower,
+                                  struct dcerpc_binding **b_out);
+NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out);
+char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b);
+NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
+const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
+enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);
 
 /* The following definitions come from ../librpc/rpc/dcerpc_util.c  */
 
@@ -123,6 +146,9 @@ void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
 uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
 void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
 uint8_t dcerpc_get_endian_flag(DATA_BLOB *blob);
+const char *dcerpc_default_transport_endpoint(TALLOC_CTX *mem_ctx,
+                                             enum dcerpc_transport_t transport,
+                                             const struct ndr_interface_table *table);
 
 /**
 * @brief       Pull a dcerpc_auth structure, taking account of any auth
@@ -166,6 +192,10 @@ struct dcerpc_binding_handle_ops {
        uint32_t (*set_timeout)(struct dcerpc_binding_handle *h,
                                uint32_t timeout);
 
+       void (*auth_info)(struct dcerpc_binding_handle *h,
+                         enum dcerpc_AuthType *auth_type,
+                         enum dcerpc_AuthLevel *auth_level);
+
        struct tevent_req *(*raw_call_send)(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
                                            struct dcerpc_binding_handle *h,
@@ -236,6 +266,10 @@ bool dcerpc_binding_handle_is_connected(struct dcerpc_binding_handle *h);
 uint32_t dcerpc_binding_handle_set_timeout(struct dcerpc_binding_handle *h,
                                           uint32_t timeout);
 
+void dcerpc_binding_handle_auth_info(struct dcerpc_binding_handle *h,
+                                    enum dcerpc_AuthType *auth_type,
+                                    enum dcerpc_AuthLevel *auth_level);
+
 struct tevent_req *dcerpc_binding_handle_raw_call_send(TALLOC_CTX *mem_ctx,
                                                struct tevent_context *ev,
                                                struct dcerpc_binding_handle *h,
@@ -281,4 +315,27 @@ NTSTATUS dcerpc_binding_handle_call(struct dcerpc_binding_handle *h,
                                    TALLOC_CTX *r_mem,
                                    void *r_ptr);
 
+/**
+ * Extract header information from a ncacn_packet
+ * as a dcerpc_sec_vt_header2 as used by the security verification trailer.
+ *
+ * @param[in] pkt a packet
+ *
+ * @return a dcerpc_sec_vt_header2
+ */
+struct dcerpc_sec_vt_header2 dcerpc_sec_vt_header2_from_ncacn_packet(const struct ncacn_packet *pkt);
+
+
+/**
+ * Test if two dcerpc_sec_vt_header2 structures are equal
+ * without consideration of reserved fields.
+ *
+ * @param v1 a pointer to a dcerpc_sec_vt_header2 structure
+ * @param v2 a pointer to a dcerpc_sec_vt_header2 structure
+ *
+ * @retval true if *v1 equals *v2
+ */
+bool dcerpc_sec_vt_header2_equal(const struct dcerpc_sec_vt_header2 *v1,
+                                const struct dcerpc_sec_vt_header2 *v2);
+
 #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */