Skip to content

Commit

Permalink
net: sockets: Move msghdr_non_empty_iov_count() to common file
Browse files Browse the repository at this point in the history
msghdr_non_empty_iov_count() is used by TLS sockets too therefore should
be available regardless of native IP sockets being enabled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and fabiobaltieri committed Oct 9, 2024
1 parent 8652e8e commit 66ff30e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 13 additions & 0 deletions subsys/net/lib/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ static inline void *get_sock_vtable(int sock,
return ctx;
}

size_t msghdr_non_empty_iov_count(const struct msghdr *msg)
{
size_t non_empty_iov_count = 0;

for (size_t i = 0; i < msg->msg_iovlen; i++) {
if (msg->msg_iov[i].iov_len) {
non_empty_iov_count++;
}
}

return non_empty_iov_count;
}

void *z_impl_zsock_get_context_object(int sock)
{
const struct socket_op_vtable *ignored;
Expand Down
13 changes: 0 additions & 13 deletions subsys/net/lib/sockets/sockets_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,19 +640,6 @@ ssize_t zsock_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
return status;
}

size_t msghdr_non_empty_iov_count(const struct msghdr *msg)
{
size_t non_empty_iov_count = 0;

for (size_t i = 0; i < msg->msg_iovlen; i++) {
if (msg->msg_iov[i].iov_len) {
non_empty_iov_count++;
}
}

return non_empty_iov_count;
}

ssize_t zsock_sendmsg_ctx(struct net_context *ctx, const struct msghdr *msg,
int flags)
{
Expand Down

0 comments on commit 66ff30e

Please sign in to comment.