aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-03-29 09:36:22 +0000
committerBart Polot <bart@net.in.tum.de>2011-03-29 09:36:22 +0000
commit6d324c54d68defac2c1727ab40e4d0258361b50b (patch)
treec99e743ee16de16b3433764ba249db439049431f /src/mesh
parent76b1f350c95e6f4e28a0bc9d915f20e354fff1ab (diff)
downloadgnunet-6d324c54d68defac2c1727ab40e4d0258361b50b.tar.gz
gnunet-6d324c54d68defac2c1727ab40e4d0258361b50b.zip
Changed message declaration location, added api messages
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c187
-rw-r--r--src/mesh/mesh.h199
2 files changed, 249 insertions, 137 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index e63b1ba40..1598603a6 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -22,6 +22,13 @@
22 * @file mesh/gnunet-service-mesh.c 22 * @file mesh/gnunet-service-mesh.c
23 * @brief GNUnet MESH service 23 * @brief GNUnet MESH service
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
25 *
26 * TODO:
27 * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue
28 * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
29 * - partial disconnect reporting -- same as error reporting?
30 * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking...
31 * - speed requirement specification (change?) in mesh API -- API call
25 */ 32 */
26 33
27#include <stdint.h> 34#include <stdint.h>
@@ -30,6 +37,174 @@
30#include "gnunet_core_service.h" 37#include "gnunet_core_service.h"
31#include <netinet/in.h> 38#include <netinet/in.h>
32 39
40
41/******************************************************************************/
42/******************** MESH NETWORK MESSAGES **************************/
43/******************************************************************************/
44
45/**
46 * Message for mesh path management
47 */
48struct GNUNET_MESH_ManipulatePath
49{
50 /**
51 * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
52 *
53 * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity)
54 */
55 struct GNUNET_MessageHeader header;
56
57 /**
58 * Id of the tunnel this path belongs to, unique in conjunction with the origin.
59 */
60 uint32_t tid GNUNET_PACKED;
61
62 /**
63 * Information about speed requirements. If the tunnel cannot sustain the
64 * minimum bandwidth, packets are to be dropped.
65 */
66 uint32_t speed_min GNUNET_PACKED;
67
68 /**
69 * path_length structs defining the *whole* path from the origin [0] to the
70 * final destination [path_length-1].
71 */
72 // struct GNUNET_PeerIdentity peers[path_length];
73};
74
75/**
76 * Message for mesh data traffic to all tunnel targets.
77 */
78struct GNUNET_MESH_OriginMulticast
79{
80 /**
81 * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST
82 */
83 struct GNUNET_MessageHeader header;
84
85 /**
86 * TID of the tunnel
87 */
88 uint32_t tid GNUNET_PACKED;
89
90 /**
91 * OID of the tunnel
92 */
93 struct GNUNET_PeerIdentity oid;
94
95 /**
96 * FIXME: Some form of authentication
97 */
98 // uint32_t token;
99
100 /**
101 * Payload follows
102 */
103};
104
105
106/**
107 * Message for mesh data traffic to a particular destination from origin.
108 */
109struct GNUNET_MESH_DataMessageFromOrigin
110{
111 /**
112 * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN
113 */
114 struct GNUNET_MessageHeader header;
115
116 /**
117 * TID of the tunnel
118 */
119 uint32_t tid GNUNET_PACKED;
120
121 /**
122 * OID of the tunnel
123 */
124 struct GNUNET_PeerIdentity oid;
125
126 /**
127 * Destination.
128 */
129 struct GNUNET_PeerIdentity destination;
130
131 /**
132 * FIXME: Some form of authentication
133 */
134 // uint32_t token;
135
136 /**
137 * Payload follows
138 */
139};
140
141
142/**
143 * Message for mesh data traffic from a tunnel participant to origin.
144 */
145struct GNUNET_MESH_DataMessageToOrigin
146{
147 /**
148 * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN
149 */
150 struct GNUNET_MessageHeader header;
151
152 /**
153 * TID of the tunnel
154 */
155 uint32_t tid GNUNET_PACKED;
156
157 /**
158 * OID of the tunnel
159 */
160 struct GNUNET_PeerIdentity oid;
161
162 /**
163 * Sender of the message.
164 */
165 struct GNUNET_PeerIdentity sender;
166
167 /**
168 * FIXME: Some form of authentication
169 */
170 // uint32_t token;
171
172 /**
173 * Payload follows
174 */
175};
176
177/**
178 * Message for mesh flow control
179 */
180struct GNUNET_MESH_SpeedNotify
181{
182 /**
183 * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY
184 */
185 struct GNUNET_MessageHeader header;
186
187 /**
188 * TID of the tunnel
189 */
190 uint32_t tid GNUNET_PACKED;
191
192 /**
193 * OID of the tunnel
194 */
195 struct GNUNET_PeerIdentity oid;
196
197 /**
198 * Slowest link down the path (above minimum speed requirement).
199 */
200 uint32_t speed_min;
201
202};
203
204/******************************************************************************/
205/************************ DATA STRUCTURES ****************************/
206/******************************************************************************/
207
33/** 208/**
34 * All the states a peer participating in a tunnel can be in. 209 * All the states a peer participating in a tunnel can be in.
35 */ 210 */
@@ -183,6 +358,7 @@ struct Clients
183 358
184/** 359/**
185 * Handler for requests of creating new path 360 * Handler for requests of creating new path
361 * type: struct GNUNET_CORE_MessageHandler
186 * 362 *
187 * @param cls closure 363 * @param cls closure
188 * @param client the client this message is from 364 * @param client the client this message is from
@@ -212,6 +388,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
212 388
213/** 389/**
214 * Core handler for path creation 390 * Core handler for path creation
391 * struct GNUNET_CORE_MessageHandler
215 * 392 *
216 * @param cls closure 393 * @param cls closure
217 * @param message message 394 * @param message message
@@ -227,6 +404,10 @@ handle_mesh_path_create (void *cls,
227 *atsi) 404 *atsi)
228{ 405{
229 /* Extract path */ 406 /* Extract path */
407 /* Find origin & self */
408 /* Search for origin in local tunnels */
409 /* Create tunnel / add path */
410 /* Retransmit to next link in chain, if any (core_notify + callback) */
230 return GNUNET_OK; 411 return GNUNET_OK;
231} 412}
232 413
@@ -269,9 +450,9 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = {
269 * Functions to handle messages from clients 450 * Functions to handle messages from clients
270 */ 451 */
271static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 452static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
272 {&handle_local_path_create, NULL, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, 453 {&handle_local_path_create, NULL, GNUNET_MESSAGE_TYPE_LOCAL_PATH_CREATE, 0},
273 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_GO, 0}, 454 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_GO, 0},
274 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_MESH_DATA_BACK, 0}, 455 {&handle_local_network_traffic, GNUNET_MESSAGE_TYPE_LOCAL_DATA_BACK, 0},
275 {NULL, NULL, 0, 0} 456 {NULL, NULL, 0, 0}
276}; 457};
277 458
diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h
index e51b0c890..dda3e2fcc 100644
--- a/src/mesh/mesh.h
+++ b/src/mesh/mesh.h
@@ -23,178 +23,109 @@
23 * @file mesh/mesh.h 23 * @file mesh/mesh.h
24 * 24 *
25 * TODO: 25 * TODO:
26 * - soft stateing (keep-alive (CHANGE?) / timeout / disconnect) -- not a message issue
27 * - error reporting (CREATE/CHANGE/ADD/DEL?) -- new message!
28 * - partial disconnect reporting -- same as error reporting?
29 * - add vs create? change vs. keep-alive? same msg or different ones? -- thinking...
30 * - speed requirement specification (change?) in mesh API -- API call
31 *
32 * - API messages! 26 * - API messages!
33 */ 27 */
34 28
35
36#ifndef MESH_H_ 29#ifndef MESH_H_
37#define MESH_H_ 30#define MESH_H_
38#include <stdint.h> 31#include <stdint.h>
39#include "gnunet_common.h" 32#include "gnunet_common.h"
40 33
41/** 34/******************************************************************************/
42 * Message for mesh path management 35/******************** MESH NETWORK MESSAGES **************************/
36/******************************************************************************/
37/* API CALL MESSAGE USED
38 * -------- ------------
39 * connect GNUNET_MESH_Connect / Server_connect? FIXME
40 * disconnect GNUNET_MESH_Disconnect / Server_disconnect? FIXME
41 *
42 * peer_request_connect_any GNUNET_MESH_ConnectPeer
43 * peer_request_connect_all GNUNET_MESH_ConnectPeer
44 * peer_request_connect_add GNUNET_MESH_ConnectPeer
45 * peer_request_connect_del GNUNET_MESH_ConnectPeer
46 * peer_request_connect_by_type GNUNET_MESH_ConnectPeerByType
47 * peer_request_connect_cancel GNUNET_MESH_Control
48 *
49 * notify_tranmit_ready GNUNET_MESH_Control? FIXME
50 * notify_tranmit_ready_cancel GNUNET_MESH_Control? FIXME
43 */ 51 */
44struct GNUNET_MESH_ManipulatePath
45{
46 /**
47 * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DEL]
48 *
49 * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + path_length * sizeof (struct GNUNET_PeerIdentity)
50 */
51 struct GNUNET_MessageHeader header;
52
53 /**
54 * Id of the tunnel this path belongs to, unique in conjunction with the origin.
55 */
56 uint32_t tid GNUNET_PACKED;
57 52
58 /** 53// struct GNUNET_MESH_Connect {
59 * Information about speed requirements. If the tunnel cannot sustain the 54// /**
60 * minimum bandwidth, packets are to be dropped. 55// * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT
56// *
57// * Size: sizeof(struct GNUNET_MESH_Connect) + messages_subscribed * sizeof (message_type)
58// */
59// struct GNUNET_MessageHeader header;
60//
61// /* uint16_t messages_subscribed[] */
62// };
63//
64// struct GNUNET_MESH_Disconnect {
65// /**
66// * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DISCONNECT
67// */
68// struct GNUNET_MessageHeader header;
69//
70// };
71
72struct GNUNET_MESH_ConnectPeer {
73 /**
74 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_[ANY|ALL|ADD|DEL]
75 *
76 * Size: sizeof(struct GNUNET_MESH_ConnectPeer) + npeers * sizeof (struct GNUNET_PeerIdentity)
61 */ 77 */
62 uint32_t speed_min GNUNET_PACKED; 78 struct GNUNET_MessageHeader header;
63 79
64 /** 80 /* struct GNUNET_PeerIdentity peers[] */
65 * path_length structs defining the *whole* path from the origin [0] to the
66 * final destination [path_length-1].
67 */
68 // struct GNUNET_PeerIdentity peers[path_length];
69}; 81};
70 82
71/** 83struct GNUNET_MESH_ConnectPeerByType {
72 * Message for mesh data traffic to all tunnel targets.
73 */
74struct GNUNET_MESH_OriginMulticast
75{
76 /** 84 /**
77 * Type: GNUNET_MESSAGE_TYPE_DATA_MULTICAST 85 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_BY_TYPE
78 */ 86 */
79 struct GNUNET_MessageHeader header; 87 struct GNUNET_MessageHeader header;
80 88
81 /** 89 /* FIXME Type specification */
82 * TID of the tunnel 90 uint32_t type;
83 */
84 uint32_t tid GNUNET_PACKED;
85
86 /**
87 * OID of the tunnel
88 */
89 struct GNUNET_PeerIdentity oid;
90
91 /**
92 * FIXME: Some form of authentication
93 */
94 // uint32_t token;
95
96 /**
97 * Payload follows
98 */
99}; 91};
100 92
101 93struct GNUNET_MESH_Control {
102/**
103 * Message for mesh data traffic to a particular destination from origin.
104 */
105struct GNUNET_MESH_DataMessageFromOrigin
106{
107 /** 94 /**
108 * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN 95 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_CANCEL
96 * more? transmit_ready?
109 */ 97 */
110 struct GNUNET_MessageHeader header; 98 struct GNUNET_MessageHeader header;
111 99
112 /** 100 uint32_t tunnel_id GNUNET_PACKED;
113 * TID of the tunnel 101 uint32_t variable GNUNET_PACKED; /* Size of data to transmit? */
114 */
115 uint32_t tid GNUNET_PACKED;
116
117 /**
118 * OID of the tunnel
119 */
120 struct GNUNET_PeerIdentity oid;
121
122 /**
123 * Destination.
124 */
125 struct GNUNET_PeerIdentity destination;
126
127 /**
128 * FIXME: Some form of authentication
129 */
130 // uint32_t token;
131
132 /**
133 * Payload follows
134 */
135}; 102};
136 103
137 104struct GNUNET_MESH_TunnelEvent {
138/**
139 * Message for mesh data traffic from a tunnel participant to origin.
140 */
141struct GNUNET_MESH_DataMessageToOrigin
142{
143 /** 105 /**
144 * Type: GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN 106 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATED\DESTROYED]
145 */ 107 */
146 struct GNUNET_MessageHeader header; 108 struct GNUNET_MessageHeader header;
147 109
148 /** 110 uint32_t tunnel_id GNUNET_PACKED;
149 * TID of the tunnel 111 uint32_t reason GNUNET_PACKED; /* incoming, connect, timeout, disconnect */
150 */
151 uint32_t tid GNUNET_PACKED;
152
153 /**
154 * OID of the tunnel
155 */
156 struct GNUNET_PeerIdentity oid;
157
158 /**
159 * Sender of the message.
160 */
161 struct GNUNET_PeerIdentity sender;
162
163 /**
164 * FIXME: Some form of authentication
165 */
166 // uint32_t token;
167
168 /**
169 * Payload follows
170 */
171}; 112};
172 113
173/** 114struct GNUNET_MESH_Data {
174 * Message for mesh flow control
175 */
176struct GNUNET_MESH_SpeedNotify
177{
178 /** 115 /**
179 * Type: GNUNET_MESSAGE_TYPE_DATA_SPEED_NOTIFY 116 * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_DATA
117 *
118 * Size: sizeof(struct GNUNET_MESH_Data) + sizeof (data)
180 */ 119 */
181 struct GNUNET_MessageHeader header; 120 struct GNUNET_MessageHeader header;
182 121
183 /** 122 uint32_t tunnel_id GNUNET_PACKED;
184 * TID of the tunnel
185 */
186 uint32_t tid GNUNET_PACKED;
187
188 /**
189 * OID of the tunnel
190 */
191 struct GNUNET_PeerIdentity oid;
192 123
193 /** 124 /* FIXME: Broadcast? New Type / NULL destination ? */
194 * Slowest link down the path (above minimum speed requirement). 125 /* FIXME: Reverese order for alignment? 1st ID, 2nd t_id? */
195 */ 126 struct GNUNET_PeerIdentity destination GNUNET_PACKED;
196 uint32_t speed_min;
197 127
128 /* uint8_t data[] */
198}; 129};
199 130
200#endif 131#endif