libcoap 4.3.5-develop-ea01661
Loading...
Searching...
No Matches
coap_hashkey_internal.h
Go to the documentation of this file.
1/*
2 * coap_hashkey_internal.h -- definition of hash key type and helper functions
3 *
4 * Copyright (C) 2010-2011 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_HASHKEY_INTERNAL_H_
18#define COAP_HASHKEY_INTERNAL_H_
19
20#include "libcoap.h"
21#include "coap_uthash_internal.h"
22#include "coap_str.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef unsigned char coap_key_t[4];
29
30#ifndef coap_hash
40void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h);
41
42#define coap_hash(String,Length,Result) \
43 coap_hash_impl((String),(Length),(Result))
44
45/* This is used to control the pre-set hash-keys for resources. */
46#define COAP_DEFAULT_HASH
47#else
48#undef COAP_DEFAULT_HASH
49#endif /* coap_hash */
50
59#define coap_str_hash(Str,H) { \
60 assert(Str); \
61 memset((H), 0, sizeof(coap_key_t)); \
62 coap_hash((Str)->s, (Str)->length, (H)); \
63 }
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif /* COAP_HASHKEY_INTERNAL_H_ */
unsigned char coap_key_t[4]
void coap_hash_impl(const unsigned char *s, size_t len, coap_key_t h)
Calculates a fast hash over the given string s of length len and stores the result into h.
Strings to be used in the CoAP library.
Platform specific header file for CoAP stack.