mcast_ips: Restore mcast ip for mcast sessions for each new coap_send()

If the server is responding to a mcast request with a packet that is a
part of larger body (i.e. responding with Block2 option) the requests
for the missing packets have to be using unicast, which continues
to be supported.

The application can determine the unicast remote address before the next
coap_send() by using coap_session_get_addr_remote().

Add in a new function coap_session_get_addr_mcast() to get the mcast IP
if the client session was set up to talk to a mcast address.
This commit is contained in:
Jon Shallow authored and Jon Shallow committed 2023-05-01 16:28:44 +01:00
1 parent 46aa5760ee
commit 3ebbcde43a
9 files changed
+107 -29

No files matched your search

+9 -6
View File
@@ -41,15 +41,18 @@ struct coap_socket_t {
coap_fd_t fd;
#endif /* WITH_LWIP */
#if defined(RIOT_VERSION)
gnrc_pktsnip_t *pkt; /* pointer to received packet for processing */
gnrc_pktsnip_t *pkt; /**< pointer to received packet for processing */
#endif /* RIOT_VERSION */
coap_socket_flags_t flags;
coap_session_t *session; /* Used to determine session owner. */
coap_socket_flags_t flags; /**< 1 or more of COAP_SOCKET* flag values */
coap_session_t *session; /**< Used to determine session owner. */
#if COAP_SERVER_SUPPORT
coap_endpoint_t *endpoint; /* Used by the epoll logic for a listening
endpoint. */
coap_endpoint_t *endpoint; /**< Used by the epoll logic for a listening
endpoint. */
#endif /* COAP_SERVER_SUPPORT */
coap_layer_func_t lfunc[COAP_LAYER_LAST]; /* Layer functions to use */
#if COAP_CLIENT_SUPPORT
coap_address_t mcast_addr; /**< remote address and port (multicast track) */
#endif /* COAP_CLIENT_SUPPORT */
coap_layer_func_t lfunc[COAP_LAYER_LAST]; /**< Layer functions to use */
};
/**
+56 -19
View File
@@ -107,7 +107,11 @@ void coap_session_set_app_data(coap_session_t *session, void *data);
void *coap_session_get_app_data(const coap_session_t *session);
/**
* Get the remote IP address from the session.
* Get the remote IP address and port from the session.
*
* Note: For clients, this can be the responding IP address for a multicast
* request before the next coap_send() is called when the multicast address
* is restored.
*
* @param session The CoAP session.
*
@@ -117,7 +121,21 @@ const coap_address_t *coap_session_get_addr_remote(
const coap_session_t *session);
/**
* Get the local IP address from the session.
* Get the remote multicast IP address and port from the session if the
* original target IP was multicast.
*
* Note: This is only available for a client.
*
* @param session The CoAP session.
*
* @return The session's remote multicast address or @c NULL on failure or if
* this is not a multicast session.
*/
const coap_address_t *coap_session_get_addr_mcast(
const coap_session_t *session);
/**
* Get the local IP address and port from the session.
*
* @param session The CoAP session.
*
@@ -362,25 +380,47 @@ void coap_session_new_token(coap_session_t *session, size_t *length,
const char *coap_session_str(const coap_session_t *session);
/**
* Create a new endpoint for communicating with peers.
*
* @param context The coap context that will own the new endpoint
* @param listen_addr Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint.
* @param proto Protocol used on this endpoint
*/
* Create a new endpoint for communicating with peers.
*
* @param context The coap context that will own the new endpoint,
* @param listen_addr Address the endpoint will listen for incoming requests
* on or originate outgoing requests from. Use NULL to
* specify that no incoming request will be accepted and
* use a random endpoint.
* @param proto Protocol used on this endpoint,
*
* @return The new endpoint or @c NULL on failure.
*/
coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto);
/**
* Set the endpoint's default MTU. This is the maximum message size that can be
* sent, excluding IP and UDP overhead.
*
* @param endpoint The CoAP endpoint.
* @param mtu maximum message size
*/
* Set the endpoint's default MTU. This is the maximum message size that can be
* sent, excluding IP and UDP overhead.
*
* @param endpoint The CoAP endpoint.
* @param mtu maximum message size
*/
void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu);
void coap_free_endpoint(coap_endpoint_t *ep);
/**
* Release an endpoint and all the structures associated with it.
*
* @param endpoint The endpoint to release.
*/
void coap_free_endpoint(coap_endpoint_t *endpoint);
/**
* Get the session associated with the specified @p remote_addr and @p index.
*
* @param context The context to search.
* @param remote_addr The remote (peer) address to search for.
* @param ifindex The Interface index that is used to access remote_addr.
*
* @return The found session or @c NULL if not found.
*/
coap_session_t *coap_session_get_by_peer(const coap_context_t *context,
const coap_address_t *remote_addr,
int ifindex);
/** @} */
@@ -393,9 +433,6 @@ void coap_free_endpoint(coap_endpoint_t *ep);
*/
const char *coap_endpoint_str(const coap_endpoint_t *endpoint);
coap_session_t *coap_session_get_by_peer(const coap_context_t *ctx,
const coap_address_t *remote_addr, int ifindex);
/**
* @ingroup application_api
* @defgroup cc Rate Control