mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-03 11:30:53 +00:00
Let the framer functions use ints instead of uint8_t to make them more generic
This commit is contained in:
parent
f5a1ffa90d
commit
4541d3e85b
@ -153,7 +153,7 @@ field_len(frame802154_t *p, field_length_t *flen)
|
|||||||
*
|
*
|
||||||
* \return The length of the frame header.
|
* \return The length of the frame header.
|
||||||
*/
|
*/
|
||||||
uint8_t
|
int
|
||||||
frame802154_hdrlen(frame802154_t *p)
|
frame802154_hdrlen(frame802154_t *p)
|
||||||
{
|
{
|
||||||
field_length_t flen;
|
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
|
* \return The length of the frame header or 0 if there was
|
||||||
* insufficient space in the buffer for the frame headers.
|
* insufficient space in the buffer for the frame headers.
|
||||||
*/
|
*/
|
||||||
uint8_t
|
int
|
||||||
frame802154_create(frame802154_t *p, uint8_t *buf, uint8_t buf_len)
|
frame802154_create(frame802154_t *p, uint8_t *buf, int buf_len)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
field_length_t flen;
|
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; */
|
/* 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 len The size of the input data
|
||||||
* \param pf The frame802154_t struct to store the parsed frame information.
|
* \param pf The frame802154_t struct to store the parsed frame information.
|
||||||
*/
|
*/
|
||||||
uint8_t
|
int
|
||||||
frame802154_parse(uint8_t *data, uint8_t len, frame802154_t *pf)
|
frame802154_parse(uint8_t *data, int len, frame802154_t *pf)
|
||||||
{
|
{
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
frame802154_fcf_t fcf;
|
frame802154_fcf_t fcf;
|
||||||
uint8_t c;
|
int c;
|
||||||
|
|
||||||
if(len < 3) {
|
if(len < 3) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -345,7 +345,7 @@ frame802154_parse(uint8_t *data, uint8_t len, frame802154_t *pf)
|
|||||||
/* header length */
|
/* header length */
|
||||||
c = p - data;
|
c = p - data;
|
||||||
/* payload length */
|
/* payload length */
|
||||||
pf->payload_len = len - c;
|
pf->payload_len = (uint8_t)(0xff & (len - c));
|
||||||
/* payload */
|
/* payload */
|
||||||
pf->payload = p;
|
pf->payload = p;
|
||||||
|
|
||||||
|
@ -160,9 +160,9 @@ typedef struct {
|
|||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
|
||||||
uint8_t frame802154_hdrlen(frame802154_t *p);
|
int frame802154_hdrlen(frame802154_t *p);
|
||||||
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);
|
||||||
uint8_t frame802154_parse(uint8_t *data, uint8_t length, frame802154_t *pf);
|
int frame802154_parse(uint8_t *data, int length, frame802154_t *pf);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif /* FRAME_802154_H */
|
#endif /* FRAME_802154_H */
|
||||||
|
@ -90,7 +90,7 @@ static int
|
|||||||
create(void)
|
create(void)
|
||||||
{
|
{
|
||||||
frame802154_t params;
|
frame802154_t params;
|
||||||
uint8_t len;
|
int len;
|
||||||
|
|
||||||
/* init to zeros */
|
/* init to zeros */
|
||||||
memset(¶ms, 0, sizeof(params));
|
memset(¶ms, 0, sizeof(params));
|
||||||
@ -174,7 +174,7 @@ create(void)
|
|||||||
|
|
||||||
PRINTF("15.4-OUT: %2X", params.fcf.frame_type);
|
PRINTF("15.4-OUT: %2X", params.fcf.frame_type);
|
||||||
PRINTADDR(params.dest_addr.u8);
|
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;
|
return len;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user