librpc/rpc: maintain "abstract_syntax" as string option of dcerpc_binding
authorStefan Metzmacher <metze@samba.org>
Tue, 4 Feb 2014 12:52:26 +0000 (13:52 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 24 Mar 2014 23:45:29 +0000 (00:45 +0100)
This should not be mixed with the object guid! They are different things!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/binding.c

index ea00a3d798c9aa18d2f32aac341d07aa3c4104cd..27ea4c620294110fedda9dd192a3d3ce1b58be22 100644 (file)
@@ -620,42 +620,55 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_assoc_group_id(struct dcerpc_binding *b,
 
 _PUBLIC_ struct ndr_syntax_id dcerpc_binding_get_abstract_syntax(const struct dcerpc_binding *b)
 {
-       /*
-        * For now we just use object, until all callers are fixed.
-        */
-       return b->object;
+       const char *s = dcerpc_binding_get_string_option(b, "abstract_syntax");
+       bool ok;
+       struct ndr_syntax_id id;
+
+       if (s == NULL) {
+               return ndr_syntax_id_null;
+       }
+
+       ok = ndr_syntax_id_from_string(s, &id);
+       if (!ok) {
+               return ndr_syntax_id_null;
+       }
+
+       return id;
 }
 
 _PUBLIC_ NTSTATUS dcerpc_binding_set_abstract_syntax(struct dcerpc_binding *b,
                                                     const struct ndr_syntax_id *syntax)
 {
        NTSTATUS status;
-       struct GUID object;
+       char *s = NULL;
 
-       /*
-        * For now we just use object, until all callers are fixed.
-        */
+       if (syntax == NULL) {
+               status = dcerpc_binding_set_string_option(b, "abstract_syntax", NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
 
-       if (syntax != NULL) {
-               object = syntax->uuid;
-       } else {
-               object = GUID_zero();
+               return NT_STATUS_OK;
        }
 
-       /*
-        * This sets also the string
-        */
-       status = dcerpc_binding_set_object(b, object);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       if (ndr_syntax_id_equal(&ndr_syntax_id_null, syntax)) {
+               status = dcerpc_binding_set_string_option(b, "abstract_syntax", NULL);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+
+               return NT_STATUS_OK;
        }
 
-       if (syntax != NULL) {
-               /*
-                * Here we need to reset the whole ndr_syntax_id
-                * structure including the .if_version
-                */
-               b->object = *syntax;
+       s = ndr_syntax_id_to_string(b, syntax);
+       if (s == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       status = dcerpc_binding_set_string_option(b, "abstract_syntax", s);
+       TALLOC_FREE(s);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
        return NT_STATUS_OK;