781398d44d6d9457ef6e3b2c8bedb432ee1fbfa1
[oweals/gnunet.git] / src / core / gnunet-service-core_sessions.h
1 /*
2      This file is part of GNUnet.
3      (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      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      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file core/gnunet-service-core_neighbours.h
23  * @brief code for managing of 'encrypted' sessions (key exchange done) 
24  * @author Christian Grothoff
25  */
26 #ifndef GNUNET_SERVICE_CORE_SESSIONS_H
27 #define GNUNET_SERVICE_CORE_SESSIONS_H
28
29 #include "gnunet_service_core_kx.h"
30 #include "gnunet_service_core_sessions.h"
31
32
33 /**
34  * End the session with the given peer (we are no longer
35  * connected). 
36  *
37  * @param pid identity of peer to kill session with
38  */
39 void
40 GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
41
42
43 /**
44  * Traffic is being solicited for the given peer.  This means that the
45  * message queue on the transport-level (NEIGHBOURS subsystem) is now
46  * empty and it is now OK to transmit another (non-control) message.
47  *
48  * @param pid identity of peer ready to receive data
49  */
50 void
51 GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
52
53
54 /**
55  * Queue a request from a client for transmission to a particular peer.
56  *
57  * @param car request to queue; this handle is then shared between
58  *         the caller (CLIENTS subsystem) and SESSIONS and must not
59  *         be released by either until either 'GNUNET_SESSIONS_dequeue',
60  *         or 'GNUNET_CLIENTS_failed'
61  *         have been invoked on it
62  */
63 void
64 GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
65
66
67 /**
68  * Dequeue a request from a client from transmission to a particular peer.
69  *
70  * @param car request to dequeue; this handle will then be 'owned' by
71  *        the caller (CLIENTS sysbsystem)
72  */
73 void
74 GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
75
76
77 /**
78  * Transmit a message to a particular peer.
79  *
80  * @param car original request that was queued and then solicited,
81  *            ownership does not change (dequeue will be called soon).
82  * @param msg message to transmit
83  */
84 void
85 GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
86                        const struct GNUNET_MessageHeader *msg);
87
88
89 /**
90  * Broadcast a message to all neighbours.
91  *
92  * @param msg message to transmit
93  */
94 void
95 GSC_SESSIONS_broadcast (const struct GNUNET_MessageHeader *msg);
96
97
98 /**
99  * We have a new client, notify it about all current sessions.
100  *
101  * @param client the new client
102  */
103 void
104 GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
105
106
107 /**
108  * Handle CORE_ITERATE_PEERS request.  For this request type, the client
109  * does not have to have transmitted an INIT request.  All current peers
110  * are returned, regardless of which message types they accept.
111  *
112  * @param cls unused
113  * @param client client sending the iteration request
114  * @param message iteration request message
115  */
116 void
117 GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client,
118                                           const struct GNUNET_MessageHeader *message);
119
120
121 /**
122  * Handle CORE_PEER_CONNECTED request.  Notify client about connection
123  * to the given neighbour.  For this request type, the client does not
124  * have to have transmitted an INIT request.  All current peers are
125  * returned, regardless of which message types they accept.
126  *
127  * @param cls unused
128  * @param client client sending the iteration request
129  * @param message iteration request message
130  */
131 void
132 GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
133                                       const struct GNUNET_MessageHeader *message);
134
135
136 /**
137  * Handle REQUEST_INFO request.  For this request type, the client must have
138  * transmitted an INIT first.
139  *
140  * @param cls unused
141  * @param client client sending the request
142  * @param message iteration request message
143  */
144 void
145 GSC_SESSIONS_handle_client_request_info (void *cls, struct GNUNET_SERVER_Client *client,
146                                          const struct GNUNET_MessageHeader *message);
147
148
149 /**
150  * Create a session, a key exchange was just completed.
151  */
152 void
153 GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer);
154
155 /**
156  * Update information about a session.
157  *
158  * @param peer peer who's session should be updated
159  * @param bw_out new outbound bandwidth limit for the peer
160  * @param atsi performance information
161  * @param atsi_count number of performance records supplied
162  */
163 void
164 GSC_SESSIONS_update (const struct GNUNET_PeerIdentity *peer,
165                      struct GNUNET_BANDWIDTH_Value32NBO bw_out,
166                      const struct GNUNET_TRANSPORT_ATS_Information *atsi,
167                      uint32_t atsi_count);
168
169
170
171 /**
172  * Initialize sessions subsystem.
173  */
174 void
175 GSC_SESSIONS_init (void);
176
177
178 /**
179  * Shutdown sessions subsystem.
180  */
181 void
182 GSC_SESSIONS_done (void);
183
184
185
186 #endif