r3667: Small COM fixes
authorJelmer Vernooij <jelmer@samba.org>
Wed, 10 Nov 2004 21:20:51 +0000 (21:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:05:43 +0000 (13:05 -0500)
(This used to be commit 7484b9be7423ccd7e37432951700939e8a53d513)

source4/build/pidl/header.pm
source4/build/pidl/idl.pm
source4/build/pidl/idl.yp
source4/lib/dcom/common/dcom.h
source4/lib/dcom/common/local.c
source4/lib/dcom/common/main.c
source4/librpc/idl/dcom.idl
source4/rpc_server/dcom/dcom.h
source4/rpc_server/dcom/remact.c

index cc9b80438723d6b2c70f3682e86701ee245196c2..b98120078102df8a4181318332ee69ee7c5358a3 100644 (file)
@@ -350,16 +350,27 @@ sub HeaderInterface($)
            $res .= "NTSTATUS dcerpc_server_$interface->{NAME}_init(void);\n\n";
     }
 
-       $count = $interface->{INHERITED_FUNCTIONS};
     foreach my $d (@{$data}) {
            if ($d->{TYPE} eq "FUNCTION") {
                    my $u_name = uc $d->{NAME};
-                   $res .= "#define DCERPC_$u_name " . sprintf("0x%02x", $count) . "\n";
+                       $res .= "#define DCERPC_$u_name (";
+               
+                       if (defined($interface->{BASE})) {
+                               $res .= "DCERPC_" . uc $interface->{BASE} . "_CALL_COUNT + ";
+                       }
+                       
+                   $res .= sprintf("0x%02x", $count) . ")\n";
                    $count++;
            }
     }
 
-    $res .= "\n\n";
+       $res .= "\n#define DCERPC_" . uc $interface->{NAME} . "_CALL_COUNT (";
+       
+       if (defined($interface->{BASE})) {
+               $res .= "DCERPC_" . uc $interface->{BASE} . "_CALL_COUNT + ";
+       }
+       
+       $res .= "$count)\n\n";
 
     foreach my $d (@{$data}) {
        ($d->{TYPE} eq "CONST") &&
index a3e2e2ca8cee7cd9fc4e958cd1d1cb1bac81ec8f..19525e42f361495c02e3b0b3c20be1e9a98da652 100644 (file)
@@ -2080,10 +2080,8 @@ sub parse_idl($$)
                                die("No such parent interface " . $x->{BASE});
                        }
                        
-                       $x->{INHERITED_FUNCTIONS} = scalar @{$parent->{INHERITED_DATA}};
                        @{$x->{INHERITED_DATA}} = (@{$parent->{INHERITED_DATA}}, @{$x->{DATA}});
                } else {
-                       $x->{INHERITED_FUNCTIONS} = 0;
                        $x->{INHERITED_DATA} = $x->{DATA};
                }
        }
index e571645c4bc5c2fc78f682bb81257dce562e0ce6..24f88dd53188b7fcd3cfde37ee816389be10c716 100644 (file)
@@ -368,10 +368,8 @@ sub parse_idl($$)
                                die("No such parent interface " . $x->{BASE});
                        }
                        
-                       $x->{INHERITED_FUNCTIONS} = scalar @{$parent->{INHERITED_DATA}};
                        @{$x->{INHERITED_DATA}} = (@{$parent->{INHERITED_DATA}}, @{$x->{DATA}});
                } else {
-                       $x->{INHERITED_FUNCTIONS} = 0;
                        $x->{INHERITED_DATA} = $x->{DATA};
                }
        }
index 23db4c355f4f8821b89643256d5057b7ffa64409..320b5a4a9f88e4f71e8f6274387d5bee5d3b5803 100644 (file)
@@ -38,6 +38,7 @@ struct dcom_context
        const char *domain;
        const char *user;
        const char *password;
+       uint32_t dcerpc_flags;
 };
 
 struct dcom_interface
index 3c5405e9dca34548b1da1b3195bd412e7ab2b4ab..a68f5f4593ce739d979d0dbd91d2ca4d26cfe73d 100644 (file)
@@ -70,3 +70,13 @@ NTSTATUS dcerpc_IUnknown_QueryInterface(struct dcom_interface *o, TALLOC_CTX *me
         * call RemQueryInterface if necessary */
        return NT_STATUS_NOT_SUPPORTED;
 }
+
+NTSTATUS dcerpc_IClassFactory_CreateInstance(struct dcom_interface *o, TALLOC_CTX *mem_ctx, struct IClassFactory_CreateInstance *rr)
+{
+       return NT_STATUS_NOT_SUPPORTED;
+}
+
+NTSTATUS dcerpc_IClassFactory_LockServer(struct dcom_interface *o, TALLOC_CTX *mem_ctx, struct IClassFactory_LockServer *rr)
+{
+       return NT_STATUS_NOT_SUPPORTED;
+}
index b2cb782953634fe7f8f4cd01615a2989fb6ab0ea..996432181ae3899e6956d70e6aaede4e33b0feed 100644 (file)
@@ -291,15 +291,16 @@ NTSTATUS dcom_get_pipe (struct dcom_interface *iface, struct dcerpc_pipe **p)
                i = 0;
                do {
                        status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding, iface->objref->u_objref.u_standard.saResAddr.stringbindings[i]);
-                       i++;
-               } while (!NT_STATUS_IS_OK(status) && iface->objref->u_objref.u_standard.saResAddr.stringbindings[i]);
 
-               if (NT_STATUS_IS_ERR(status)) {
-                       DEBUG(1, ("Error parsing string binding"));
-                       return status;
-               }
+                       if (NT_STATUS_IS_OK(status)) {
+                               binding.flags = iface->ctx->dcerpc_flags;
+                               status = dcerpc_pipe_connect_b(&po, &binding, DCERPC_IOXIDRESOLVER_UUID, DCERPC_IOXIDRESOLVER_VERSION, iface->ctx->domain, iface->ctx->user, iface->ctx->password);
+                       } else {
+                               DEBUG(1, ("Error parsing string binding - %s", nt_errstr(status)));
+                       }
 
-               status = dcerpc_pipe_connect_b(&po, &binding, DCERPC_IOXIDRESOLVER_UUID, DCERPC_IOXIDRESOLVER_VERSION, iface->ctx->domain, iface->ctx->user, iface->ctx->password);
+                       i++;
+               } while (!NT_STATUS_IS_OK(status) && iface->objref->u_objref.u_standard.saResAddr.stringbindings[i]);
 
                if (NT_STATUS_IS_ERR(status)) {
                        DEBUG(1, ("Error while connecting to OXID Resolver : %s\n", nt_errstr(status)));
@@ -337,17 +338,18 @@ NTSTATUS dcom_get_pipe (struct dcom_interface *iface, struct dcerpc_pipe **p)
        i = 0;
        do {
                status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding, m->bindings.stringbindings[i]);
+               if (NT_STATUS_IS_ERR(status)) {
+                       DEBUG(1, ("Error parsing string binding"));
+               } else {
+                       binding.flags = iface->ctx->dcerpc_flags;
+                       status = dcerpc_pipe_connect_b(&m->pipe, &binding, GUID_string(iface->ctx, &iid) , 0.0, iface->ctx->domain, iface->ctx->user, iface->ctx->password);
+               }
+
                i++;
        } while (NT_STATUS_IS_ERR(status) && m->bindings.stringbindings[i]);
 
        if (NT_STATUS_IS_ERR(status)) {
-               DEBUG(1, ("Error parsing string binding"));
-               return status;
-       }
-
-       status = dcerpc_pipe_connect_b(&m->pipe, &binding, GUID_string(iface->ctx, &iid) , 0.0, iface->ctx->domain, iface->ctx->user, iface->ctx->password);
-
-       if (NT_STATUS_IS_ERR(status)) {
+               DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status)));
                return status;
        }
 
index 165d47473ab71dd4d601826acb116a54337c4fff..b1295315d8b746ba043393b7cacd9c54d5fa6574 100644 (file)
@@ -57,14 +57,13 @@ interface ObjectRpcBaseTypes
        } COMVERSION;
 
        /* enumeration of additional information present in the call packet. */
-       /* Should be an enum but DCE IDL does not support sparse enumerators. */
        typedef enum {
-               ORPCF_NULL = 0, /* no additional info in packet */
-               ORPCF_LOCAL = 1, /* call is local to this machine */
-               ORPCF_RESERVED1 = 2, /* reserved for local use */
-               ORPCF_RESERVED2 = 4, /* reserved for local use */
-               ORPCF_RESERVED3 = 8, /* reserved for local use */
-               ORPCF_RESERVED4 = 16 /* reserved for local use */
+               ORPCF_NULL =                    0x00, /* no additional info in packet */
+               ORPCF_LOCAL =                   0x01, /* call is local to this machine */
+               ORPCF_RESERVED1 =               0x02, /* reserved for local use */
+               ORPCF_RESERVED2 =               0x04, /* reserved for local use */
+               ORPCF_RESERVED3 =               0x08, /* reserved for local use */
+               ORPCF_RESERVED4 =           0x10  /* reserved for local use */
        } ORPC_FLAGS;
 
        /* Extension to implicit parameters. */
@@ -127,7 +126,9 @@ interface ObjectRpcBaseTypes
        }       SECURITYBINDING;
 
        /* signature value for OBJREF (object reference, actually the */
-       /* marshaled form of a COM interface). */
+       /* marshaled form of a COM interface). 
+        * MEOW apparently stands for "Microsoft Extended Object Wireformat"
+        */
        const uint32 OBJREF_SIGNATURE = 0x574f454d; /* 'MEOW' */
 
        /* flag values for OBJREF */
@@ -198,7 +199,7 @@ interface ObjectRpcBaseTypes
        } OBJREF_Types;
 
        /* OBJREF is the format of a marshaled interface pointer. */
-       typedef [public] struct 
+       typedef [public,flag(NDR_LITTLE_ENDIAN)] struct 
        {
                uint32 signature;
                uint32 flags; /* OBJREF flags (see above) */
@@ -245,7 +246,7 @@ interface IUnknown
        pointer_default(unique)
 ] interface IClassFactory : IUnknown
 {
-       [local] WERROR CreateInstance(/*FIXME[in] IUnknown *pUnknown*/
+       [local] WERROR IClassFactory_CreateInstance([in] MInterfacePointer *pUnknown
                               [in] GUID *iid,
                               [out, iid_is(riid)] MInterfacePointer *ppv);
 
@@ -253,7 +254,7 @@ interface IUnknown
 
        /* Set lock to TRUE when you want to do a lock
        and set it to FALSE when you want to unlock */
-       [local] WERROR LockServer([in] uint8 lock);
+       [local] WERROR IClassFactory_LockServer([in] uint8 lock);
 
        [call_as(LockServer)] WERROR RemoteLockServer();
 }
index 4fdcd0e0e67209d79d7c0680912ca33303637e6d..2d4dc7d628591986fb7b5d156207f572cde3a42f 100644 (file)
 struct dcom_class
 {
        const char *name;
+       const char *prog_id;
        struct GUID CLSID;
 
        /* List of IID's implemented */
-       uint32 cIIDs;
+       uint32 num_iids;
        struct GUID *IID;
 
        /* Pointers to functions this class implements */
+       void **interfaces;
 };
 
 struct dcom_object 
@@ -45,6 +47,7 @@ struct dcom_object
 struct dcom_interface_pointer
 {
        struct dcom_object *object;
+       struct dcerpc_interface_table *interface;
        struct GUID ipid;
 };
 
index 0ec1ea5a5122f197314bc73a1c491ff0c028ef5b..7a2b21a78992863bc9b38ea3fbaf37cf487f6bb5 100644 (file)
@@ -38,11 +38,14 @@ struct dcom_interface_pointer *dcom_interface_pointer_by_ipid(struct GUID *ipid)
 */
 static WERROR RemoteActivation(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct RemoteActivation *r)
 {
+       struct IClassFactory_CreateInstance *cr;
+       struct IUnknown_Release *ur;
+       struct dcom_interface *o;
        int i;
+
        /* FIXME: CoGetClassObject() */
        /* FIXME: IClassFactory::CreateInstance() */
-       /* FIXME: Register newly created object with dcerpc subsystem */
-       /* FIXME: IClassFactory::Release() */
+       /* FIXME: IUnknown::Release() */
        
        ZERO_STRUCT(r->out);
        r->out.ServerVersion.MajorVersion = COM_MAJOR_VERSION;
@@ -55,17 +58,21 @@ static WERROR RemoteActivation(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
         * r->out.interfaces */
        r->out.ifaces = talloc_array_p(mem_ctx, struct pMInterfacePointer, r->in.Interfaces);
        r->out.results = talloc_array_p(mem_ctx, WERROR, r->in.Interfaces);
+       r->out.hr = cr->out.result;
+
        for (i = 0; i < r->in.Interfaces; i++) {
-                       ZERO_STRUCT(r->out.ifaces[i]);  
-                       r->out.results[i] = WERR_NOT_SUPPORTED;
+               struct IUnknown_QueryInterface rr;
+               rr.in.iid = &r->in.pIIDs[i];
+               dcerpc_IUnknown_QueryInterface(o, mem_ctx, &rr);
+               ZERO_STRUCT(r->out.ifaces[i]);  
+               r->out.results[i] = rr.out.result;
        }
 
        /* FIXME: */
        r->out.pOxid = 0;
        ZERO_STRUCT(r->out.ipidRemUnknown);
-       r->out.hr = WERR_NOT_SUPPORTED;
        
-       return WERR_NOT_SUPPORTED;
+       return WERR_OK;
 }