Skip to content
Snippets Groups Projects
Commit 9e7cebae authored by Martine Lenders's avatar Martine Lenders
Browse files

sock_udp: allow creation with ephemeral ports

This change allows the port for local endpoint to be zero 0. If this is
the case the `sock_udp_create()` function binds the object to an
ephemeral port.
parent 48c1c052
Branches
No related tags found
No related merge requests found
...@@ -293,17 +293,17 @@ typedef struct sock_udp sock_udp_t; ...@@ -293,17 +293,17 @@ typedef struct sock_udp sock_udp_t;
* @brief Creates a new UDP sock object * @brief Creates a new UDP sock object
* *
* @pre `(sock != NULL)` * @pre `(sock != NULL)`
* @pre `(local == NULL) || (local->port != 0)`
* @pre `(remote == NULL) || (remote->port != 0)` * @pre `(remote == NULL) || (remote->port != 0)`
* *
* @param[out] sock The resulting sock object. * @param[out] sock The resulting sock object.
* @param[in] local Local end point for the sock object. * @param[in] local Local end point for the sock object.
* May be NULL. * May be NULL.
* sock_udp_ep_t::port must not be 0 if `local != NULL`.
* sock_udp_ep_t::netif must either be * sock_udp_ep_t::netif must either be
* @ref SOCK_ADDR_ANY_NETIF or equal to * @ref SOCK_ADDR_ANY_NETIF or equal to
* sock_udp_ep_t::netif of @p remote if `remote != NULL`. * sock_udp_ep_t::netif of @p remote if `remote != NULL`.
* If NULL @ref sock_udp_send() may bind implicitly. * If NULL @ref sock_udp_send() may bind implicitly.
* sock_udp_ep_t::port may also be 0 to bind the `sock` to
* an ephemeral port.
* @param[in] remote Remote end point for the sock object. * @param[in] remote Remote end point for the sock object.
* May be `NULL` but then the `remote` parameter of * May be `NULL` but then the `remote` parameter of
* @ref sock_udp_send() may not be `NULL` or it will * @ref sock_udp_send() may not be `NULL` or it will
...@@ -318,7 +318,8 @@ typedef struct sock_udp sock_udp_t; ...@@ -318,7 +318,8 @@ typedef struct sock_udp sock_udp_t;
* *
* @return 0 on success. * @return 0 on success.
* @return -EADDRINUSE, if `local != NULL` and @p local is already used * @return -EADDRINUSE, if `local != NULL` and @p local is already used
* elsewhere * elsewhere or if `local->port == 0` but the pool of ephemeral ports
* is depleted
* @return -EAFNOSUPPORT, if `local != NULL` or `remote != NULL` and * @return -EAFNOSUPPORT, if `local != NULL` or `remote != NULL` and
* sock_udp_ep_t::family of @p local or @p remote is not supported. * sock_udp_ep_t::family of @p local or @p remote is not supported.
* @return -EINVAL, if sock_udp_ep_t::addr of @p remote is an invalid address. * @return -EINVAL, if sock_udp_ep_t::addr of @p remote is an invalid address.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment