-/* $OpenBSD: clnt.h,v 1.12 2022/02/14 03:38:59 guenther Exp $ */
+/* $OpenBSD: clnt.h,v 1.13 2022/07/15 17:33:28 deraadt Exp $ */
/* $NetBSD: clnt.h,v 1.6 1995/04/29 05:27:58 cgd Exp $ */
/*
*/
#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */
#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */
+#define CLSET_CONNECTED 6 /* socket is connected, so use send() */
/*
* void
-/* $OpenBSD: clnt_tcp.c,v 1.35 2022/02/14 03:38:59 guenther Exp $ */
+/* $OpenBSD: clnt_tcp.c,v 1.36 2022/07/15 17:33:28 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
struct ct_data {
int ct_sock;
bool_t ct_closeit;
+ int ct_connected; /* pre-connected */
struct timeval ct_wait;
bool_t ct_waitset; /* wait set by clnt_control? */
struct sockaddr_in ct_addr;
case CLGET_SERVER_ADDR:
*(struct sockaddr_in *)info = ct->ct_addr;
break;
+ case CLSET_CONNECTED:
+ ct->ct_connected = *(int *)info;
+ break;
default:
return (FALSE);
}
-/* $OpenBSD: clnt_udp.c,v 1.38 2022/02/14 03:38:59 guenther Exp $ */
+/* $OpenBSD: clnt_udp.c,v 1.39 2022/07/15 17:33:28 deraadt Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
int cu_sock;
bool_t cu_closeit;
struct sockaddr_in cu_raddr;
+ int cu_connected; /* use send() instead */
int cu_rlen;
struct timeval cu_wait;
struct timeval cu_total;
cl->cl_ops = &udp_ops;
cl->cl_private = (caddr_t)cu;
cu->cu_raddr = *raddr;
+ cu->cu_connected = 0;
cu->cu_rlen = sizeof (cu->cu_raddr);
cu->cu_wait = wait;
cu->cu_total.tv_sec = -1;
XDR *xdrs;
int outlen;
int inlen;
+ int ret;
socklen_t fromlen;
struct pollfd pfd[1];
struct sockaddr_in from;
outlen = (int)XDR_GETPOS(xdrs);
send_again:
- if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
- (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen) != outlen) {
+ if (cu->cu_connected)
+ ret = send(cu->cu_sock, cu->cu_outbuf, outlen, 0);
+ else
+ ret = sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0,
+ (struct sockaddr *)&(cu->cu_raddr), cu->cu_rlen);
+ if (ret != outlen) {
cu->cu_error.re_errno = errno;
return (cu->cu_error.re_status = RPC_CANTSEND);
}
case CLGET_SERVER_ADDR:
*(struct sockaddr_in *)info = cu->cu_raddr;
break;
+ case CLSET_CONNECTED:
+ cu->cu_connected = *(int *)info;
+ break;
default:
return (FALSE);
}