mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[coap] add support for Proxy-Uri option (#3211)
This commit is contained in:
committed by
Jonathan Hui
parent
52669a925a
commit
34c6af0789
@@ -328,7 +328,7 @@ otError otCoapHeaderAppendUintOption(otCoapHeader *aHeader, uint16_t aNumber, ui
|
||||
otError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve);
|
||||
|
||||
/**
|
||||
* This function appends an Uri-Path option.
|
||||
* This function appends a Uri-Path option.
|
||||
*
|
||||
* @param[inout] aHeader A pointer to the CoAP header.
|
||||
* @param[in] aUriPath A pointer to a NULL-terminated string.
|
||||
@@ -340,6 +340,19 @@ otError otCoapHeaderAppendObserveOption(otCoapHeader *aHeader, uint32_t aObserve
|
||||
*/
|
||||
otError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUriPath);
|
||||
|
||||
/**
|
||||
* This function appends a Proxy-Uri option.
|
||||
*
|
||||
* @param[inout] aHeader A pointer to the CoAP header.
|
||||
* @param[in] aUriPath A pointer to a NULL-terminated string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully appended the option.
|
||||
* @retval OT_ERROR_INVALID_ARGS The option type is not equal or greater than the last option type.
|
||||
* @retval OT_ERROR_NO_BUFS The option length exceeds the buffer size.
|
||||
*
|
||||
*/
|
||||
otError otCoapHeaderAppendProxyUriOption(otCoapHeader *aHeader, const char *aUriPath);
|
||||
|
||||
/**
|
||||
* This function appends a Max-Age option.
|
||||
*
|
||||
|
||||
@@ -83,6 +83,11 @@ otError otCoapHeaderAppendUriPathOptions(otCoapHeader *aHeader, const char *aUri
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendUriPathOptions(aUriPath);
|
||||
}
|
||||
|
||||
otError otCoapHeaderAppendProxyUriOption(otCoapHeader *aHeader, const char *aUriPath)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendProxyUriOption(aUriPath);
|
||||
}
|
||||
|
||||
otError otCoapHeaderAppendMaxAgeOption(otCoapHeader *aHeader, uint32_t aMaxAge)
|
||||
{
|
||||
return static_cast<Coap::Header *>(aHeader)->AppendMaxAgeOption(aMaxAge);
|
||||
|
||||
@@ -275,6 +275,17 @@ otError Header::AppendUintOption(uint16_t aNumber, uint32_t aValue)
|
||||
return AppendOption(coapOption);
|
||||
}
|
||||
|
||||
otError Header::AppendStringOption(uint16_t aNumber, const char *aValue)
|
||||
{
|
||||
Option coapOption;
|
||||
|
||||
coapOption.mNumber = aNumber;
|
||||
coapOption.mLength = static_cast<uint16_t>(strlen(aValue));
|
||||
coapOption.mValue = reinterpret_cast<const uint8_t *>(aValue);
|
||||
|
||||
return AppendOption(coapOption);
|
||||
}
|
||||
|
||||
otError Header::AppendObserveOption(uint32_t aObserve)
|
||||
{
|
||||
return AppendUintOption(OT_COAP_OPTION_OBSERVE, aObserve & 0xFFFFFF);
|
||||
@@ -297,14 +308,17 @@ otError Header::AppendUriPathOptions(const char *aUriPath)
|
||||
cur = end + 1;
|
||||
}
|
||||
|
||||
coapOption.mLength = static_cast<uint16_t>(strlen(cur));
|
||||
coapOption.mValue = reinterpret_cast<const uint8_t *>(cur);
|
||||
SuccessOrExit(error = AppendOption(coapOption));
|
||||
SuccessOrExit(error = AppendStringOption(OT_COAP_OPTION_URI_PATH, cur));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError Header::AppendProxyUriOption(const char *aProxyUri)
|
||||
{
|
||||
return AppendStringOption(OT_COAP_OPTION_PROXY_URI, aProxyUri);
|
||||
}
|
||||
|
||||
otError Header::AppendContentFormatOption(otCoapOptionContentFormat aContentFormat)
|
||||
{
|
||||
return AppendUintOption(OT_COAP_OPTION_CONTENT_FORMAT, static_cast<uint32_t>(aContentFormat));
|
||||
@@ -317,13 +331,7 @@ otError Header::AppendMaxAgeOption(uint32_t aMaxAge)
|
||||
|
||||
otError Header::AppendUriQueryOption(const char *aUriQuery)
|
||||
{
|
||||
Option coapOption;
|
||||
|
||||
coapOption.mNumber = OT_COAP_OPTION_URI_QUERY;
|
||||
coapOption.mLength = static_cast<uint16_t>(strlen(aUriQuery));
|
||||
coapOption.mValue = reinterpret_cast<const uint8_t *>(aUriQuery);
|
||||
|
||||
return AppendOption(coapOption);
|
||||
return AppendStringOption(OT_COAP_OPTION_URI_QUERY, aUriQuery);
|
||||
}
|
||||
|
||||
const Header::Option *Header::GetFirstOption(void)
|
||||
|
||||
@@ -306,6 +306,19 @@ public:
|
||||
*/
|
||||
otError AppendUintOption(uint16_t aNumber, uint32_t aValue);
|
||||
|
||||
/**
|
||||
* This method appends a string CoAP option.
|
||||
*
|
||||
* @param[in] aNumber The CoAP Option number.
|
||||
* @param[in] aValue The CoAP Option string value.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully appended the option.
|
||||
* @retval OT_ERROR_INVALID_ARGS The option type is not equal or greater than the last option type.
|
||||
* @retval OT_ERROR_NO_BUFS The option length exceeds the buffer size.
|
||||
*
|
||||
*/
|
||||
otError AppendStringOption(uint16_t aNumber, const char *aValue);
|
||||
|
||||
/**
|
||||
* This method appends an Observe option.
|
||||
*
|
||||
@@ -320,7 +333,7 @@ public:
|
||||
/**
|
||||
* This method appends a Uri-Path option.
|
||||
*
|
||||
* @param[in] aUriPath A pointer to a NULL-terminated string.
|
||||
* @param[in] aUriPath A pointer to a NULL-terminated string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully appended the option.
|
||||
* @retval OT_ERROR_INVALID_ARGS The option type is not equal or greater than the last option type.
|
||||
@@ -329,6 +342,18 @@ public:
|
||||
*/
|
||||
otError AppendUriPathOptions(const char *aUriPath);
|
||||
|
||||
/**
|
||||
* This method appends a Proxy-Uri option.
|
||||
*
|
||||
* @param[in] aProxyUri A pointer to a NULL-terminated string.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully appended the option.
|
||||
* @retval OT_ERROR_INVALID_ARGS The option type is not equal or greater than the last option type.
|
||||
* @retval OT_ERROR_NO_BUFS The option length exceeds the buffer size.
|
||||
*
|
||||
*/
|
||||
otError AppendProxyUriOption(const char *aProxyUri);
|
||||
|
||||
/**
|
||||
* This method appends a Content-Format option.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user