summaryrefslogtreecommitdiff
path: root/source4/libcli/raw/clitransport.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-21 11:18:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:03 -0500
commit2383787f199c51cdc202a3cef5822a9fe6b8774c (patch)
tree52419b4e736f5ae1727561a3c9831e899edb35c5 /source4/libcli/raw/clitransport.c
parentf1aaef3015864f9323711127a4964a8eceff6a52 (diff)
downloadsamba-2383787f199c51cdc202a3cef5822a9fe6b8774c.tar.gz
samba-2383787f199c51cdc202a3cef5822a9fe6b8774c.tar.bz2
samba-2383787f199c51cdc202a3cef5822a9fe6b8774c.zip
r4891: - added a generic resolve_name() async interface in libcli/resolve/,
which will eventually try all resolution methods setup in smb.conf - only resolution backend at the moment is bcast, which does a parallel broadcast to all configured network interfaces, and takes the first reply that comes in (this nicely demonstrates how to do parallel requests using the async APIs) - converted all the existing code to use the new resolve_name() api - removed all the old nmb code (yay!) (This used to be commit 239c310f255e43dd2d1c2433f666c9faaacbdce3)
Diffstat (limited to 'source4/libcli/raw/clitransport.c')
-rw-r--r--source4/libcli/raw/clitransport.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index e6d40639c6..918f18fa40 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -145,41 +145,52 @@ static void smbcli_transport_write_disable(struct smbcli_transport *transport)
send a session request
*/
struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *transport,
- struct nmb_name *calling,
- struct nmb_name *called)
+ struct nbt_name *calling,
+ struct nbt_name *called)
{
uint8_t *p;
- int len = NBT_HDR_SIZE;
struct smbcli_request *req;
+ DATA_BLOB calling_blob, called_blob;
+ TALLOC_CTX *tmp_ctx = talloc_new(transport);
+ NTSTATUS status;
- if (called) {
- transport->called = *called;
- }
+ status = nbt_name_dup(transport, called, &transport->called);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+
+ status = nbt_name_to_blob(tmp_ctx, &calling_blob, calling);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
+
+ status = nbt_name_to_blob(tmp_ctx, &called_blob, called);
+ if (!NT_STATUS_IS_OK(status)) goto failed;
/* allocate output buffer */
req = smbcli_request_setup_nonsmb(transport,
- NBT_HDR_SIZE + 2*nbt_mangled_name_len());
- if (req == NULL) return NULL;
+ NBT_HDR_SIZE +
+ calling_blob.length + called_blob.length);
+ if (req == NULL) goto failed;
/* put in the destination name */
p = req->out.buffer + NBT_HDR_SIZE;
- name_mangle(called->name, (char *)p, called->name_type);
- len += name_len((char *)p);
+ memcpy(p, called_blob.data, called_blob.length);
+ p += called_blob.length;
- /* and my name */
- p = req->out.buffer+len;
- name_mangle(calling->name, (char *)p, calling->name_type);
- len += name_len((char *)p);
+ memcpy(p, calling_blob.data, calling_blob.length);
+ p += calling_blob.length;
- _smb_setlen(req->out.buffer,len-4);
+ _smb_setlen(req->out.buffer, PTR_DIFF(p, req->out.buffer)-4);
SCVAL(req->out.buffer,0,0x81);
if (!smbcli_request_send(req)) {
smbcli_request_destroy(req);
- return NULL;
+ goto failed;
}
+ talloc_free(tmp_ctx);
return req;
+
+failed:
+ talloc_free(tmp_ctx);
+ return NULL;
}
/*
@@ -237,8 +248,8 @@ NTSTATUS smbcli_transport_connect_recv(struct smbcli_request *req)
send a session request (if needed)
*/
BOOL smbcli_transport_connect(struct smbcli_transport *transport,
- struct nmb_name *calling,
- struct nmb_name *called)
+ struct nbt_name *calling,
+ struct nbt_name *called)
{
struct smbcli_request *req;
NTSTATUS status;