2 This file is part of GNUnet.
3 Copyright (C) 2009-2014 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_neighbours.h
18 * @brief code for managing of 'encrypted' sessions (key exchange done)
19 * @author Christian Grothoff
21 #ifndef GNUNET_SERVICE_CORE_SESSIONS_H
22 #define GNUNET_SERVICE_CORE_SESSIONS_H
24 #include "gnunet-service-core.h"
25 #include "gnunet-service-core_kx.h"
29 * Create a session, a key exchange was just completed.
31 * @param peer peer that is now connected
32 * @param kx key exchange that completed
35 GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
36 struct GSC_KeyExchangeInfo *kx);
40 * The other peer has indicated that he 'lost' the session
41 * (KX down), reinitialize the session on our end, in particular
42 * this means to restart the typemap transmission.
44 * @param peer peer that is now connected
47 GSC_SESSIONS_reinit (const struct GNUNET_PeerIdentity *peer);
51 * The other peer has confirmed receiving our type map,
52 * check if it is current and if so, stop retransmitting it.
54 * @param peer peer that confirmed the type map
55 * @param msg confirmation message we received
58 GSC_SESSIONS_confirm_typemap (const struct GNUNET_PeerIdentity *peer,
59 const struct GNUNET_MessageHeader *msg);
63 * End the session with the given peer (we are no longer
66 * @param pid identity of peer to kill session with
69 GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
73 * Traffic is being solicited for the given peer. This means that the
74 * message queue on the transport-level (NEIGHBOURS subsystem) is now
75 * empty and it is now OK to transmit another (non-control) message.
77 * @param pid identity of peer ready to receive data
80 GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
84 * Queue a request from a client for transmission to a particular peer.
86 * @param car request to queue; this handle is then shared between
87 * the caller (CLIENTS subsystem) and SESSIONS and must not
88 * be released by either until either 'GNUNET_SESSIONS_dequeue',
89 * or 'GNUNET_CLIENTS_failed'
90 * have been invoked on it
93 GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
97 * Dequeue a request from a client from transmission to a particular peer.
99 * @param car request to dequeue; this handle will then be 'owned' by
100 * the caller (CLIENTS sysbsystem)
103 GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
107 * Transmit a message to a particular peer.
109 * @param car original request that was queued and then solicited,
110 * ownership does not change (dequeue will be called soon).
111 * @param msg message to transmit
112 * @param cork is corking allowed?
113 * @param priority how important is this message
116 GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
117 const struct GNUNET_MessageHeader *msg,
119 enum GNUNET_CORE_Priority priority);
123 * Broadcast an updated typemap message to all neighbours.
124 * Restarts the retransmissions until the typemaps are confirmed.
126 * @param msg message to transmit
129 GSC_SESSIONS_broadcast_typemap (const struct GNUNET_MessageHeader *msg);
133 * We have a new client, notify it about all current sessions.
135 * @param client the new client
138 GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
142 * We've received a typemap message from a peer, update ours.
143 * Notifies clients about the session.
145 * @param peer peer this is about
146 * @param msg typemap update message
149 GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
150 const struct GNUNET_MessageHeader *msg);
154 * The given peer send a message of the specified type. Make sure the
155 * respective bit is set in its type-map and that clients are notified
158 * @param peer peer this is about
159 * @param type type of the message
162 GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
167 * Initialize sessions subsystem.
170 GSC_SESSIONS_init (void);
174 * Shutdown sessions subsystem.
177 GSC_SESSIONS_done (void);