diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-09-20 09:13:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:53 -0500 |
commit | be61c9d8773eb3d0dd97bcd5e9ccd3f1aabcd1d6 (patch) | |
tree | 419697c4f043ce721b110da67def9678a4c90d82 /source4 | |
parent | 635f5fa942c2ecd82a2a787b96bf2ce2a587c616 (diff) | |
download | samba-be61c9d8773eb3d0dd97bcd5e9ccd3f1aabcd1d6.tar.gz samba-be61c9d8773eb3d0dd97bcd5e9ccd3f1aabcd1d6.tar.bz2 samba-be61c9d8773eb3d0dd97bcd5e9ccd3f1aabcd1d6.zip |
r2439: - function that return just an int don't need a TALLOC_CTX
- fix some return and state bugs
metze
(This used to be commit 2757c593ab746b9dd7090f2cf5fcc31686adf67f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/socket/socket.c | 18 | ||||
-rw-r--r-- | source4/lib/socket/socket.h | 6 | ||||
-rw-r--r-- | source4/lib/socket/socket_ipv4.c | 19 |
3 files changed, 22 insertions, 21 deletions
diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 5fd587a635..6869114587 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -39,7 +39,7 @@ NTSTATUS socket_create(const char *name, enum socket_type type, struct socket_co (*new_sock)->ops = socket_getops_byname(name, type); if (!(*new_sock)->ops) { talloc_free((*new_sock)); - return status; + return NT_STATUS_INVALID_PARAMETER; } status = (*new_sock)->ops->init((*new_sock)); @@ -120,7 +120,7 @@ NTSTATUS socket_recv(struct socket_context *sock, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if (sock->state != SOCKET_STATE_CLIENT_CONNECTED || + if (sock->state != SOCKET_STATE_CLIENT_CONNECTED && sock->state != SOCKET_STATE_SERVER_CONNECTED) { return NT_STATUS_INVALID_PARAMETER; } @@ -139,7 +139,7 @@ NTSTATUS socket_send(struct socket_context *sock, TALLOC_CTX *mem_ctx, return NT_STATUS_INVALID_PARAMETER; } - if (sock->state != SOCKET_STATE_CLIENT_CONNECTED || + if (sock->state != SOCKET_STATE_CLIENT_CONNECTED && sock->state != SOCKET_STATE_SERVER_CONNECTED) { return NT_STATUS_INVALID_PARAMETER; } @@ -169,13 +169,13 @@ char *socket_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) return sock->ops->get_peer_addr(sock, mem_ctx); } -int socket_get_peer_port(struct socket_context *sock, TALLOC_CTX *mem_ctx) +int socket_get_peer_port(struct socket_context *sock) { if (!sock->ops->get_peer_port) { return -1; } - return sock->ops->get_peer_port(sock, mem_ctx); + return sock->ops->get_peer_port(sock); } char *socket_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) @@ -187,22 +187,22 @@ char *socket_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx) return sock->ops->get_my_addr(sock, mem_ctx); } -int socket_get_my_port(struct socket_context *sock, TALLOC_CTX *mem_ctx) +int socket_get_my_port(struct socket_context *sock) { if (!sock->ops->get_my_port) { return -1; } - return sock->ops->get_my_port(sock, mem_ctx); + return sock->ops->get_my_port(sock); } -int socket_get_fd(struct socket_context *sock, TALLOC_CTX *mem_ctx) +int socket_get_fd(struct socket_context *sock) { if (!sock->ops->get_fd) { return -1; } - return sock->ops->get_fd(sock, mem_ctx); + return sock->ops->get_fd(sock); } const struct socket_ops *socket_getops_byname(const char *name, enum socket_type type) diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index 10e937c4e2..ea4de1d291 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -56,11 +56,11 @@ struct socket_ops { NTSTATUS (*set_option)(struct socket_context *sock, const char *option, const char *val); char *(*get_peer_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx); - int (*get_peer_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx); + int (*get_peer_port)(struct socket_context *sock); char *(*get_my_addr)(struct socket_context *sock, TALLOC_CTX *mem_ctx); - int (*get_my_port)(struct socket_context *sock, TALLOC_CTX *mem_ctx); + int (*get_my_port)(struct socket_context *sock); - int (*get_fd)(struct socket_context *sock, TALLOC_CTX *mem_ctx); + int (*get_fd)(struct socket_context *sock); }; enum socket_state { diff --git a/source4/lib/socket/socket_ipv4.c b/source4/lib/socket/socket_ipv4.c index 9246ac4070..f423ded302 100644 --- a/source4/lib/socket/socket_ipv4.c +++ b/source4/lib/socket/socket_ipv4.c @@ -67,7 +67,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock, return NT_STATUS_FOOBAR; } - ret = bind(sock->fd, &my_addr, sizeof(my_addr)); + ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); if (ret == -1) { /* TODO: we need to map from errno to NTSTATUS here! */ return NT_STATUS_FOOBAR; @@ -90,7 +90,7 @@ static NTSTATUS ipv4_tcp_connect(struct socket_context *sock, } - ret = connect(sock->fd, &srv_addr, sizeof(srv_addr)); + ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr)); if (ret == -1) { /* TODO: we need to map from errno to NTSTATUS here! */ return NT_STATUS_FOOBAR; @@ -109,14 +109,13 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock, struct in_addr ip_addr; int ret; - ZERO_STRUCT(my_addr); - ret = inet_aton(my_address, &ip_addr); if (ret == 0) { /* not a valid ipv4 address */ return NT_STATUS_FOOBAR; } + ZERO_STRUCT(my_addr); #ifdef HAVE_SOCK_SIN_LEN my_addr.sin_len = sizeof(my_addr); #endif @@ -124,7 +123,7 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock, my_addr.sin_port = htons(port); my_addr.sin_family = PF_INET; - ret = bind(sock->fd, &my_addr, sizeof(my_addr)); + ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr)); if (ret == -1) { /* TODO: we need to map from errno to NTSTATUS here! */ return NT_STATUS_FOOBAR; @@ -144,7 +143,9 @@ static NTSTATUS ipv4_tcp_listen(struct socket_context *sock, } } - return NT_STATUS_NOT_IMPLEMENTED; + sock->state= SOCKET_STATE_SERVER_LISTEN; + + return NT_STATUS_OK; } static NTSTATUS ipv4_tcp_accept(struct socket_context *sock, struct socket_context **new_sock, uint32_t flags) @@ -298,7 +299,7 @@ static char *ipv4_tcp_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem return NULL; } -static int ipv4_tcp_get_peer_port(struct socket_context *sock, TALLOC_CTX *mem_ctx) +static int ipv4_tcp_get_peer_port(struct socket_context *sock) { return -1; } @@ -308,12 +309,12 @@ static char *ipv4_tcp_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_c return NULL; } -static int ipv4_tcp_get_my_port(struct socket_context *sock, TALLOC_CTX *mem_ctx) +static int ipv4_tcp_get_my_port(struct socket_context *sock) { return -1; } -static int ipv4_tcp_get_fd(struct socket_context *sock, TALLOC_CTX *mem_ctx) +static int ipv4_tcp_get_fd(struct socket_context *sock) { return sock->fd; } |