Allow for using a fixed frame header length.

When SICSLOWPAN_FRAMER_HDRLEN is defined its value is used
as a frame header length. This allows for using sicslowpan
without calling a framer. This is usefull if framer is not
used on a given platform or when header length is always
the same.

In addition this commit also fixes an inline define.
This commit is contained in:
Wojciech Bober 2015-10-24 18:21:05 +02:00 committed by Wojciech Bober
parent 4cd0e3ad35
commit 7d60fdc8b5

View file

@ -169,6 +169,14 @@ void uip_log(char *msg);
#define COMPRESSION_THRESHOLD 0 #define COMPRESSION_THRESHOLD 0
#endif #endif
/** \brief Fixed size of a frame header. This value is
* used in case framer returns an error or if SICSLOWPAN_USE_FIXED_HDRLEN
* is defined.
*/
#ifndef SICSLOWPAN_FIXED_HDRLEN
#define SICSLOWPAN_FIXED_HDRLEN 21
#endif
/** \name General variables /** \name General variables
* @{ * @{
*/ */
@ -1345,16 +1353,15 @@ output(const uip_lladdr_t *localdest)
/* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_RDC. /* Calculate NETSTACK_FRAMER's header length, that will be added in the NETSTACK_RDC.
* We calculate it here only to make a better decision of whether the outgoing packet * We calculate it here only to make a better decision of whether the outgoing packet
* needs to be fragmented or not. */ * needs to be fragmented or not. */
#define USE_FRAMER_HDRLEN 1 #ifndef SICSLOWPAN_USE_FIXED_HDRLEN
#if USE_FRAMER_HDRLEN
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest); packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest);
framer_hdrlen = NETSTACK_FRAMER.length(); framer_hdrlen = NETSTACK_FRAMER.length();
if(framer_hdrlen < 0) { if(framer_hdrlen < 0) {
/* Framing failed, we assume the maximum header length */ /* Framing failed, we assume the maximum header length */
framer_hdrlen = 21; framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
} }
#else /* USE_FRAMER_HDRLEN */ #else /* USE_FRAMER_HDRLEN */
framer_hdrlen = 21; framer_hdrlen = SICSLOWPAN_FIXED_HDRLEN;
#endif /* USE_FRAMER_HDRLEN */ #endif /* USE_FRAMER_HDRLEN */
max_payload = MAC_MAX_PAYLOAD - framer_hdrlen; max_payload = MAC_MAX_PAYLOAD - framer_hdrlen;