diff options
author | Volker Lendecke <vl@samba.org> | 2011-05-29 20:51:43 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2011-05-29 21:17:27 +0200 |
commit | 4ee443d7b35a67ea792adcd5e0f83c3e92978785 (patch) | |
tree | a35a542c0c14588f2091f257ee8543d15158e2c9 /source3/libsmb | |
parent | f92b90c67606b3a44a0a12101281f1d54a36a0f7 (diff) | |
download | samba-4ee443d7b35a67ea792adcd5e0f83c3e92978785.tar.gz samba-4ee443d7b35a67ea792adcd5e0f83c3e92978785.tar.bz2 samba-4ee443d7b35a67ea792adcd5e0f83c3e92978785.zip |
s3: Remove unused cli_connect
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/cliconnect.c | 177 | ||||
-rw-r--r-- | source3/libsmb/proto.h | 3 |
2 files changed, 0 insertions, 180 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 5f6488d81b..c0d0793015 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2915,183 +2915,6 @@ fail: return ret; } -struct fd_struct { - int fd; -}; - -static void smb_sock_connected(struct tevent_req *req) -{ - struct fd_struct *pfd = tevent_req_callback_data( - req, struct fd_struct); - int fd; - NTSTATUS status; - - status = open_socket_out_defer_recv(req, &fd); - if (NT_STATUS_IS_OK(status)) { - pfd->fd = fd; - } -} - -static NTSTATUS open_smb_socket(const struct sockaddr_storage *pss, - uint16_t *port, int timeout, int *pfd) -{ - struct event_context *ev; - struct tevent_req *r139, *r445; - struct fd_struct *fd139, *fd445; - NTSTATUS status = NT_STATUS_NO_MEMORY; - - if (*port != 0) { - return open_socket_out(pss, *port, timeout, pfd); - } - - ev = event_context_init(talloc_tos()); - if (ev == NULL) { - return NT_STATUS_NO_MEMORY; - } - - fd139 = talloc(ev, struct fd_struct); - if (fd139 == NULL) { - goto done; - } - fd139->fd = -1; - - fd445 = talloc(ev, struct fd_struct); - if (fd445 == NULL) { - goto done; - } - fd445->fd = -1; - - r445 = open_socket_out_defer_send(ev, ev, timeval_set(0, 0), - pss, 445, timeout); - r139 = open_socket_out_defer_send(ev, ev, timeval_set(0, 3000), - pss, 139, timeout); - if ((r445 == NULL) || (r139 == NULL)) { - goto done; - } - tevent_req_set_callback(r445, smb_sock_connected, fd445); - tevent_req_set_callback(r139, smb_sock_connected, fd139); - - while ((fd445->fd == -1) && (fd139->fd == -1) - && (tevent_req_is_in_progress(r139) - || tevent_req_is_in_progress(r445))) { - event_loop_once(ev); - } - - if ((fd139->fd != -1) && (fd445->fd != -1)) { - close(fd139->fd); - fd139->fd = -1; - } - - if (fd445->fd != -1) { - *port = 445; - *pfd = fd445->fd; - status = NT_STATUS_OK; - goto done; - } - if (fd139->fd != -1) { - *port = 139; - *pfd = fd139->fd; - status = NT_STATUS_OK; - goto done; - } - - status = open_socket_out_defer_recv(r445, &fd445->fd); - done: - TALLOC_FREE(ev); - return status; -} - -/**************************************************************************** - Open the client sockets. -****************************************************************************/ - -NTSTATUS cli_connect(struct cli_state *cli, - const char *host, - struct sockaddr_storage *dest_ss) - -{ - int name_type = 0x20; - TALLOC_CTX *frame = talloc_stackframe(); - unsigned int num_addrs = 0; - unsigned int i = 0; - struct sockaddr_storage *ss_arr = NULL; - char *p = NULL; - - /* reasonable default hostname */ - if (!host) { - host = STAR_SMBSERVER; - } - - cli->desthost = talloc_strdup(cli, host); - if (cli->desthost == NULL) { - return NT_STATUS_NO_MEMORY; - } - - /* allow hostnames of the form NAME#xx and do a netbios lookup */ - if ((p = strchr(cli->desthost, '#'))) { - name_type = strtol(p+1, NULL, 16); - *p = 0; - } - - if (!dest_ss || is_zero_addr(dest_ss)) { - NTSTATUS status =resolve_name_list(frame, - cli->desthost, - name_type, - &ss_arr, - &num_addrs); - if (!NT_STATUS_IS_OK(status)) { - TALLOC_FREE(frame); - return NT_STATUS_BAD_NETWORK_NAME; - } - } else { - num_addrs = 1; - ss_arr = TALLOC_P(frame, struct sockaddr_storage); - if (!ss_arr) { - TALLOC_FREE(frame); - return NT_STATUS_NO_MEMORY; - } - *ss_arr = *dest_ss; - } - - for (i = 0; i < num_addrs; i++) { - cli->dest_ss = ss_arr[i]; - if (getenv("LIBSMB_PROG")) { - cli->fd = sock_exec(getenv("LIBSMB_PROG")); - } else { - uint16_t port = cli->port; - NTSTATUS status; - status = open_smb_socket(&cli->dest_ss, &port, - cli->timeout, &cli->fd); - if (NT_STATUS_IS_OK(status)) { - cli->port = port; - } - } - if (cli->fd == -1) { - char addr[INET6_ADDRSTRLEN]; - print_sockaddr(addr, sizeof(addr), &ss_arr[i]); - DEBUG(2,("Error connecting to %s (%s)\n", - dest_ss?addr:host,strerror(errno))); - } else { - /* Exit from loop on first connection. */ - break; - } - } - - if (cli->fd == -1) { - TALLOC_FREE(frame); - return map_nt_error_from_unix(errno); - } - - if (dest_ss) { - *dest_ss = cli->dest_ss; - } - - set_socket_options(cli->fd, lp_socket_options()); - - TALLOC_FREE(frame); - return NT_STATUS_OK; -} - 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 2eb6374b24..16b450ee59 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -70,9 +70,6 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx, 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(struct cli_state *cli, - const char *host, - struct sockaddr_storage *dest_ss); 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); |