diff options
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/messaging/messaging.c | 4 | ||||
-rw-r--r-- | source4/lib/socket/socket.c | 20 | ||||
-rw-r--r-- | source4/lib/socket/socket.h | 16 | ||||
-rw-r--r-- | source4/lib/socket/socket_ipv4.c | 38 | ||||
-rw-r--r-- | source4/lib/socket/socket_ipv6.c | 19 | ||||
-rw-r--r-- | source4/lib/socket/socket_unix.c | 26 | ||||
-rw-r--r-- | source4/lib/stream/packet.c | 4 | ||||
-rw-r--r-- | source4/lib/tls/tls.c | 10 |
8 files changed, 47 insertions, 90 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 62170b64f3..bf06d68a33 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -170,7 +170,7 @@ static NTSTATUS try_send(struct messaging_rec *rec) /* we send with privileges so messages work from any context */ priv = root_privileges(); - status = socket_sendto(msg->sock, &rec->packet, &nsent, 0, path); + status = socket_sendto(msg->sock, &rec->packet, &nsent, path); talloc_free(path); talloc_free(priv); @@ -226,7 +226,7 @@ static void messaging_recv_handler(struct messaging_context *msg) return; } - status = socket_recv(msg->sock, packet.data, msize, &msize, 0); + status = socket_recv(msg->sock, packet.data, msize, &msize); if (!NT_STATUS_IS_OK(status)) { data_blob_free(&packet); return; diff --git a/source4/lib/socket/socket.c b/source4/lib/socket/socket.c index 9d18377db1..4f7f4ef4b9 100644 --- a/source4/lib/socket/socket.c +++ b/source4/lib/socket/socket.c @@ -171,7 +171,7 @@ _PUBLIC_ NTSTATUS socket_accept(struct socket_context *sock, struct socket_conte } _PUBLIC_ NTSTATUS socket_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags) + size_t wantlen, size_t *nread) { if (sock == NULL) { return NT_STATUS_CONNECTION_DISCONNECTED; @@ -191,14 +191,14 @@ _PUBLIC_ NTSTATUS socket_recv(struct socket_context *sock, void *buf, *nread = 0; return STATUS_MORE_ENTRIES; } - return sock->ops->fn_recv(sock, buf, 1+(random() % wantlen), nread, flags); + return sock->ops->fn_recv(sock, buf, 1+(random() % wantlen), nread); } - return sock->ops->fn_recv(sock, buf, wantlen, nread, flags); + return sock->ops->fn_recv(sock, buf, wantlen, nread); } _PUBLIC_ NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags, + size_t wantlen, size_t *nread, TALLOC_CTX *mem_ctx, struct socket_address **src_addr) { if (sock == NULL) { @@ -212,12 +212,12 @@ _PUBLIC_ NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf, return NT_STATUS_NOT_IMPLEMENTED; } - return sock->ops->fn_recvfrom(sock, buf, wantlen, nread, flags, + return sock->ops->fn_recvfrom(sock, buf, wantlen, nread, mem_ctx, src_addr); } _PUBLIC_ NTSTATUS socket_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) + const DATA_BLOB *blob, size_t *sendlen) { if (sock == NULL) { return NT_STATUS_CONNECTION_DISCONNECTED; @@ -238,15 +238,15 @@ _PUBLIC_ NTSTATUS socket_send(struct socket_context *sock, return STATUS_MORE_ENTRIES; } blob2.length = 1+(random() % blob2.length); - return sock->ops->fn_send(sock, &blob2, sendlen, flags); + return sock->ops->fn_send(sock, &blob2, sendlen); } - return sock->ops->fn_send(sock, blob, sendlen, flags); + return sock->ops->fn_send(sock, blob, sendlen); } _PUBLIC_ NTSTATUS socket_sendto(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest_addr) { if (sock == NULL) { @@ -265,7 +265,7 @@ _PUBLIC_ NTSTATUS socket_sendto(struct socket_context *sock, return NT_STATUS_NOT_IMPLEMENTED; } - return sock->ops->fn_sendto(sock, blob, sendlen, flags, dest_addr); + return sock->ops->fn_sendto(sock, blob, sendlen, dest_addr); } diff --git a/source4/lib/socket/socket.h b/source4/lib/socket/socket.h index 31dadb2f89..04ae53e464 100644 --- a/source4/lib/socket/socket.h +++ b/source4/lib/socket/socket.h @@ -62,15 +62,15 @@ struct socket_ops { /* general ops */ NTSTATUS (*fn_recv)(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags); + size_t wantlen, size_t *nread); NTSTATUS (*fn_send)(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags); + const DATA_BLOB *blob, size_t *sendlen); NTSTATUS (*fn_sendto)(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest_addr); NTSTATUS (*fn_recvfrom)(struct socket_context *sock, - void *buf, size_t wantlen, size_t *nread, uint32_t flags, + void *buf, size_t wantlen, size_t *nread, TALLOC_CTX *addr_ctx, struct socket_address **src_addr); NTSTATUS (*fn_pending)(struct socket_context *sock, size_t *npending); @@ -129,14 +129,14 @@ NTSTATUS socket_listen(struct socket_context *sock, int queue_size, uint32_t flags); NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_sock); NTSTATUS socket_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags); + size_t wantlen, size_t *nread); NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags, + size_t wantlen, size_t *nread, TALLOC_CTX *addr_ctx, struct socket_address **src_addr); NTSTATUS socket_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags); + const DATA_BLOB *blob, size_t *sendlen); NTSTATUS socket_sendto(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest_addr); NTSTATUS socket_pending(struct socket_context *sock, size_t *npending); NTSTATUS socket_set_option(struct socket_context *sock, const char *option, const char *val); diff --git a/source4/lib/socket/socket_ipv4.c b/source4/lib/socket/socket_ipv4.c index 9e1f60d40a..38c9f98fdb 100644 --- a/source4/lib/socket/socket_ipv4.c +++ b/source4/lib/socket/socket_ipv4.c @@ -251,23 +251,13 @@ static NTSTATUS ipv4_accept(struct socket_context *sock, struct socket_context * } static NTSTATUS ipv4_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags) + size_t wantlen, size_t *nread) { ssize_t gotlen; - int flgs = 0; - - /* TODO: we need to map all flags here */ - if (flags & SOCKET_FLAG_PEEK) { - flgs |= MSG_PEEK; - } - - if (flags & SOCKET_FLAG_BLOCK) { - flgs |= MSG_WAITALL; - } *nread = 0; - gotlen = recv(sock->fd, buf, wantlen, flgs); + gotlen = recv(sock->fd, buf, wantlen, 0); if (gotlen == 0) { return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { @@ -281,11 +271,10 @@ static NTSTATUS ipv4_recv(struct socket_context *sock, void *buf, static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags, + size_t wantlen, size_t *nread, TALLOC_CTX *addr_ctx, struct socket_address **_src) { ssize_t gotlen; - int flgs = 0; struct sockaddr_in *from_addr; socklen_t from_len = sizeof(*from_addr); struct socket_address *src; @@ -305,17 +294,10 @@ static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf, } src->sockaddr = (struct sockaddr *)from_addr; - if (flags & SOCKET_FLAG_PEEK) { - flgs |= MSG_PEEK; - } - - if (flags & SOCKET_FLAG_BLOCK) { - flgs |= MSG_WAITALL; - } *nread = 0; - gotlen = recvfrom(sock->fd, buf, wantlen, flgs, + gotlen = recvfrom(sock->fd, buf, wantlen, 0, src->sockaddr, &from_len); if (gotlen == 0) { talloc_free(src); @@ -345,14 +327,13 @@ static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf, } static NTSTATUS ipv4_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) + const DATA_BLOB *blob, size_t *sendlen) { ssize_t len; - int flgs = 0; *sendlen = 0; - len = send(sock->fd, blob->data, blob->length, flgs); + len = send(sock->fd, blob->data, blob->length, 0); if (len == -1) { return map_nt_error_from_unix(errno); } @@ -363,14 +344,13 @@ static NTSTATUS ipv4_send(struct socket_context *sock, } static NTSTATUS ipv4_sendto(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest_addr) { ssize_t len; - int flgs = 0; if (dest_addr->sockaddr) { - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, dest_addr->sockaddr, dest_addr->sockaddrlen); } else { struct sockaddr_in srv_addr; @@ -387,7 +367,7 @@ static NTSTATUS ipv4_sendto(struct socket_context *sock, *sendlen = 0; - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, (struct sockaddr *)&srv_addr, sizeof(srv_addr)); } if (len == -1) { diff --git a/source4/lib/socket/socket_ipv6.c b/source4/lib/socket/socket_ipv6.c index 9b6dcbf985..3e987b4306 100644 --- a/source4/lib/socket/socket_ipv6.c +++ b/source4/lib/socket/socket_ipv6.c @@ -224,23 +224,13 @@ static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_conte } static NTSTATUS ipv6_tcp_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags) + size_t wantlen, size_t *nread) { ssize_t gotlen; - int flgs = 0; - - /* TODO: we need to map all flags here */ - if (flags & SOCKET_FLAG_PEEK) { - flgs |= MSG_PEEK; - } - - if (flags & SOCKET_FLAG_BLOCK) { - flgs |= MSG_WAITALL; - } *nread = 0; - gotlen = recv(sock->fd, buf, wantlen, flgs); + gotlen = recv(sock->fd, buf, wantlen, 0); if (gotlen == 0) { return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { @@ -253,14 +243,13 @@ static NTSTATUS ipv6_tcp_recv(struct socket_context *sock, void *buf, } static NTSTATUS ipv6_tcp_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) + const DATA_BLOB *blob, size_t *sendlen) { ssize_t len; - int flgs = 0; *sendlen = 0; - len = send(sock->fd, blob->data, blob->length, flgs); + len = send(sock->fd, blob->data, blob->length, 0); if (len == -1) { return map_nt_error_from_unix(errno); } diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c index 3feb1bf234..d59ef02ba9 100644 --- a/source4/lib/socket/socket_unix.c +++ b/source4/lib/socket/socket_unix.c @@ -219,23 +219,13 @@ static NTSTATUS unixdom_accept(struct socket_context *sock, } static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, - size_t wantlen, size_t *nread, uint32_t flags) + size_t wantlen, size_t *nread) { ssize_t gotlen; - int flgs = 0; - - /* TODO: we need to map all flags here */ - if (flags & SOCKET_FLAG_PEEK) { - flgs |= MSG_PEEK; - } - - if (flags & SOCKET_FLAG_BLOCK) { - flgs |= MSG_WAITALL; - } *nread = 0; - gotlen = recv(sock->fd, buf, wantlen, flgs); + gotlen = recv(sock->fd, buf, wantlen, 0); if (gotlen == 0) { return NT_STATUS_END_OF_FILE; } else if (gotlen == -1) { @@ -248,14 +238,13 @@ static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, } static NTSTATUS unixdom_send(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags) + const DATA_BLOB *blob, size_t *sendlen) { ssize_t len; - int flgs = 0; *sendlen = 0; - len = send(sock->fd, blob->data, blob->length, flgs); + len = send(sock->fd, blob->data, blob->length, 0); if (len == -1) { return unixdom_error(errno); } @@ -267,15 +256,14 @@ static NTSTATUS unixdom_send(struct socket_context *sock, static NTSTATUS unixdom_sendto(struct socket_context *sock, - const DATA_BLOB *blob, size_t *sendlen, uint32_t flags, + const DATA_BLOB *blob, size_t *sendlen, const struct socket_address *dest) { ssize_t len; - int flgs = 0; *sendlen = 0; if (dest->sockaddr) { - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, dest->sockaddr, dest->sockaddrlen); } else { struct sockaddr_un srv_addr; @@ -288,7 +276,7 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock, srv_addr.sun_family = AF_UNIX; strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path)); - len = sendto(sock->fd, blob->data, blob->length, flgs, + len = sendto(sock->fd, blob->data, blob->length, 0, (struct sockaddr *)&srv_addr, sizeof(srv_addr)); } if (len == -1) { diff --git a/source4/lib/stream/packet.c b/source4/lib/stream/packet.c index 987193c7d7..613400226b 100644 --- a/source4/lib/stream/packet.c +++ b/source4/lib/stream/packet.c @@ -298,7 +298,7 @@ _PUBLIC_ void packet_recv(struct packet_context *pc) npending, &nread); } else { status = socket_recv(pc->sock, pc->partial.data + pc->num_read, - npending, &nread, 0); + npending, &nread); } if (NT_STATUS_IS_ERR(status)) { packet_error(pc, status); @@ -455,7 +455,7 @@ _PUBLIC_ void packet_queue_run(struct packet_context *pc) if (pc->tls) { status = tls_socket_send(pc->tls, &blob, &nwritten); } else { - status = socket_send(pc->sock, &blob, &nwritten, 0); + status = socket_send(pc->sock, &blob, &nwritten); } if (NT_STATUS_IS_ERR(status)) { packet_error(pc, NT_STATUS_NET_WRITE_FAULT); diff --git a/source4/lib/tls/tls.c b/source4/lib/tls/tls.c index 3d40fdafa0..7c129b573c 100644 --- a/source4/lib/tls/tls.c +++ b/source4/lib/tls/tls.c @@ -77,7 +77,7 @@ static ssize_t tls_pull(gnutls_transport_ptr ptr, void *buf, size_t size) return 1; } - status = socket_recv(tls->socket, buf, size, &nread, 0); + status = socket_recv(tls->socket, buf, size, &nread); if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { return 0; } @@ -118,7 +118,7 @@ static ssize_t tls_push(gnutls_transport_ptr ptr, const void *buf, size_t size) b.data = discard_const(buf); b.length = size; - status = socket_send(tls->socket, &b, &nwritten, 0); + status = socket_send(tls->socket, &b, &nwritten); if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { errno = EAGAIN; return -1; @@ -225,7 +225,7 @@ NTSTATUS tls_socket_recv(struct tls_context *tls, void *buf, size_t wantlen, int ret; NTSTATUS status; if (tls->tls_enabled && tls->tls_detect) { - status = socket_recv(tls->socket, &tls->first_byte, 1, nread, 0); + status = socket_recv(tls->socket, &tls->first_byte, 1, nread); NT_STATUS_NOT_OK_RETURN(status); if (*nread == 0) return NT_STATUS_OK; tls->tls_detect = False; @@ -240,7 +240,7 @@ NTSTATUS tls_socket_recv(struct tls_context *tls, void *buf, size_t wantlen, } if (!tls->tls_enabled) { - return socket_recv(tls->socket, buf, wantlen, nread, 0); + return socket_recv(tls->socket, buf, wantlen, nread); } status = tls_handshake(tls); @@ -274,7 +274,7 @@ NTSTATUS tls_socket_send(struct tls_context *tls, const DATA_BLOB *blob, size_t int ret; if (!tls->tls_enabled) { - return socket_send(tls->socket, blob, sendlen, 0); + return socket_send(tls->socket, blob, sendlen); } status = tls_handshake(tls); |