summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
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);
}
/****************************************************************************