2 This file is part of GNUnet.
3 Copyright (C) 2011 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file core/gnunet-service-core_typemap.h
21 * @brief management of map that specifies which message types this peer supports
22 * @author Christian Grothoff
24 #ifndef GNUNET_SERVICE_CORE_TYPEMAP_H
25 #define GNUNET_SERVICE_CORE_TYPEMAP_H
27 #include "gnunet_util_lib.h"
28 #include "gnunet_transport_service.h"
31 * Map specifying which message types a peer supports.
37 * Add a set of types to our type map.
39 * @param types array of message types supported by this peer
40 * @param tlen number of entries in @a types
43 GSC_TYPEMAP_add (const uint16_t *types,
48 * Remove a set of message types from our type map.
50 * @param types array of message types no longer supported by this peer
51 * @param tlen number of entries in @a types
54 GSC_TYPEMAP_remove (const uint16_t *types,
59 * Compute a type map message for this peer.
61 * @return this peers current type map message.
63 struct GNUNET_MessageHeader *
64 GSC_TYPEMAP_compute_type_map_message (void);
68 * Check if the given hash matches our current type map.
70 * @param hc hash code to check if it matches our type map
71 * @return #GNUNET_YES if the hash matches, #GNUNET_NO if not
74 GSC_TYPEMAP_check_hash (const struct GNUNET_HashCode *hc);
78 * Hash the contents of a type map.
80 * @param tm map to hash
81 * @param hc where to store the hash code
84 GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm,
85 struct GNUNET_HashCode *hc);
89 * Extract a type map from a
90 * #GNUNET_MESSAGE_TYPE_CORE_COMRESSED_TYPE_MAP or
91 * #GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP message.
93 * @param msg a type map message
94 * @return NULL on error
97 GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg);
101 * Test if any of the types from the types array is in the
104 * @param tmap map to test
105 * @param types array of types
106 * @param tcnt number of entries in @a types
107 * @return #GNUNET_YES if a type is in the map, #GNUNET_NO if not
110 GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
111 const uint16_t *types,
116 * Add additional types to a given typemap.
118 * @param tmap map to extend (not changed)
119 * @param types array of types to add
120 * @param tcnt number of entries in @a types
121 * @return updated type map (fresh copy)
124 GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
125 const uint16_t *types,
130 * Create an empty type map.
132 * @return an empty type map
135 GSC_TYPEMAP_create (void);
139 * Free the given type map.
141 * @param tmap a type map
144 GSC_TYPEMAP_destroy (struct GSC_TypeMap *tmap);
148 * Initialize typemap subsystem.
151 GSC_TYPEMAP_init (void);
155 * Shutdown typemap subsystem.
158 GSC_TYPEMAP_done (void);
161 /* end of gnunet-service-core_typemap.h */