diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_local.h')
-rw-r--r-- | src/cadet/gnunet-service-cadet_local.h | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/src/cadet/gnunet-service-cadet_local.h b/src/cadet/gnunet-service-cadet_local.h new file mode 100644 index 000000000..b78b3c5da --- /dev/null +++ b/src/cadet/gnunet-service-cadet_local.h | |||
@@ -0,0 +1,226 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2013 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 cadet/gnunet-service-cadet_local.h | ||
23 | * @brief cadet service; dealing with local clients | ||
24 | * @author Bartlomiej Polot | ||
25 | * | ||
26 | * All functions in this file should use the prefix GML (Gnunet Cadet Local) | ||
27 | */ | ||
28 | |||
29 | #ifndef GNUNET_SERVICE_CADET_LOCAL_H | ||
30 | #define GNUNET_SERVICE_CADET_LOCAL_H | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" | ||
34 | { | ||
35 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
36 | } | ||
37 | #endif | ||
38 | #endif | ||
39 | |||
40 | #include "platform.h" | ||
41 | #include "gnunet_util_lib.h" | ||
42 | |||
43 | /** | ||
44 | * Struct containing information about a client of the service | ||
45 | */ | ||
46 | struct CadetClient; | ||
47 | |||
48 | #include "gnunet-service-cadet_channel.h" | ||
49 | |||
50 | /******************************************************************************/ | ||
51 | /******************************** API ***********************************/ | ||
52 | /******************************************************************************/ | ||
53 | |||
54 | /** | ||
55 | * Initialize server subsystem. | ||
56 | * | ||
57 | * @param handle Server handle. | ||
58 | */ | ||
59 | void | ||
60 | GML_init (struct GNUNET_SERVER_Handle *handle); | ||
61 | |||
62 | /** | ||
63 | * Install server (service) handlers and start listening to clients. | ||
64 | */ | ||
65 | void | ||
66 | GML_start (void); | ||
67 | |||
68 | /** | ||
69 | * Shutdown server. | ||
70 | */ | ||
71 | void | ||
72 | GML_shutdown (void); | ||
73 | |||
74 | /** | ||
75 | * Get a channel from a client. | ||
76 | * | ||
77 | * @param c Client to check. | ||
78 | * @param chid Channel ID, must be local (> 0x800...). | ||
79 | * | ||
80 | * @return non-NULL if channel exists in the clients lists | ||
81 | */ | ||
82 | struct CadetChannel * | ||
83 | GML_channel_get (struct CadetClient *c, uint32_t chid); | ||
84 | |||
85 | /** | ||
86 | * Add a channel to a client | ||
87 | * | ||
88 | * @param client Client. | ||
89 | * @param chid Channel ID. | ||
90 | * @param ch Channel. | ||
91 | */ | ||
92 | void | ||
93 | GML_channel_add (struct CadetClient *client, | ||
94 | uint32_t chid, | ||
95 | struct CadetChannel *ch); | ||
96 | |||
97 | /** | ||
98 | * Remove a channel from a client | ||
99 | * | ||
100 | * @param client Client. | ||
101 | * @param chid Channel ID. | ||
102 | * @param ch Channel. | ||
103 | */ | ||
104 | void | ||
105 | GML_channel_remove (struct CadetClient *client, | ||
106 | uint32_t chid, | ||
107 | struct CadetChannel *ch); | ||
108 | |||
109 | /** | ||
110 | * Get the tunnel's next free local channel ID. | ||
111 | * | ||
112 | * @param c Client. | ||
113 | * | ||
114 | * @return LID of a channel free to use. | ||
115 | */ | ||
116 | CADET_ChannelNumber | ||
117 | GML_get_next_chid (struct CadetClient *c); | ||
118 | |||
119 | /** | ||
120 | * Check if client has registered with the service and has not disconnected | ||
121 | * | ||
122 | * @param client the client to check | ||
123 | * | ||
124 | * @return non-NULL if client exists in the global DLL | ||
125 | */ | ||
126 | struct CadetClient * | ||
127 | GML_client_get (struct GNUNET_SERVER_Client *client); | ||
128 | |||
129 | /** | ||
130 | * Find a client that has opened a port | ||
131 | * | ||
132 | * @param port Port to check. | ||
133 | * | ||
134 | * @return non-NULL if a client has the port. | ||
135 | */ | ||
136 | struct CadetClient * | ||
137 | GML_client_get_by_port (uint32_t port); | ||
138 | |||
139 | /** | ||
140 | * Deletes a tunnel from a client (either owner or destination). | ||
141 | * | ||
142 | * @param c Client whose tunnel to delete. | ||
143 | * @param ch Channel which should be deleted. | ||
144 | * @param id Channel ID. | ||
145 | */ | ||
146 | void | ||
147 | GML_client_delete_channel (struct CadetClient *c, | ||
148 | struct CadetChannel *ch, | ||
149 | CADET_ChannelNumber id); | ||
150 | |||
151 | /** | ||
152 | * Build a local ACK message and send it to a local client, if needed. | ||
153 | * | ||
154 | * If the client was already allowed to send data, do nothing. | ||
155 | * | ||
156 | * @param c Client to whom send the ACK. | ||
157 | * @param id Channel ID to use | ||
158 | */ | ||
159 | void | ||
160 | GML_send_ack (struct CadetClient *c, CADET_ChannelNumber id); | ||
161 | |||
162 | /** | ||
163 | * Notify the appropriate client that a new incoming channel was created. | ||
164 | * | ||
165 | * @param c Client to notify. | ||
166 | * @param id Channel ID. | ||
167 | * @param port Channel's destination port. | ||
168 | * @param opt Options (bit array). | ||
169 | * @param peer Origin peer. | ||
170 | */ | ||
171 | void | ||
172 | GML_send_channel_create (struct CadetClient *c, | ||
173 | uint32_t id, uint32_t port, uint32_t opt, | ||
174 | const struct GNUNET_PeerIdentity *peer); | ||
175 | |||
176 | /** | ||
177 | * Build a local channel NACK message and send it to a local client. | ||
178 | * | ||
179 | * @param c Client to whom send the NACK. | ||
180 | * @param id Channel ID to use | ||
181 | */ | ||
182 | void | ||
183 | GML_send_channel_nack (struct CadetClient *c, CADET_ChannelNumber id); | ||
184 | |||
185 | /** | ||
186 | * Notify a client that a channel is no longer valid. | ||
187 | * | ||
188 | * @param c Client. | ||
189 | * @param id ID of the channel that is destroyed. | ||
190 | */ | ||
191 | void | ||
192 | GML_send_channel_destroy (struct CadetClient *c, uint32_t id); | ||
193 | |||
194 | /** | ||
195 | * Modify the cadet message ID from global to local and send to client. | ||
196 | * | ||
197 | * @param c Client to send to. | ||
198 | * @param msg Message to modify and send. | ||
199 | * @param id Channel ID to use (c can be both owner and client). | ||
200 | */ | ||
201 | void | ||
202 | GML_send_data (struct CadetClient *c, | ||
203 | const struct GNUNET_CADET_Data *msg, | ||
204 | CADET_ChannelNumber id); | ||
205 | |||
206 | /** | ||
207 | * Get the static string to represent a client. | ||
208 | * | ||
209 | * @param c Client. | ||
210 | * | ||
211 | * @return Static string for the client. | ||
212 | */ | ||
213 | const char * | ||
214 | GML_2s (const struct CadetClient *c); | ||
215 | |||
216 | |||
217 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
218 | { | ||
219 | #endif | ||
220 | #ifdef __cplusplus | ||
221 | } | ||
222 | #endif | ||
223 | |||
224 | /* ifndef GNUNET_CADET_SERVICE_LOCAL_H */ | ||
225 | #endif | ||
226 | /* end of gnunet-cadet-service_LOCAL.h */ | ||