diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-11-04 12:49:09 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-11-10 22:07:33 -0700 |
commit | 1e8897a61addec5c2067ffbab38122d6c236ced3 (patch) | |
tree | 0e81b9b4d07fa8a3394ccadee919b79e059ba19e /libhw | |
parent | 3c81186daf97cf7011fd2806dfd0bc3b875e92f3 (diff) |
libhw: net.h: Clarify UDP truncation behavior
Diffstat (limited to 'libhw')
-rw-r--r-- | libhw/common_include/libhw/generic/net.h | 5 | ||||
-rw-r--r-- | libhw/host_net.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libhw/common_include/libhw/generic/net.h b/libhw/common_include/libhw/generic/net.h index 8dedaea..e23dcda 100644 --- a/libhw/common_include/libhw/generic/net.h +++ b/libhw/common_include/libhw/generic/net.h @@ -106,6 +106,11 @@ struct net_packet_conn_vtable { ssize_t (*sendto )(implements_net_packet_conn *self, void *buf, size_t len, struct net_ip4_addr node, uint16_t port); + /** + * @return The full length of the message, which may be more + * than the given `len` (as if the Linux MSG_TRUNC flag were + * given). + */ ssize_t (*recvfrom)(implements_net_packet_conn *self, void *buf, size_t len, struct net_ip4_addr *ret_node, uint16_t *ret_port); diff --git a/libhw/host_net.c b/libhw/host_net.c index 27df2e2..75486aa 100644 --- a/libhw/host_net.c +++ b/libhw/host_net.c @@ -457,7 +457,8 @@ static void *hostnet_pthread_recvfrom(void *_args) { if (*(args->ret_size) < 0) goto end; - *(args->ret_size) = recvfrom(args->connfd, args->buf, args->count, 0, &addr.gen, &addr_size); + *(args->ret_size) = recvfrom(args->connfd, args->buf, args->count, + MSG_TRUNC, &addr.gen, &addr_size); if (*(args->ret_size) < 0) goto end; |