glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / core / gnunet-service-core_sessions.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2009-2014 GNUnet e.V.
4
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.
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      Affero General Public License for more details.
14 */
15
16 /**
17  * @file core/gnunet-service-core_neighbours.h
18  * @brief code for managing of 'encrypted' sessions (key exchange done)
19  * @author Christian Grothoff
20  */
21 #ifndef GNUNET_SERVICE_CORE_SESSIONS_H
22 #define GNUNET_SERVICE_CORE_SESSIONS_H
23
24 #include "gnunet-service-core.h"
25 #include "gnunet-service-core_kx.h"
26
27
28 /**
29  * Create a session, a key exchange was just completed.
30  *
31  * @param peer peer that is now connected
32  * @param kx key exchange that completed
33  */
34 void
35 GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
36                      struct GSC_KeyExchangeInfo *kx);
37
38
39 /**
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.
43  *
44  * @param peer peer that is now connected
45  */
46 void
47 GSC_SESSIONS_reinit (const struct GNUNET_PeerIdentity *peer);
48
49
50 /**
51  * The other peer has confirmed receiving our type map,
52  * check if it is current and if so, stop retransmitting it.
53  *
54  * @param peer peer that confirmed the type map
55  * @param msg confirmation message we received
56  */
57 void
58 GSC_SESSIONS_confirm_typemap (const struct GNUNET_PeerIdentity *peer,
59                               const struct GNUNET_MessageHeader *msg);
60
61
62 /**
63  * End the session with the given peer (we are no longer
64  * connected).
65  *
66  * @param pid identity of peer to kill session with
67  */
68 void
69 GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
70
71
72 /**
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.
76  *
77  * @param pid identity of peer ready to receive data
78  */
79 void
80 GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
81
82
83 /**
84  * Queue a request from a client for transmission to a particular peer.
85  *
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
91  */
92 void
93 GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
94
95
96 /**
97  * Dequeue a request from a client from transmission to a particular peer.
98  *
99  * @param car request to dequeue; this handle will then be 'owned' by
100  *        the caller (CLIENTS sysbsystem)
101  */
102 void
103 GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
104
105
106 /**
107  * Transmit a message to a particular peer.
108  *
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
114  */
115 void
116 GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
117                        const struct GNUNET_MessageHeader *msg,
118                        int cork,
119                        enum GNUNET_CORE_Priority priority);
120
121
122 /**
123  * Broadcast an updated typemap message to all neighbours.
124  * Restarts the retransmissions until the typemaps are confirmed.
125  *
126  * @param msg message to transmit
127  */
128 void
129 GSC_SESSIONS_broadcast_typemap (const struct GNUNET_MessageHeader *msg);
130
131
132 /**
133  * We have a new client, notify it about all current sessions.
134  *
135  * @param client the new client
136  */
137 void
138 GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
139
140
141 /**
142  * We've received a typemap message from a peer, update ours.
143  * Notifies clients about the session.
144  *
145  * @param peer peer this is about
146  * @param msg typemap update message
147  */
148 void
149 GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
150                           const struct GNUNET_MessageHeader *msg);
151
152
153 /**
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
156  * about the session.
157  *
158  * @param peer peer this is about
159  * @param type type of the message
160  */
161 void
162 GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
163                              uint16_t type);
164
165
166 /**
167  * Initialize sessions subsystem.
168  */
169 void
170 GSC_SESSIONS_init (void);
171
172
173 /**
174  * Shutdown sessions subsystem.
175  */
176 void
177 GSC_SESSIONS_done (void);
178
179
180
181 #endif