diff options
-rw-r--r-- | source3/libsmb/cliconnect.c | 129 | ||||
-rw-r--r-- | source3/libsmb/proto.h | 2 |
2 files changed, 0 insertions, 131 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index c0d0793015..2b269378dc 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2786,135 +2786,6 @@ NTSTATUS cli_negprot(struct cli_state *cli) return status; } -/**************************************************************************** - Send a session request. See rfc1002.txt 4.3 and 4.3.2. -****************************************************************************/ - -bool cli_session_request(struct cli_state *cli, - struct nmb_name *calling, struct nmb_name *called) -{ - TALLOC_CTX *frame; - uint8_t len_buf[4]; - struct iovec iov[3]; - ssize_t len; - uint8_t *inbuf; - int err; - bool ret = false; - - /* 445 doesn't have session request */ - if (cli->port == 445) - return True; - - memcpy(&(cli->calling), calling, sizeof(*calling)); - memcpy(&(cli->called ), called , sizeof(*called )); - - /* put in the destination name */ - - frame = talloc_stackframe(); - - iov[0].iov_base = len_buf; - iov[0].iov_len = sizeof(len_buf); - - /* put in the destination name */ - - iov[1].iov_base = name_mangle(talloc_tos(), called->name, - called->name_type); - if (iov[1].iov_base == NULL) { - goto fail; - } - iov[1].iov_len = name_len((unsigned char *)iov[1].iov_base, - talloc_get_size(iov[1].iov_base)); - - /* and my name */ - - iov[2].iov_base = name_mangle(talloc_tos(), calling->name, - calling->name_type); - if (iov[2].iov_base == NULL) { - goto fail; - } - iov[2].iov_len = name_len((unsigned char *)iov[2].iov_base, - talloc_get_size(iov[2].iov_base)); - - /* send a session request (RFC 1002) */ - /* setup the packet length - * Remove four bytes from the length count, since the length - * field in the NBT Session Service header counts the number - * of bytes which follow. The cli_send_smb() function knows - * about this and accounts for those four bytes. - * CRH. - */ - - _smb_setlen(len_buf, iov[1].iov_len + iov[2].iov_len); - SCVAL(len_buf,0,0x81); - - len = write_data_iov(cli->fd, iov, 3); - if (len == -1) { - goto fail; - } - len = read_smb(cli->fd, talloc_tos(), &inbuf, &err); - if (len == -1) { - errno = err; - goto fail; - } - - if (CVAL(inbuf,0) == 0x84) { - /* C. Hoch 9/14/95 Start */ - /* For information, here is the response structure. - * We do the byte-twiddling to for portability. - struct RetargetResponse{ - unsigned char type; - unsigned char flags; - int16 length; - int32 ip_addr; - int16 port; - }; - */ - uint16_t port = (CVAL(inbuf,8)<<8)+CVAL(inbuf,9); - struct in_addr dest_ip; - NTSTATUS status; - - /* SESSION RETARGET */ - putip((char *)&dest_ip,inbuf+4); - in_addr_to_sockaddr_storage(&cli->dest_ss, dest_ip); - - status = open_socket_out(&cli->dest_ss, port, - LONG_CONNECT_TIMEOUT, &cli->fd); - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - - DEBUG(3,("Retargeted\n")); - - set_socket_options(cli->fd, lp_socket_options()); - - /* Try again */ - { - static int depth; - if (depth > 4) { - DEBUG(0,("Retarget recursion - failing\n")); - goto fail; - } - depth++; - ret = cli_session_request(cli, calling, called); - depth--; - goto done; - } - } /* C. Hoch 9/14/95 End */ - - if (CVAL(inbuf,0) != 0x82) { - /* This is the wrong place to put the error... JRA. */ - cli->rap_error = CVAL(inbuf,4); - goto fail; - } -done: - ret = true; -fail: - err = errno; - TALLOC_FREE(frame); - errno = err; - return ret; -} - static NTSTATUS cli_connect_sock(const char *host, int name_type, const struct sockaddr_storage *pss, const char *myname, uint16_t port, diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 16b450ee59..37a928e0ca 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -68,8 +68,6 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct cli_state *cli); NTSTATUS cli_negprot_recv(struct tevent_req *req); -bool cli_session_request(struct cli_state *cli, - struct nmb_name *calling, struct nmb_name *called); NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss, uint16_t port, int name_type, const char *myname, int signing_state, struct cli_state **pcli); |