CoAP option update (#1523)

* Do not drop CoAP requests with unknown options

If packets are dropped due to unrecognized options, then it should be done
according to RFC7252 Section 5.4.1., otherwise leave it for the user.

* Implement CoAP Header GetFirstOption

* Implement in Header
* Add to CoAP API
* Use in code

* Remove CoAP Header GetCurrentOption

* Correction in the comments

* Initialize CoAP Header before parsing
This commit is contained in:
Giedrius
2017-03-29 05:54:43 -07:00
committed by Jonathan Hui
parent 77fed906ac
commit e5d15f1911
5 changed files with 38 additions and 15 deletions
+4 -3
View File
@@ -136,6 +136,7 @@ typedef struct otCoapHeader
} mHeader; ///< The CoAP header encoding
uint8_t mHeaderLength; ///< The CoAP header length (bytes)
uint16_t mOptionLast; ///< The last CoAP Option Number value
uint16_t mFirstOptionOffset; ///< The byte offset for the first CoAP Option
uint16_t mNextOptionOffset; ///< The byte offset for the next CoAP Option
otCoapOption mOption; ///< A structure representing the current CoAP Option.
} otCoapHeader;
@@ -344,14 +345,14 @@ uint8_t otCoapHeaderGetTokenLength(const otCoapHeader *aHeader);
const uint8_t *otCoapHeaderGetToken(const otCoapHeader *aHeader);
/**
* This function returns a pointer to the current option.
* This function returns a pointer to the first option.
*
* @param[in] aHeader A pointer to the CoAP header.
*
* @returns A pointer to the current option. If no option is present NULL pointer is returned.
* @returns A pointer to the first option. If no option is present NULL pointer is returned.
*
*/
const otCoapOption *otCoapHeaderGetCurrentOption(const otCoapHeader *aHeader);
const otCoapOption *otCoapHeaderGetFirstOption(otCoapHeader *aHeader);
/**
* This function returns a pointer to the next option.