diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 100 | ||||
-rw-r--r-- | src/mesh/mesh2.h | 16 | ||||
-rw-r--r-- | src/mesh/mesh2_api.c | 64 | ||||
-rw-r--r-- | src/mesh/mesh2_protocol.h | 31 |
4 files changed, 104 insertions, 107 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index 32ae6998f..49b70319a 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -294,6 +294,11 @@ struct MeshTunnel | |||
294 | struct MESH_TunnelID id; | 294 | struct MESH_TunnelID id; |
295 | 295 | ||
296 | /** | 296 | /** |
297 | * Port of the tunnel. | ||
298 | */ | ||
299 | uint32_t port; | ||
300 | |||
301 | /** | ||
297 | * State of the tunnel. | 302 | * State of the tunnel. |
298 | */ | 303 | */ |
299 | enum MeshTunnelState state; | 304 | enum MeshTunnelState state; |
@@ -1196,7 +1201,7 @@ send_create_path (struct MeshTunnel *t) | |||
1196 | neighbor = peer_get_short (t->next_hop); | 1201 | neighbor = peer_get_short (t->next_hop); |
1197 | queue_add (t, | 1202 | queue_add (t, |
1198 | GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, | 1203 | GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, |
1199 | sizeof (struct GNUNET_MESH_ManipulatePath) + | 1204 | sizeof (struct GNUNET_MESH_CreateTunnel) + |
1200 | (t->path->length * sizeof (struct GNUNET_PeerIdentity)), | 1205 | (t->path->length * sizeof (struct GNUNET_PeerIdentity)), |
1201 | neighbor, | 1206 | neighbor, |
1202 | t); | 1207 | t); |
@@ -2419,7 +2424,7 @@ static size_t | |||
2419 | send_core_path_create (void *cls, size_t size, void *buf) | 2424 | send_core_path_create (void *cls, size_t size, void *buf) |
2420 | { | 2425 | { |
2421 | struct MeshTunnel *t = cls; | 2426 | struct MeshTunnel *t = cls; |
2422 | struct GNUNET_MESH_ManipulatePath *msg; | 2427 | struct GNUNET_MESH_CreateTunnel *msg; |
2423 | struct GNUNET_PeerIdentity *peer_ptr; | 2428 | struct GNUNET_PeerIdentity *peer_ptr; |
2424 | struct MeshPeerPath *p = t->path; | 2429 | struct MeshPeerPath *p = t->path; |
2425 | size_t size_needed; | 2430 | size_t size_needed; |
@@ -2428,7 +2433,7 @@ send_core_path_create (void *cls, size_t size, void *buf) | |||
2428 | 2433 | ||
2429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CREATE PATH sending...\n"); | 2434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CREATE PATH sending...\n"); |
2430 | size_needed = | 2435 | size_needed = |
2431 | sizeof (struct GNUNET_MESH_ManipulatePath) + | 2436 | sizeof (struct GNUNET_MESH_CreateTunnel) + |
2432 | p->length * sizeof (struct GNUNET_PeerIdentity); | 2437 | p->length * sizeof (struct GNUNET_PeerIdentity); |
2433 | 2438 | ||
2434 | if (size < size_needed || NULL == buf) | 2439 | if (size < size_needed || NULL == buf) |
@@ -2436,7 +2441,7 @@ send_core_path_create (void *cls, size_t size, void *buf) | |||
2436 | GNUNET_break (0); | 2441 | GNUNET_break (0); |
2437 | return 0; | 2442 | return 0; |
2438 | } | 2443 | } |
2439 | msg = (struct GNUNET_MESH_ManipulatePath *) buf; | 2444 | msg = (struct GNUNET_MESH_CreateTunnel *) buf; |
2440 | msg->header.size = htons (size_needed); | 2445 | msg->header.size = htons (size_needed); |
2441 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE); | 2446 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE); |
2442 | msg->tid = ntohl (t->id.tid); | 2447 | msg->tid = ntohl (t->id.tid); |
@@ -2444,8 +2449,8 @@ send_core_path_create (void *cls, size_t size, void *buf) | |||
2444 | opt = 0; | 2449 | opt = 0; |
2445 | if (GNUNET_YES == t->nobuffer) | 2450 | if (GNUNET_YES == t->nobuffer) |
2446 | opt |= MESH_TUNNEL_OPT_NOBUFFER; | 2451 | opt |= MESH_TUNNEL_OPT_NOBUFFER; |
2447 | msg->opt = htonl(opt); | 2452 | msg->opt = htonl (opt); |
2448 | msg->reserved = 0; | 2453 | msg->port = htonl (t->port); |
2449 | 2454 | ||
2450 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; | 2455 | peer_ptr = (struct GNUNET_PeerIdentity *) &msg[1]; |
2451 | for (i = 0; i < p->length; i++) | 2456 | for (i = 0; i < p->length; i++) |
@@ -2871,7 +2876,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2871 | uint16_t size; | 2876 | uint16_t size; |
2872 | uint16_t i; | 2877 | uint16_t i; |
2873 | MESH_TunnelNumber tid; | 2878 | MESH_TunnelNumber tid; |
2874 | struct GNUNET_MESH_ManipulatePath *msg; | 2879 | struct GNUNET_MESH_CreateTunnel *msg; |
2875 | struct GNUNET_PeerIdentity *pi; | 2880 | struct GNUNET_PeerIdentity *pi; |
2876 | struct GNUNET_HashCode hash; | 2881 | struct GNUNET_HashCode hash; |
2877 | struct MeshPeerPath *path; | 2882 | struct MeshPeerPath *path; |
@@ -2883,13 +2888,13 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2883 | "Received a path create msg [%s]\n", | 2888 | "Received a path create msg [%s]\n", |
2884 | GNUNET_i2s (&my_full_id)); | 2889 | GNUNET_i2s (&my_full_id)); |
2885 | size = ntohs (message->size); | 2890 | size = ntohs (message->size); |
2886 | if (size < sizeof (struct GNUNET_MESH_ManipulatePath)) | 2891 | if (size < sizeof (struct GNUNET_MESH_CreateTunnel)) |
2887 | { | 2892 | { |
2888 | GNUNET_break_op (0); | 2893 | GNUNET_break_op (0); |
2889 | return GNUNET_OK; | 2894 | return GNUNET_OK; |
2890 | } | 2895 | } |
2891 | 2896 | ||
2892 | size -= sizeof (struct GNUNET_MESH_ManipulatePath); | 2897 | size -= sizeof (struct GNUNET_MESH_CreateTunnel); |
2893 | if (size % sizeof (struct GNUNET_PeerIdentity)) | 2898 | if (size % sizeof (struct GNUNET_PeerIdentity)) |
2894 | { | 2899 | { |
2895 | GNUNET_break_op (0); | 2900 | GNUNET_break_op (0); |
@@ -2902,7 +2907,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2902 | return GNUNET_OK; | 2907 | return GNUNET_OK; |
2903 | } | 2908 | } |
2904 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " path has %u hops.\n", size); | 2909 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " path has %u hops.\n", size); |
2905 | msg = (struct GNUNET_MESH_ManipulatePath *) message; | 2910 | msg = (struct GNUNET_MESH_CreateTunnel *) message; |
2906 | 2911 | ||
2907 | tid = ntohl (msg->tid); | 2912 | tid = ntohl (msg->tid); |
2908 | pi = (struct GNUNET_PeerIdentity *) &msg[1]; | 2913 | pi = (struct GNUNET_PeerIdentity *) &msg[1]; |
@@ -3023,79 +3028,6 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3023 | 3028 | ||
3024 | 3029 | ||
3025 | /** | 3030 | /** |
3026 | * Core handler for path destruction | ||
3027 | * | ||
3028 | * @param cls closure | ||
3029 | * @param message message | ||
3030 | * @param peer peer identity this notification is about | ||
3031 | * | ||
3032 | * @return GNUNET_OK to keep the connection open, | ||
3033 | * GNUNET_SYSERR to close it (signal serious error) | ||
3034 | */ | ||
3035 | static int | ||
3036 | handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
3037 | const struct GNUNET_MessageHeader *message) | ||
3038 | { | ||
3039 | struct GNUNET_MESH_ManipulatePath *msg; | ||
3040 | struct GNUNET_PeerIdentity *pi; | ||
3041 | struct MeshTunnel *t; | ||
3042 | unsigned int own_pos; | ||
3043 | unsigned int i; | ||
3044 | size_t size; | ||
3045 | |||
3046 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3047 | "Received a PATH DESTROY msg from %s\n", GNUNET_i2s (peer)); | ||
3048 | size = ntohs (message->size); | ||
3049 | if (size < sizeof (struct GNUNET_MESH_ManipulatePath)) | ||
3050 | { | ||
3051 | GNUNET_break_op (0); | ||
3052 | return GNUNET_OK; | ||
3053 | } | ||
3054 | |||
3055 | size -= sizeof (struct GNUNET_MESH_ManipulatePath); | ||
3056 | if (size % sizeof (struct GNUNET_PeerIdentity)) | ||
3057 | { | ||
3058 | GNUNET_break_op (0); | ||
3059 | return GNUNET_OK; | ||
3060 | } | ||
3061 | size /= sizeof (struct GNUNET_PeerIdentity); | ||
3062 | if (size < 2) | ||
3063 | { | ||
3064 | GNUNET_break_op (0); | ||
3065 | return GNUNET_OK; | ||
3066 | } | ||
3067 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " path has %u hops.\n", size); | ||
3068 | |||
3069 | msg = (struct GNUNET_MESH_ManipulatePath *) message; | ||
3070 | pi = (struct GNUNET_PeerIdentity *) &msg[1]; | ||
3071 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3072 | " path is for tunnel %s [%X].\n", GNUNET_i2s (pi), | ||
3073 | msg->tid); | ||
3074 | t = tunnel_get (pi, ntohl (msg->tid)); | ||
3075 | if (NULL == t) | ||
3076 | { | ||
3077 | /* TODO notify back: we don't know this tunnel */ | ||
3078 | GNUNET_break_op (0); | ||
3079 | return GNUNET_OK; | ||
3080 | } | ||
3081 | own_pos = 0; | ||
3082 | for (i = 0; i < size; i++) | ||
3083 | { | ||
3084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u: %s\n", i, GNUNET_i2s (&pi[i])); | ||
3085 | if (GNUNET_PEER_search (&pi[i]) == myid) | ||
3086 | own_pos = i; | ||
3087 | } | ||
3088 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); | ||
3089 | if (own_pos < size - 1) | ||
3090 | send_prebuilt_message (message, t->next_hop, t); | ||
3091 | else | ||
3092 | send_client_tunnel_destroy (t); | ||
3093 | |||
3094 | return GNUNET_OK; | ||
3095 | } | ||
3096 | |||
3097 | |||
3098 | /** | ||
3099 | * Core handler for notifications of broken paths | 3031 | * Core handler for notifications of broken paths |
3100 | * | 3032 | * |
3101 | * @param cls closure | 3033 | * @param cls closure |
@@ -3650,7 +3582,6 @@ handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3650 | */ | 3582 | */ |
3651 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { | 3583 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { |
3652 | {&handle_mesh_path_create, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, | 3584 | {&handle_mesh_path_create, GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE, 0}, |
3653 | {&handle_mesh_path_destroy, GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY, 0}, | ||
3654 | {&handle_mesh_path_broken, GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN, | 3585 | {&handle_mesh_path_broken, GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN, |
3655 | sizeof (struct GNUNET_MESH_PathBroken)}, | 3586 | sizeof (struct GNUNET_MESH_PathBroken)}, |
3656 | {&handle_mesh_tunnel_destroy, GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY, | 3587 | {&handle_mesh_tunnel_destroy, GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY, |
@@ -3994,6 +3925,7 @@ handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, | |||
3994 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 3925 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
3995 | return; | 3926 | return; |
3996 | } | 3927 | } |
3928 | t->port = ntohl (t->port); | ||
3997 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CREATED TUNNEL %s [%x] (%x)\n", | 3929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CREATED TUNNEL %s [%x] (%x)\n", |
3998 | GNUNET_i2s (&my_full_id), t->id.tid, t->local_tid); | 3930 | GNUNET_i2s (&my_full_id), t->id.tid, t->local_tid); |
3999 | 3931 | ||
diff --git a/src/mesh/mesh2.h b/src/mesh/mesh2.h index ec2e14a1f..d42a630a0 100644 --- a/src/mesh/mesh2.h +++ b/src/mesh/mesh2.h | |||
@@ -113,7 +113,9 @@ struct GNUNET_MESH_ClientConnect | |||
113 | */ | 113 | */ |
114 | struct GNUNET_MessageHeader header; | 114 | struct GNUNET_MessageHeader header; |
115 | uint16_t types GNUNET_PACKED; | 115 | uint16_t types GNUNET_PACKED; |
116 | uint16_t ports GNUNET_PACKED; | ||
116 | /* uint16_t list_types[types] */ | 117 | /* uint16_t list_types[types] */ |
118 | /* uint32_t list_ports[ports] */ | ||
117 | }; | 119 | }; |
118 | 120 | ||
119 | 121 | ||
@@ -125,6 +127,7 @@ struct GNUNET_MESH_ClientConnect | |||
125 | */ | 127 | */ |
126 | typedef uint32_t MESH_TunnelNumber; | 128 | typedef uint32_t MESH_TunnelNumber; |
127 | 129 | ||
130 | |||
128 | /** | 131 | /** |
129 | * Message for a client to create and destroy tunnels. | 132 | * Message for a client to create and destroy tunnels. |
130 | */ | 133 | */ |
@@ -132,7 +135,6 @@ struct GNUNET_MESH_TunnelMessage | |||
132 | { | 135 | { |
133 | /** | 136 | /** |
134 | * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY] | 137 | * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[CREATE|DESTROY] |
135 | * GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_[MAX|MIN] | ||
136 | * | 138 | * |
137 | * Size: sizeof(struct GNUNET_MESH_TunnelMessage) | 139 | * Size: sizeof(struct GNUNET_MESH_TunnelMessage) |
138 | */ | 140 | */ |
@@ -147,6 +149,11 @@ struct GNUNET_MESH_TunnelMessage | |||
147 | * Tunnel's peer | 149 | * Tunnel's peer |
148 | */ | 150 | */ |
149 | struct GNUNET_PeerIdentity peer; | 151 | struct GNUNET_PeerIdentity peer; |
152 | |||
153 | /** | ||
154 | * Port of the tunnel. | ||
155 | */ | ||
156 | uint32_t port GNUNET_PACKED; | ||
150 | }; | 157 | }; |
151 | 158 | ||
152 | 159 | ||
@@ -173,9 +180,14 @@ struct GNUNET_MESH_TunnelNotification | |||
173 | struct GNUNET_PeerIdentity peer; | 180 | struct GNUNET_PeerIdentity peer; |
174 | 181 | ||
175 | /** | 182 | /** |
183 | * Port for this tunnel | ||
184 | */ | ||
185 | uint32_t port GNUNET_PACKED; | ||
186 | |||
187 | /** | ||
176 | * Tunnel options (speed, buffering) | 188 | * Tunnel options (speed, buffering) |
177 | */ | 189 | */ |
178 | uint32_t opt; | 190 | uint32_t opt GNUNET_PACKED; |
179 | }; | 191 | }; |
180 | 192 | ||
181 | 193 | ||
diff --git a/src/mesh/mesh2_api.c b/src/mesh/mesh2_api.c index 90a216774..31681bec1 100644 --- a/src/mesh/mesh2_api.c +++ b/src/mesh/mesh2_api.c | |||
@@ -117,6 +117,21 @@ struct GNUNET_MESH_Handle | |||
117 | */ | 117 | */ |
118 | const struct GNUNET_MESH_MessageHandler *message_handlers; | 118 | const struct GNUNET_MESH_MessageHandler *message_handlers; |
119 | 119 | ||
120 | /** | ||
121 | * Number of handlers in the handlers array. | ||
122 | */ | ||
123 | unsigned int n_handlers; | ||
124 | |||
125 | /** | ||
126 | * Ports open. | ||
127 | */ | ||
128 | uint32_t *ports; | ||
129 | |||
130 | /** | ||
131 | * Number of ports. | ||
132 | */ | ||
133 | unsigned int n_ports; | ||
134 | |||
120 | /** | 135 | /** |
121 | * Double linked list of the tunnels this client is connected to, head. | 136 | * Double linked list of the tunnels this client is connected to, head. |
122 | */ | 137 | */ |
@@ -163,11 +178,6 @@ struct GNUNET_MESH_Handle | |||
163 | MESH_TunnelNumber next_tid; | 178 | MESH_TunnelNumber next_tid; |
164 | 179 | ||
165 | /** | 180 | /** |
166 | * Number of handlers in the handlers array. | ||
167 | */ | ||
168 | unsigned int n_handlers; | ||
169 | |||
170 | /** | ||
171 | * Have we started the task to receive messages from the service | 181 | * Have we started the task to receive messages from the service |
172 | * yet? We do this after we send the 'MESH_LOCAL_CONNECT' message. | 182 | * yet? We do this after we send the 'MESH_LOCAL_CONNECT' message. |
173 | */ | 183 | */ |
@@ -265,6 +275,11 @@ struct GNUNET_MESH_Tunnel | |||
265 | MESH_TunnelNumber tid; | 275 | MESH_TunnelNumber tid; |
266 | 276 | ||
267 | /** | 277 | /** |
278 | * Port number. | ||
279 | */ | ||
280 | uint32_t port; | ||
281 | |||
282 | /** | ||
268 | * Other end of the tunnel. | 283 | * Other end of the tunnel. |
269 | */ | 284 | */ |
270 | GNUNET_PEER_Id peer; | 285 | GNUNET_PEER_Id peer; |
@@ -633,23 +648,32 @@ send_connect (struct GNUNET_MESH_Handle *h) | |||
633 | char buf[size] GNUNET_ALIGN; | 648 | char buf[size] GNUNET_ALIGN; |
634 | struct GNUNET_MESH_ClientConnect *msg; | 649 | struct GNUNET_MESH_ClientConnect *msg; |
635 | uint16_t *types; | 650 | uint16_t *types; |
636 | uint16_t ntypes; | 651 | uint32_t *ports; |
652 | uint16_t i; | ||
637 | 653 | ||
638 | /* build connection packet */ | 654 | /* build connection packet */ |
639 | msg = (struct GNUNET_MESH_ClientConnect *) buf; | 655 | msg = (struct GNUNET_MESH_ClientConnect *) buf; |
640 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT); | 656 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT); |
641 | msg->header.size = htons (size); | 657 | msg->header.size = htons (size); |
642 | types = (uint16_t *) & msg[1]; | 658 | msg->types = htons (h->n_handlers); |
643 | for (ntypes = 0; ntypes < h->n_handlers; ntypes++) | 659 | msg->ports = htons (h->n_ports); |
660 | types = (uint16_t *) &msg[1]; | ||
661 | for (i = 0; i < h->n_handlers; i++) | ||
644 | { | 662 | { |
645 | types[ntypes] = htons (h->message_handlers[ntypes].type); | 663 | types[i] = htons (h->message_handlers[i].type); |
646 | LOG (GNUNET_ERROR_TYPE_DEBUG, " type %u\n", | 664 | LOG (GNUNET_ERROR_TYPE_DEBUG, " type %u\n", |
647 | h->message_handlers[ntypes].type); | 665 | h->message_handlers[i].type); |
666 | } | ||
667 | ports = (uint32_t *) &types[h->n_handlers]; | ||
668 | for (i = 0; i < h->n_ports; i++) | ||
669 | { | ||
670 | ports[i] = htonl (h->ports[i]); | ||
671 | LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", | ||
672 | h->ports[i]); | ||
648 | } | 673 | } |
649 | msg->types = htons (ntypes); | ||
650 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 674 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
651 | "Sending %lu bytes long message %d types\n", | 675 | "Sending %lu bytes long message %u types and %u ports\n", |
652 | ntohs (msg->header.size), ntypes); | 676 | ntohs (msg->header.size), h->n_handlers, h->n_ports); |
653 | send_packet (h, &msg->header, NULL); | 677 | send_packet (h, &msg->header, NULL); |
654 | } | 678 | } |
655 | } | 679 | } |
@@ -803,12 +827,13 @@ process_tunnel_created (struct GNUNET_MESH_Handle *h, | |||
803 | GNUNET_PEER_change_rc (t->peer, 1); | 827 | GNUNET_PEER_change_rc (t->peer, 1); |
804 | t->mesh = h; | 828 | t->mesh = h; |
805 | t->tid = tid; | 829 | t->tid = tid; |
830 | t->port = ntohl (msg->port); | ||
806 | if ((msg->opt & MESH_TUNNEL_OPT_NOBUFFER) != 0) | 831 | if ((msg->opt & MESH_TUNNEL_OPT_NOBUFFER) != 0) |
807 | t->buffering = GNUNET_NO; | 832 | t->buffering = GNUNET_NO; |
808 | else | 833 | else |
809 | t->buffering = GNUNET_YES; | 834 | t->buffering = GNUNET_YES; |
810 | LOG (GNUNET_ERROR_TYPE_DEBUG, " created tunnel %p\n", t); | 835 | LOG (GNUNET_ERROR_TYPE_DEBUG, " created tunnel %p\n", t); |
811 | t->ctx = h->new_tunnel (h->cls, t, &msg->peer); | 836 | t->ctx = h->new_tunnel (h->cls, t, &msg->peer, t->port); |
812 | LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n"); | 837 | LOG (GNUNET_ERROR_TYPE_DEBUG, "User notified\n"); |
813 | } | 838 | } |
814 | else | 839 | else |
@@ -1340,7 +1365,8 @@ struct GNUNET_MESH_Handle * | |||
1340 | GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, | 1365 | GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, |
1341 | GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel, | 1366 | GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel, |
1342 | GNUNET_MESH_TunnelEndHandler cleaner, | 1367 | GNUNET_MESH_TunnelEndHandler cleaner, |
1343 | const struct GNUNET_MESH_MessageHandler *handlers) | 1368 | const struct GNUNET_MESH_MessageHandler *handlers, |
1369 | uint32_t *ports) | ||
1344 | { | 1370 | { |
1345 | struct GNUNET_MESH_Handle *h; | 1371 | struct GNUNET_MESH_Handle *h; |
1346 | 1372 | ||
@@ -1359,6 +1385,7 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, | |||
1359 | } | 1385 | } |
1360 | h->cls = cls; | 1386 | h->cls = cls; |
1361 | h->message_handlers = handlers; | 1387 | h->message_handlers = handlers; |
1388 | h->ports = ports; | ||
1362 | h->next_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; | 1389 | h->next_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; |
1363 | h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS; | 1390 | h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS; |
1364 | h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 1391 | h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -1367,6 +1394,9 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, | |||
1367 | for (h->n_handlers = 0; | 1394 | for (h->n_handlers = 0; |
1368 | handlers && handlers[h->n_handlers].type; | 1395 | handlers && handlers[h->n_handlers].type; |
1369 | h->n_handlers++) ; | 1396 | h->n_handlers++) ; |
1397 | for (h->n_ports = 0; | ||
1398 | ports && ports[h->n_ports]; | ||
1399 | h->n_ports++) ; | ||
1370 | send_connect (h); | 1400 | send_connect (h); |
1371 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect() END\n"); | 1401 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect() END\n"); |
1372 | return h; | 1402 | return h; |
@@ -1455,7 +1485,8 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
1455 | struct GNUNET_MESH_Tunnel * | 1485 | struct GNUNET_MESH_Tunnel * |
1456 | GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, | 1486 | GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, |
1457 | void *tunnel_ctx, | 1487 | void *tunnel_ctx, |
1458 | const struct GNUNET_PeerIdentity *peer) | 1488 | const struct GNUNET_PeerIdentity *peer, |
1489 | uint32_t port) | ||
1459 | { | 1490 | { |
1460 | struct GNUNET_MESH_Tunnel *t; | 1491 | struct GNUNET_MESH_Tunnel *t; |
1461 | struct GNUNET_MESH_TunnelMessage msg; | 1492 | struct GNUNET_MESH_TunnelMessage msg; |
@@ -1468,6 +1499,7 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, | |||
1468 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); | 1499 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_CREATE); |
1469 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); | 1500 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); |
1470 | msg.tunnel_id = htonl (t->tid); | 1501 | msg.tunnel_id = htonl (t->tid); |
1502 | msg.port = htonl (port); | ||
1471 | msg.peer = *peer; | 1503 | msg.peer = *peer; |
1472 | send_packet (h, &msg.header, t); | 1504 | send_packet (h, &msg.header, t); |
1473 | return t; | 1505 | return t; |
diff --git a/src/mesh/mesh2_protocol.h b/src/mesh/mesh2_protocol.h index 2a312eff7..b96f43efc 100644 --- a/src/mesh/mesh2_protocol.h +++ b/src/mesh/mesh2_protocol.h | |||
@@ -45,12 +45,12 @@ extern "C" | |||
45 | GNUNET_NETWORK_STRUCT_BEGIN | 45 | GNUNET_NETWORK_STRUCT_BEGIN |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Message for mesh path management | 48 | * Message for mesh path creation. |
49 | */ | 49 | */ |
50 | struct GNUNET_MESH_ManipulatePath | 50 | struct GNUNET_MESH_CreateTunnel |
51 | { | 51 | { |
52 | /** | 52 | /** |
53 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_[CREATE|CHANGE|ADD|DESTROY] | 53 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_CREATE |
54 | * | 54 | * |
55 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + | 55 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + |
56 | * path_length * sizeof (struct GNUNET_PeerIdentity) | 56 | * path_length * sizeof (struct GNUNET_PeerIdentity) |
@@ -69,17 +69,38 @@ struct GNUNET_MESH_ManipulatePath | |||
69 | uint32_t opt GNUNET_PACKED; | 69 | uint32_t opt GNUNET_PACKED; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * 64 bit alignment padding. | 72 | * Destination port. |
73 | */ | 73 | */ |
74 | uint32_t reserved GNUNET_PACKED; | 74 | uint32_t port GNUNET_PACKED; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * FIXME do not add the first hop | ||
77 | * path_length structs defining the *whole* path from the origin [0] to the | 78 | * path_length structs defining the *whole* path from the origin [0] to the |
78 | * final destination [path_length-1]. | 79 | * final destination [path_length-1]. |
79 | */ | 80 | */ |
80 | /* struct GNUNET_PeerIdentity peers[path_length]; */ | 81 | /* struct GNUNET_PeerIdentity peers[path_length]; */ |
81 | }; | 82 | }; |
82 | 83 | ||
84 | /** | ||
85 | * Message for mesh path destruction. | ||
86 | */ | ||
87 | struct GNUNET_MESH_DestroyTunnel | ||
88 | { | ||
89 | /** | ||
90 | * Type: GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY | ||
91 | * | ||
92 | * Size: sizeof(struct GNUNET_MESH_ManipulatePath) + | ||
93 | * path_length * sizeof (struct GNUNET_PeerIdentity) | ||
94 | */ | ||
95 | struct GNUNET_MessageHeader header; | ||
96 | |||
97 | /** | ||
98 | * Global id of the tunnel this path belongs to, | ||
99 | * unique in conjunction with the origin. | ||
100 | */ | ||
101 | uint32_t tid GNUNET_PACKED; | ||
102 | }; | ||
103 | |||
83 | 104 | ||
84 | /** | 105 | /** |
85 | * Message for mesh data traffic to a particular destination from origin. | 106 | * Message for mesh data traffic to a particular destination from origin. |