Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / dht / gnunet-service-dht_routing.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011 GNUnet e.V.
4
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.
9
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.
14     
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/>.
17 */
18
19 /**
20  * @file dht/gnunet-service-dht_routing.h
21  * @brief GNUnet DHT tracking of requests for routing replies
22  * @author Christian Grothoff
23  */
24 #ifndef GNUNET_SERVICE_DHT_ROUTING_H
25 #define GNUNET_SERVICE_DHT_ROUTING_H
26
27 #include "gnunet_util_lib.h"
28 #include "gnunet_block_lib.h"
29 #include "gnunet_dht_service.h"
30
31
32 /**
33  * Handle a reply (route to origin).  Only forwards the reply back to
34  * other peers waiting for it.  Does not do local caching or
35  * forwarding to local clients.  Essentially calls
36  * #GDS_NEIGHBOURS_handle_reply() for all peers that sent us a matching
37  * request recently.
38  *
39  * @param type type of the block
40  * @param expiration_time when does the content expire
41  * @param key key for the content
42  * @param put_path_length number of entries in @a put_path
43  * @param put_path peers the original PUT traversed (if tracked)
44  * @param get_path_length number of entries in @a get_path
45  * @param get_path peers this reply has traversed so far (if tracked)
46  * @param data payload of the reply
47  * @param data_size number of bytes in @a data
48  */
49 void
50 GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
51                      struct GNUNET_TIME_Absolute expiration_time,
52                      const struct GNUNET_HashCode *key,
53                      unsigned int put_path_length,
54                      const struct GNUNET_PeerIdentity *put_path,
55                      unsigned int get_path_length,
56                      const struct GNUNET_PeerIdentity *get_path,
57                      const void *data,
58                      size_t data_size);
59
60
61 /**
62  * Add a new entry to our routing table.
63  *
64  * @param sender peer that originated the request
65  * @param type type of the block
66  * @param bg block group to evaluate replies, henceforth owned by routing
67  * @param options options for processing
68  * @param key key for the content
69  * @param xquery extended query
70  * @param xquery_size number of bytes in @a xquery
71  */
72 void
73 GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
74                  enum GNUNET_BLOCK_Type type,
75                  struct GNUNET_BLOCK_Group *bg,
76                  enum GNUNET_DHT_RouteOption options,
77                  const struct GNUNET_HashCode * key,
78                  const void *xquery,
79                  size_t xquery_size);
80
81
82 /**
83  * Initialize routing subsystem.
84  */
85 void
86 GDS_ROUTING_init (void);
87
88
89 /**
90  * Shutdown routing subsystem.
91  */
92 void
93 GDS_ROUTING_done (void);
94
95 #endif