1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r15356: Remove unused 'flags' argument from socket_send() and friends.

This is in preperation for making TLS a socket library.

Andrew Bartlett
(This used to be commit a312812b92)
This commit is contained in:
Andrew Bartlett 2006-04-30 05:58:31 +00:00 committed by Gerald (Jerry) Carter
parent 4bdc83ad5c
commit c2cc10c786
15 changed files with 69 additions and 143 deletions

View File

@ -99,7 +99,7 @@ static void smb_krb5_socket_recv(struct smb_krb5_socket *smb_krb5)
return; return;
} }
smb_krb5->status = socket_recv(smb_krb5->sock, blob.data, blob.length, &nread, 0); smb_krb5->status = socket_recv(smb_krb5->sock, blob.data, blob.length, &nread);
if (!NT_STATUS_IS_OK(smb_krb5->status)) { if (!NT_STATUS_IS_OK(smb_krb5->status)) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
return; return;
@ -137,7 +137,7 @@ static void smb_krb5_socket_recv(struct smb_krb5_socket *smb_krb5)
smb_krb5->status = socket_recv(smb_krb5->sock, smb_krb5->status = socket_recv(smb_krb5->sock,
smb_krb5->partial.data + smb_krb5->partial_read, smb_krb5->partial.data + smb_krb5->partial_read,
4 - smb_krb5->partial_read, 4 - smb_krb5->partial_read,
&nread, 0); &nread);
/* todo: this should be converted to the packet_*() routines */ /* todo: this should be converted to the packet_*() routines */
if (!NT_STATUS_IS_OK(smb_krb5->status)) { if (!NT_STATUS_IS_OK(smb_krb5->status)) {
return; return;
@ -164,7 +164,7 @@ static void smb_krb5_socket_recv(struct smb_krb5_socket *smb_krb5)
smb_krb5->status = socket_recv(smb_krb5->sock, smb_krb5->status = socket_recv(smb_krb5->sock,
smb_krb5->partial.data + smb_krb5->partial_read, smb_krb5->partial.data + smb_krb5->partial_read,
smb_krb5->partial.length - smb_krb5->partial_read, smb_krb5->partial.length - smb_krb5->partial_read,
&nread, 0); &nread);
if (!NT_STATUS_IS_OK(smb_krb5->status)) return; if (!NT_STATUS_IS_OK(smb_krb5->status)) return;
smb_krb5->partial_read += nread; smb_krb5->partial_read += nread;
@ -200,7 +200,7 @@ static void smb_krb5_socket_send(struct smb_krb5_socket *smb_krb5)
size_t len; size_t len;
len = smb_krb5->request.length; len = smb_krb5->request.length;
status = socket_send(smb_krb5->sock, &smb_krb5->request, &len, 0); status = socket_send(smb_krb5->sock, &smb_krb5->request, &len);
if (!NT_STATUS_IS_OK(status)) return; if (!NT_STATUS_IS_OK(status)) return;

View File

@ -87,7 +87,7 @@ static void kdc_send_handler(struct kdc_socket *kdc_socket)
NTSTATUS status; NTSTATUS status;
size_t sendlen; size_t sendlen;
status = socket_sendto(kdc_socket->sock, &rep->packet, &sendlen, 0, status = socket_sendto(kdc_socket->sock, &rep->packet, &sendlen,
rep->dest); rep->dest);
if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
break; break;
@ -134,7 +134,7 @@ static void kdc_recv_handler(struct kdc_socket *kdc_socket)
return; return;
} }
status = socket_recvfrom(kdc_socket->sock, blob.data, blob.length, &nread, 0, status = socket_recvfrom(kdc_socket->sock, blob.data, blob.length, &nread,
tmp_ctx, &src); tmp_ctx, &src);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);

View File

@ -170,7 +170,7 @@ static NTSTATUS try_send(struct messaging_rec *rec)
/* we send with privileges so messages work from any context */ /* we send with privileges so messages work from any context */
priv = root_privileges(); 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(path);
talloc_free(priv); talloc_free(priv);
@ -226,7 +226,7 @@ static void messaging_recv_handler(struct messaging_context *msg)
return; 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)) { if (!NT_STATUS_IS_OK(status)) {
data_blob_free(&packet); data_blob_free(&packet);
return; return;

View File

@ -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, _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) { if (sock == NULL) {
return NT_STATUS_CONNECTION_DISCONNECTED; return NT_STATUS_CONNECTION_DISCONNECTED;
@ -191,14 +191,14 @@ _PUBLIC_ NTSTATUS socket_recv(struct socket_context *sock, void *buf,
*nread = 0; *nread = 0;
return STATUS_MORE_ENTRIES; 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, _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) TALLOC_CTX *mem_ctx, struct socket_address **src_addr)
{ {
if (sock == NULL) { if (sock == NULL) {
@ -212,12 +212,12 @@ _PUBLIC_ NTSTATUS socket_recvfrom(struct socket_context *sock, void *buf,
return NT_STATUS_NOT_IMPLEMENTED; 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); mem_ctx, src_addr);
} }
_PUBLIC_ NTSTATUS socket_send(struct socket_context *sock, _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) { if (sock == NULL) {
return NT_STATUS_CONNECTION_DISCONNECTED; return NT_STATUS_CONNECTION_DISCONNECTED;
@ -238,15 +238,15 @@ _PUBLIC_ NTSTATUS socket_send(struct socket_context *sock,
return STATUS_MORE_ENTRIES; return STATUS_MORE_ENTRIES;
} }
blob2.length = 1+(random() % blob2.length); 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, _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) const struct socket_address *dest_addr)
{ {
if (sock == NULL) { if (sock == NULL) {
@ -265,7 +265,7 @@ _PUBLIC_ NTSTATUS socket_sendto(struct socket_context *sock,
return NT_STATUS_NOT_IMPLEMENTED; 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);
} }

View File

@ -62,15 +62,15 @@ struct socket_ops {
/* general ops */ /* general ops */
NTSTATUS (*fn_recv)(struct socket_context *sock, void *buf, 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, 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, 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); const struct socket_address *dest_addr);
NTSTATUS (*fn_recvfrom)(struct socket_context *sock, 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); TALLOC_CTX *addr_ctx, struct socket_address **src_addr);
NTSTATUS (*fn_pending)(struct socket_context *sock, size_t *npending); 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); int queue_size, uint32_t flags);
NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_sock); NTSTATUS socket_accept(struct socket_context *sock, struct socket_context **new_sock);
NTSTATUS socket_recv(struct socket_context *sock, void *buf, 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, 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); TALLOC_CTX *addr_ctx, struct socket_address **src_addr);
NTSTATUS socket_send(struct socket_context *sock, 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, 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); const struct socket_address *dest_addr);
NTSTATUS socket_pending(struct socket_context *sock, size_t *npending); NTSTATUS socket_pending(struct socket_context *sock, size_t *npending);
NTSTATUS socket_set_option(struct socket_context *sock, const char *option, const char *val); NTSTATUS socket_set_option(struct socket_context *sock, const char *option, const char *val);

View File

@ -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, 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; 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; *nread = 0;
gotlen = recv(sock->fd, buf, wantlen, flgs); gotlen = recv(sock->fd, buf, wantlen, 0);
if (gotlen == 0) { if (gotlen == 0) {
return NT_STATUS_END_OF_FILE; return NT_STATUS_END_OF_FILE;
} else if (gotlen == -1) { } 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, 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) TALLOC_CTX *addr_ctx, struct socket_address **_src)
{ {
ssize_t gotlen; ssize_t gotlen;
int flgs = 0;
struct sockaddr_in *from_addr; struct sockaddr_in *from_addr;
socklen_t from_len = sizeof(*from_addr); socklen_t from_len = sizeof(*from_addr);
struct socket_address *src; struct socket_address *src;
@ -305,17 +294,10 @@ static NTSTATUS ipv4_recvfrom(struct socket_context *sock, void *buf,
} }
src->sockaddr = (struct sockaddr *)from_addr; src->sockaddr = (struct sockaddr *)from_addr;
if (flags & SOCKET_FLAG_PEEK) {
flgs |= MSG_PEEK;
}
if (flags & SOCKET_FLAG_BLOCK) {
flgs |= MSG_WAITALL;
}
*nread = 0; *nread = 0;
gotlen = recvfrom(sock->fd, buf, wantlen, flgs, gotlen = recvfrom(sock->fd, buf, wantlen, 0,
src->sockaddr, &from_len); src->sockaddr, &from_len);
if (gotlen == 0) { if (gotlen == 0) {
talloc_free(src); 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, 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; ssize_t len;
int flgs = 0;
*sendlen = 0; *sendlen = 0;
len = send(sock->fd, blob->data, blob->length, flgs); len = send(sock->fd, blob->data, blob->length, 0);
if (len == -1) { if (len == -1) {
return map_nt_error_from_unix(errno); 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, 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) const struct socket_address *dest_addr)
{ {
ssize_t len; ssize_t len;
int flgs = 0;
if (dest_addr->sockaddr) { 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); dest_addr->sockaddr, dest_addr->sockaddrlen);
} else { } else {
struct sockaddr_in srv_addr; struct sockaddr_in srv_addr;
@ -387,7 +367,7 @@ static NTSTATUS ipv4_sendto(struct socket_context *sock,
*sendlen = 0; *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)); (struct sockaddr *)&srv_addr, sizeof(srv_addr));
} }
if (len == -1) { if (len == -1) {

View File

@ -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, 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; 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; *nread = 0;
gotlen = recv(sock->fd, buf, wantlen, flgs); gotlen = recv(sock->fd, buf, wantlen, 0);
if (gotlen == 0) { if (gotlen == 0) {
return NT_STATUS_END_OF_FILE; return NT_STATUS_END_OF_FILE;
} else if (gotlen == -1) { } 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, 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; ssize_t len;
int flgs = 0;
*sendlen = 0; *sendlen = 0;
len = send(sock->fd, blob->data, blob->length, flgs); len = send(sock->fd, blob->data, blob->length, 0);
if (len == -1) { if (len == -1) {
return map_nt_error_from_unix(errno); return map_nt_error_from_unix(errno);
} }

View File

@ -219,23 +219,13 @@ static NTSTATUS unixdom_accept(struct socket_context *sock,
} }
static NTSTATUS unixdom_recv(struct socket_context *sock, void *buf, 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; 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; *nread = 0;
gotlen = recv(sock->fd, buf, wantlen, flgs); gotlen = recv(sock->fd, buf, wantlen, 0);
if (gotlen == 0) { if (gotlen == 0) {
return NT_STATUS_END_OF_FILE; return NT_STATUS_END_OF_FILE;
} else if (gotlen == -1) { } 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, 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; ssize_t len;
int flgs = 0;
*sendlen = 0; *sendlen = 0;
len = send(sock->fd, blob->data, blob->length, flgs); len = send(sock->fd, blob->data, blob->length, 0);
if (len == -1) { if (len == -1) {
return unixdom_error(errno); return unixdom_error(errno);
} }
@ -267,15 +256,14 @@ static NTSTATUS unixdom_send(struct socket_context *sock,
static NTSTATUS unixdom_sendto(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) const struct socket_address *dest)
{ {
ssize_t len; ssize_t len;
int flgs = 0;
*sendlen = 0; *sendlen = 0;
if (dest->sockaddr) { 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); dest->sockaddr, dest->sockaddrlen);
} else { } else {
struct sockaddr_un srv_addr; struct sockaddr_un srv_addr;
@ -288,7 +276,7 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock,
srv_addr.sun_family = AF_UNIX; srv_addr.sun_family = AF_UNIX;
strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path)); 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)); (struct sockaddr *)&srv_addr, sizeof(srv_addr));
} }
if (len == -1) { if (len == -1) {

View File

@ -298,7 +298,7 @@ _PUBLIC_ void packet_recv(struct packet_context *pc)
npending, &nread); npending, &nread);
} else { } else {
status = socket_recv(pc->sock, pc->partial.data + pc->num_read, status = socket_recv(pc->sock, pc->partial.data + pc->num_read,
npending, &nread, 0); npending, &nread);
} }
if (NT_STATUS_IS_ERR(status)) { if (NT_STATUS_IS_ERR(status)) {
packet_error(pc, status); packet_error(pc, status);
@ -455,7 +455,7 @@ _PUBLIC_ void packet_queue_run(struct packet_context *pc)
if (pc->tls) { if (pc->tls) {
status = tls_socket_send(pc->tls, &blob, &nwritten); status = tls_socket_send(pc->tls, &blob, &nwritten);
} else { } else {
status = socket_send(pc->sock, &blob, &nwritten, 0); status = socket_send(pc->sock, &blob, &nwritten);
} }
if (NT_STATUS_IS_ERR(status)) { if (NT_STATUS_IS_ERR(status)) {
packet_error(pc, NT_STATUS_NET_WRITE_FAULT); packet_error(pc, NT_STATUS_NET_WRITE_FAULT);

View File

@ -77,7 +77,7 @@ static ssize_t tls_pull(gnutls_transport_ptr ptr, void *buf, size_t size)
return 1; 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)) { if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
return 0; 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.data = discard_const(buf);
b.length = size; 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)) { if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
errno = EAGAIN; errno = EAGAIN;
return -1; return -1;
@ -225,7 +225,7 @@ NTSTATUS tls_socket_recv(struct tls_context *tls, void *buf, size_t wantlen,
int ret; int ret;
NTSTATUS status; NTSTATUS status;
if (tls->tls_enabled && tls->tls_detect) { 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); NT_STATUS_NOT_OK_RETURN(status);
if (*nread == 0) return NT_STATUS_OK; if (*nread == 0) return NT_STATUS_OK;
tls->tls_detect = False; 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) { 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); status = tls_handshake(tls);
@ -274,7 +274,7 @@ NTSTATUS tls_socket_send(struct tls_context *tls, const DATA_BLOB *blob, size_t
int ret; int ret;
if (!tls->tls_enabled) { if (!tls->tls_enabled) {
return socket_send(tls->socket, blob, sendlen, 0); return socket_send(tls->socket, blob, sendlen);
} }
status = tls_handshake(tls); status = tls_handshake(tls);

View File

@ -83,7 +83,7 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
return; return;
} }
status = socket_recvfrom(cldap->sock, blob.data, blob.length, &nread, 0, status = socket_recvfrom(cldap->sock, blob.data, blob.length, &nread,
tmp_ctx, &src); tmp_ctx, &src);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
@ -156,7 +156,7 @@ static void cldap_request_timeout(struct event_context *event_ctx,
req->num_retries--; req->num_retries--;
socket_sendto(req->cldap->sock, &req->encoded, &len, 0, socket_sendto(req->cldap->sock, &req->encoded, &len,
req->dest); req->dest);
req->te = event_add_timed(req->cldap->event_ctx, req, req->te = event_add_timed(req->cldap->event_ctx, req,
@ -183,7 +183,7 @@ static void cldap_socket_send(struct cldap_socket *cldap)
size_t len; size_t len;
len = req->encoded.length; len = req->encoded.length;
status = socket_sendto(cldap->sock, &req->encoded, &len, 0, status = socket_sendto(cldap->sock, &req->encoded, &len,
req->dest); req->dest);
if (NT_STATUS_IS_ERR(status)) { if (NT_STATUS_IS_ERR(status)) {
DEBUG(3,("Failed to send cldap request of length %u to %s:%d\n", DEBUG(3,("Failed to send cldap request of length %u to %s:%d\n",

View File

@ -53,7 +53,7 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock)
return; return;
} }
status = socket_recvfrom(dgmsock->sock, blob.data, blob.length, &nread, 0, status = socket_recvfrom(dgmsock->sock, blob.data, blob.length, &nread,
tmp_ctx, &src); tmp_ctx, &src);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
@ -113,7 +113,7 @@ static void dgm_socket_send(struct nbt_dgram_socket *dgmsock)
size_t len; size_t len;
len = req->encoded.length; len = req->encoded.length;
status = socket_sendto(dgmsock->sock, &req->encoded, &len, 0, status = socket_sendto(dgmsock->sock, &req->encoded, &len,
req->dest); req->dest);
if (NT_STATUS_IS_ERR(status)) { if (NT_STATUS_IS_ERR(status)) {
DEBUG(3,("Failed to send datagram of length %u to %s:%d: %s\n", DEBUG(3,("Failed to send datagram of length %u to %s:%d: %s\n",

View File

@ -73,7 +73,7 @@ static void nbt_name_socket_send(struct nbt_name_socket *nbtsock)
size_t len; size_t len;
len = req->encoded.length; len = req->encoded.length;
status = socket_sendto(nbtsock->sock, &req->encoded, &len, 0, status = socket_sendto(nbtsock->sock, &req->encoded, &len,
req->dest); req->dest);
if (NT_STATUS_IS_ERR(status)) goto failed; if (NT_STATUS_IS_ERR(status)) goto failed;
@ -172,7 +172,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
return; return;
} }
status = socket_recvfrom(nbtsock->sock, blob.data, blob.length, &nread, 0, status = socket_recvfrom(nbtsock->sock, blob.data, blob.length, &nread,
tmp_ctx, &src); tmp_ctx, &src);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);

View File

@ -47,7 +47,7 @@ static NTSTATUS dcerpc_write_fn(void *private_data, DATA_BLOB *out, size_t *nwri
struct socket_context *sock = talloc_get_type(private_data, struct socket_context); struct socket_context *sock = talloc_get_type(private_data, struct socket_context);
size_t sendlen; size_t sendlen;
status = socket_send(sock, out, &sendlen, 0); status = socket_send(sock, out, &sendlen);
NT_STATUS_IS_ERR_RETURN(status); NT_STATUS_IS_ERR_RETURN(status);
*nwritten = sendlen; *nwritten = sendlen;
@ -152,7 +152,7 @@ static void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags)
return; return;
} }
status = socket_recv(conn->socket, tmp_blob.data, tmp_blob.length, &nread, 0); status = socket_recv(conn->socket, tmp_blob.data, tmp_blob.length, &nread);
if (NT_STATUS_IS_ERR(status)) { if (NT_STATUS_IS_ERR(status)) {
dcesrv_terminate_connection(dce_conn, nt_errstr(status)); dcesrv_terminate_connection(dce_conn, nt_errstr(status));
return; return;

View File

@ -82,10 +82,10 @@ static BOOL test_udp(TALLOC_CTX *mem_ctx)
generate_random_buffer(blob.data, blob.length); generate_random_buffer(blob.data, blob.length);
sent = size; sent = size;
status = socket_sendto(sock2, &blob, &sent, 0, srv_addr); status = socket_sendto(sock2, &blob, &sent, srv_addr);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
status = socket_recvfrom(sock1, blob2.data, size, &nread, 0, status = socket_recvfrom(sock1, blob2.data, size, &nread,
sock1, &from_addr); sock1, &from_addr);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
@ -104,10 +104,10 @@ static BOOL test_udp(TALLOC_CTX *mem_ctx)
} }
generate_random_buffer(blob.data, blob.length); generate_random_buffer(blob.data, blob.length);
status = socket_sendto(sock1, &blob, &sent, 0, from_addr); status = socket_sendto(sock1, &blob, &sent, from_addr);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
status = socket_recvfrom(sock2, blob2.data, size, &nread, 0, status = socket_recvfrom(sock2, blob2.data, size, &nread,
sock2, &from_addr); sock2, &from_addr);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
if (strcmp(from_addr->addr, srv_addr->addr) != 0) { if (strcmp(from_addr->addr, srv_addr->addr) != 0) {
@ -195,10 +195,10 @@ static BOOL test_tcp(TALLOC_CTX *mem_ctx)
generate_random_buffer(blob.data, blob.length); generate_random_buffer(blob.data, blob.length);
sent = size; sent = size;
status = socket_send(sock2, &blob, &sent, 0); status = socket_send(sock2, &blob, &sent);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
status = socket_recv(sock3, blob2.data, size, &nread, 0); status = socket_recv(sock3, blob2.data, size, &nread);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(status, NT_STATUS_OK);
from_addr = socket_get_peer_addr(sock3, mem_ctx); from_addr = socket_get_peer_addr(sock3, mem_ctx);
@ -217,38 +217,7 @@ static BOOL test_tcp(TALLOC_CTX *mem_ctx)
} }
if (memcmp(blob2.data, blob.data, size) != 0) { if (memcmp(blob2.data, blob.data, size) != 0) {
printf("Bad data in recvfrom\n"); printf("Bad data in recv\n");
ret = False;
}
generate_random_buffer(blob.data, blob.length);
status = socket_send(sock3, &blob, &sent, 0);
CHECK_STATUS(status, NT_STATUS_OK);
status = socket_recv(sock2, blob2.data, size, &nread, 0);
CHECK_STATUS(status, NT_STATUS_OK);
from_addr = socket_get_peer_addr(sock2, mem_ctx);
if (!from_addr || !from_addr->addr) {
printf("Unexpected recvfrom addr NULL\n");
return False;
}
if (strcmp(from_addr->addr, srv_addr->addr) != 0) {
printf("Unexpected recvfrom addr %s\n", from_addr ? from_addr->addr : NULL);
ret = False;
}
if (nread != size) {
printf("Unexpected recvfrom size %d should be %d\n", (int)nread, (int)size);
ret = False;
}
if (from_addr->port != srv_addr->port) {
printf("Unexpected recvfrom port %d should be %d\n",
from_addr->port, srv_addr->port);
ret = False;
}
if (memcmp(blob2.data, blob.data, size) != 0) {
printf("Bad data in recvfrom\n");
ret = False; ret = False;
} }