svn commit: samba r7732 - in branches/SAMBA_4_0/source/libnet: .

mimir at samba.org mimir at samba.org
Sat Jun 18 22:10:32 GMT 2005


Author: mimir
Date: 2005-06-18 22:10:32 +0000 (Sat, 18 Jun 2005)
New Revision: 7732

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7732

Log:
Implementation of very basic lookup function (to be used in more
specific routines like resolving a pdc).
Also, couple of formatting fixes.


rafal


Added:
   branches/SAMBA_4_0/source/libnet/libnet_lookup.c
   branches/SAMBA_4_0/source/libnet/libnet_lookup.h
Modified:
   branches/SAMBA_4_0/source/libnet/composite.h
   branches/SAMBA_4_0/source/libnet/config.mk
   branches/SAMBA_4_0/source/libnet/libnet_user.c
   branches/SAMBA_4_0/source/libnet/userinfo.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/composite.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/composite.h	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/composite.h	2005-06-18 22:10:32 UTC (rev 7732)
@@ -22,6 +22,9 @@
   composite function io definitions
 */
 
+#include "librpc/gen_ndr/ndr_samr.h"
+
+
 struct libnet_rpc_userinfo {
 	struct {
 		struct policy_handle domain_handle;

Modified: branches/SAMBA_4_0/source/libnet/config.mk
===================================================================
--- branches/SAMBA_4_0/source/libnet/config.mk	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/config.mk	2005-06-18 22:10:32 UTC (rev 7732)
@@ -13,7 +13,9 @@
 		libnet/libnet_share.o \
 		libnet/userinfo.o \
 		libnet/userman.o \
-		libnet/domain.o
-REQUIRED_SUBSYSTEMS = RPC_NDR_SAMR RPC_NDR_SRVSVC LIBCLI_COMPOSITE LIBSAMBA3
+		libnet/domain.o \
+		libnet/lookup.o
+
+REQUIRED_SUBSYSTEMS = RPC_NDR_SAMR RPC_NDR_SRVSVC LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBSAMBA3
 # End SUBSYSTEM LIBNET
 #################################

Added: branches/SAMBA_4_0/source/libnet/libnet_lookup.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_lookup.c	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/libnet_lookup.c	2005-06-18 22:10:32 UTC (rev 7732)
@@ -0,0 +1,95 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Rafal Szczesniak 2005
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+  a composite function for name resolving
+*/
+
+#include "includes.h"
+#include "libcli/raw/libcliraw.h"
+#include "lib/events/events.h"
+#include "libcli/composite/composite.h"
+#include "libcli/composite/monitor.h"
+#include "libnet/composite.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+
+
+struct lookup_state {
+	struct composite_context *resolve_ctx;
+	struct nbt_name hostname;
+	char address[16];
+};
+
+
+struct composite_context *libnet_Lookup_send(struct libnet_lookup *io)
+{
+	struct composite_context *c;
+	struct lookup_state *s;
+
+	if (!io) return NULL;
+
+	/* allocate context and state structures */
+	c = talloc_zero(NULL, struct composite_context);
+	if (c == NULL) goto failed;
+
+	s = talloc_zero(c, struct lookup_state);
+	if (s == NULL) goto failed;
+	
+	/* prepare event context */
+	c->event_ctx = event_context_init(c);
+	if (c->event_ctx == NULL) goto failed;
+
+	/* parameters */
+	s->hostname.name   = talloc_strdup(s, io->in.hostname);
+	s->hostname.type   = io->in.type;
+	s->hostname.scope  = NULL;
+
+	c->private  = s;
+	c->state    = SMBCLI_REQUEST_SEND;
+
+	/* send resolve request */
+	s->resolve_ctx = resolve_name_send(&s->hostname, c->event_ctx, io->in.methods);
+
+	return c;
+
+failed:
+	talloc_free(c);
+	return NULL;
+}
+
+
+NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+			    struct libnet_lookup *io)
+{
+	NTSTATUS status;
+	struct lookup_state *s;
+
+	s = talloc_get_type(c->private, struct lookup_state);
+
+	status = resolve_name_recv(s->resolve_ctx, mem_ctx, io->out.address);
+	return status;
+}
+
+
+NTSTATUS libnet_Lookup(TALLOC_CTX *mem_ctx, struct libnet_lookup *io)
+{
+	struct composite_context *c = libnet_Lookup_send(io);
+	return libnet_Lookup_recv(c, mem_ctx, io);
+}

Added: branches/SAMBA_4_0/source/libnet/libnet_lookup.h
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_lookup.h	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/libnet_lookup.h	2005-06-18 22:10:32 UTC (rev 7732)
@@ -0,0 +1,31 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Rafal Szczesniak 2005
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+struct libnet_Lookup {
+	struct {
+		const char *hostname;
+		int type;
+		const char **methods;
+	} in;
+	struct {
+		const char **address;
+	} out;
+};

Modified: branches/SAMBA_4_0/source/libnet/libnet_user.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/libnet_user.c	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/libnet_user.c	2005-06-18 22:10:32 UTC (rev 7732)
@@ -22,7 +22,6 @@
 #include "includes.h"
 #include "libnet/libnet.h"
 #include "libnet/composite.h"
-#include "librpc/gen_ndr/ndr_samr.h"
 
 
 NTSTATUS libnet_CreateUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_CreateUser *r)
@@ -41,7 +40,7 @@
 	if (!NT_STATUS_IS_OK(status)) return status;
 
 	/* connect rpc service of remote server */
-	cn.standard.level                      = LIBNET_RPC_CONNECT_STANDARD;
+	cn.standard.level                      = LIBNET_RPC_CONNECT_PDC;
 	cn.standard.in.server_name             = fp.generic.out.pdc_name;
 	cn.standard.in.dcerpc_iface_name       = DCERPC_SAMR_NAME;
 	cn.standard.in.dcerpc_iface_uuid       = DCERPC_SAMR_UUID;

Modified: branches/SAMBA_4_0/source/libnet/userinfo.c
===================================================================
--- branches/SAMBA_4_0/source/libnet/userinfo.c	2005-06-18 20:32:21 UTC (rev 7731)
+++ branches/SAMBA_4_0/source/libnet/userinfo.c	2005-06-18 22:10:32 UTC (rev 7732)
@@ -174,12 +174,14 @@
  * @param io arguments and results of the call
  */
 struct composite_context *libnet_rpc_userinfo_send(struct dcerpc_pipe *p,
-						      struct libnet_rpc_userinfo *io,
-						      void (*monitor)(struct monitor_msg*))
+						   struct libnet_rpc_userinfo *io,
+						   void (*monitor)(struct monitor_msg*))
 {
 	struct composite_context *c;
 	struct userinfo_state *s;
 	struct dom_sid *sid;
+
+	if (!p || !io) return NULL;
 	
 	c = talloc_zero(p, struct composite_context);
 	if (c == NULL) goto failure;
@@ -229,7 +231,7 @@
  */
 
 NTSTATUS libnet_rpc_userinfo_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
-				     struct libnet_rpc_userinfo *io)
+				  struct libnet_rpc_userinfo *io)
 {
 	NTSTATUS status;
 	struct userinfo_state *s;
@@ -259,8 +261,8 @@
  */
 
 NTSTATUS libnet_rpc_userinfo(struct dcerpc_pipe *pipe,
-				TALLOC_CTX *mem_ctx,
-				struct libnet_rpc_userinfo *io)
+			     TALLOC_CTX *mem_ctx,
+			     struct libnet_rpc_userinfo *io)
 {
 	struct composite_context *c = libnet_rpc_userinfo_send(pipe, io, NULL);
 	return libnet_rpc_userinfo_recv(c, mem_ctx, io);



More information about the samba-cvs mailing list