summaryrefslogtreecommitdiff
path: root/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@sernet.de>2008-01-16 14:51:56 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-19 07:05:42 +0100
commitebab6d6ce40ec4d64126964c0223aa2bdef99094 (patch)
treef934f966e8b64369a652a17c13c409dae8637450 /libcli
parent26c48098e6c387cc76b123a78d50f23518d734cf (diff)
downloadsamba-ebab6d6ce40ec4d64126964c0223aa2bdef99094.tar.gz
samba-ebab6d6ce40ec4d64126964c0223aa2bdef99094.tar.bz2
samba-ebab6d6ce40ec4d64126964c0223aa2bdef99094.zip
libcli/nbt: add nbt_name_socket_handle_response_packet()
Move the last part of nbt_name_socket_recv() into a new function nbt_name_socket_handle_response_packet() so that it can be reused by an unexpected handler. metze (from samba4wins tree cb0377f3b95e50c84fac999a49dde80acc933124)
Diffstat (limited to 'libcli')
-rw-r--r--libcli/nbt/libnbt.h3
-rw-r--r--libcli/nbt/nbtsocket.c13
2 files changed, 13 insertions, 3 deletions
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 87183c2c13..491abd7b8a 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -277,6 +277,9 @@ struct nbt_name_release {
struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
struct tevent_context *event_ctx,
struct smb_iconv_convenience *iconv_convenience);
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+ struct nbt_name_packet *packet,
+ struct socket_address *src);
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,
diff --git a/libcli/nbt/nbtsocket.c b/libcli/nbt/nbtsocket.c
index 4816b816fe..0d269faa0e 100644
--- a/libcli/nbt/nbtsocket.c
+++ b/libcli/nbt/nbtsocket.c
@@ -231,6 +231,16 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
return;
}
+ talloc_steal(req, packet);
+ talloc_steal(req, src);
+ talloc_free(tmp_ctx);
+ nbt_name_socket_handle_response_packet(req, packet, src);
+}
+
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+ struct nbt_name_packet *packet,
+ struct socket_address *src)
+{
/* if this is a WACK response, this we need to go back to waiting,
but perhaps increase the timeout */
if ((packet->operation & NBT_OPCODE) == NBT_OPCODE_WACK) {
@@ -266,7 +276,6 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
req->te = event_add_timed(req->nbtsock->event_ctx, req,
timeval_current_ofs(req->timeout, 0),
nbt_name_socket_timeout, req);
- talloc_free(tmp_ctx);
return;
}
@@ -288,7 +297,6 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
/* if we don't want multiple replies then we are done */
if (req->allow_multiple_replies &&
req->num_replies < NBT_MAX_REPLIES) {
- talloc_free(tmp_ctx);
return;
}
@@ -297,7 +305,6 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
req->status = NT_STATUS_OK;
done:
- talloc_free(tmp_ctx);
if (req->async.fn) {
req->async.fn(req);
}