2 This file is part of GNUnet.
3 Copyright (C) 2013 GNUnet e.V.
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.
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.
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.
22 * @file cadet/gnunet-service-cadet_local.h
23 * @brief cadet service; dealing with local clients
24 * @author Bartlomiej Polot
26 * All functions in this file should use the prefix GML (Gnunet Cadet Local)
29 #ifndef GNUNET_SERVICE_CADET_LOCAL_H
30 #define GNUNET_SERVICE_CADET_LOCAL_H
35 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_util_lib.h"
44 * Struct containing information about a client of the service
48 #include "gnunet-service-cadet_channel.h"
50 /******************************************************************************/
51 /******************************** API ***********************************/
52 /******************************************************************************/
55 * Initialize server subsystem.
57 * @param handle Server handle.
60 GML_init (struct GNUNET_SERVER_Handle *handle);
63 * Install server (service) handlers and start listening to clients.
75 * Get a channel from a client.
77 * @param c Client to check.
78 * @param chid Channel ID, must be local (> 0x800...).
80 * @return non-NULL if channel exists in the clients lists
83 GML_channel_get (struct CadetClient *c,
84 struct GNUNET_CADET_ClientChannelNumber chid);
87 * Add a channel to a client
89 * @param client Client.
90 * @param chid Channel ID.
94 GML_channel_add (struct CadetClient *client,
95 struct GNUNET_CADET_ClientChannelNumber chid,
96 struct CadetChannel *ch);
99 * Remove a channel from a client
101 * @param client Client.
102 * @param chid Channel ID.
106 GML_channel_remove (struct CadetClient *client,
107 struct GNUNET_CADET_ClientChannelNumber chid,
108 struct CadetChannel *ch);
111 * Get the tunnel's next free local channel ID.
115 * @return LID of a channel free to use.
117 struct GNUNET_CADET_ClientChannelNumber
118 GML_get_next_chid (struct CadetClient *c);
121 * Check if client has registered with the service and has not disconnected
123 * @param client the client to check
125 * @return non-NULL if client exists in the global DLL
128 GML_client_get (struct GNUNET_SERVER_Client *client);
131 * Find a client that has opened a port
133 * @param port Port to check.
135 * @return non-NULL if a client has the port.
138 GML_client_get_by_port (const struct GNUNET_HashCode *port);
141 * Deletes a tunnel from a client (either owner or destination).
143 * @param c Client whose tunnel to delete.
144 * @param ch Channel which should be deleted.
145 * @param id Channel ID.
148 GML_client_delete_channel (struct CadetClient *c,
149 struct CadetChannel *ch,
150 struct GNUNET_CADET_ClientChannelNumber id);
153 * Build a local ACK message and send it to a local client, if needed.
155 * If the client was already allowed to send data, do nothing.
157 * @param c Client to whom send the ACK.
158 * @param id Channel ID to use
161 GML_send_ack (struct CadetClient *c,
162 struct GNUNET_CADET_ClientChannelNumber id);
165 * Notify the appropriate client that a new incoming channel was created.
167 * @param c Client to notify.
168 * @param id Channel ID.
169 * @param port Channel's destination port.
170 * @param opt Options (bit array).
171 * @param peer Origin peer.
174 GML_send_channel_create (struct CadetClient *c,
175 struct GNUNET_CADET_ClientChannelNumber id,
176 const struct GNUNET_HashCode *port,
178 const struct GNUNET_PeerIdentity *peer);
181 * Build a local channel NACK message and send it to a local client.
183 * @param c Client to whom send the NACK.
184 * @param id Channel ID to use
187 GML_send_channel_nack (struct CadetClient *c,
188 struct GNUNET_CADET_ClientChannelNumber id);
192 * Notify a client that a channel is no longer valid.
195 * @param id ID of the channel that is destroyed.
198 GML_send_channel_destroy (struct CadetClient *c,
199 struct GNUNET_CADET_ClientChannelNumber id);
203 * Modify the cadet message ID from global to local and send to client.
205 * @param c Client to send to.
206 * @param msg Message to modify and send.
207 * @param id Channel ID to use (c can be both owner and client).
210 GML_send_data (struct CadetClient *c,
211 const struct GNUNET_CADET_ChannelAppDataMessage *msg,
212 struct GNUNET_CADET_ClientChannelNumber id);
215 * Get the static string to represent a client.
219 * @return Static string for the client.
222 GML_2s (const struct CadetClient *c);
225 #if 0 /* keep Emacsens' auto-indent happy */
232 /* ifndef GNUNET_CADET_SERVICE_LOCAL_H */
234 /* end of gnunet-cadet-service_LOCAL.h */