Let the framer functions use ints instead of uint8_t to make them more generic

This commit is contained in:
Adam Dunkels 2013-03-17 23:42:06 +01:00
parent f5a1ffa90d
commit 4541d3e85b
3 changed files with 13 additions and 13 deletions

View File

@ -153,7 +153,7 @@ field_len(frame802154_t *p, field_length_t *flen)
*
* \return The length of the frame header.
*/
uint8_t
int
frame802154_hdrlen(frame802154_t *p)
{
field_length_t flen;
@ -176,8 +176,8 @@ frame802154_hdrlen(frame802154_t *p)
* \return The length of the frame header or 0 if there was
* insufficient space in the buffer for the frame headers.
*/
uint8_t
frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len)
int
frame802154_create(frame802154_t *p, uint8_t *buf, int buf_len)
{
int c;
field_length_t flen;
@ -236,7 +236,7 @@ frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len)
/* pos += flen.aux_sec_len; */
}
return pos;
return (int)pos;
}
/*----------------------------------------------------------------------------*/
/**
@ -248,12 +248,12 @@ frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len)
* \param len The size of the input data
* \param pf The frame802154_t struct to store the parsed frame information.
*/
uint8_t
frame802154_parse(uint8_t *data, uint8_t len, frame802154_t *pf)
int
frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
{
uint8_t *p;
frame802154_fcf_t fcf;
uint8_t c;
int c;
if(len < 3) {
return 0;
@ -345,7 +345,7 @@ frame802154_parse(uint8_t *data, uint8_t len, frame802154_t *pf)
/* header length */
c = p - data;
/* payload length */
pf->payload_len = len - c;
pf->payload_len = (uint8_t)(0xff & (len - c));
/* payload */
pf->payload = p;

View File

@ -160,9 +160,9 @@ typedef struct {
/* Prototypes */
uint8_t frame802154_hdrlen(frame802154_t *p);
uint8_t frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len);
uint8_t frame802154_parse(uint8_t *data, uint8_t length, frame802154_t *pf);
int frame802154_hdrlen(frame802154_t *p);
int frame802154_create(frame802154_t *p, uint8_t *buf, int buf_len);
int frame802154_parse(uint8_t *data, int length, frame802154_t *pf);
/** @} */
#endif /* FRAME_802154_H */

View File

@ -90,7 +90,7 @@ static int
create(void)
{
frame802154_t params;
uint8_t len;
int len;
/* init to zeros */
memset(&params, 0, sizeof(params));
@ -174,7 +174,7 @@ create(void)
PRINTF("15.4-OUT: %2X", params.fcf.frame_type);
PRINTADDR(params.dest_addr.u8);
PRINTF("%u %u (%u)\n", len, packetbuf_datalen(), packetbuf_totlen());
PRINTF("%d %u (%u)\n", len, packetbuf_datalen(), packetbuf_totlen());
return len;
} else {