mirror of
https://github.com/espressif/openthread.git
synced 2026-09-05 16:50:05 +00:00
Clean up coap names. (#1857)
This commit is contained in:
+48
-48
@@ -68,17 +68,17 @@ extern "C" {
|
||||
*/
|
||||
typedef enum otCoapType
|
||||
{
|
||||
kCoapTypeConfirmable = 0x00, ///< Confirmable
|
||||
kCoapTypeNonConfirmable = 0x10, ///< Non-confirmable
|
||||
kCoapTypeAcknowledgment = 0x20, ///< Acknowledgment
|
||||
kCoapTypeReset = 0x30, ///< Reset
|
||||
OT_COAP_TYPE_CONFIRMABLE = 0x00, ///< Confirmable
|
||||
OT_COAP_TYPE_NON_CONFIRMABLE = 0x10, ///< Non-confirmable
|
||||
OT_COAP_TYPE_ACKNOWLEDGMENT = 0x20, ///< Acknowledgment
|
||||
OT_COAP_TYPE_RESET = 0x30, ///< Reset
|
||||
} otCoapType;
|
||||
|
||||
/**
|
||||
* Helper macro to define CoAP Code values.
|
||||
*
|
||||
*/
|
||||
#define COAP_CODE(c, d) ((((c) & 0x7) << 5) | ((d) & 0x1f))
|
||||
#define OT_COAP_CODE(c, d) ((((c) & 0x7) << 5) | ((d) & 0x1f))
|
||||
|
||||
/**
|
||||
* CoAP Code values.
|
||||
@@ -86,36 +86,36 @@ typedef enum otCoapType
|
||||
*/
|
||||
typedef enum otCoapCode
|
||||
{
|
||||
kCoapCodeEmpty = COAP_CODE(0, 0), ///< Empty message code
|
||||
kCoapRequestGet = COAP_CODE(0, 1), ///< Get
|
||||
kCoapRequestPost = COAP_CODE(0, 2), ///< Post
|
||||
kCoapRequestPut = COAP_CODE(0, 3), ///< Put
|
||||
kCoapRequestDelete = COAP_CODE(0, 4), ///< Delete
|
||||
OT_COAP_CODE_EMPTY = OT_COAP_CODE(0, 0), ///< Empty message code
|
||||
OT_COAP_CODE_GET = OT_COAP_CODE(0, 1), ///< Get
|
||||
OT_COAP_CODE_POST = OT_COAP_CODE(0, 2), ///< Post
|
||||
OT_COAP_CODE_PUT = OT_COAP_CODE(0, 3), ///< Put
|
||||
OT_COAP_CODE_DELETE = OT_COAP_CODE(0, 4), ///< Delete
|
||||
|
||||
kCoapResponseCodeMin = COAP_CODE(2, 0), ///< 2.00
|
||||
kCoapResponseCreated = COAP_CODE(2, 1), ///< Created
|
||||
kCoapResponseDeleted = COAP_CODE(2, 2), ///< Deleted
|
||||
kCoapResponseValid = COAP_CODE(2, 3), ///< Valid
|
||||
kCoapResponseChanged = COAP_CODE(2, 4), ///< Changed
|
||||
kCoapResponseContent = COAP_CODE(2, 5), ///< Content
|
||||
OT_COAP_CODE_RESPONSE_MIN = OT_COAP_CODE(2, 0), ///< 2.00
|
||||
OT_COAP_CODE_CREATED = OT_COAP_CODE(2, 1), ///< Created
|
||||
OT_COAP_CODE_DELETED = OT_COAP_CODE(2, 2), ///< Deleted
|
||||
OT_COAP_CODE_VALID = OT_COAP_CODE(2, 3), ///< Valid
|
||||
OT_COAP_CODE_CHANGED = OT_COAP_CODE(2, 4), ///< Changed
|
||||
OT_COAP_CODE_CONTENT = OT_COAP_CODE(2, 5), ///< Content
|
||||
|
||||
kCoapResponseBadRequest = COAP_CODE(4, 0), ///< Bad Request
|
||||
kCoapResponseUnauthorized = COAP_CODE(4, 1), ///< Unauthorized
|
||||
kCoapResponseBadOption = COAP_CODE(4, 2), ///< Bad Option
|
||||
kCoapResponseForbidden = COAP_CODE(4, 3), ///< Forbidden
|
||||
kCoapResponseNotFound = COAP_CODE(4, 4), ///< Not Found
|
||||
kCoapResponseMethodNotAllowed = COAP_CODE(4, 5), ///< Method Not Allowed
|
||||
kCoapResponseNotAcceptable = COAP_CODE(4, 6), ///< Not Acceptable
|
||||
kCoapResponsePreconditionFailed = COAP_CODE(4, 12), ///< Precondition Failed
|
||||
kCoapResponseRequestTooLarge = COAP_CODE(4, 13), ///< Request Entity Too Large
|
||||
kCoapResponseUnsupportedFormat = COAP_CODE(4, 15), ///< Unsupported Content-Format
|
||||
OT_COAP_CODE_BAD_REQUEST = OT_COAP_CODE(4, 0), ///< Bad Request
|
||||
OT_COAP_CODE_UNAUTHORIZED = OT_COAP_CODE(4, 1), ///< Unauthorized
|
||||
OT_COAP_CODE_BAD_OPTION = OT_COAP_CODE(4, 2), ///< Bad Option
|
||||
OT_COAP_CODE_FORBIDDEN = OT_COAP_CODE(4, 3), ///< Forbidden
|
||||
OT_COAP_CODE_NOT_FOUND = OT_COAP_CODE(4, 4), ///< Not Found
|
||||
OT_COAP_CODE_METHOD_NOT_ALLOWED = OT_COAP_CODE(4, 5), ///< Method Not Allowed
|
||||
OT_COAP_CODE_NOT_ACCEPTABLE = OT_COAP_CODE(4, 6), ///< Not Acceptable
|
||||
OT_COAP_CODE_PRECONDITION_FAILED = OT_COAP_CODE(4, 12), ///< Precondition Failed
|
||||
OT_COAP_CODE_REQUEST_TOO_LARGE = OT_COAP_CODE(4, 13), ///< Request Entity Too Large
|
||||
OT_COAP_CODE_UNSUPPORTED_FORMAT = OT_COAP_CODE(4, 15), ///< Unsupported Content-Format
|
||||
|
||||
kCoapResponseInternalError = COAP_CODE(5, 0), ///< Internal Server Error
|
||||
kCoapResponseNotImplemented = COAP_CODE(5, 1), ///< Not Implemented
|
||||
kCoapResponseBadGateway = COAP_CODE(5, 2), ///< Bad Gateway
|
||||
kCoapResponseServiceUnavailable = COAP_CODE(5, 3), ///< Service Unavailable
|
||||
kCoapResponseGatewayTimeout = COAP_CODE(5, 4), ///< Gateway Timeout
|
||||
kCoapResponseProxyNotSupported = COAP_CODE(5, 5), ///< Proxying Not Supported
|
||||
OT_COAP_CODE_INTERNAL_ERROR = OT_COAP_CODE(5, 0), ///< Internal Server Error
|
||||
OT_COAP_CODE_NOT_IMPLEMENTED = OT_COAP_CODE(5, 1), ///< Not Implemented
|
||||
OT_COAP_CODE_BAD_GATEWAY = OT_COAP_CODE(5, 2), ///< Bad Gateway
|
||||
OT_COAP_CODE_SERVICE_UNAVAILABLE = OT_COAP_CODE(5, 3), ///< Service Unavailable
|
||||
OT_COAP_CODE_GATEWAY_TIMEOUT = OT_COAP_CODE(5, 4), ///< Gateway Timeout
|
||||
OT_COAP_CODE_PROXY_NOT_SUPPORTED = OT_COAP_CODE(5, 5), ///< Proxying Not Supported
|
||||
} otCoapCode;
|
||||
|
||||
/**
|
||||
@@ -123,22 +123,22 @@ typedef enum otCoapCode
|
||||
*/
|
||||
typedef enum otCoapOptionType
|
||||
{
|
||||
kCoapOptionIfMatch = 1, ///< If-Match
|
||||
kCoapOptionUriHost = 3, ///< Uri-Host
|
||||
kCoapOptionETag = 4, ///< ETag
|
||||
kCoapOptionIfNoneMatch = 5, ///< If-None-Match
|
||||
kCoapOptionObserve = 6, ///< Observe
|
||||
kCoapOptionUriPort = 7, ///< Uri-Port
|
||||
kCoapOptionLocationPath = 8, ///< Location-Path
|
||||
kCoapOptionUriPath = 11, ///< Uri-Path
|
||||
kCoapOptionContentFormat = 12, ///< Content-Format
|
||||
kCoapOptionMaxAge = 14, ///< Max-Age
|
||||
kCoapOptionUriQuery = 15, ///< Uri-Query
|
||||
kCoapOptionAccept = 17, ///< Accept
|
||||
kCoapOptionLocationQuery = 20, ///< Location-Query
|
||||
kCoapOptionProxyUri = 35, ///< Proxy-Uri
|
||||
kCoapOptionProxyScheme = 39, ///< Proxy-Scheme
|
||||
kCoapOptionSize1 = 60, ///< Size1
|
||||
OT_COAP_OPTION_IF_MATCH = 1, ///< If-Match
|
||||
OT_COAP_OPTION_URI_HOST = 3, ///< Uri-Host
|
||||
OT_COAP_OPTION_E_TAG = 4, ///< ETag
|
||||
OT_COAP_OPTION_IF_NONE_MATCH = 5, ///< If-None-Match
|
||||
OT_COAP_OPTION_OBSERVE = 6, ///< Observe
|
||||
OT_COAP_OPTION_URI_PORT = 7, ///< Uri-Port
|
||||
OT_COAP_OPTION_LOCATION_PATH = 8, ///< Location-Path
|
||||
OT_COAP_OPTION_URI_PATH = 11, ///< Uri-Path
|
||||
OT_COAP_OPTION_CONTENT_FORMAT = 12, ///< Content-Format
|
||||
OT_COAP_OPTION_MAX_AGE = 14, ///< Max-Age
|
||||
OT_COAP_OPTION_URI_QUERY = 15, ///< Uri-Query
|
||||
OT_COAP_OPTION_ACCEPT = 17, ///< Accept
|
||||
OT_COAP_OPTION_LOCATION_QUERY = 20, ///< Location-Query
|
||||
OT_COAP_OPTION_PROXY_URI = 35, ///< Proxy-Uri
|
||||
OT_COAP_OPTION_PROXY_SCHEME = 39, ///< Proxy-Scheme
|
||||
OT_COAP_OPTION_SIZE1 = 60, ///< Size1
|
||||
} otCoapOptionType;
|
||||
|
||||
/**
|
||||
|
||||
+21
-21
@@ -182,7 +182,7 @@ void Coap::HandleServerResponse(otCoapHeader *aHeader, otMessage *aMessage, otMe
|
||||
otError error = OT_ERROR_NONE;
|
||||
otCoapHeader responseHeader;
|
||||
otMessage *responseMessage;
|
||||
otCoapCode responseCode = kCoapCodeEmpty;
|
||||
otCoapCode responseCode = OT_COAP_CODE_EMPTY;
|
||||
char responseContent = '0';
|
||||
|
||||
sServer->OutputFormat("Received CoAP request from [%x:%x:%x:%x:%x:%x:%x:%x]: ",
|
||||
@@ -197,19 +197,19 @@ void Coap::HandleServerResponse(otCoapHeader *aHeader, otMessage *aMessage, otMe
|
||||
|
||||
switch (otCoapHeaderGetCode(aHeader))
|
||||
{
|
||||
case kCoapRequestGet:
|
||||
case OT_COAP_CODE_GET:
|
||||
sServer->OutputFormat("GET");
|
||||
break;
|
||||
|
||||
case kCoapRequestDelete:
|
||||
case OT_COAP_CODE_DELETE:
|
||||
sServer->OutputFormat("DELETE");
|
||||
break;
|
||||
|
||||
case kCoapRequestPut:
|
||||
case OT_COAP_CODE_PUT:
|
||||
sServer->OutputFormat("PUT");
|
||||
break;
|
||||
|
||||
case kCoapRequestPost:
|
||||
case OT_COAP_CODE_POST:
|
||||
sServer->OutputFormat("POST");
|
||||
break;
|
||||
|
||||
@@ -220,22 +220,22 @@ void Coap::HandleServerResponse(otCoapHeader *aHeader, otMessage *aMessage, otMe
|
||||
|
||||
PrintPayload(aMessage);
|
||||
|
||||
if ((otCoapHeaderGetType(aHeader) == kCoapTypeConfirmable) || otCoapHeaderGetCode(aHeader) == kCoapRequestGet)
|
||||
if ((otCoapHeaderGetType(aHeader) == OT_COAP_TYPE_CONFIRMABLE) || otCoapHeaderGetCode(aHeader) == OT_COAP_CODE_GET)
|
||||
{
|
||||
if (otCoapHeaderGetCode(aHeader) == kCoapRequestGet)
|
||||
if (otCoapHeaderGetCode(aHeader) == OT_COAP_CODE_GET)
|
||||
{
|
||||
responseCode = kCoapResponseContent;
|
||||
responseCode = OT_COAP_CODE_CONTENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
responseCode = kCoapResponseValid;
|
||||
responseCode = OT_COAP_CODE_VALID;
|
||||
}
|
||||
|
||||
otCoapHeaderInit(&responseHeader, kCoapTypeAcknowledgment, responseCode);
|
||||
otCoapHeaderInit(&responseHeader, OT_COAP_TYPE_ACKNOWLEDGMENT, responseCode);
|
||||
otCoapHeaderSetMessageId(&responseHeader, otCoapHeaderGetMessageId(aHeader));
|
||||
otCoapHeaderSetToken(&responseHeader, otCoapHeaderGetToken(aHeader), otCoapHeaderGetTokenLength(aHeader));
|
||||
|
||||
if (otCoapHeaderGetCode(aHeader) == kCoapRequestGet)
|
||||
if (otCoapHeaderGetCode(aHeader) == OT_COAP_CODE_GET)
|
||||
{
|
||||
otCoapHeaderSetPayloadMarker(&responseHeader);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ void Coap::HandleServerResponse(otCoapHeader *aHeader, otMessage *aMessage, otMe
|
||||
responseMessage = otCoapNewMessage(sInstance, &responseHeader);
|
||||
VerifyOrExit(responseMessage != NULL, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
if (otCoapHeaderGetCode(aHeader) == kCoapRequestGet)
|
||||
if (otCoapHeaderGetCode(aHeader) == OT_COAP_CODE_GET)
|
||||
{
|
||||
SuccessOrExit(error = otMessageAppend(responseMessage, &responseContent, sizeof(responseContent)));
|
||||
}
|
||||
@@ -260,7 +260,7 @@ exit:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (responseCode >= kCoapResponseCodeMin)
|
||||
if (responseCode >= OT_COAP_CODE_RESPONSE_MIN)
|
||||
{
|
||||
sServer->OutputFormat("CoAP response sent successfully!\r\n");
|
||||
}
|
||||
@@ -277,8 +277,8 @@ otError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
// Default parameters
|
||||
char coapUri[kMaxUriLength] = "test";
|
||||
otCoapType coapType = kCoapTypeNonConfirmable;
|
||||
otCoapCode coapCode = kCoapRequestGet;
|
||||
otCoapType coapType = OT_COAP_TYPE_NON_CONFIRMABLE;
|
||||
otCoapCode coapCode = OT_COAP_CODE_GET;
|
||||
otIp6Address coapDestinationIp;
|
||||
|
||||
VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS);
|
||||
@@ -288,19 +288,19 @@ otError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
if (strcmp(argv[0], "get") == 0)
|
||||
{
|
||||
coapCode = kCoapRequestGet;
|
||||
coapCode = OT_COAP_CODE_GET;
|
||||
}
|
||||
else if (strcmp(argv[0], "post") == 0)
|
||||
{
|
||||
coapCode = kCoapRequestPost;
|
||||
coapCode = OT_COAP_CODE_POST;
|
||||
}
|
||||
else if (strcmp(argv[0], "put") == 0)
|
||||
{
|
||||
coapCode = kCoapRequestPut;
|
||||
coapCode = OT_COAP_CODE_PUT;
|
||||
}
|
||||
else if (strcmp(argv[0], "delete") == 0)
|
||||
{
|
||||
coapCode = kCoapRequestDelete;
|
||||
coapCode = OT_COAP_CODE_DELETE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -334,7 +334,7 @@ otError Coap::ProcessClient(int argc, char *argv[])
|
||||
|
||||
if (strcmp(argv[3], "con") == 0)
|
||||
{
|
||||
coapType = kCoapTypeConfirmable;
|
||||
coapType = OT_COAP_TYPE_CONFIRMABLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ otError Coap::ProcessClient(int argc, char *argv[])
|
||||
messageInfo.mPeerPort = OT_DEFAULT_COAP_PORT;
|
||||
messageInfo.mInterfaceId = OT_NETIF_INTERFACE_ID_THREAD;
|
||||
|
||||
if ((coapType == kCoapTypeConfirmable) || coapCode == kCoapRequestGet)
|
||||
if ((coapType == OT_COAP_TYPE_CONFIRMABLE) || coapCode == OT_COAP_CODE_GET)
|
||||
{
|
||||
error = otCoapSendRequest(sInstance, message, &messageInfo,
|
||||
(otCoapResponseHandler) &Coap::s_HandleClientResponse, NULL);
|
||||
|
||||
+17
-17
@@ -172,8 +172,8 @@ otError Coap::SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageInf
|
||||
|
||||
SuccessOrExit(error = header.FromMessage(aMessage, 0));
|
||||
|
||||
if ((header.GetType() == kCoapTypeAcknowledgment || header.GetType() == kCoapTypeReset) &&
|
||||
header.GetCode() != kCoapCodeEmpty)
|
||||
if ((header.GetType() == OT_COAP_TYPE_ACKNOWLEDGMENT || header.GetType() == OT_COAP_TYPE_RESET) &&
|
||||
header.GetCode() != OT_COAP_CODE_EMPTY)
|
||||
{
|
||||
mResponsesQueue.EnqueueResponse(aMessage, aMessageInfo);
|
||||
}
|
||||
@@ -227,9 +227,9 @@ otError Coap::SendEmptyMessage(Header::Type aType, const Header &aRequestHeader,
|
||||
Header responseHeader;
|
||||
Message *message = NULL;
|
||||
|
||||
VerifyOrExit(aRequestHeader.GetType() == kCoapTypeConfirmable, error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(aRequestHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
responseHeader.Init(aType, kCoapCodeEmpty);
|
||||
responseHeader.Init(aType, OT_COAP_CODE_EMPTY);
|
||||
responseHeader.SetMessageId(aRequestHeader.GetMessageId());
|
||||
|
||||
VerifyOrExit((message = NewMessage(responseHeader)) != NULL, error = OT_ERROR_NO_BUFS);
|
||||
@@ -260,13 +260,13 @@ otError Coap::SendHeaderResponse(Header::Code aCode, const Header &aRequestHeade
|
||||
|
||||
switch (requestType)
|
||||
{
|
||||
case kCoapTypeConfirmable:
|
||||
responseHeader.Init(kCoapTypeAcknowledgment, aCode);
|
||||
case OT_COAP_TYPE_CONFIRMABLE:
|
||||
responseHeader.Init(OT_COAP_TYPE_ACKNOWLEDGMENT, aCode);
|
||||
responseHeader.SetMessageId(aRequestHeader.GetMessageId());
|
||||
break;
|
||||
|
||||
case kCoapTypeNonConfirmable:
|
||||
responseHeader.Init(kCoapTypeNonConfirmable, aCode);
|
||||
case OT_COAP_TYPE_NON_CONFIRMABLE:
|
||||
responseHeader.Init(OT_COAP_TYPE_NON_CONFIRMABLE, aCode);
|
||||
responseHeader.SetMessageId(mMessageId++);
|
||||
break;
|
||||
|
||||
@@ -494,8 +494,8 @@ Message *Coap::FindRelatedRequest(const Header &aResponseHeader, const Ip6::Mess
|
||||
|
||||
switch (aResponseHeader.GetType())
|
||||
{
|
||||
case kCoapTypeReset:
|
||||
case kCoapTypeAcknowledgment:
|
||||
case OT_COAP_TYPE_RESET:
|
||||
case OT_COAP_TYPE_ACKNOWLEDGMENT:
|
||||
if (aResponseHeader.GetMessageId() == aRequestHeader.GetMessageId())
|
||||
{
|
||||
ExitNow();
|
||||
@@ -503,8 +503,8 @@ Message *Coap::FindRelatedRequest(const Header &aResponseHeader, const Ip6::Mess
|
||||
|
||||
break;
|
||||
|
||||
case kCoapTypeConfirmable:
|
||||
case kCoapTypeNonConfirmable:
|
||||
case OT_COAP_TYPE_CONFIRMABLE:
|
||||
case OT_COAP_TYPE_NON_CONFIRMABLE:
|
||||
if (aResponseHeader.IsTokenEqual(aRequestHeader))
|
||||
{
|
||||
ExitNow();
|
||||
@@ -570,7 +570,7 @@ void Coap::ProcessReceivedResponse(Header &aResponseHeader, Message &aMessage,
|
||||
|
||||
switch (aResponseHeader.GetType())
|
||||
{
|
||||
case kCoapTypeReset:
|
||||
case OT_COAP_TYPE_RESET:
|
||||
if (aResponseHeader.IsEmpty())
|
||||
{
|
||||
FinalizeCoapTransaction(*message, coapMetadata, NULL, NULL, NULL, OT_ERROR_ABORT);
|
||||
@@ -579,7 +579,7 @@ void Coap::ProcessReceivedResponse(Header &aResponseHeader, Message &aMessage,
|
||||
// Silently ignore non-empty reset messages (RFC 7252, p. 4.2).
|
||||
break;
|
||||
|
||||
case kCoapTypeAcknowledgment:
|
||||
case OT_COAP_TYPE_ACKNOWLEDGMENT:
|
||||
if (aResponseHeader.IsEmpty())
|
||||
{
|
||||
// Empty acknowledgment.
|
||||
@@ -605,14 +605,14 @@ void Coap::ProcessReceivedResponse(Header &aResponseHeader, Message &aMessage,
|
||||
// or with no token match (RFC 7252, p. 5.3.2)
|
||||
break;
|
||||
|
||||
case kCoapTypeConfirmable:
|
||||
case OT_COAP_TYPE_CONFIRMABLE:
|
||||
// Send empty ACK if it is a CON message.
|
||||
SendAck(aResponseHeader, aMessageInfo);
|
||||
|
||||
// fall through
|
||||
;
|
||||
|
||||
case kCoapTypeNonConfirmable:
|
||||
case OT_COAP_TYPE_NON_CONFIRMABLE:
|
||||
// Separate response.
|
||||
FinalizeCoapTransaction(*message, coapMetadata, &aResponseHeader, &aMessage, &aMessageInfo, OT_ERROR_NONE);
|
||||
|
||||
@@ -667,7 +667,7 @@ void Coap::ProcessReceivedRequest(Header &aHeader, Message &aMessage, const Ip6:
|
||||
{
|
||||
switch (coapOption->mNumber)
|
||||
{
|
||||
case kCoapOptionUriPath:
|
||||
case OT_COAP_OPTION_URI_PATH:
|
||||
if (curUriPath != uriPath)
|
||||
{
|
||||
*curUriPath++ = '/';
|
||||
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
*
|
||||
*/
|
||||
otError SendReset(Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo) {
|
||||
return SendEmptyMessage(kCoapTypeReset, aRequestHeader, aMessageInfo);
|
||||
return SendEmptyMessage(OT_COAP_TYPE_RESET, aRequestHeader, aMessageInfo);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -568,7 +568,7 @@ public:
|
||||
*
|
||||
*/
|
||||
otError SendAck(Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo) {
|
||||
return SendEmptyMessage(kCoapTypeAcknowledgment, aRequestHeader, aMessageInfo);
|
||||
return SendEmptyMessage(OT_COAP_TYPE_ACKNOWLEDGMENT, aRequestHeader, aMessageInfo);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -583,8 +583,8 @@ public:
|
||||
*
|
||||
*/
|
||||
otError SendEmptyAck(const Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo) {
|
||||
return (aRequestHeader.GetType() == kCoapTypeConfirmable ?
|
||||
SendHeaderResponse(kCoapResponseChanged, aRequestHeader, aMessageInfo) :
|
||||
return (aRequestHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE ?
|
||||
SendHeaderResponse(OT_COAP_CODE_CHANGED, aRequestHeader, aMessageInfo) :
|
||||
OT_ERROR_INVALID_ARGS);
|
||||
}
|
||||
|
||||
@@ -599,7 +599,7 @@ public:
|
||||
*
|
||||
*/
|
||||
otError SendNotFound(const Header &aRequestHeader, const Ip6::MessageInfo &aMessageInfo) {
|
||||
return SendHeaderResponse(kCoapResponseNotFound, aRequestHeader, aMessageInfo);
|
||||
return SendHeaderResponse(OT_COAP_CODE_NOT_FOUND, aRequestHeader, aMessageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -289,7 +289,7 @@ otError Header::AppendUintOption(uint16_t aNumber, uint32_t aValue)
|
||||
|
||||
otError Header::AppendObserveOption(uint32_t aObserve)
|
||||
{
|
||||
return AppendUintOption(kCoapOptionObserve, aObserve & 0xFFFFFF);
|
||||
return AppendUintOption(OT_COAP_OPTION_OBSERVE, aObserve & 0xFFFFFF);
|
||||
}
|
||||
|
||||
otError Header::AppendUriPathOptions(const char *aUriPath)
|
||||
@@ -299,7 +299,7 @@ otError Header::AppendUriPathOptions(const char *aUriPath)
|
||||
const char *end;
|
||||
Header::Option coapOption;
|
||||
|
||||
coapOption.mNumber = kCoapOptionUriPath;
|
||||
coapOption.mNumber = OT_COAP_OPTION_URI_PATH;
|
||||
|
||||
while ((end = strchr(cur, '/')) != NULL)
|
||||
{
|
||||
@@ -319,19 +319,19 @@ exit:
|
||||
|
||||
otError Header::AppendContentFormatOption(MediaType aType)
|
||||
{
|
||||
return AppendUintOption(kCoapOptionContentFormat, aType);
|
||||
return AppendUintOption(OT_COAP_OPTION_CONTENT_FORMAT, aType);
|
||||
}
|
||||
|
||||
otError Header::AppendMaxAgeOption(uint32_t aMaxAge)
|
||||
{
|
||||
return AppendUintOption(kCoapOptionMaxAge, aMaxAge);
|
||||
return AppendUintOption(OT_COAP_OPTION_MAX_AGE, aMaxAge);
|
||||
}
|
||||
|
||||
otError Header::AppendUriQueryOption(const char *aUriQuery)
|
||||
{
|
||||
Option coapOption;
|
||||
|
||||
coapOption.mNumber = kCoapOptionUriQuery;
|
||||
coapOption.mNumber = OT_COAP_OPTION_URI_QUERY;
|
||||
coapOption.mLength = static_cast<uint16_t>(strlen(aUriQuery));
|
||||
coapOption.mValue = reinterpret_cast<const uint8_t *>(aUriQuery);
|
||||
|
||||
@@ -442,7 +442,7 @@ void Header::SetToken(uint8_t aTokenLength)
|
||||
|
||||
void Header::SetDefaultResponseHeader(const Header &aRequestHeader)
|
||||
{
|
||||
Init(kCoapTypeAcknowledgment, kCoapResponseChanged);
|
||||
Init(OT_COAP_TYPE_ACKNOWLEDGMENT, OT_COAP_CODE_CHANGED);
|
||||
SetMessageId(aRequestHeader.GetMessageId());
|
||||
SetToken(aRequestHeader.GetToken(), aRequestHeader.GetTokenLength());
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ public:
|
||||
* @retval FALSE Header is not a request header.
|
||||
*
|
||||
*/
|
||||
bool IsRequest(void) const { return (GetCode() >= kCoapRequestGet && GetCode() <= kCoapRequestDelete); };
|
||||
bool IsRequest(void) const { return (GetCode() >= OT_COAP_CODE_GET && GetCode() <= OT_COAP_CODE_DELETE); };
|
||||
|
||||
/**
|
||||
* This method checks if a header is a response header.
|
||||
@@ -427,7 +427,7 @@ public:
|
||||
* @retval FALSE Header is not a response header.
|
||||
*
|
||||
*/
|
||||
bool IsResponse(void) const { return (GetCode() >= kCoapResponseCodeMin); };
|
||||
bool IsResponse(void) const { return (GetCode() >= OT_COAP_CODE_RESPONSE_MIN); };
|
||||
|
||||
/**
|
||||
* This method checks if a header is a CON message header.
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
* @retval FALSE Header is not is a CON message header.
|
||||
*
|
||||
*/
|
||||
bool IsConfirmable(void) const { return (GetType() == kCoapTypeConfirmable); };
|
||||
bool IsConfirmable(void) const { return (GetType() == OT_COAP_TYPE_CONFIRMABLE); };
|
||||
|
||||
/**
|
||||
* This method checks if a header is a NON message header.
|
||||
@@ -445,7 +445,7 @@ public:
|
||||
* @retval FALSE Header is not is a NON message header.
|
||||
*
|
||||
*/
|
||||
bool IsNonConfirmable(void) const { return (GetType() == kCoapTypeNonConfirmable); };
|
||||
bool IsNonConfirmable(void) const { return (GetType() == OT_COAP_TYPE_NON_CONFIRMABLE); };
|
||||
|
||||
/**
|
||||
* This method checks if a header is a ACK message header.
|
||||
@@ -454,7 +454,7 @@ public:
|
||||
* @retval FALSE Header is not is a ACK message header.
|
||||
*
|
||||
*/
|
||||
bool IsAck(void) const { return (GetType() == kCoapTypeAcknowledgment); };
|
||||
bool IsAck(void) const { return (GetType() == OT_COAP_TYPE_ACKNOWLEDGMENT); };
|
||||
|
||||
/**
|
||||
* This method checks if a header is a RST message header.
|
||||
@@ -463,7 +463,7 @@ public:
|
||||
* @retval FALSE Header is not is a RST message header.
|
||||
*
|
||||
*/
|
||||
bool IsReset(void) const { return (GetType() == kCoapTypeReset); };
|
||||
bool IsReset(void) const { return (GetType() == OT_COAP_TYPE_RESET); };
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -81,8 +81,8 @@ otError AnnounceBeginClient::SendRequest(uint32_t aChannelMask, uint8_t aCount,
|
||||
|
||||
VerifyOrExit(mNetif.GetCommissioner().IsActive(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
header.Init(aAddress.IsMulticast() ? kCoapTypeNonConfirmable : kCoapTypeConfirmable,
|
||||
kCoapRequestPost);
|
||||
header.Init(aAddress.IsMulticast() ? OT_COAP_TYPE_NON_CONFIRMABLE : OT_COAP_TYPE_CONFIRMABLE,
|
||||
OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ANNOUNCE_BEGIN);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -411,7 +411,7 @@ otError Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs,
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_COMMISSIONER_GET);
|
||||
|
||||
@@ -465,7 +465,7 @@ void Commissioner::HandleMgmtCommissisonerGetResponse(Coap::Header *aHeader, Mes
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == kCoapResponseChanged);
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED);
|
||||
otLogInfoMeshCoP(GetInstance(), "received MGMT_COMMISSIONER_GET response");
|
||||
|
||||
exit:
|
||||
@@ -482,7 +482,7 @@ otError Commissioner::SendMgmtCommissionerSetRequest(const otCommissioningDatase
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_COMMISSIONER_SET);
|
||||
header.SetPayloadMarker();
|
||||
@@ -568,7 +568,7 @@ void Commissioner::HandleMgmtCommissisonerSetResponse(Coap::Header *aHeader, Mes
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == kCoapResponseChanged);
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED);
|
||||
otLogInfoMeshCoP(GetInstance(), "received MGMT_COMMISSIONER_SET response");
|
||||
|
||||
exit:
|
||||
@@ -587,7 +587,7 @@ otError Commissioner::SendPetition(void)
|
||||
|
||||
mTransmitAttempts++;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_LEADER_PETITION);
|
||||
header.SetPayloadMarker();
|
||||
@@ -639,7 +639,7 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Header *aHeader, Message *
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mState == OT_COMMISSIONER_STATE_PETITION, mState = OT_COMMISSIONER_STATE_DISABLED);
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == kCoapResponseChanged, retransmit = true);
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED, retransmit = true);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "received Leader Petition response");
|
||||
|
||||
@@ -686,7 +686,7 @@ otError Commissioner::SendKeepAlive(void)
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_LEADER_KEEP_ALIVE);
|
||||
header.SetPayloadMarker();
|
||||
@@ -738,7 +738,7 @@ void Commissioner::HandleLeaderKeepAliveResponse(Coap::Header *aHeader, Message
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, mState = OT_COMMISSIONER_STATE_DISABLED);
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == kCoapResponseChanged,
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED,
|
||||
mState = OT_COMMISSIONER_STATE_DISABLED);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "received Leader Petition response");
|
||||
@@ -783,8 +783,8 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage,
|
||||
|
||||
VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeNonConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_NON_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
SuccessOrExit(error = Tlv::GetTlv(aMessage, Tlv::kJoinerUdpPort, sizeof(joinerPort), joinerPort));
|
||||
VerifyOrExit(joinerPort.IsValid(), error = OT_ERROR_PARSE);
|
||||
@@ -861,8 +861,8 @@ void Commissioner::HandleDatasetChanged(void *aContext, otCoapHeader *aHeader, o
|
||||
void Commissioner::HandleDatasetChanged(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "received dataset changed");
|
||||
(void)aMessage;
|
||||
@@ -991,7 +991,7 @@ otError Commissioner::SendRelayTransmit(Message &aMessage, const Ip6::MessageInf
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeNonConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_RELAY_TX);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ otError DatasetManager::Register(void)
|
||||
Message *message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriSet);
|
||||
header.SetPayloadMarker();
|
||||
@@ -593,7 +593,7 @@ otError DatasetManager::SendSetRequest(const otOperationalDataset &aDataset, con
|
||||
Message *message;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriSet);
|
||||
header.SetPayloadMarker();
|
||||
@@ -751,7 +751,7 @@ otError DatasetManager::SendGetRequest(const uint8_t *aTlvTypes, uint8_t aLength
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Tlv tlv;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(mUriGet);
|
||||
|
||||
|
||||
@@ -90,8 +90,8 @@ otError EnergyScanClient::SendQuery(uint32_t aChannelMask, uint8_t aCount, uint1
|
||||
|
||||
VerifyOrExit(mNetif.GetCommissioner().IsActive(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
header.Init(aAddress.IsMulticast() ? kCoapTypeNonConfirmable : kCoapTypeConfirmable,
|
||||
kCoapRequestPost);
|
||||
header.Init(aAddress.IsMulticast() ? OT_COAP_TYPE_NON_CONFIRMABLE : OT_COAP_TYPE_CONFIRMABLE,
|
||||
OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ENERGY_SCAN);
|
||||
header.SetPayloadMarker();
|
||||
@@ -160,8 +160,8 @@ void EnergyScanClient::HandleReport(Coap::Header &aHeader, Message &aMessage, co
|
||||
uint8_t list[OPENTHREAD_CONFIG_MAX_ENERGY_RESULTS];
|
||||
} OT_TOOL_PACKED_END energyList;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "received energy scan report");
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ void Joiner::SendJoinerFinalize(void)
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_JOINER_FINALIZE);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -366,8 +366,8 @@ void Joiner::HandleJoinerFinalizeResponse(Coap::Header *aHeader, Message *aMessa
|
||||
|
||||
VerifyOrExit(mState == kStateConnected &&
|
||||
aResult == OT_ERROR_NONE &&
|
||||
aHeader->GetType() == kCoapTypeAcknowledgment &&
|
||||
aHeader->GetCode() == kCoapResponseChanged);
|
||||
aHeader->GetType() == OT_COAP_TYPE_ACKNOWLEDGMENT &&
|
||||
aHeader->GetCode() == OT_COAP_CODE_CHANGED);
|
||||
|
||||
SuccessOrExit(Tlv::GetTlv(*aMessage, Tlv::kState, sizeof(state), state));
|
||||
VerifyOrExit(state.IsValid());
|
||||
@@ -411,8 +411,8 @@ void Joiner::HandleJoinerEntrust(Coap::Header &aHeader, Message &aMessage, const
|
||||
otLogFuncEntry();
|
||||
|
||||
VerifyOrExit(mState == kStateEntrust &&
|
||||
aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost, error = OT_ERROR_DROP);
|
||||
aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST, error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "Received joiner entrust");
|
||||
otLogCertMeshCoP(GetInstance(), "[THCI] direction=recv | type=JOIN_ENT.ntf");
|
||||
|
||||
@@ -178,7 +178,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
|
||||
SuccessOrExit(error = GetBorderAgentRloc(borderAgentRloc));
|
||||
|
||||
header.Init(kCoapTypeNonConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_RELAY_RX);
|
||||
header.SetPayloadMarker();
|
||||
@@ -256,8 +256,8 @@ void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage,
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
otLogFuncEntry();
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeNonConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost, error = OT_ERROR_DROP);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_NON_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST, error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "Received relay transmit");
|
||||
|
||||
@@ -337,7 +337,7 @@ otError JoinerRouter::DelaySendingJoinerEntrust(const Ip6::MessageInfo &aMessage
|
||||
|
||||
otLogFuncEntry();
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_JOINER_ENTRUST);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -524,7 +524,7 @@ void JoinerRouter::HandleJoinerEntrustResponse(Coap::Header *aHeader, Message *a
|
||||
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader != NULL && aMessage != NULL);
|
||||
|
||||
VerifyOrExit(aHeader->GetCode() == kCoapResponseChanged);
|
||||
VerifyOrExit(aHeader->GetCode() == OT_COAP_CODE_CHANGED);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "Receive joiner entrust response");
|
||||
otLogCertMeshCoP(GetInstance(), "[THCI] direction=recv | type=JOIN_ENT.rsp");
|
||||
|
||||
@@ -247,7 +247,7 @@ otError Leader::SendDatasetChanged(const Ip6::Address &aAddress)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Message *message;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_DATASET_CHANGED);
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ otError PanIdQueryClient::SendQuery(uint16_t aPanId, uint32_t aChannelMask, cons
|
||||
|
||||
VerifyOrExit(mNetif.GetCommissioner().IsActive(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
header.Init(aAddress.IsMulticast() ? kCoapTypeNonConfirmable : kCoapTypeConfirmable,
|
||||
kCoapRequestPost);
|
||||
header.Init(aAddress.IsMulticast() ? OT_COAP_TYPE_NON_CONFIRMABLE : OT_COAP_TYPE_CONFIRMABLE,
|
||||
OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_PANID_QUERY);
|
||||
header.SetPayloadMarker();
|
||||
@@ -139,8 +139,8 @@ void PanIdQueryClient::HandleConflict(Coap::Header &aHeader, Message &aMessage,
|
||||
MeshCoP::ChannelMask0Tlv channelMask;
|
||||
Ip6::MessageInfo responseInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoMeshCoP(GetInstance(), "received panid conflict");
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ otError AddressResolver::SendAddressQuery(const Ip6::Address &aEid)
|
||||
ThreadTargetTlv targetTlv;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(kCoapTypeNonConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ADDRESS_QUERY);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -295,8 +295,8 @@ void AddressResolver::HandleAddressNotification(Coap::Header &aHeader, Message &
|
||||
ThreadLastTransactionTimeTlv lastTransactionTimeTlv;
|
||||
uint32_t lastTransactionTime;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoArp(GetInstance(), "Received address notification from %04x",
|
||||
HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
@@ -377,8 +377,8 @@ otError AddressResolver::SendAddressError(const ThreadTargetTlv &aTarget, const
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(aDestination == NULL ? kCoapTypeNonConfirmable : kCoapTypeConfirmable,
|
||||
kCoapRequestPost);
|
||||
header.Init(aDestination == NULL ? OT_COAP_TYPE_NON_CONFIRMABLE : OT_COAP_TYPE_CONFIRMABLE,
|
||||
OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ADDRESS_ERROR);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -434,8 +434,8 @@ void AddressResolver::HandleAddressError(Coap::Header &aHeader, Message &aMessag
|
||||
Mac::ExtAddress macAddr;
|
||||
Ip6::Address destination;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost, error = OT_ERROR_DROP);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST, error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoArp(GetInstance(), "Received address error notification");
|
||||
|
||||
@@ -515,8 +515,8 @@ void AddressResolver::HandleAddressQuery(Coap::Header &aHeader, Message &aMessag
|
||||
Child *children;
|
||||
uint8_t numChildren;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeNonConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_NON_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoArp(GetInstance(), "Received address query from %04x", HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
|
||||
|
||||
@@ -574,7 +574,7 @@ void AddressResolver::SendAddressQueryResponse(const ThreadTargetTlv &aTargetTlv
|
||||
ThreadRloc16Tlv rloc16Tlv;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ADDRESS_NOTIFY);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ void AnnounceBeginServer::HandleRequest(Coap::Header &aHeader, Message &aMessage
|
||||
MeshCoP::PeriodTlv period;
|
||||
Ip6::MessageInfo responseInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask));
|
||||
VerifyOrExit(channelMask.IsValid());
|
||||
|
||||
@@ -93,7 +93,7 @@ void EnergyScanServer::HandleRequest(Coap::Header &aHeader, Message &aMessage, c
|
||||
MeshCoP::ChannelMask0Tlv channelMask;
|
||||
Ip6::MessageInfo responseInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kCount, sizeof(count), count));
|
||||
VerifyOrExit(count.IsValid());
|
||||
@@ -199,7 +199,7 @@ otError EnergyScanServer::SendReport(void)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Message *message;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ENERGY_REPORT);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -3807,7 +3807,7 @@ otError MleRouter::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Message *message;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ADDRESS_SOLICIT);
|
||||
header.SetPayloadMarker();
|
||||
@@ -3857,7 +3857,7 @@ otError MleRouter::SendAddressRelease(void)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Message *message;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_ADDRESS_RELEASE);
|
||||
header.SetPayloadMarker();
|
||||
@@ -3913,7 +3913,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe
|
||||
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE && aHeader != NULL && aMessage != NULL);
|
||||
|
||||
VerifyOrExit(aHeader->GetCode() == kCoapResponseChanged);
|
||||
VerifyOrExit(aHeader->GetCode() == OT_COAP_CODE_CHANGED);
|
||||
|
||||
otLogInfoMle(GetInstance(), "Received address reply");
|
||||
|
||||
@@ -4034,7 +4034,7 @@ void MleRouter::HandleAddressSolicit(Coap::Header &aHeader, Message &aMessage, c
|
||||
uint8_t routerId = kInvalidRouterId;
|
||||
Router *router = NULL;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable && aHeader.GetCode() == kCoapRequestPost,
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE && aHeader.GetCode() == OT_COAP_CODE_POST,
|
||||
error = OT_ERROR_PARSE);
|
||||
|
||||
otLogInfoMle(GetInstance(), "Received address solicit");
|
||||
@@ -4195,8 +4195,8 @@ void MleRouter::HandleAddressRelease(Coap::Header &aHeader, Message &aMessage,
|
||||
uint8_t routerId;
|
||||
Router *router;
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoMle(GetInstance(), "Received address release");
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ otError NetworkData::SendServerDataNotification(uint16_t aRloc16)
|
||||
VerifyOrExit(!mLastAttemptWait || static_cast<int32_t>(Timer::GetNow() - mLastAttempt) < kDataResubmitDelay,
|
||||
error = OT_ERROR_ALREADY);
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_SERVER_DATA);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
@@ -103,14 +103,14 @@ otError NetworkDiagnostic::SendDiagnosticGet(const Ip6::Address &aDestination, c
|
||||
|
||||
if (aDestination.IsMulticast())
|
||||
{
|
||||
header.Init(kCoapTypeNonConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_DIAGNOSTIC_GET_QUERY);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler = &NetworkDiagnostic::HandleDiagnosticGetResponse;
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_DIAGNOSTIC_GET_REQUEST);
|
||||
}
|
||||
@@ -157,7 +157,7 @@ void NetworkDiagnostic::HandleDiagnosticGetResponse(Coap::Header &aHeader, Messa
|
||||
otError aResult)
|
||||
{
|
||||
VerifyOrExit(aResult == OT_ERROR_NONE);
|
||||
VerifyOrExit(aHeader.GetCode() == kCoapResponseChanged);
|
||||
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_CHANGED);
|
||||
|
||||
otLogInfoNetDiag(GetInstance(), "Received diagnostic get response");
|
||||
|
||||
@@ -181,8 +181,8 @@ void NetworkDiagnostic::HandleDiagnosticGetAnswer(void *aContext, otCoapHeader *
|
||||
void NetworkDiagnostic::HandleDiagnosticGetAnswer(Coap::Header &aHeader, Message &aMessage,
|
||||
const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
otLogInfoNetDiag(GetInstance(), "Diagnostic get answer received");
|
||||
|
||||
@@ -444,7 +444,7 @@ void NetworkDiagnostic::HandleDiagnosticGetQuery(Coap::Header &aHeader, Message
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
VerifyOrExit(aHeader.GetCode() == kCoapRequestPost, error = OT_ERROR_DROP);
|
||||
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST, error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoNetDiag(GetInstance(), "Received diagnostic get query");
|
||||
|
||||
@@ -456,7 +456,7 @@ void NetworkDiagnostic::HandleDiagnosticGetQuery(Coap::Header &aHeader, Message
|
||||
VerifyOrExit((static_cast<TypeListTlv *>(&networkDiagnosticTlv)->IsValid()), error = OT_ERROR_DROP);
|
||||
|
||||
// DIAG_GET.qry may be sent as a confirmable message.
|
||||
if (aHeader.GetType() == kCoapTypeConfirmable)
|
||||
if (aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE)
|
||||
{
|
||||
if (mNetif.GetCoap().SendEmptyAck(aHeader, aMessageInfo) == OT_ERROR_NONE)
|
||||
{
|
||||
@@ -464,7 +464,7 @@ void NetworkDiagnostic::HandleDiagnosticGetQuery(Coap::Header &aHeader, Message
|
||||
}
|
||||
}
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_DIAGNOSTIC_GET_ANSWER);
|
||||
|
||||
@@ -511,8 +511,8 @@ void NetworkDiagnostic::HandleDiagnosticGetRequest(Coap::Header &aHeader, Messag
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost, error = OT_ERROR_DROP);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST, error = OT_ERROR_DROP);
|
||||
|
||||
otLogInfoNetDiag(GetInstance(), "Received diagnostic get request");
|
||||
|
||||
@@ -556,7 +556,7 @@ otError NetworkDiagnostic::SendDiagnosticReset(const Ip6::Address &aDestination,
|
||||
Coap::Header header;
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_DIAGNOSTIC_RESET);
|
||||
|
||||
@@ -605,8 +605,8 @@ void NetworkDiagnostic::HandleDiagnosticReset(Coap::Header &aHeader, Message &aM
|
||||
|
||||
otLogInfoNetDiag(GetInstance(), "Received diagnostic reset request");
|
||||
|
||||
VerifyOrExit(aHeader.GetType() == kCoapTypeConfirmable &&
|
||||
aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE &&
|
||||
aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
VerifyOrExit((aMessage.Read(aMessage.GetOffset(), sizeof(NetworkDiagnosticTlv),
|
||||
&networkDiagnosticTlv) == sizeof(NetworkDiagnosticTlv)));
|
||||
|
||||
@@ -83,7 +83,7 @@ void PanIdQueryServer::HandleQuery(Coap::Header &aHeader, Message &aMessage, con
|
||||
MeshCoP::ChannelMask0Tlv channelMask;
|
||||
Ip6::MessageInfo responseInfo(aMessageInfo);
|
||||
|
||||
VerifyOrExit(aHeader.GetCode() == kCoapRequestPost);
|
||||
VerifyOrExit(aHeader.GetCode() == OT_COAP_CODE_POST);
|
||||
|
||||
SuccessOrExit(MeshCoP::Tlv::GetTlv(aMessage, MeshCoP::Tlv::kChannelMask, sizeof(channelMask), channelMask));
|
||||
VerifyOrExit(channelMask.IsValid());
|
||||
@@ -139,7 +139,7 @@ otError PanIdQueryServer::SendConflict(void)
|
||||
Ip6::MessageInfo messageInfo;
|
||||
Message *message;
|
||||
|
||||
header.Init(kCoapTypeConfirmable, kCoapRequestPost);
|
||||
header.Init(OT_COAP_TYPE_CONFIRMABLE, OT_COAP_CODE_POST);
|
||||
header.SetToken(Coap::Header::kDefaultTokenLength);
|
||||
header.AppendUriPathOptions(OT_URI_PATH_PANID_CONFLICT);
|
||||
header.SetPayloadMarker();
|
||||
|
||||
Reference in New Issue
Block a user