1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

r4767: handle the different NBT session request refusals, and map them to

reasonable NT_STATUS values
(This used to be commit b193a9cb0c851a4ec55ad9956a815be93eea35e4)
This commit is contained in:
Andrew Tridgell 2005-01-16 01:22:08 +00:00 committed by Gerald (Jerry) Carter
parent 1be1d8046d
commit eec22cfe2f

View File

@ -181,25 +181,54 @@ struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *tr
return req; return req;
} }
/*
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() 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)) { if (!smbcli_request_receive(req)) {
smbcli_request_destroy(req); smbcli_request_destroy(req);
return False; return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
} }
if (CVAL(req->in.buffer,0) != 0x82) { switch (CVAL(req->in.buffer,0)) {
req->transport->error.etype = ETYPE_NBT; case 0x82:
req->transport->error.e.nbt_error = CVAL(req->in.buffer,4); status = NT_STATUS_OK;
smbcli_request_destroy(req); break;
return False; 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); 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 nmb_name *called)
{ {
struct smbcli_request *req; struct smbcli_request *req;
NTSTATUS status;
if (transport->socket->port == 445) { if (transport->socket->port == 445) {
return True; return True;
} }
req = smbcli_transport_connect_send(transport, req = smbcli_transport_connect_send(transport,
calling, called); calling, called);
return smbcli_transport_connect_recv(req); status = smbcli_transport_connect_recv(req);
return NT_STATUS_IS_OK(status);
} }
/**************************************************************************** /****************************************************************************