2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 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.h
18 * @brief Globals for gnunet-service-core
19 * @author Christian Grothoff
21 #ifndef GNUNET_SERVICE_CORE_H
22 #define GNUNET_SERVICE_CORE_H
24 #include "gnunet_statistics_service.h"
25 #include "gnunet_core_service.h"
27 #include "gnunet-service-core_typemap.h"
31 * Opaque handle to a client.
37 * Record kept for each request for transmission issued by a
38 * client that is still pending. (This struct is used by
39 * both the 'CLIENTS' and 'SESSIONS' subsystems.)
41 struct GSC_ClientActiveRequest
45 * Active requests are kept in a doubly-linked list of
46 * the respective target peer.
48 struct GSC_ClientActiveRequest *next;
51 * Active requests are kept in a doubly-linked list of
52 * the respective target peer.
54 struct GSC_ClientActiveRequest *prev;
57 * Handle to the client.
59 struct GSC_Client *client_handle;
62 * Which peer is the message going to be for?
64 struct GNUNET_PeerIdentity target;
67 * At what time did we first see this request?
69 struct GNUNET_TIME_Absolute received_time;
72 * By what time would the client want to see this message out?
74 struct GNUNET_TIME_Absolute deadline;
77 * How important is this request.
79 enum GNUNET_CORE_Priority priority;
82 * Has this request been solicited yet?
87 * How many bytes does the client intend to send?
92 * Unique request ID (in big endian).
100 * Tell a client that we are ready to receive the message.
102 * @param car request that is now ready; the responsibility
103 * for the handle remains shared between CLIENTS
104 * and SESSIONS after this call.
107 GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car);
111 * We will never be ready to transmit the given message in (disconnect
112 * or invalid request). Frees resources associated with @a car. We
113 * don't explicitly tell the client, he'll learn with the disconnect
114 * (or violated the protocol).
116 * @param car request that now permanently failed; the
117 * responsibility for the handle is now returned
118 * to CLIENTS (SESSIONS is done with it).
119 * @param drop_client #GNUNET_YES if the client violated the protocol
120 * and we should thus drop the connection
123 GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car,
128 * Notify a particular client about a change to existing connection to
129 * one of our neighbours (check if the client is interested). Called
130 * from #GSC_SESSIONS_notify_client_about_sessions().
132 * @param client client to notify
133 * @param neighbour identity of the neighbour that changed status
134 * @param tmap_old previous type map for the neighbour, NULL for connect
135 * @param tmap_new updated type map for the neighbour, NULL for disconnect
138 GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
139 const struct GNUNET_PeerIdentity *neighbour,
140 const struct GSC_TypeMap *tmap_old,
141 const struct GSC_TypeMap *tmap_new);
145 * Deliver P2P message to interested clients. Caller must have checked
146 * that the sending peer actually lists the given message type as one
149 * @param sender peer who sent us the message
150 * @param msg the message
151 * @param msize number of bytes to transmit
152 * @param options options for checking which clients should
153 * receive the message
156 GSC_CLIENTS_deliver_message (const struct GNUNET_PeerIdentity *sender,
157 const struct GNUNET_MessageHeader *msg,
163 * Notify all clients about a change to existing session.
164 * Called from SESSIONS whenever there is a change in sessions
165 * or types processed by the respective peer.
167 * @param neighbour identity of the neighbour that changed status
168 * @param tmap_old previous type map for the neighbour, NULL for connect
169 * @param tmap_new updated type map for the neighbour, NULL for disconnect
172 GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
173 const struct GSC_TypeMap *tmap_old,
174 const struct GSC_TypeMap *tmap_new);
180 extern const struct GNUNET_CONFIGURATION_Handle *GSC_cfg;
183 * For creating statistics.
185 extern struct GNUNET_STATISTICS_Handle *GSC_stats;
190 extern struct GNUNET_PeerIdentity GSC_my_identity;