s4:lib/messaging: add irpc_binding_handle_by_name() helper function
authorStefan Metzmacher <metze@samba.org>
Mon, 30 Aug 2010 11:44:41 +0000 (13:44 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 3 Sep 2010 15:00:18 +0000 (17:00 +0200)
metze

source4/lib/messaging/irpc.h
source4/lib/messaging/messaging.c

index 158b9cb3ec5149b1430aa5317c372bf14a8d467b..88f142ee1eb7a367b2fb03d7beb7ec3ecb15c76a 100644 (file)
@@ -102,6 +102,10 @@ struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx,
                                        struct messaging_context *msg_ctx,
                                        struct server_id server_id,
                                        const struct ndr_interface_table *table);
+struct dcerpc_binding_handle *irpc_binding_handle_by_name(TALLOC_CTX *mem_ctx,
+                                       struct messaging_context *msg_ctx,
+                                       const char *dest_task,
+                                       const struct ndr_interface_table *table);
 
 NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
 struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
index 67b8401bf570cc6a39ce4d3130b0cd3b617e69c2..f460d676cd3902d57d3bb5246df9842b27446326 100644 (file)
@@ -1401,3 +1401,35 @@ struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx,
 
        return h;
 }
+
+struct dcerpc_binding_handle *irpc_binding_handle_by_name(TALLOC_CTX *mem_ctx,
+                                       struct messaging_context *msg_ctx,
+                                       const char *dest_task,
+                                       const struct ndr_interface_table *table)
+{
+       struct dcerpc_binding_handle *h;
+       struct server_id *sids;
+       struct server_id sid;
+
+       /* find the server task */
+       sids = irpc_servers_byname(msg_ctx, mem_ctx, dest_task);
+       if (sids == NULL) {
+               errno = EADDRNOTAVAIL;
+               return NULL;
+       }
+       if (sids[0].id == 0) {
+               talloc_free(sids);
+               errno = EADDRNOTAVAIL;
+               return NULL;
+       }
+       sid = sids[0];
+       talloc_free(sids);
+
+       h = irpc_binding_handle(mem_ctx, msg_ctx,
+                               sid, table);
+       if (h == NULL) {
+               return NULL;
+       }
+
+       return h;
+}