-fix (C) notices
[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
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., 51 Franklin Street, Fifth Floor,
18      Boston, MA 02110-1301, 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  * The other peer has indicated that he 'lost' the session
46  * (KX down), reinitialize the session on our end, in particular
47  * this means to restart the typemap transmission.
48  *
49  * @param peer peer that is now connected
50  */
51 void
52 GSC_SESSIONS_reinit (const struct GNUNET_PeerIdentity *peer);
53
54
55 /**
56  * The other peer has confirmed receiving our type map,
57  * check if it is current and if so, stop retransmitting it.
58  *
59  * @param peer peer that confirmed the type map
60  * @param msg confirmation message we received
61  */
62 void
63 GSC_SESSIONS_confirm_typemap (const struct GNUNET_PeerIdentity *peer,
64                               const struct GNUNET_MessageHeader *msg);
65
66
67 /**
68  * End the session with the given peer (we are no longer
69  * connected).
70  *
71  * @param pid identity of peer to kill session with
72  */
73 void
74 GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid);
75
76
77 /**
78  * Traffic is being solicited for the given peer.  This means that the
79  * message queue on the transport-level (NEIGHBOURS subsystem) is now
80  * empty and it is now OK to transmit another (non-control) message.
81  *
82  * @param pid identity of peer ready to receive data
83  */
84 void
85 GSC_SESSIONS_solicit (const struct GNUNET_PeerIdentity *pid);
86
87
88 /**
89  * Queue a request from a client for transmission to a particular peer.
90  *
91  * @param car request to queue; this handle is then shared between
92  *         the caller (CLIENTS subsystem) and SESSIONS and must not
93  *         be released by either until either 'GNUNET_SESSIONS_dequeue',
94  *         or 'GNUNET_CLIENTS_failed'
95  *         have been invoked on it
96  */
97 void
98 GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest *car);
99
100
101 /**
102  * Dequeue a request from a client from transmission to a particular peer.
103  *
104  * @param car request to dequeue; this handle will then be 'owned' by
105  *        the caller (CLIENTS sysbsystem)
106  */
107 void
108 GSC_SESSIONS_dequeue_request (struct GSC_ClientActiveRequest *car);
109
110
111 /**
112  * Transmit a message to a particular peer.
113  *
114  * @param car original request that was queued and then solicited,
115  *            ownership does not change (dequeue will be called soon).
116  * @param msg message to transmit
117  * @param cork is corking allowed?
118  * @param priority how important is this message
119  */
120 void
121 GSC_SESSIONS_transmit (struct GSC_ClientActiveRequest *car,
122                        const struct GNUNET_MessageHeader *msg,
123                        int cork,
124                        enum GNUNET_CORE_Priority priority);
125
126
127 /**
128  * Broadcast an updated typemap message to all neighbours.
129  * Restarts the retransmissions until the typemaps are confirmed.
130  *
131  * @param msg message to transmit
132  */
133 void
134 GSC_SESSIONS_broadcast_typemap (const struct GNUNET_MessageHeader *msg);
135
136
137 /**
138  * We have a new client, notify it about all current sessions.
139  *
140  * @param client the new client
141  */
142 void
143 GSC_SESSIONS_notify_client_about_sessions (struct GSC_Client *client);
144
145
146 /**
147  * We've received a typemap message from a peer, update ours.
148  * Notifies clients about the session.
149  *
150  * @param peer peer this is about
151  * @param msg typemap update message
152  */
153 void
154 GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
155                           const struct GNUNET_MessageHeader *msg);
156
157
158 /**
159  * The given peer send a message of the specified type.  Make sure the
160  * respective bit is set in its type-map and that clients are notified
161  * about the session.
162  *
163  * @param peer peer this is about
164  * @param type type of the message
165  */
166 void
167 GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
168                              uint16_t type);
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