s4:rpc_server: make it possible to specify ncacn_np_secondary_endpoint
[gd/samba-autobuild/.git] / pidl / lib / Parse / Pidl / Samba4 / NDR / Server.pm
index 0ffed39394f33c7cceb0e25450f3f1ef72304d19..945c0ffcee0f5e9ddea2ed183d09bf711b9e80eb 100644 (file)
@@ -81,10 +81,10 @@ sub Boilerplate_Iface($)
        my $if_version = $interface->{VERSION};
 
        pidl "
-static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
+static NTSTATUS $name\__op_bind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
 {
 #ifdef DCESRV_INTERFACE_$uname\_BIND
-       return DCESRV_INTERFACE_$uname\_BIND(dce_call,iface);
+       return DCESRV_INTERFACE_$uname\_BIND(context,iface);
 #else
        return NT_STATUS_OK;
 #endif
@@ -192,15 +192,20 @@ static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_C
        return NT_STATUS_OK;
 }
 
-const struct dcesrv_interface dcesrv\_$name\_interface = {
-       .name           = \"$name\",
-       .syntax_id  = {".print_uuid($uuid).",$if_version},
-       .bind           = $name\__op_bind,
-       .unbind         = $name\__op_unbind,
-       .ndr_pull       = $name\__op_ndr_pull,
-       .dispatch       = $name\__op_dispatch,
-       .reply          = $name\__op_reply,
-       .ndr_push       = $name\__op_ndr_push
+static const struct dcesrv_interface dcesrv\_$name\_interface = {
+       .name               = \"$name\",
+       .syntax_id          = {".print_uuid($uuid).",$if_version},
+       .bind               = $name\__op_bind,
+       .unbind             = $name\__op_unbind,
+       .ndr_pull           = $name\__op_ndr_pull,
+       .dispatch           = $name\__op_dispatch,
+       .reply              = $name\__op_reply,
+       .ndr_push           = $name\__op_ndr_push,
+#ifdef DCESRV_INTERFACE_$uname\_FLAGS
+       .flags              = DCESRV_INTERFACE_$uname\_FLAGS
+#else
+       .flags              = 0
+#endif
 };
 
 ";
@@ -218,12 +223,22 @@ sub Boilerplate_Ep_Server($)
 static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
 {
        int i;
+#ifdef DCESRV_INTERFACE_$uname\_NCACN_NP_SECONDARY_ENDPOINT
+       const char *ncacn_np_secondary_endpoint =
+               DCESRV_INTERFACE_$uname\_NCACN_NP_SECONDARY_ENDPOINT;
+#else
+       const char *ncacn_np_secondary_endpoint = NULL;
+#endif
 
        for (i=0;i<ndr_table_$name.endpoints->count;i++) {
                NTSTATUS ret;
                const char *name = ndr_table_$name.endpoints->names[i];
 
-               ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_$name\_interface, NULL);
+               ret = dcesrv_interface_register(dce_ctx,
+                                               name,
+                                               ncacn_np_secondary_endpoint,
+                                               &dcesrv_$name\_interface,
+                                               NULL);
                if (!NT_STATUS_IS_OK(ret)) {
                        DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name));
                        return ret;
@@ -254,20 +269,22 @@ static bool $name\__op_interface_by_name(struct dcesrv_interface *iface, const c
        return false;
 }
 
-NTSTATUS dcerpc_server_$name\_init(void)
+NTSTATUS dcerpc_server_$name\_init(TALLOC_CTX *ctx)
 {
        NTSTATUS ret;
-       struct dcesrv_endpoint_server ep_server;
-
-       /* fill in our name */
-       ep_server.name = \"$name\";
-
-       /* fill in all the operations */
-       ep_server.init_server = $name\__op_init_server;
-
-       ep_server.interface_by_uuid = $name\__op_interface_by_uuid;
-       ep_server.interface_by_name = $name\__op_interface_by_name;
+       static const struct dcesrv_endpoint_server ep_server = {
+           /* fill in our name */
+           .name = \"$name\",
 
+           /* fill in all the operations */
+#ifdef DCESRV_INTERFACE_$uname\_INIT_SERVER
+           .init_server = DCESRV_INTERFACE_$uname\_INIT_SERVER,
+#else
+           .init_server = $name\__op_init_server,
+#endif
+           .interface_by_uuid = $name\__op_interface_by_uuid,
+           .interface_by_name = $name\__op_interface_by_name
+       };
        /* register ourselves with the DCERPC subsystem. */
        ret = dcerpc_register_ep_server(&ep_server);
 
@@ -289,7 +306,7 @@ sub ParseInterface($)
        my($interface) = shift;
        my $count = 0;
 
-       $res .= "NTSTATUS dcerpc_server_$interface->{NAME}\_init(void);\n";
+       $res .= "NTSTATUS dcerpc_server_$interface->{NAME}\_init(TALLOC_CTX *);\n";
        $res .= "\n";
 
        if (!defined $interface->{PROPERTIES}->{uuid}) {