aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_core_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_core_service.h')
-rw-r--r--src/include/gnunet_core_service.h142
1 files changed, 5 insertions, 137 deletions
diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h
index 6ec486b26..8136770b7 100644
--- a/src/include/gnunet_core_service.h
+++ b/src/include/gnunet_core_service.h
@@ -91,30 +91,8 @@ struct GNUNET_CORE_Handle;
91 * @param cls closure 91 * @param cls closure
92 * @param peer peer identity this notification is about 92 * @param peer peer identity this notification is about
93 */ 93 */
94typedef void
95(*GNUNET_CORE_ConnectEventHandler) (void *cls,
96 const struct GNUNET_PeerIdentity *peer);
97
98
99/**
100 * Method called whenever a peer disconnects.
101 *
102 * @param cls closure
103 * @param peer peer identity this notification is about
104 */
105typedef void
106(*GNUNET_CORE_DisconnectEventHandler) (void *cls,
107 const struct GNUNET_PeerIdentity *peer);
108
109
110/**
111 * Method called whenever a given peer connects.
112 *
113 * @param cls closure
114 * @param peer peer identity this notification is about
115 */
116typedef void * 94typedef void *
117(*GNUNET_CORE_ConnecTEventHandler) (void *cls, 95(*GNUNET_CORE_ConnectEventHandler) (void *cls,
118 const struct GNUNET_PeerIdentity *peer, 96 const struct GNUNET_PeerIdentity *peer,
119 struct GNUNET_MQ_Handle *mq); 97 struct GNUNET_MQ_Handle *mq);
120 98
@@ -126,55 +104,12 @@ typedef void *
126 * @param peer peer identity this notification is about 104 * @param peer peer identity this notification is about
127 */ 105 */
128typedef void 106typedef void
129(*GNUNET_CORE_DisconnecTEventHandler) (void *cls, 107(*GNUNET_CORE_DisconnectEventHandler) (void *cls,
130 const struct GNUNET_PeerIdentity *peer, 108 const struct GNUNET_PeerIdentity *peer,
131 void *peer_cls); 109 void *peer_cls);
132 110
133 111
134/** 112/**
135 * Functions with this signature are called whenever a message is
136 * received or transmitted.
137 *
138 * @param cls closure (set from #GNUNET_CORE_connect)
139 * @param peer the other peer involved (sender or receiver, NULL
140 * for loopback messages where we are both sender and receiver)
141 * @param message the actual message
142 * @return #GNUNET_OK to keep the connection open,
143 * #GNUNET_SYSERR to close connection to the peer (signal serious error)
144 */
145typedef int
146(*GNUNET_CORE_MessageCallback) (void *cls,
147 const struct GNUNET_PeerIdentity *other,
148 const struct GNUNET_MessageHeader *message);
149
150
151/**
152 * Message handler. Each struct specifies how to handle on particular
153 * type of message received.
154 */
155struct GNUNET_CORE_MessageHandler
156{
157 /**
158 * Function to call for messages of @e type.
159 */
160 GNUNET_CORE_MessageCallback callback;
161
162 /**
163 * Type of the message this handler covers.
164 */
165 uint16_t type;
166
167 /**
168 * Expected size of messages of this type. Use 0 for variable-size.
169 * If non-zero, messages of the given type will be discarded if they
170 * do not have the right size.
171 */
172 uint16_t expected_size;
173
174};
175
176
177/**
178 * Function called after #GNUNET_CORE_connect has succeeded (or failed 113 * Function called after #GNUNET_CORE_connect has succeeded (or failed
179 * for good). Note that the private key of the peer is intentionally 114 * for good). Note that the private key of the peer is intentionally
180 * not exposed here; if you need it, your process should try to read 115 * not exposed here; if you need it, your process should try to read
@@ -208,26 +143,6 @@ typedef void
208 * connected to the core service 143 * connected to the core service
209 * @param connects function to call on peer connect, can be NULL 144 * @param connects function to call on peer connect, can be NULL
210 * @param disconnects function to call on peer disconnect / timeout, can be NULL 145 * @param disconnects function to call on peer disconnect / timeout, can be NULL
211 * @param inbound_notify function to call for all inbound messages, can be NULL
212 * note that the core is allowed to drop notifications about inbound
213 * messages if the client does not process them fast enough (for this
214 * notification type, a bounded queue is used)
215 * @param inbound_hdr_only set to #GNUNET_YES if @a inbound_notify will only read the
216 * `struct GNUNET_MessageHeader` and hence we do not need to give it the full message;
217 * can be used to improve efficiency, ignored if inbound_notify is NULL
218 * note that the core is allowed to drop notifications about inbound
219 * messages if the client does not process them fast enough (for this
220 * notification type, a bounded queue is used)
221 * @param outbound_notify function to call for all outbound messages, can be NULL;
222 * note that the core is allowed to drop notifications about outbound
223 * messages if the client does not process them fast enough (for this
224 * notification type, a bounded queue is used)
225 * @param outbound_hdr_only set to #GNUNET_YES if @a outbound_notify will only read the
226 * `struct GNUNET_MessageHeader` and hence we do not need to give it the full message
227 * can be used to improve efficiency, ignored if outbound_notify is NULL
228 * note that the core is allowed to drop notifications about outbound
229 * messages if the client does not process them fast enough (for this
230 * notification type, a bounded queue is used)
231 * @param handlers callbacks for messages we care about, NULL-terminated 146 * @param handlers callbacks for messages we care about, NULL-terminated
232 * note that the core is allowed to drop notifications about inbound 147 * note that the core is allowed to drop notifications about inbound
233 * messages if the client does not process them fast enough (for this 148 * messages if the client does not process them fast enough (for this
@@ -241,53 +156,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
241 GNUNET_CORE_StartupCallback init, 156 GNUNET_CORE_StartupCallback init,
242 GNUNET_CORE_ConnectEventHandler connects, 157 GNUNET_CORE_ConnectEventHandler connects,
243 GNUNET_CORE_DisconnectEventHandler disconnects, 158 GNUNET_CORE_DisconnectEventHandler disconnects,
244 GNUNET_CORE_MessageCallback inbound_notify,
245 int inbound_hdr_only,
246 GNUNET_CORE_MessageCallback outbound_notify,
247 int outbound_hdr_only,
248 const struct GNUNET_CORE_MessageHandler *handlers);
249
250/**
251 * Disconnect from the core service. This function can only
252 * be called *after* all pending #GNUNET_CORE_notify_transmit_ready
253 * requests have been explicitly cancelled.
254 *
255 * @param handle connection to core to disconnect
256 */
257void
258GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle);
259
260
261/**
262 * Connect to the core service. Note that the connection may complete
263 * (or fail) asynchronously. This function primarily causes the given
264 * callback notification functions to be invoked whenever the
265 * specified event happens. The maximum number of queued
266 * notifications (queue length) is per client; the queue is shared
267 * across all types of notifications. So a slow client that registers
268 * for @a outbound_notify also risks missing @a inbound_notify messages.
269 * Certain events (such as connect/disconnect notifications) are not
270 * subject to queue size limitations.
271 *
272 * @param cfg configuration to use
273 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
274 * @param init callback to call once we have successfully
275 * connected to the core service
276 * @param connects function to call on peer connect, can be NULL
277 * @param disconnects function to call on peer disconnect / timeout, can be NULL
278 * @param handlers callbacks for messages we care about, NULL-terminated
279 * note that the core is allowed to drop notifications about inbound
280 * messages if the client does not process them fast enough (for this
281 * notification type, a bounded queue is used)
282 * @return handle to the core service (only useful for disconnect until @a init is called),
283 * NULL on error (in this case, init is never called)
284 */
285struct GNUNET_CORE_Handle *
286GNUNET_CORE_connecT (const struct GNUNET_CONFIGURATION_Handle *cfg,
287 void *cls,
288 GNUNET_CORE_StartupCallback init,
289 GNUNET_CORE_ConnecTEventHandler connects,
290 GNUNET_CORE_DisconnecTEventHandler disconnects,
291 const struct GNUNET_MQ_MessageHandler *handlers); 159 const struct GNUNET_MQ_MessageHandler *handlers);
292 160
293 161
@@ -297,7 +165,7 @@ GNUNET_CORE_connecT (const struct GNUNET_CONFIGURATION_Handle *cfg,
297 * @param handle connection to core to disconnect 165 * @param handle connection to core to disconnect
298 */ 166 */
299void 167void
300GNUNET_CORE_disconnecT (struct GNUNET_CORE_Handle *handle); 168GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle);
301 169
302 170
303/** 171/**
@@ -305,7 +173,7 @@ GNUNET_CORE_disconnecT (struct GNUNET_CORE_Handle *handle);
305 * so that it is transmitted with the given @a priority and 173 * so that it is transmitted with the given @a priority and
306 * the given @a cork value. 174 * the given @a cork value.
307 * 175 *
308 * @param cork desired corking 176 * @param cork desired corking
309 * @param priority desired message priority 177 * @param priority desired message priority
310 * @param[out] flags set to `flags` value for #GNUNET_MQ_set_options() 178 * @param[out] flags set to `flags` value for #GNUNET_MQ_set_options()
311 * @return `extra` argument to give to #GNUNET_MQ_set_options() 179 * @return `extra` argument to give to #GNUNET_MQ_set_options()
@@ -320,7 +188,7 @@ GNUNET_CORE_get_mq_options (int cork,
320 * Obtain the message queue for a connected peer. 188 * Obtain the message queue for a connected peer.
321 * 189 *
322 * @param h the core handle 190 * @param h the core handle
323 * @param pid the identity of the peer 191 * @param pid the identity of the peer
324 * @return NULL if @a pid is not connected 192 * @return NULL if @a pid is not connected
325 */ 193 */
326struct GNUNET_MQ_Handle * 194struct GNUNET_MQ_Handle *