2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file core/gnunet-service-core_typemap.h
23 * @brief management of map that specifies which message types this peer supports
24 * @author Christian Grothoff
26 #ifndef GNUNET_SERVICE_CORE_TYPEMAP_H
27 #define GNUNET_SERVICE_CORE_TYPEMAP_H
29 #include "gnunet_util_lib.h"
30 #include "gnunet_transport_service.h"
33 * Map specifying which message types a peer supports.
39 * Add a set of types to our type map.
41 * @param types array of message types supported by this peer
42 * @param tlen number of entries in @a types
45 GSC_TYPEMAP_add (const uint16_t *types,
50 * Remove a set of message types from our type map.
52 * @param types array of message types no longer supported by this peer
53 * @param tlen number of entries in @a types
56 GSC_TYPEMAP_remove (const uint16_t *types,
61 * Compute a type map message for this peer.
63 * @return this peers current type map message.
65 struct GNUNET_MessageHeader *
66 GSC_TYPEMAP_compute_type_map_message (void);
70 * Check if the given hash matches our current type map.
72 * @param hc hash code to check if it matches our type map
73 * @return #GNUNET_YES if the hash matches, #GNUNET_NO if not
76 GSC_TYPEMAP_check_hash (const struct GNUNET_HashCode *hc);
80 * Hash the contents of a type map.
82 * @param tm map to hash
83 * @param hc where to store the hash code
86 GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm,
87 struct GNUNET_HashCode *hc);
91 * Extract a type map from a
92 * #GNUNET_MESSAGE_TYPE_CORE_COMRESSED_TYPE_MAP or
93 * #GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP message.
95 * @param msg a type map message
96 * @return NULL on error
99 GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg);
103 * Test if any of the types from the types array is in the
106 * @param tmap map to test
107 * @param types array of types
108 * @param tcnt number of entries in @a types
109 * @return #GNUNET_YES if a type is in the map, #GNUNET_NO if not
112 GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
113 const uint16_t *types,
118 * Add additional types to a given typemap.
120 * @param tmap map to extend (not changed)
121 * @param types array of types to add
122 * @param tcnt number of entries in @a types
123 * @return updated type map (fresh copy)
126 GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
127 const uint16_t *types,
132 * Create an empty type map.
134 * @return an empty type map
137 GSC_TYPEMAP_create (void);
141 * Free the given type map.
143 * @param tmap a type map
146 GSC_TYPEMAP_destroy (struct GSC_TypeMap *tmap);
150 * Initialize typemap subsystem.
153 GSC_TYPEMAP_init (void);
157 * Shutdown typemap subsystem.
160 GSC_TYPEMAP_done (void);
163 /* end of gnunet-service-core_typemap.h */