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.
17 * @file core/gnunet-service-core_typemap.h
18 * @brief management of map that specifies which message types this peer supports
19 * @author Christian Grothoff
21 #ifndef GNUNET_SERVICE_CORE_TYPEMAP_H
22 #define GNUNET_SERVICE_CORE_TYPEMAP_H
24 #include "gnunet_util_lib.h"
25 #include "gnunet_transport_service.h"
28 * Map specifying which message types a peer supports.
34 * Add a set of types to our type map.
36 * @param types array of message types supported by this peer
37 * @param tlen number of entries in @a types
40 GSC_TYPEMAP_add (const uint16_t *types,
45 * Remove a set of message types from our type map.
47 * @param types array of message types no longer supported by this peer
48 * @param tlen number of entries in @a types
51 GSC_TYPEMAP_remove (const uint16_t *types,
56 * Compute a type map message for this peer.
58 * @return this peers current type map message.
60 struct GNUNET_MessageHeader *
61 GSC_TYPEMAP_compute_type_map_message (void);
65 * Check if the given hash matches our current type map.
67 * @param hc hash code to check if it matches our type map
68 * @return #GNUNET_YES if the hash matches, #GNUNET_NO if not
71 GSC_TYPEMAP_check_hash (const struct GNUNET_HashCode *hc);
75 * Hash the contents of a type map.
77 * @param tm map to hash
78 * @param hc where to store the hash code
81 GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm,
82 struct GNUNET_HashCode *hc);
86 * Extract a type map from a
87 * #GNUNET_MESSAGE_TYPE_CORE_COMRESSED_TYPE_MAP or
88 * #GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP message.
90 * @param msg a type map message
91 * @return NULL on error
94 GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg);
98 * Test if any of the types from the types array is in the
101 * @param tmap map to test
102 * @param types array of types
103 * @param tcnt number of entries in @a types
104 * @return #GNUNET_YES if a type is in the map, #GNUNET_NO if not
107 GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
108 const uint16_t *types,
113 * Add additional types to a given typemap.
115 * @param tmap map to extend (not changed)
116 * @param types array of types to add
117 * @param tcnt number of entries in @a types
118 * @return updated type map (fresh copy)
121 GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
122 const uint16_t *types,
127 * Create an empty type map.
129 * @return an empty type map
132 GSC_TYPEMAP_create (void);
136 * Free the given type map.
138 * @param tmap a type map
141 GSC_TYPEMAP_destroy (struct GSC_TypeMap *tmap);
145 * Initialize typemap subsystem.
148 GSC_TYPEMAP_init (void);
152 * Shutdown typemap subsystem.
155 GSC_TYPEMAP_done (void);
158 /* end of gnunet-service-core_typemap.h */