summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-16 01:22:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:52 -0500
commiteec22cfe2fe8cf46190761369016382a274426c6 (patch)
tree87434f6a63afb3396c9b47dc6058dcdd3b6379c3 /source4/libcli
parent1be1d8046dd198d5038240f4bf1c884db1b74fb6 (diff)
downloadsamba-eec22cfe2fe8cf46190761369016382a274426c6.tar.gz
samba-eec22cfe2fe8cf46190761369016382a274426c6.tar.bz2
samba-eec22cfe2fe8cf46190761369016382a274426c6.zip
r4767: handle the different NBT session request refusals, and map them to
reasonable NT_STATUS values (This used to be commit b193a9cb0c851a4ec55ad9956a815be93eea35e4)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/raw/clitransport.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index fc9de577ee..14c0779968 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -182,24 +182,53 @@ struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *tr
}
/*
+ map a session request error to a NTSTATUS
+ */
+static NTSTATUS map_session_refused_error(uint8_t error)
+{
+ switch (error) {
+ case 0x80:
+ case 0x81:
+ return NT_STATUS_REMOTE_NOT_LISTENING;
+ case 0x82:
+ return NT_STATUS_RESOURCE_NAME_NOT_FOUND;
+ case 0x83:
+ return NT_STATUS_REMOTE_RESOURCES;
+ }
+ return NT_STATUS_UNEXPECTED_IO_ERROR;
+}
+
+
+/*
finish a smbcli_transport_connect()
*/
-BOOL smbcli_transport_connect_recv(struct smbcli_request *req)
+NTSTATUS smbcli_transport_connect_recv(struct smbcli_request *req)
{
+ NTSTATUS status;
+
if (!smbcli_request_receive(req)) {
smbcli_request_destroy(req);
- return False;
+ return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
}
- if (CVAL(req->in.buffer,0) != 0x82) {
- req->transport->error.etype = ETYPE_NBT;
- req->transport->error.e.nbt_error = CVAL(req->in.buffer,4);
- smbcli_request_destroy(req);
- return False;
+ switch (CVAL(req->in.buffer,0)) {
+ case 0x82:
+ status = NT_STATUS_OK;
+ break;
+ case 0x83:
+ status = map_session_refused_error(CVAL(req->in.buffer,4));
+ break;
+ case 0x84:
+ DEBUG(1,("Warning: session retarget not supported\n"));
+ status = NT_STATUS_NOT_SUPPORTED;
+ break;
+ default:
+ status = NT_STATUS_UNEXPECTED_IO_ERROR;
+ break;
}
smbcli_request_destroy(req);
- return True;
+ return status;
}
@@ -211,14 +240,16 @@ BOOL smbcli_transport_connect(struct smbcli_transport *transport,
struct nmb_name *called)
{
struct smbcli_request *req;
-
+ NTSTATUS status;
+
if (transport->socket->port == 445) {
return True;
}
req = smbcli_transport_connect_send(transport,
calling, called);
- return smbcli_transport_connect_recv(req);
+ status = smbcli_transport_connect_recv(req);
+ return NT_STATUS_IS_OK(status);
}
/****************************************************************************