aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-04-07 15:18:48 +0000
committerBart Polot <bart@net.in.tum.de>2011-04-07 15:18:48 +0000
commit47afb3b4c553e503e0fed668c9d9f31c43518410 (patch)
tree9764318fd8bc21e96a873cab8503aa9a07f8ce06 /src
parentf43a092ddd82985e23d9277dbb5df400dc49491e (diff)
downloadgnunet-47afb3b4c553e503e0fed668c9d9f31c43518410.tar.gz
gnunet-47afb3b4c553e503e0fed668c9d9f31c43518410.zip
Work in progress, fix compile error
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c3
-rw-r--r--src/mesh/mesh_api_new.c126
2 files changed, 119 insertions, 10 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index e927d2737..145807338 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -255,6 +255,7 @@ struct PeerInfo
255 uint32_t max_speed; 255 uint32_t max_speed;
256}; 256};
257 257
258
258typedef uint32_t MESH_PathID; 259typedef uint32_t MESH_PathID;
259/** 260/**
260 * Information regarding a path 261 * Information regarding a path
@@ -277,7 +278,7 @@ struct Path
277 GNUNET_PEER_Id *peers; 278 GNUNET_PEER_Id *peers;
278}; 279};
279 280
280typedef uint32_t MESH_TunnelID; 281
281/** 282/**
282 * Struct containing all information regarding a tunnel 283 * Struct containing all information regarding a tunnel
283 * For an intermediate node the improtant info used will be: 284 * For an intermediate node the improtant info used will be:
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c
index f7b0e9034..2c292f7f1 100644
--- a/src/mesh/mesh_api_new.c
+++ b/src/mesh/mesh_api_new.c
@@ -55,6 +55,7 @@ struct GNUNET_MESH_Tunnel {
55 GNUNET_MESH_TunnelConnectHandler connect_handler; 55 GNUNET_MESH_TunnelConnectHandler connect_handler;
56 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler; 56 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler;
57 GNUNET_PEER_Id *peers; 57 GNUNET_PEER_Id *peers;
58 void *cls;
58}; 59};
59 60
60 61
@@ -62,14 +63,15 @@ struct GNUNET_MESH_Tunnel {
62 * Connect to the mesh service. 63 * Connect to the mesh service.
63 * 64 *
64 * @param cfg configuration to use 65 * @param cfg configuration to use
65 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 66 * @param cls closure for the various callbacks that follow
67 * (including handlers in the handlers array)
66 * @param cleaner function called when an *inbound* tunnel is destroyed 68 * @param cleaner function called when an *inbound* tunnel is destroyed
67 * @param handlers callbacks for messages we care about, NULL-terminated 69 * @param handlers callbacks for messages we care about, NULL-terminated
68 * note that the mesh is allowed to drop notifications about inbound 70 * note that the mesh is allowed to drop notifications about
69 * messages if the client does not process them fast enough (for this 71 * inbound messages if the client does not process them fast
70 * notification type, a bounded queue is used) 72 * enough (for this notification type, a bounded queue is used)
71 * @return handle to the mesh service 73 * @return handle to the mesh service
72 * NULL on error (in this case, init is never called) 74 * NULL on error (in this case, init is never called)
73 */ 75 */
74struct GNUNET_MESH_Handle * 76struct GNUNET_MESH_Handle *
75GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 77GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -84,18 +86,22 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
84 return h; 86 return h;
85} 87}
86 88
89
87/** 90/**
88 * Disconnect from the mesh service. 91 * Disconnect from the mesh service.
89 * 92 *
90 * @param handle connection to mesh to disconnect 93 * @param handle connection to mesh to disconnect
91 */ 94 */
92void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) { 95void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) {
96
97 GNUNET_free(handle);
93 return; 98 return;
94} 99}
95 100
101
96/** 102/**
97 * Create a new tunnel (we're initiator and will be allowed to add/remove peers and 103 * Create a new tunnel (we're initiator and will be allowed to add/remove peers
98 * to broadcast). 104 * and to broadcast).
99 * 105 *
100 * @param h mesh handle 106 * @param h mesh handle
101 * @param connect_handler function to call when peers are actually connected 107 * @param connect_handler function to call when peers are actually connected
@@ -104,8 +110,10 @@ void GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) {
104 */ 110 */
105struct GNUNET_MESH_Tunnel * 111struct GNUNET_MESH_Tunnel *
106GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, 112GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
107 GNUNET_MESH_TunnelConnectHandler connect_handler, 113 GNUNET_MESH_TunnelConnectHandler
108 GNUNET_MESH_TunnelDisconnectHandler disconnect_handler, 114 connect_handler,
115 GNUNET_MESH_TunnelDisconnectHandler
116 disconnect_handler,
109 void *handler_cls) { 117 void *handler_cls) {
110 GNUNET_MESH_Tunnel *tunnel; 118 GNUNET_MESH_Tunnel *tunnel;
111 tunnel = GNUNET_malloc(sizeof(GNUNET_MESH_Tunnel)); 119 tunnel = GNUNET_malloc(sizeof(GNUNET_MESH_Tunnel));
@@ -113,10 +121,110 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h,
113 tunnel->connect_handler = connect_handler; 121 tunnel->connect_handler = connect_handler;
114 tunnel->disconnect_handler = disconnect_handler; 122 tunnel->disconnect_handler = disconnect_handler;
115 tunnel->peers = NULL; 123 tunnel->peers = NULL;
124 tunnel->cls = handler_cls;
116 125
117 return tunnel; 126 return tunnel;
118} 127}
119 128
129
130/**
131 * Request that a peer should be added to the tunnel. The existing
132 * connect handler will be called ONCE with either success or failure.
133 *
134 * @param tunnel handle to existing tunnel
135 * @param timeout how long to try to establish a connection
136 * @param peer peer to add
137 */
138void
139GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel,
140 struct GNUNET_TIME_Relative timeout,
141 const struct GNUNET_PeerIdentity *peer) {
142 static GNUNET_PEER_Id peer_id;
143
144 peer_id = GNUNET_PEER_intern(peer);
145
146 /* FIXME ACTUALLY DO STUFF */
147 tunnel->peers = &peer;
148 tunnel->connect_handler(tunnel->cls, peer, NULL);
149 return;
150}
151
152
153/**
154 * Request that a peer should be removed from the tunnel. The existing
155 * disconnect handler will be called ONCE if we were connected.
156 *
157 * @param tunnel handle to existing tunnel
158 * @param peer peer to remove
159 */
160void
161GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel,
162 const struct GNUNET_PeerIdentity *peer) {
163 /* FIXME ACTUALLY DO STUFF */
164 tunnel->peers = NULL;
165 tunnel->disconnect_handler(tunnel->cls, peer);
166 return;
167}
168
169
170/**
171 * Request that the mesh should try to connect to a peer supporting the given
172 * message type.
173 *
174 * @param tunnel handle to existing tunnel
175 * @param timeout how long to try to establish a connection
176 * @param app_type application type that must be supported by the peer (MESH
177 * should discover peer in proximity handling this type)
178 */
179void
180GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel,
181 struct GNUNET_TIME_Relative timeout,
182 GNUNET_MESH_ApplicationType
183 app_type) {
184 return;
185}
186
187
188/**
189 * Ask the mesh to call "notify" once it is ready to transmit the
190 * given number of bytes to the specified "target". If we are not yet
191 * connected to the specified peer, a call to this function will cause
192 * us to try to establish a connection.
193 *
194 * @param tunnel tunnel to use for transmission
195 * @param cork is corking allowed for this transmission?
196 * @param priority how important is the message?
197 * @param maxdelay how long can the message wait?
198 * @param target destination for the message,
199 * NULL for multicast to all tunnel targets
200 * @param notify_size how many bytes of buffer space does notify want?
201 * @param notify function to call when buffer space is available;
202 * will be called with NULL on timeout or if the overall queue
203 * for this peer is larger than queue_size and this is currently
204 * the message with the lowest priority
205 * @param notify_cls closure for notify
206 * @return non-NULL if the notify callback was queued,
207 * NULL if we can not even queue the request (insufficient
208 * memory); if NULL is returned, "notify" will NOT be called.
209 */
210struct GNUNET_MESH_TransmitHandle *
211GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel,
212 int cork,
213 uint32_t priority,
214 struct GNUNET_TIME_Relative maxdelay,
215 const struct GNUNET_PeerIdentity *target,
216 size_t notify_size,
217 GNUNET_CONNECTION_TransmitReadyNotify
218 notify,
219 void *notify_cls) {
220 struct GNUNET_MESH_Handle *handle;
221
222 handle = GNUNET_malloc(sizeof(GNUNET_MESH_Handle));
223
224 return handle;
225}
226
227
120#if 0 /* keep Emacsens' auto-indent happy */ 228#if 0 /* keep Emacsens' auto-indent happy */
121{ 229{
122#endif 230#endif