Loading...
Searching...
No Matches
coap_encode.h
Go to the documentation of this file.
/*
* encode.h -- encoding and decoding of CoAP data types
*
* Copyright (C) 2010-2012 Olaf Bergmann <bergmann@tzi.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_ENCODE_H_
#define COAP_ENCODE_H_
#if (BSD >= 199103) || defined(WITH_CONTIKI) || defined(_WIN32)
# include <string.h>
#else
# include <strings.h>
#endif
#include <stdint.h>
#ifndef HAVE_FLS
/* include this only if fls() is not available */
extern int coap_fls(unsigned int i);
#else
#define coap_fls(i) fls(i)
#endif
#ifndef HAVE_FLSLL
/* include this only if flsll() is not available */
extern int coap_flsll(long long i);
#else
#define coap_flsll(i) flsll(i)
#endif
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length);
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length);
unsigned int coap_encode_var_safe(uint8_t *buf,
size_t length,
unsigned int value);
unsigned int coap_encode_var_safe8(uint8_t *buf,
size_t length,
uint64_t value);
COAP_STATIC_INLINE COAP_DEPRECATED int
coap_encode_var_bytes(uint8_t *buf, unsigned int value) {
return (int)coap_encode_var_safe(buf, sizeof(value), value);
}
#endif /* COAP_ENCODE_H_ */
coap_flsll
int coap_flsll(long long i)
Definition coap_encode.c:28
coap_fls
int coap_fls(unsigned int i)
Definition coap_encode.c:21
coap_encode_var_bytes
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes(uint8_t *buf, unsigned int value)
Definition coap_encode.h:123
coap_encode_var_safe
unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int value)
Encodes multiple-length byte sequences.
Definition coap_encode.c:47
coap_decode_var_bytes
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition coap_encode.c:38
coap_decode_var_bytes8
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition coap_encode.c:67
coap_encode_var_safe8
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t value)
Encodes multiple-length byte sequences.
Definition coap_encode.c:77
COAP_DEPRECATED
#define COAP_DEPRECATED
Definition libcoap.h:61
COAP_STATIC_INLINE
#define COAP_STATIC_INLINE
Definition libcoap.h:53