TSCH: change the return type of the APIs (tsch-security.h)

The return type is changed to "int" to "unsigned int" because APIs
provided by tsch-security are supposed to return an integer larger than
or equal to zero. This change clarifies that.
This commit is contained in:
Yasuyuki Tanaka 2016-12-15 17:07:58 +01:00
parent da853386a6
commit 4faf139523
2 changed files with 11 additions and 9 deletions

View File

@ -125,7 +125,7 @@ tsch_security_check_level(const frame802154_t *frame)
frame->aux_hdr.key_index == required_key_index); frame->aux_hdr.key_index == required_key_index);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int unsigned int
tsch_security_mic_len(const frame802154_t *frame) tsch_security_mic_len(const frame802154_t *frame)
{ {
if(frame != NULL && frame->fcf.security_enabled) { if(frame != NULL && frame->fcf.security_enabled) {
@ -135,7 +135,7 @@ tsch_security_mic_len(const frame802154_t *frame)
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int unsigned int
tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf, tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf,
int hdrlen, int datalen, struct asn_t *asn) int hdrlen, int datalen, struct asn_t *asn)
{ {
@ -198,7 +198,7 @@ tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf,
return mic_len; return mic_len;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int unsigned int
tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen, tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen,
const frame802154_t *frame, const linkaddr_t *sender, struct asn_t *asn) const frame802154_t *frame, const linkaddr_t *sender, struct asn_t *asn)
{ {

View File

@ -122,22 +122,24 @@ typedef uint8_t aes_key[16];
* \brief Return MIC length * \brief Return MIC length
* \return The length of MIC (>= 0) * \return The length of MIC (>= 0)
*/ */
int tsch_security_mic_len(const frame802154_t *frame); unsigned int tsch_security_mic_len(const frame802154_t *frame);
/** /**
* \brief Protect a frame with encryption and/or MIC * \brief Protect a frame with encryption and/or MIC
* \return The length of a generated MIC (>= 0) * \return The length of a generated MIC (>= 0)
*/ */
int tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf, unsigned int tsch_security_secure_frame(uint8_t *hdr, uint8_t *outbuf,
int hdrlen, int datalen, struct asn_t *asn); int hdrlen, int datalen,
struct asn_t *asn);
/** /**
* \brief Parse and check a frame protected with encryption and/or MIC * \brief Parse and check a frame protected with encryption and/or MIC
* \retval 0 On error or security check failure (insecure frame) * \retval 0 On error or security check failure (insecure frame)
* \retval 1 On success or no need for security check (good frame) * \retval 1 On success or no need for security check (good frame)
*/ */
int tsch_security_parse_frame(const uint8_t *hdr, int hdrlen, int datalen, unsigned int tsch_security_parse_frame(const uint8_t *hdr, int hdrlen,
const frame802154_t *frame, int datalen, const frame802154_t *frame,
const linkaddr_t *sender, struct asn_t *asn); const linkaddr_t *sender,
struct asn_t *asn);
#endif /* __TSCH_SECURITY_H__ */ #endif /* __TSCH_SECURITY_H__ */