s4:librpc/rpc: remove some unused functions and structures from dcerpc_sock.c
authorStefan Metzmacher <metze@samba.org>
Fri, 14 Feb 2014 00:15:23 +0000 (01:15 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 26 May 2014 01:31:28 +0000 (03:31 +0200)
Now we just dcerpc_sock.c doesn't need to maintain 'struct sock_private'
in p->transport.private_data anymore, we're just using a raw tstream_context
as p->transport.stream.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/librpc/rpc/dcerpc_sock.c

index de86e9802c4629f16313a1c4b8021e4610bab657..f5a1c07c922516ed22bbb0bddf71dd719083b512 100644 (file)
 #include "libcli/resolve/resolve.h"
 #include "librpc/rpc/rpc_common.h"
 
 #include "libcli/resolve/resolve.h"
 #include "librpc/rpc/rpc_common.h"
 
-/* transport private information used by general socket pipe transports */
-struct sock_private {
-       const char *path; /* For ncacn_unix_sock and ncalrpc */
-
-       struct socket_address *peer_addr;
-};
-
 struct pipe_open_socket_state {
        struct dcecli_connection *conn;
        struct socket_context *socket_ctx;
 struct pipe_open_socket_state {
        struct dcecli_connection *conn;
        struct socket_context *socket_ctx;
-       struct sock_private *sock;
        struct socket_address *localaddr;
        struct socket_address *server;
        const char *target_hostname;
        struct socket_address *localaddr;
        struct socket_address *server;
        const char *target_hostname;
@@ -54,7 +46,6 @@ struct pipe_open_socket_state {
 static void continue_socket_connect(struct composite_context *ctx)
 {
        struct dcecli_connection *conn;
 static void continue_socket_connect(struct composite_context *ctx)
 {
        struct dcecli_connection *conn;
-       struct sock_private *sock;
        struct composite_context *c = talloc_get_type_abort(
                ctx->async.private_data, struct composite_context);
        struct pipe_open_socket_state *s = talloc_get_type_abort(
        struct composite_context *c = talloc_get_type_abort(
                ctx->async.private_data, struct composite_context);
        struct pipe_open_socket_state *s = talloc_get_type_abort(
@@ -64,7 +55,6 @@ static void continue_socket_connect(struct composite_context *ctx)
 
        /* make it easier to write a function calls */
        conn = s->conn;
 
        /* make it easier to write a function calls */
        conn = s->conn;
-       sock = s->sock;
 
        c->status = socket_connect_recv(ctx);
        if (!NT_STATUS_IS_OK(c->status)) {
 
        c->status = socket_connect_recv(ctx);
        if (!NT_STATUS_IS_OK(c->status)) {
@@ -77,17 +67,11 @@ static void continue_socket_connect(struct composite_context *ctx)
 
        s->client = socket_get_my_addr(s->socket_ctx, s);
        if (s->client == NULL) {
 
        s->client = socket_get_my_addr(s->socket_ctx, s);
        if (s->client == NULL) {
-               talloc_free(sock);
+               TALLOC_FREE(s->socket_ctx);
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
        sock_fd = socket_get_fd(s->socket_ctx);
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
        sock_fd = socket_get_fd(s->socket_ctx);
-       sock->peer_addr = socket_get_peer_addr(s->socket_ctx, sock);
-       if (sock->peer_addr == NULL) {
-               talloc_free(sock);
-               composite_error(c, NT_STATUS_NO_MEMORY);
-               return;
-       }
        socket_set_flags(s->socket_ctx, SOCKET_FLAG_NOCLOSE);
        TALLOC_FREE(s->socket_ctx);
 
        socket_set_flags(s->socket_ctx, SOCKET_FLAG_NOCLOSE);
        TALLOC_FREE(s->socket_ctx);
 
@@ -107,12 +91,10 @@ static void continue_socket_connect(struct composite_context *ctx)
        conn->transport.pending_reads = 0;
        conn->server_name   = strupper_talloc(conn, s->target_hostname);
 
        conn->transport.pending_reads = 0;
        conn->server_name   = strupper_talloc(conn, s->target_hostname);
 
-       conn->transport.private_data = sock;
-
-       rc = tstream_bsd_existing_socket(sock, sock_fd,
+       rc = tstream_bsd_existing_socket(conn, sock_fd,
                                         &conn->transport.stream);
        if (rc < 0) {
                                         &conn->transport.stream);
        if (rc < 0) {
-               talloc_free(sock);
+               close(sock_fd);
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
@@ -120,7 +102,7 @@ static void continue_socket_connect(struct composite_context *ctx)
        conn->transport.write_queue =
                tevent_queue_create(conn, "dcerpc sock write queue");
        if (conn->transport.write_queue == NULL) {
        conn->transport.write_queue =
                tevent_queue_create(conn, "dcerpc sock write queue");
        if (conn->transport.write_queue == NULL) {
-               talloc_free(sock);
+               TALLOC_FREE(conn->transport.stream);
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
                composite_error(c, NT_STATUS_NO_MEMORY);
                return;
        }
@@ -164,18 +146,10 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct
                if (composite_nomem(s->target_hostname, c)) return c;
        }
 
                if (composite_nomem(s->target_hostname, c)) return c;
        }
 
-       s->sock = talloc_zero(cn, struct sock_private);
-       if (composite_nomem(s->sock, c)) return c;
-
        c->status = socket_create(server->family, SOCKET_TYPE_STREAM, &s->socket_ctx, 0);
        if (!composite_is_ok(c)) return c;
 
        c->status = socket_create(server->family, SOCKET_TYPE_STREAM, &s->socket_ctx, 0);
        if (!composite_is_ok(c)) return c;
 
-       talloc_steal(s->sock, s->socket_ctx);
-
-       if (full_path != NULL) {
-               s->sock->path = talloc_strdup(s->sock, full_path);
-               if (composite_nomem(s->sock->path, c)) return c;
-       }
+       talloc_steal(s, s->socket_ctx);
 
        conn_req = socket_connect_send(s->socket_ctx, s->localaddr, s->server, 0,
                                       c->event_ctx);
 
        conn_req = socket_connect_send(s->socket_ctx, s->localaddr, s->server, 0,
                                       c->event_ctx);
@@ -519,18 +493,3 @@ NTSTATUS dcerpc_pipe_open_pipe(struct dcecli_connection *conn, const char *ncalr
        struct composite_context *c = dcerpc_pipe_open_pipe_send(conn, ncalrpc_dir, identifier);
        return dcerpc_pipe_open_pipe_recv(c);
 }
        struct composite_context *c = dcerpc_pipe_open_pipe_send(conn, ncalrpc_dir, identifier);
        return dcerpc_pipe_open_pipe_recv(c);
 }
-
-const char *dcerpc_unix_socket_path(struct dcecli_connection *p)
-{
-       struct sock_private *sock = talloc_get_type_abort(
-               p->transport.private_data, struct sock_private);
-       return sock->path;
-}
-
-struct socket_address *dcerpc_socket_peer_addr(struct dcecli_connection *p, TALLOC_CTX *mem_ctx)
-{
-       struct sock_private *sock = talloc_get_type_abort(
-               p->transport.private_data, struct sock_private);
-       return socket_address_copy(mem_ctx, sock->peer_addr);
-}
-