libcoap 4.3.5-develop-7be2515
Loading...
Searching...
No Matches
coap_encode.h
Go to the documentation of this file.
1/*
2 * encode.h -- encoding and decoding of CoAP data types
3 *
4 * Copyright (C) 2010-2012,2023-2026 Olaf Bergmann <bergmann@tzi.org>
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * This file is part of the CoAP library libcoap. Please see README for terms
9 * of use.
10 */
11
17#ifndef COAP_ENCODE_H_
18#define COAP_ENCODE_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#ifndef HAVE_FLS
25/* include this only if fls() is not available */
26extern int coap_fls(unsigned int i);
27#else
28#define coap_fls(i) fls(i)
29#endif
30
31#ifndef HAVE_FLSLL
32/* include this only if flsll() is not available */
33extern int coap_flsll(long long i);
34#else
35#define coap_flsll(i) flsll(i)
36#endif
37
54unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length);
55
65uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length);
66
80unsigned int coap_encode_var_safe(uint8_t *buf,
81 size_t length,
82 unsigned int value);
83
97unsigned int coap_encode_var_safe8(uint8_t *buf,
98 size_t length,
99 uint64_t value);
100
119coap_encode_var_bytes(uint8_t *buf, unsigned int value) {
120 return (int)coap_encode_var_safe(buf, sizeof(value), value);
121}
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* COAP_ENCODE_H_ */
int coap_flsll(long long i)
Definition coap_encode.c:28
int coap_fls(unsigned int i)
Definition coap_encode.c:21
COAP_STATIC_INLINE COAP_DEPRECATED int coap_encode_var_bytes(uint8_t *buf, unsigned int value)
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
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition coap_encode.c:38
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t length)
Decodes multiple-length byte sequences.
Definition coap_encode.c:70
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t value)
Encodes multiple-length byte sequences.
Definition coap_encode.c:80
#define COAP_DEPRECATED
Definition libcoap.h:66
#define COAP_STATIC_INLINE
Definition libcoap.h:57