Skip to content

Commit

Permalink
Merge pull request #6021 from miri64/gnrc_sock/fix/actually-bind-impl…
Browse files Browse the repository at this point in the history
…icitly

gnrc_sock: actually bind implicitly
  • Loading branch information
miri64 authored Oct 30, 2016
2 parents 1de2175 + 60d7b7e commit 04f8cc2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sys/net/gnrc/sock/udp/gnrc_sock_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ ssize_t sock_udp_send(sock_udp_t *sock, const void *data, size_t len,
}
if ((remote == NULL) &&
/* sock can't be NULL as per assertion above */
(sock->remote.port == AF_UNSPEC)) {
(sock->remote.family == AF_UNSPEC)) {
return -ENOTCONN;
}
/* compiler evaluates lazily so this isn't a redundundant check and cppcheck
Expand Down Expand Up @@ -221,11 +221,18 @@ ssize_t sock_udp_send(sock_udp_t *sock, const void *data, size_t len,
if (sock != NULL) {
/* bind sock object implicitly */
sock->local.port = src_port;
if (remote == NULL) {
sock->local.family = sock->remote.family;
}
else {
sock->local.family = remote->family;
}
#ifdef MODULE_GNRC_SOCK_CHECK_REUSE
/* prepend to current socks */
sock->reg.next = (gnrc_sock_reg_t *)_udp_socks;
_udp_socks = sock;
#endif
gnrc_sock_create(&sock->reg, GNRC_NETTYPE_UDP, src_port);
}
}
else {
Expand Down

0 comments on commit 04f8cc2

Please sign in to comment.