dead code elimination
[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.h"
30 #include "gnunet-service-core_kx.h"
31
32
33 /**
34  * Create a session, a key exchange was just completed.
35  *
36  * @param peer peer that is now connected
37  * @param kx key exchange that completed
38  */
39 void
40 GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
41                      struct GSC_KeyExchangeInfo *kx);
42
43
44 /**
45  * Update information about a session.
46  *
47  * @param peer peer who's session should be updated
48  * @param bw_out new outbound bandwidth limit for the peer
49  */
50 void
51 GSC_SESSIONS_update (const struct GNUNET_PeerIdentity *peer,
52                      struct GNUNET_BANDWIDTH_Value32NBO bw_out);
53
54
55 /**
56  * End the session with the given peer (we are no longer
57  * connected). 
58  *
59  * @param pid identity of peer to kill session with
60  */
61 void
62 GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
63
64
65 /**
66  * Traffic is being solicited for the given peer.  This means that the
67  * message queue on the transport-level (NEIGHBOURS subsystem) is now
68  * empty and it is now OK to transmit another (non-control) message.
69  *
70  * @param pid identity of peer ready to receive data
71  */
72 void
73 GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
74
75
76 /**
77  * Queue a request from a client for transmission to a particular peer.
78  *
79  * @param car request to queue; this handle is then shared between
80  *         the caller (CLIENTS subsystem) and SESSIONS and must not
81  *         be released by either until either 'GNUNET_SESSIONS_dequeue',
82  *         or 'GNUNET_CLIENTS_failed'
83  *         have been invoked on it
84  */
85 void
86 GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
87
88
89 /**
90  * Dequeue a request from a client from transmission to a particular peer.
91  *
92  * @param car request to dequeue; this handle will then be 'owned' by
93  *        the caller (CLIENTS sysbsystem)
94  */
95 void
96 GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
97
98
99 /**
100  * Transmit a message to a particular peer.
101  *
102  * @param car original request that was queued and then solicited,
103  *            ownership does not change (dequeue will be called soon).
104  * @param msg message to transmit
105  * @param cork is corking allowed?
106  */
107 void
108 GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
109                        const struct GNUNET_MessageHeader *msg,
110                        int cork);
111
112
113 /**
114  * Broadcast a message to all neighbours.
115  *
116  * @param msg message to transmit
117  */
118 void
119 GSC_SESSIONS_broadcast (const struct GNUNET_MessageHeader *msg);
120
121
122 /**
123  * We have a new client, notify it about all current sessions.
124  *
125  * @param client the new client
126  */
127 void
128 GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
129
130
131 /**
132  * Handle CORE_ITERATE_PEERS request.  For this request type, the client
133  * does not have to have transmitted an INIT request.  All current peers
134  * are returned, regardless of which message types they accept.
135  *
136  * @param cls unused
137  * @param client client sending the iteration request
138  * @param message iteration request message
139  */
140 void
141 GSC_SESSIONS_handle_client_iterate_peers (void *cls, struct GNUNET_SERVER_Client *client,
142                                           const struct GNUNET_MessageHeader *message);
143
144
145 /**
146  * Handle CORE_PEER_CONNECTED request.  Notify client about connection
147  * to the given neighbour.  For this request type, the client does not
148  * have to have transmitted an INIT request.  All current peers are
149  * returned, regardless of which message types they accept.
150  *
151  * @param cls unused
152  * @param client client sending the iteration request
153  * @param message iteration request message
154  */
155 void
156 GSC_SESSIONS_handle_client_have_peer (void *cls, struct GNUNET_SERVER_Client *client,
157                                       const struct GNUNET_MessageHeader *message);
158
159
160
161 /**
162  * Initialize sessions subsystem.
163  */
164 void
165 GSC_SESSIONS_init (void);
166
167
168 /**
169  * Shutdown sessions subsystem.
170  */
171 void
172 GSC_SESSIONS_done (void);
173
174
175
176 #endif