pdu: add support for TCP-style headers

Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
This commit is contained in:
jcmichelou committed 2017-10-21 16:11:11 +02:00
1 parent 95a97c349e
commit bcfd7a0753
37 files changed
+1213 -890

No files matched your search

+4 -2
View File
@@ -16,6 +16,8 @@
# include <strings.h>
#endif
#include <stdint.h>
#define Nn 8 /* duplicate definition of N if built on sky motes */
#define ENCODE_HEADER_SIZE 4
#define HIBIT (1 << (Nn - 1))
@@ -47,13 +49,13 @@ extern int coap_flsll(long long i);
* Decodes multiple-length byte sequences. buf points to an input byte sequence
* of length len. Returns the decoded value.
*/
unsigned int coap_decode_var_bytes(unsigned char *buf,unsigned int len);
unsigned int coap_decode_var_bytes(const uint8_t *buf, unsigned int len);
/**
* Encodes multiple-length byte sequences. buf points to an output buffer of
* sufficient length to store the encoded bytes. val is the value to encode.
* Returns the number of bytes used to encode val or 0 on error.
*/
unsigned int coap_encode_var_bytes(unsigned char *buf, unsigned int val);
unsigned int coap_encode_var_bytes(uint8_t *buf, unsigned int val);
#endif /* _COAP_ENCODE_H_ */