Skip to content
Permalink
Browse files

net: context: sendmsg: Allow use of connected UDP sockets

If the UDP socket is connected, then allow the user to leave
out the remote address in msghdr struct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information...
jukkar committed Aug 8, 2019
1 parent 9fb1fd4 commit c80407d30e18696a48ce232e5b4c71dcf6361485
Showing with 2 additions and 12 deletions.
  1. +2 −12 subsys/net/ip/net_context.c
@@ -1364,14 +1364,9 @@ static int context_sendto(struct net_context *context,
addr6 = msghdr->msg_name;
addrlen = msghdr->msg_namelen;

if (net_context_get_ip_proto(context) ==
IPPROTO_TCP) {
if (!addr6) {
addr6 = net_sin6(&context->remote);
addrlen = sizeof(struct sockaddr_in6);
} else {
if (!addr6) {
return -EINVAL;
}
}

/* For sendmsg(), the dst_addr is NULL so set it here.
@@ -1395,14 +1390,9 @@ static int context_sendto(struct net_context *context,
addr4 = msghdr->msg_name;
addrlen = msghdr->msg_namelen;

if (net_context_get_ip_proto(context) ==
IPPROTO_TCP) {
if (!addr4) {
addr4 = net_sin(&context->remote);
addrlen = sizeof(struct sockaddr_in);
} else {
if (!addr4) {
return -EINVAL;
}
}

/* For sendmsg(), the dst_addr is NULL so set it here.

0 comments on commit c80407d

Please sign in to comment.
You can’t perform that action at this time.