mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gcoap: move tl_type to coap_request_ctx_t
This commit is contained in:
parent
eb12f44331
commit
d7bb42296a
@ -230,13 +230,6 @@ typedef struct {
|
||||
BITFIELD(opt_crit, CONFIG_NANOCOAP_NOPTS_MAX); /**< unhandled critical option */
|
||||
#ifdef MODULE_GCOAP
|
||||
uint32_t observe_value; /**< observe value */
|
||||
/**
|
||||
* @brief transport the packet was received over
|
||||
* @see @ref gcoap_socket_type_t for values.
|
||||
* @note @ref gcoap_socket_type_t can not be used, as this would
|
||||
* cyclically include the @ref net_gcoap header.
|
||||
*/
|
||||
uint32_t tl_type;
|
||||
#endif
|
||||
} coap_pkt_t;
|
||||
|
||||
@ -344,6 +337,16 @@ const char *coap_request_ctx_get_path(const coap_request_ctx_t *ctx);
|
||||
*/
|
||||
void *coap_request_ctx_get_context(const coap_request_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief Get transport the packet was received over
|
||||
* @see @ref gcoap_socket_type_t for values.
|
||||
*
|
||||
* @param[in] ctx The request context
|
||||
*
|
||||
* @return Transport Layer type of the request
|
||||
*/
|
||||
uint32_t coap_request_ctx_get_tl_type(const coap_request_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief Block1 helper struct
|
||||
*/
|
||||
|
@ -684,13 +684,12 @@ static size_t _handle_req(gcoap_socket_t *sock, coap_pkt_t *pdu, uint8_t *buf,
|
||||
return -1;
|
||||
}
|
||||
|
||||
pdu->tl_type = (uint32_t)sock->type;
|
||||
|
||||
ssize_t pdu_len;
|
||||
char *offset;
|
||||
|
||||
coap_request_ctx_t ctx = {
|
||||
.resource = resource,
|
||||
.tl_type = (uint32_t)sock->type,
|
||||
};
|
||||
|
||||
if (coap_get_proxy_uri(pdu, &offset) > 0) {
|
||||
@ -899,7 +898,7 @@ static ssize_t _well_known_core_handler(coap_pkt_t* pdu, uint8_t *buf, size_t le
|
||||
|
||||
plen += gcoap_get_resource_list_tl(pdu->payload, (size_t)pdu->payload_len,
|
||||
COAP_FORMAT_LINK,
|
||||
(gcoap_socket_type_t)pdu->tl_type);
|
||||
(gcoap_socket_type_t)coap_request_ctx_get_tl_type(ctx));
|
||||
return plen;
|
||||
}
|
||||
|
||||
|
@ -1246,3 +1246,13 @@ void *coap_request_ctx_get_context(const coap_request_ctx_t *ctx)
|
||||
{
|
||||
return ctx->context;
|
||||
}
|
||||
|
||||
uint32_t coap_request_ctx_get_tl_type(const coap_request_ctx_t *ctx)
|
||||
{
|
||||
#ifdef MODULE_GCOAP
|
||||
return ctx->tl_type;
|
||||
#else
|
||||
(void)ctx;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -32,6 +32,15 @@ struct _coap_request_ctx {
|
||||
const coap_resource_t *resource; /**< resource of the request */
|
||||
void *context; /**< request context, needed to supply
|
||||
the remote for the forward proxy */
|
||||
#if defined(MODULE_GCOAP) || DOXYGEN
|
||||
/**
|
||||
* @brief transport the packet was received over
|
||||
* @see @ref gcoap_socket_type_t for values.
|
||||
* @note @ref gcoap_socket_type_t can not be used, as this would
|
||||
* cyclically include the @ref net_gcoap header.
|
||||
*/
|
||||
uint32_t tl_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user