[SCM] Samba Shared Repository - branch master updated - 7f5aef542ae07e5b53a2372c41b6da4e1123459b

Günther Deschner gd at samba.org
Tue Sep 23 07:37:47 GMT 2008


The branch, master has been updated
       via  7f5aef542ae07e5b53a2372c41b6da4e1123459b (commit)
       via  9f8813e4d4f4963e6ec15e1886e03421c782f638 (commit)
       via  83c042583b8a18fbb41e1fa8402ac91490941cff (commit)
       via  a1a92688ba0a811400b4d12920988c62fa0efdf4 (commit)
       via  6f33f3e4c26564602d5d13c7459938955b56a16e (commit)
       via  be8b72dd5541182e24f522026bafbaef044a47e3 (commit)
       via  13a3971438fb12d60aa0eaf88d22019a5e4f67cd (commit)
       via  c48186f507219e8732f02bdc2f835a7d8d02541c (commit)
       via  c8858058e93aa5c44df5fd64f2844a34e240a0e9 (commit)
       via  9421ecac33b79dcb56b685c2b17d32cff7524331 (commit)
       via  f093ddbc111ccdfe0995d40d24bed94a3d62deb6 (commit)
       via  9216153827f0000cc82cb51adcba722181c94999 (commit)
       via  b60d612cdeb7dad7c1e2496c5b1e19abb58da50f (commit)
      from  c5265ea3bf493035385fdc9a2bc59a9b0a0bb8f3 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7f5aef542ae07e5b53a2372c41b6da4e1123459b
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:34:22 2008 +0200

    s3-nbt: use ../libcli/nbt helper.
    
    Guenther

commit 9f8813e4d4f4963e6ec15e1886e03421c782f638
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:59:40 2008 +0200

    s3: re-run make idl.
    
    Guenther

commit 83c042583b8a18fbb41e1fa8402ac91490941cff
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:59:19 2008 +0200

    s3-nbt: refer to ../libcli/nbt in nbt.idl.
    
    Guenther

commit a1a92688ba0a811400b4d12920988c62fa0efdf4
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:06:33 2008 +0200

    s4-nbt: use ../libcli/nbt
    
    Guenther

commit 6f33f3e4c26564602d5d13c7459938955b56a16e
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 06:58:17 2008 +0200

    s4-nbt: move libcli/nbt up one level.
    
    Guenther

commit be8b72dd5541182e24f522026bafbaef044a47e3
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 09:34:03 2008 +0200

    s4-nbt: merge some fixes from samba3 nbt helper.
    
    Guenther

commit 13a3971438fb12d60aa0eaf88d22019a5e4f67cd
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 09:02:16 2008 +0200

    s4-nbt: use private_data instead of private.
    
    Guenther

commit c48186f507219e8732f02bdc2f835a7d8d02541c
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:09:37 2008 +0200

    s3: use samba4 prototype for ndr_push/pull_struct_blob.
    
    Guenther

commit c8858058e93aa5c44df5fd64f2844a34e240a0e9
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:58:37 2008 +0200

    s3: re-run make idl.
    
    Guenther

commit 9421ecac33b79dcb56b685c2b17d32cff7524331
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:31:34 2008 +0200

    s3-nbt: fix nbt.idl in order to use shared nbt helper.
    
    Guenther

commit f093ddbc111ccdfe0995d40d24bed94a3d62deb6
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 02:41:44 2008 +0200

    s3-charset: add smb_iconv_convenience.
    
    Guenther

commit 9216153827f0000cc82cb51adcba722181c94999
Author: Günther Deschner <gd at samba.org>
Date:   Mon Sep 22 22:22:04 2008 +0200

    s4-nbt: remove unrequired include.
    
    Guenther

commit b60d612cdeb7dad7c1e2496c5b1e19abb58da50f
Author: Günther Deschner <gd at samba.org>
Date:   Tue Sep 23 08:32:42 2008 +0200

    s4: add talloc_strdup_upper.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 libcli/nbt/libnbt.h                      |  351 ++++++++++++++++
 libcli/nbt/namequery.c                   |  235 +++++++++++
 libcli/nbt/namerefresh.c                 |  302 ++++++++++++++
 libcli/nbt/nameregister.c                |  442 ++++++++++++++++++++
 libcli/nbt/namerelease.c                 |  135 ++++++
 libcli/nbt/nbtname.c                     |  648 +++++++++++++++++++++++++++++
 libcli/nbt/nbtsocket.c                   |  521 ++++++++++++++++++++++++
 libcli/nbt/pynbt.c                       |  408 +++++++++++++++++++
 source3/Makefile.in                      |    2 +-
 source3/include/charset.h                |    2 +
 source3/include/proto.h                  |   23 +-
 source3/libads/authdata.c                |   14 +-
 source3/libads/cldap.c                   |    2 +-
 source3/librpc/gen_ndr/nbt.h             |    2 +-
 source3/librpc/gen_ndr/ndr_nbt.c         |   12 +-
 source3/librpc/gen_ndr/ndr_nbt.h         |    8 +-
 source3/librpc/idl/nbt.idl               |    8 +-
 source3/librpc/ndr/ndr.c                 |   14 +-
 source3/libsmb/dsgetdcname.c             |    4 +-
 source3/libsmb/samlogon_cache.c          |    4 +-
 source3/smbd/notify_internal.c           |    8 +-
 source3/winbindd/winbindd_pam.c          |    2 +-
 source4/lib/charset/util_unistr.c        |    8 +-
 source4/libcli/composite/composite.c     |    4 +-
 source4/libcli/config.mk                 |   10 +-
 source4/libcli/finddcs.c                 |    2 +-
 source4/libcli/nbt/libnbt.h              |  351 ----------------
 source4/libcli/nbt/namequery.c           |  235 -----------
 source4/libcli/nbt/namerefresh.c         |  302 --------------
 source4/libcli/nbt/nameregister.c        |  442 --------------------
 source4/libcli/nbt/namerelease.c         |  135 ------
 source4/libcli/nbt/nbtname.c             |  649 ------------------------------
 source4/libcli/nbt/nbtsocket.c           |  521 ------------------------
 source4/libcli/nbt/pynbt.c               |  408 -------------------
 source4/libcli/raw/clitransport.c        |    2 +-
 source4/libcli/resolve/nbtlist.c         |    6 +-
 source4/libcli/resolve/resolve.h         |    2 +-
 source4/libcli/resolve/wins.c            |    2 +-
 source4/librpc/idl/nbt.idl               |    2 +-
 source4/nbt_server/defense.c             |    2 +-
 source4/nbt_server/interfaces.c          |    2 +-
 source4/nbt_server/nbt_server.h          |    2 +-
 source4/nbt_server/nodestatus.c          |    2 +-
 source4/nbt_server/packet.c              |   14 +-
 source4/nbt_server/query.c               |    2 +-
 source4/nbt_server/register.c            |    4 +-
 source4/nbt_server/wins/wins_dns_proxy.c |    2 +-
 source4/nbt_server/wins/winsserver.c     |   16 +-
 source4/nbt_server/wins/winswack.c       |    8 +-
 source4/torture/nbt/nbt.c                |    2 +-
 source4/torture/nbt/query.c              |    4 +-
 source4/torture/nbt/winsbench.c          |   12 +-
 source4/torture/nbt/winsreplication.c    |    6 +-
 source4/utils/nmblookup.c                |    2 +-
 54 files changed, 3154 insertions(+), 3154 deletions(-)
 create mode 100644 libcli/nbt/libnbt.h
 create mode 100644 libcli/nbt/namequery.c
 create mode 100644 libcli/nbt/namerefresh.c
 create mode 100644 libcli/nbt/nameregister.c
 create mode 100644 libcli/nbt/namerelease.c
 create mode 100644 libcli/nbt/nbtname.c
 create mode 100644 libcli/nbt/nbtsocket.c
 create mode 100644 libcli/nbt/pynbt.c
 delete mode 100644 source4/libcli/nbt/libnbt.h
 delete mode 100644 source4/libcli/nbt/namequery.c
 delete mode 100644 source4/libcli/nbt/namerefresh.c
 delete mode 100644 source4/libcli/nbt/nameregister.c
 delete mode 100644 source4/libcli/nbt/namerelease.c
 delete mode 100644 source4/libcli/nbt/nbtname.c
 delete mode 100644 source4/libcli/nbt/nbtsocket.c
 delete mode 100644 source4/libcli/nbt/pynbt.c


Changeset truncated at 500 lines:

diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
new file mode 100644
index 0000000..4ef4e9d
--- /dev/null
+++ b/libcli/nbt/libnbt.h
@@ -0,0 +1,351 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   a raw async NBT library
+
+   Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __LIBNBT_H__
+#define __LIBNBT_H__
+
+#include "librpc/gen_ndr/nbt.h"
+#include "librpc/ndr/libndr.h"
+
+/*
+  possible states for pending requests
+*/
+enum nbt_request_state {NBT_REQUEST_SEND,
+			NBT_REQUEST_WAIT,
+			NBT_REQUEST_DONE,
+			NBT_REQUEST_TIMEOUT,
+			NBT_REQUEST_ERROR};
+
+/*
+  a nbt name request
+*/
+struct nbt_name_request {
+	struct nbt_name_request *next, *prev;
+
+	enum nbt_request_state state;
+
+	NTSTATUS status;
+
+	/* the socket this was on */
+	struct nbt_name_socket *nbtsock;
+
+	/* where to send the request */
+	struct socket_address *dest;
+
+	/* timeout between retries */
+	int timeout;
+
+	/* how many retries to send on timeout */
+	int num_retries;
+
+	/* whether we have received a WACK */
+	bool received_wack;
+
+	/* the timeout event */
+	struct timed_event *te;
+
+	/* the name transaction id */
+	uint16_t name_trn_id;
+
+	/* is it a reply? */
+	bool is_reply;
+
+	/* the encoded request */
+	DATA_BLOB encoded;
+
+	/* shall we allow multiple replies? */
+	bool allow_multiple_replies;
+
+	unsigned int num_replies;
+	struct nbt_name_reply {
+		struct nbt_name_packet *packet;
+		struct socket_address *dest;
+	} *replies;
+
+	/* information on what to do on completion */
+	struct {
+		void (*fn)(struct nbt_name_request *);
+		void *private_data;
+	} async;
+};
+
+
+
+/*
+  context structure for operations on name queries
+*/
+struct nbt_name_socket {
+	struct socket_context *sock;
+	struct event_context *event_ctx;
+	struct smb_iconv_convenience *iconv_convenience;
+
+	/* a queue of requests pending to be sent */
+	struct nbt_name_request *send_queue;
+
+	/* the fd event */
+	struct fd_event *fde;
+
+	/* mapping from name_trn_id to pending event */
+	struct idr_context *idr;
+
+	/* how many requests are waiting for a reply */
+	uint16_t num_pending;
+
+	/* what to do with incoming request packets */
+	struct {
+		void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+				struct socket_address *);
+		void *private_data;
+	} incoming;
+
+	/* what to do with unexpected replies */
+	struct {
+		void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+				struct socket_address *);
+		void *private_data;
+	} unexpected;
+};
+
+
+/* a simple name query */
+struct nbt_name_query {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		bool broadcast;
+		bool wins_lookup;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		int16_t num_addrs;
+		const char **reply_addrs;
+	} out;
+};
+
+/* a simple name status query */
+struct nbt_name_status {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		struct nbt_rdata_status status;
+	} out;
+};
+
+/* a name registration request */
+struct nbt_name_register {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		const char *address;
+		uint16_t nb_flags;
+		bool register_demand;
+		bool broadcast;
+		bool multi_homed;
+		uint32_t ttl;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		const char *reply_addr;
+		uint8_t rcode;
+	} out;
+};
+
+/* a send 3 times then demand name broadcast name registration */
+struct nbt_name_register_bcast {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		const char *address;
+		uint16_t nb_flags;
+		uint32_t ttl;
+	} in;
+};
+
+
+/* wins name register with multiple wins servers to try and multiple
+   addresses to register */
+struct nbt_name_register_wins {
+	struct {
+		struct nbt_name name;
+		const char **wins_servers;
+		uint16_t wins_port;
+		const char **addresses;
+		uint16_t nb_flags;
+		uint32_t ttl;
+	} in;
+	struct {
+		const char *wins_server;
+		uint8_t rcode;
+	} out;
+};
+
+
+
+/* a name refresh request */
+struct nbt_name_refresh {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		const char *address;
+		uint16_t nb_flags;
+		bool broadcast;
+		uint32_t ttl;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		const char *reply_addr;
+		uint8_t rcode;
+	} out;
+};
+
+/* wins name refresh with multiple wins servers to try and multiple
+   addresses to register */
+struct nbt_name_refresh_wins {
+	struct {
+		struct nbt_name name;
+		const char **wins_servers;
+		uint16_t wins_port;
+		const char **addresses;
+		uint16_t nb_flags;
+		uint32_t ttl;
+	} in;
+	struct {
+		const char *wins_server;
+		uint8_t rcode;
+	} out;
+};
+
+
+/* a name release request */
+struct nbt_name_release {
+	struct {
+		struct nbt_name name;
+		const char *dest_addr;
+		uint16_t dest_port;
+		const char *address;
+		uint16_t nb_flags;
+		bool broadcast;
+		int timeout; /* in seconds */
+		int retries;
+	} in;
+	struct {
+		const char *reply_from;
+		struct nbt_name name;
+		const char *reply_addr;
+		uint8_t rcode;
+	} out;
+};
+
+struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
+					     struct event_context *event_ctx,
+					     struct smb_iconv_convenience *iconv_convenience);
+struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
+					     struct nbt_name_query *io);
+NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
+			     TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
+			TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
+struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *nbtsock,
+					      struct nbt_name_status *io);
+NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
+			     TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
+NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
+			TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
+
+NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
+NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, DATA_BLOB *blob, struct nbt_name *name);
+NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
+void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
+char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name);
+NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
+			   TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
+NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
+			   TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
+NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
+			   TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
+NTSTATUS nbt_name_register_wins(struct nbt_name_socket *nbtsock,
+				TALLOC_CTX *mem_ctx,
+				struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock,
+				TALLOC_CTX *mem_ctx,
+				struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
+				TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
+struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
+						struct nbt_name_register *io);
+NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
+			       TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
+
+struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
+					       struct nbt_name_release *io);
+
+NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
+			       TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
+
+NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
+				  void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+						  struct socket_address *),
+				  void *private_data);
+NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
+			     struct socket_address *dest,
+			     struct nbt_name_packet *request);
+
+
+NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *);
+NDR_SCALAR_PROTO(nbt_string, const char *);
+NDR_BUFFER_PROTO(nbt_name, struct nbt_name);
+NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
+
+struct composite_context;
+struct composite_context *nbt_name_register_bcast_send(struct nbt_name_socket *nbtsock,
+						       struct nbt_name_register_bcast *io);
+NTSTATUS nbt_name_register_bcast_recv(struct composite_context *c);
+struct composite_context *nbt_name_register_wins_send(struct nbt_name_socket *nbtsock,
+						      struct nbt_name_register_wins *io);
+NTSTATUS nbt_name_refresh_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+				     struct nbt_name_refresh_wins *io);
+struct composite_context *nbt_name_refresh_wins_send(struct nbt_name_socket *nbtsock,
+						      struct nbt_name_refresh_wins *io);
+NTSTATUS nbt_name_register_wins_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
+				     struct nbt_name_register_wins *io);
+
+
+#endif /* __LIBNBT_H__ */
diff --git a/libcli/nbt/namequery.c b/libcli/nbt/namequery.c
new file mode 100644
index 0000000..ed3d8a2
--- /dev/null
+++ b/libcli/nbt/namequery.c
@@ -0,0 +1,235 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   make nbt name query requests
+
+   Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
+#include "lib/socket/socket.h"
+#include "param/param.h"
+
+/**
+  send a nbt name query
+*/
+_PUBLIC_ struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
+					     struct nbt_name_query *io)
+{
+	struct nbt_name_request *req;
+	struct nbt_name_packet *packet;
+	struct socket_address *dest;
+
+	packet = talloc_zero(nbtsock, struct nbt_name_packet);
+	if (packet == NULL) return NULL;
+
+	packet->qdcount = 1;
+	packet->operation = NBT_OPCODE_QUERY;
+	if (io->in.broadcast) {
+		packet->operation |= NBT_FLAG_BROADCAST;
+	}
+	if (io->in.wins_lookup) {
+		packet->operation |= NBT_FLAG_RECURSION_DESIRED;
+	}
+
+	packet->questions = talloc_array(packet, struct nbt_name_question, 1);
+	if (packet->questions == NULL) goto failed;
+
+	packet->questions[0].name = io->in.name;
+	packet->questions[0].question_type = NBT_QTYPE_NETBIOS;
+	packet->questions[0].question_class = NBT_QCLASS_IP;
+
+	dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
+					   io->in.dest_addr, io->in.dest_port);
+	if (dest == NULL) goto failed;
+	req = nbt_name_request_send(nbtsock, dest, packet,
+				    io->in.timeout, io->in.retries, false);
+	if (req == NULL) goto failed;
+
+	talloc_free(packet);
+	return req;
+
+failed:
+	talloc_free(packet);
+	return NULL;
+}
+
+/**
+  wait for a name query reply
+*/
+_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
+			     TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
+{
+	NTSTATUS status;
+	struct nbt_name_packet *packet;
+	int i;
+
+	status = nbt_name_request_recv(req);
+	if (!NT_STATUS_IS_OK(status) ||
+	    req->num_replies == 0) {
+		talloc_free(req);
+		return status;
+	}
+
+	packet = req->replies[0].packet;
+	io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
+
+	if ((packet->operation & NBT_RCODE) != 0) {
+		status = nbt_rcode_to_ntstatus(packet->operation & NBT_RCODE);
+		talloc_free(req);
+		return status;
+	}
+
+	if (packet->ancount != 1 ||
+	    packet->answers[0].rr_type != NBT_QTYPE_NETBIOS ||
+	    packet->answers[0].rr_class != NBT_QCLASS_IP) {
+		talloc_free(req);
+		return status;
+	}
+
+	io->out.name = packet->answers[0].name;
+	io->out.num_addrs = packet->answers[0].rdata.netbios.length / 6;
+	io->out.reply_addrs = talloc_array(mem_ctx, const char *, io->out.num_addrs+1);
+	if (io->out.reply_addrs == NULL) {
+		talloc_free(req);
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	for (i=0;i<io->out.num_addrs;i++) {
+		io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs,
+						      packet->answers[0].rdata.netbios.addresses[i].ipaddr);
+	}
+	io->out.reply_addrs[i] = NULL;
+
+	talloc_steal(mem_ctx, io->out.name.name);
+	talloc_steal(mem_ctx, io->out.name.scope);
+
+	talloc_free(req);
+
+	return NT_STATUS_OK;
+}
+
+/**
+  wait for a name query reply
+*/
+_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
+			TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
+{
+	struct nbt_name_request *req = nbt_name_query_send(nbtsock, io);
+	return nbt_name_query_recv(req, mem_ctx, io);
+}
+
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list