diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-11-14 13:55:12 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-11-14 13:55:12 +0000 |
commit | b7366f3d6a56d38d0269a33039f88de967e8c130 (patch) | |
tree | e299448a28e358c6549670a094b82f247925f7e2 /src/scalarproduct | |
parent | 6bde5e0c83d1fd344a26de64172ddce37920bb40 (diff) | |
download | gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.tar.gz gnunet-b7366f3d6a56d38d0269a33039f88de967e8c130.zip |
Use encrypted MESH by default
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index 47e1697e3..b6c8e6077 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -203,9 +203,9 @@ struct ServiceSession | |||
203 | struct GNUNET_SERVER_TransmitHandle * client_transmit_handle; | 203 | struct GNUNET_SERVER_TransmitHandle * client_transmit_handle; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * tunnel-handle associated with our mesh handle | 206 | * channel-handle associated with our mesh handle |
207 | */ | 207 | */ |
208 | struct GNUNET_MESH_Tunnel * tunnel; | 208 | struct GNUNET_MESH_Channel * channel; |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * Handle to a task that sends a msg to the our client | 211 | * Handle to a task that sends a msg to the our client |
@@ -783,10 +783,10 @@ handle_client_disconnect (void *cls, | |||
783 | 783 | ||
784 | if (!(session->role == BOB && session->state == FINALIZED)) { | 784 | if (!(session->role == BOB && session->state == FINALIZED)) { |
785 | //we MUST terminate any client message underway | 785 | //we MUST terminate any client message underway |
786 | if (session->service_transmit_handle && session->tunnel) | 786 | if (session->service_transmit_handle && session->channel) |
787 | GNUNET_MESH_notify_transmit_ready_cancel (session->service_transmit_handle); | 787 | GNUNET_MESH_notify_transmit_ready_cancel (session->service_transmit_handle); |
788 | if (session->tunnel && session->state == WAITING_FOR_SERVICE_RESPONSE) | 788 | if (session->channel && session->state == WAITING_FOR_SERVICE_RESPONSE) |
789 | GNUNET_MESH_tunnel_destroy (session->tunnel); | 789 | GNUNET_MESH_channel_destroy (session->channel); |
790 | } | 790 | } |
791 | if (GNUNET_SCHEDULER_NO_TASK != session->client_notification_task) { | 791 | if (GNUNET_SCHEDULER_NO_TASK != session->client_notification_task) { |
792 | GNUNET_SCHEDULER_cancel (session->client_notification_task); | 792 | GNUNET_SCHEDULER_cancel (session->client_notification_task); |
@@ -1014,7 +1014,7 @@ prepare_service_response_multipart (void *cls) | |||
1014 | session->transferred += todo_count; | 1014 | session->transferred += todo_count; |
1015 | session->msg = (struct GNUNET_MessageHeader *) msg; | 1015 | session->msg = (struct GNUNET_MessageHeader *) msg; |
1016 | session->service_transmit_handle = | 1016 | session->service_transmit_handle = |
1017 | GNUNET_MESH_notify_transmit_ready (session->tunnel, | 1017 | GNUNET_MESH_notify_transmit_ready (session->channel, |
1018 | GNUNET_YES, | 1018 | GNUNET_YES, |
1019 | GNUNET_TIME_UNIT_FOREVER_REL, | 1019 | GNUNET_TIME_UNIT_FOREVER_REL, |
1020 | msg_length, | 1020 | msg_length, |
@@ -1152,7 +1152,7 @@ prepare_service_response (gcry_mpi_t s, | |||
1152 | 1152 | ||
1153 | session->msg = (struct GNUNET_MessageHeader *) msg; | 1153 | session->msg = (struct GNUNET_MessageHeader *) msg; |
1154 | session->service_transmit_handle = | 1154 | session->service_transmit_handle = |
1155 | GNUNET_MESH_notify_transmit_ready (session->tunnel, | 1155 | GNUNET_MESH_notify_transmit_ready (session->channel, |
1156 | GNUNET_YES, | 1156 | GNUNET_YES, |
1157 | GNUNET_TIME_UNIT_FOREVER_REL, | 1157 | GNUNET_TIME_UNIT_FOREVER_REL, |
1158 | msg_length, | 1158 | msg_length, |
@@ -1476,13 +1476,13 @@ prepare_service_request_multipart (void *cls) | |||
1476 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); | 1476 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); |
1477 | 1477 | ||
1478 | //transmit via mesh messaging | 1478 | //transmit via mesh messaging |
1479 | session->service_transmit_handle = GNUNET_MESH_notify_transmit_ready (session->tunnel, GNUNET_YES, | 1479 | session->service_transmit_handle = GNUNET_MESH_notify_transmit_ready (session->channel, GNUNET_YES, |
1480 | GNUNET_TIME_UNIT_FOREVER_REL, | 1480 | GNUNET_TIME_UNIT_FOREVER_REL, |
1481 | msg_length, | 1481 | msg_length, |
1482 | &do_send_message, | 1482 | &do_send_message, |
1483 | session); | 1483 | session); |
1484 | if (!session->service_transmit_handle) { | 1484 | if (!session->service_transmit_handle) { |
1485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-request multipart message to tunnel!\n")); | 1485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-request multipart message to channel!\n")); |
1486 | GNUNET_free (msg); | 1486 | GNUNET_free (msg); |
1487 | session->msg = NULL; | 1487 | session->msg = NULL; |
1488 | session->client_notification_task = | 1488 | session->client_notification_task = |
@@ -1522,7 +1522,7 @@ prepare_service_request (void *cls, | |||
1522 | 1522 | ||
1523 | session->service_request_task = GNUNET_SCHEDULER_NO_TASK; | 1523 | session->service_request_task = GNUNET_SCHEDULER_NO_TASK; |
1524 | 1524 | ||
1525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Successfully created new tunnel to peer (%s)!\n"), GNUNET_i2s (&session->peer)); | 1525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Successfully created new channel to peer (%s)!\n"), GNUNET_i2s (&session->peer)); |
1526 | 1526 | ||
1527 | msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request) | 1527 | msg_length = sizeof (struct GNUNET_SCALARPRODUCT_service_request) |
1528 | +session->mask_length | 1528 | +session->mask_length |
@@ -1603,13 +1603,13 @@ prepare_service_request (void *cls, | |||
1603 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); | 1603 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Transmitting service request.\n")); |
1604 | 1604 | ||
1605 | //transmit via mesh messaging | 1605 | //transmit via mesh messaging |
1606 | session->service_transmit_handle = GNUNET_MESH_notify_transmit_ready (session->tunnel, GNUNET_YES, | 1606 | session->service_transmit_handle = GNUNET_MESH_notify_transmit_ready (session->channel, GNUNET_YES, |
1607 | GNUNET_TIME_UNIT_FOREVER_REL, | 1607 | GNUNET_TIME_UNIT_FOREVER_REL, |
1608 | msg_length, | 1608 | msg_length, |
1609 | &do_send_message, | 1609 | &do_send_message, |
1610 | session); | 1610 | session); |
1611 | if (!session->service_transmit_handle) { | 1611 | if (!session->service_transmit_handle) { |
1612 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send message to tunnel!\n")); | 1612 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send message to channel!\n")); |
1613 | GNUNET_free (msg); | 1613 | GNUNET_free (msg); |
1614 | session->msg = NULL; | 1614 | session->msg = NULL; |
1615 | session->client_notification_task = | 1615 | session->client_notification_task = |
@@ -1710,7 +1710,7 @@ handle_client_request (void *cls, | |||
1710 | 1710 | ||
1711 | if (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE == msg_type) { | 1711 | if (GNUNET_MESSAGE_TYPE_SCALARPRODUCT_CLIENT_TO_ALICE == msg_type) { |
1712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1712 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1713 | _ ("Got client-request-session with key %s, preparing tunnel to remote service.\n"), | 1713 | _ ("Got client-request-session with key %s, preparing channel to remote service.\n"), |
1714 | GNUNET_h2s (&session->key)); | 1714 | GNUNET_h2s (&session->key)); |
1715 | 1715 | ||
1716 | session->role = ALICE; | 1716 | session->role = ALICE; |
@@ -1746,15 +1746,15 @@ handle_client_request (void *cls, | |||
1746 | // get our peer ID | 1746 | // get our peer ID |
1747 | memcpy (&session->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity)); | 1747 | memcpy (&session->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity)); |
1748 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1748 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1749 | _ ("Creating new tunnel for session with key %s.\n"), | 1749 | _ ("Creating new channel for session with key %s.\n"), |
1750 | GNUNET_h2s (&session->key)); | 1750 | GNUNET_h2s (&session->key)); |
1751 | session->tunnel = GNUNET_MESH_tunnel_create (my_mesh, session, | 1751 | session->channel = GNUNET_MESH_channel_create (my_mesh, session, |
1752 | &session->peer, | 1752 | &session->peer, |
1753 | GNUNET_APPLICATION_TYPE_SCALARPRODUCT, | 1753 | GNUNET_APPLICATION_TYPE_SCALARPRODUCT, |
1754 | GNUNET_NO, | 1754 | GNUNET_NO, |
1755 | GNUNET_YES); | 1755 | GNUNET_YES); |
1756 | //prepare_service_request, tunnel_peer_disconnect_handler, | 1756 | //prepare_service_request, channel_peer_disconnect_handler, |
1757 | if (!session->tunnel) { | 1757 | if (!session->channel) { |
1758 | GNUNET_break (0); | 1758 | GNUNET_break (0); |
1759 | GNUNET_free (session->vector); | 1759 | GNUNET_free (session->vector); |
1760 | GNUNET_free (session); | 1760 | GNUNET_free (session); |
@@ -1809,26 +1809,26 @@ handle_client_request (void *cls, | |||
1809 | 1809 | ||
1810 | 1810 | ||
1811 | /** | 1811 | /** |
1812 | * Function called for inbound tunnels. | 1812 | * Function called for inbound channels. |
1813 | * | 1813 | * |
1814 | * @param cls closure | 1814 | * @param cls closure |
1815 | * @param tunnel new handle to the tunnel | 1815 | * @param channel new handle to the channel |
1816 | * @param initiator peer that started the tunnel | 1816 | * @param initiator peer that started the channel |
1817 | * @param port unused | 1817 | * @param port unused |
1818 | * @return session associated with the tunnel | 1818 | * @return session associated with the channel |
1819 | */ | 1819 | */ |
1820 | static void * | 1820 | static void * |
1821 | tunnel_incoming_handler (void *cls, | 1821 | channel_incoming_handler (void *cls, |
1822 | struct GNUNET_MESH_Tunnel *tunnel, | 1822 | struct GNUNET_MESH_Channel *channel, |
1823 | const struct GNUNET_PeerIdentity *initiator, | 1823 | const struct GNUNET_PeerIdentity *initiator, |
1824 | uint32_t port) | 1824 | uint32_t port) |
1825 | { | 1825 | { |
1826 | struct ServiceSession * c = GNUNET_new (struct ServiceSession); | 1826 | struct ServiceSession * c = GNUNET_new (struct ServiceSession); |
1827 | 1827 | ||
1828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("New incoming tunnel from peer %s.\n"), GNUNET_i2s (initiator)); | 1828 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("New incoming channel from peer %s.\n"), GNUNET_i2s (initiator)); |
1829 | 1829 | ||
1830 | c->peer = *initiator; | 1830 | c->peer = *initiator; |
1831 | c->tunnel = tunnel; | 1831 | c->channel = channel; |
1832 | c->role = BOB; | 1832 | c->role = BOB; |
1833 | c->state = WAITING_FOR_SERVICE_REQUEST; | 1833 | c->state = WAITING_FOR_SERVICE_REQUEST; |
1834 | return c; | 1834 | return c; |
@@ -1836,22 +1836,22 @@ tunnel_incoming_handler (void *cls, | |||
1836 | 1836 | ||
1837 | 1837 | ||
1838 | /** | 1838 | /** |
1839 | * Function called whenever a tunnel is destroyed. Should clean up | 1839 | * Function called whenever a channel is destroyed. Should clean up |
1840 | * any associated state. | 1840 | * any associated state. |
1841 | * | 1841 | * |
1842 | * It must NOT call GNUNET_MESH_tunnel_destroy on the tunnel. | 1842 | * It must NOT call GNUNET_MESH_channel_destroy on the channel. |
1843 | * | 1843 | * |
1844 | * @param cls closure (set from GNUNET_MESH_connect) | 1844 | * @param cls closure (set from GNUNET_MESH_connect) |
1845 | * @param tunnel connection to the other end (henceforth invalid) | 1845 | * @param channel connection to the other end (henceforth invalid) |
1846 | * @param tunnel_ctx place where local state associated | 1846 | * @param channel_ctx place where local state associated |
1847 | * with the tunnel is stored | 1847 | * with the channel is stored |
1848 | */ | 1848 | */ |
1849 | static void | 1849 | static void |
1850 | tunnel_destruction_handler (void *cls, | 1850 | channel_destruction_handler (void *cls, |
1851 | const struct GNUNET_MESH_Tunnel *tunnel, | 1851 | const struct GNUNET_MESH_Channel *channel, |
1852 | void *tunnel_ctx) | 1852 | void *channel_ctx) |
1853 | { | 1853 | { |
1854 | struct ServiceSession * session = tunnel_ctx; | 1854 | struct ServiceSession * session = channel_ctx; |
1855 | struct ServiceSession * client_session; | 1855 | struct ServiceSession * client_session; |
1856 | struct ServiceSession * curr; | 1856 | struct ServiceSession * curr; |
1857 | 1857 | ||
@@ -1863,7 +1863,7 @@ tunnel_destruction_handler (void *cls, | |||
1863 | // as we have only one peer connected in each session, just remove the session | 1863 | // as we have only one peer connected in each session, just remove the session |
1864 | 1864 | ||
1865 | if ((SERVICE_RESPONSE_RECEIVED > session->state) && (!do_shutdown)) { | 1865 | if ((SERVICE_RESPONSE_RECEIVED > session->state) && (!do_shutdown)) { |
1866 | session->tunnel = NULL; | 1866 | session->channel = NULL; |
1867 | // if this happened before we received the answer, we must terminate the session | 1867 | // if this happened before we received the answer, we must terminate the session |
1868 | session->client_notification_task = | 1868 | session->client_notification_task = |
1869 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 1869 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
@@ -1985,16 +1985,16 @@ compute_scalar_product (struct ServiceSession * session) | |||
1985 | * Handle a multipart-chunk of a request from another service to calculate a scalarproduct with us. | 1985 | * Handle a multipart-chunk of a request from another service to calculate a scalarproduct with us. |
1986 | * | 1986 | * |
1987 | * @param cls closure (set from #GNUNET_MESH_connect) | 1987 | * @param cls closure (set from #GNUNET_MESH_connect) |
1988 | * @param tunnel connection to the other end | 1988 | * @param channel connection to the other end |
1989 | * @param tunnel_ctx place to store local state associated with the tunnel | 1989 | * @param channel_ctx place to store local state associated with the channel |
1990 | * @param message the actual message | 1990 | * @param message the actual message |
1991 | * @return #GNUNET_OK to keep the connection open, | 1991 | * @return #GNUNET_OK to keep the connection open, |
1992 | * #GNUNET_SYSERR to close it (signal serious error) | 1992 | * #GNUNET_SYSERR to close it (signal serious error) |
1993 | */ | 1993 | */ |
1994 | static int | 1994 | static int |
1995 | handle_service_request_multipart (void *cls, | 1995 | handle_service_request_multipart (void *cls, |
1996 | struct GNUNET_MESH_Tunnel * tunnel, | 1996 | struct GNUNET_MESH_Channel * channel, |
1997 | void **tunnel_ctx, | 1997 | void **channel_ctx, |
1998 | const struct GNUNET_MessageHeader * message) | 1998 | const struct GNUNET_MessageHeader * message) |
1999 | { | 1999 | { |
2000 | struct ServiceSession * session; | 2000 | struct ServiceSession * session; |
@@ -2007,7 +2007,7 @@ handle_service_request_multipart (void *cls, | |||
2007 | int32_t i = -1; | 2007 | int32_t i = -1; |
2008 | 2008 | ||
2009 | // are we in the correct state? | 2009 | // are we in the correct state? |
2010 | session = (struct ServiceSession *) * tunnel_ctx; | 2010 | session = (struct ServiceSession *) * channel_ctx; |
2011 | if ((BOB != session->role) || (WAITING_FOR_MULTIPART_TRANSMISSION != session->state)) { | 2011 | if ((BOB != session->role) || (WAITING_FOR_MULTIPART_TRANSMISSION != session->state)) { |
2012 | goto except; | 2012 | goto except; |
2013 | } | 2013 | } |
@@ -2077,16 +2077,16 @@ except: | |||
2077 | * Handle a request from another service to calculate a scalarproduct with us. | 2077 | * Handle a request from another service to calculate a scalarproduct with us. |
2078 | * | 2078 | * |
2079 | * @param cls closure (set from #GNUNET_MESH_connect) | 2079 | * @param cls closure (set from #GNUNET_MESH_connect) |
2080 | * @param tunnel connection to the other end | 2080 | * @param channel connection to the other end |
2081 | * @param tunnel_ctx place to store local state associated with the tunnel | 2081 | * @param channel_ctx place to store local state associated with the channel |
2082 | * @param message the actual message | 2082 | * @param message the actual message |
2083 | * @return #GNUNET_OK to keep the connection open, | 2083 | * @return #GNUNET_OK to keep the connection open, |
2084 | * #GNUNET_SYSERR to close it (signal serious error) | 2084 | * #GNUNET_SYSERR to close it (signal serious error) |
2085 | */ | 2085 | */ |
2086 | static int | 2086 | static int |
2087 | handle_service_request (void *cls, | 2087 | handle_service_request (void *cls, |
2088 | struct GNUNET_MESH_Tunnel * tunnel, | 2088 | struct GNUNET_MESH_Channel * channel, |
2089 | void **tunnel_ctx, | 2089 | void **channel_ctx, |
2090 | const struct GNUNET_MessageHeader * message) | 2090 | const struct GNUNET_MessageHeader * message) |
2091 | { | 2091 | { |
2092 | struct ServiceSession * session; | 2092 | struct ServiceSession * session; |
@@ -2102,7 +2102,7 @@ handle_service_request (void *cls, | |||
2102 | int32_t i = -1; | 2102 | int32_t i = -1; |
2103 | enum SessionState needed_state; | 2103 | enum SessionState needed_state; |
2104 | 2104 | ||
2105 | session = (struct ServiceSession *) * tunnel_ctx; | 2105 | session = (struct ServiceSession *) * channel_ctx; |
2106 | if (WAITING_FOR_SERVICE_REQUEST != session->state) { | 2106 | if (WAITING_FOR_SERVICE_REQUEST != session->state) { |
2107 | goto invalid_msg; | 2107 | goto invalid_msg; |
2108 | } | 2108 | } |
@@ -2147,7 +2147,7 @@ handle_service_request (void *cls, | |||
2147 | session->total = element_count; | 2147 | session->total = element_count; |
2148 | session->used = used_elements; | 2148 | session->used = used_elements; |
2149 | session->transferred = contained_elements; | 2149 | session->transferred = contained_elements; |
2150 | session->tunnel = tunnel; | 2150 | session->channel = channel; |
2151 | 2151 | ||
2152 | // session key | 2152 | // session key |
2153 | memcpy (&session->key, &msg->key, sizeof (struct GNUNET_HashCode)); | 2153 | memcpy (&session->key, &msg->key, sizeof (struct GNUNET_HashCode)); |
@@ -2226,16 +2226,16 @@ invalid_msg: | |||
2226 | * Handle a multipart chunk of a response we got from another service we wanted to calculate a scalarproduct with. | 2226 | * Handle a multipart chunk of a response we got from another service we wanted to calculate a scalarproduct with. |
2227 | * | 2227 | * |
2228 | * @param cls closure (set from #GNUNET_MESH_connect) | 2228 | * @param cls closure (set from #GNUNET_MESH_connect) |
2229 | * @param tunnel connection to the other end | 2229 | * @param channel connection to the other end |
2230 | * @param tunnel_ctx place to store local state associated with the tunnel | 2230 | * @param channel_ctx place to store local state associated with the channel |
2231 | * @param message the actual message | 2231 | * @param message the actual message |
2232 | * @return #GNUNET_OK to keep the connection open, | 2232 | * @return #GNUNET_OK to keep the connection open, |
2233 | * #GNUNET_SYSERR to close it (signal serious error) | 2233 | * #GNUNET_SYSERR to close it (signal serious error) |
2234 | */ | 2234 | */ |
2235 | static int | 2235 | static int |
2236 | handle_service_response_multipart (void *cls, | 2236 | handle_service_response_multipart (void *cls, |
2237 | struct GNUNET_MESH_Tunnel * tunnel, | 2237 | struct GNUNET_MESH_Channel * channel, |
2238 | void **tunnel_ctx, | 2238 | void **channel_ctx, |
2239 | const struct GNUNET_MessageHeader * message) | 2239 | const struct GNUNET_MessageHeader * message) |
2240 | { | 2240 | { |
2241 | struct ServiceSession * session; | 2241 | struct ServiceSession * session; |
@@ -2250,7 +2250,7 @@ handle_service_response_multipart (void *cls, | |||
2250 | 2250 | ||
2251 | GNUNET_assert (NULL != message); | 2251 | GNUNET_assert (NULL != message); |
2252 | // are we in the correct state? | 2252 | // are we in the correct state? |
2253 | session = (struct ServiceSession *) * tunnel_ctx; | 2253 | session = (struct ServiceSession *) * channel_ctx; |
2254 | if ((ALICE != session->role) || (WAITING_FOR_MULTIPART_TRANSMISSION != session->state)) { | 2254 | if ((ALICE != session->role) || (WAITING_FOR_MULTIPART_TRANSMISSION != session->state)) { |
2255 | goto invalid_msg; | 2255 | goto invalid_msg; |
2256 | } | 2256 | } |
@@ -2295,13 +2295,13 @@ invalid_msg: | |||
2295 | // send message with product to client | 2295 | // send message with product to client |
2296 | if (ALICE == session->role){ | 2296 | if (ALICE == session->role){ |
2297 | session->state = FINALIZED; | 2297 | session->state = FINALIZED; |
2298 | session->tunnel = NULL; | 2298 | session->channel = NULL; |
2299 | session->client_notification_task = | 2299 | session->client_notification_task = |
2300 | GNUNET_SCHEDULER_add_now (&prepare_client_response, | 2300 | GNUNET_SCHEDULER_add_now (&prepare_client_response, |
2301 | session); | 2301 | session); |
2302 | } | 2302 | } |
2303 | // the tunnel has done its job, terminate our connection and the tunnel | 2303 | // the channel has done its job, terminate our connection and the channel |
2304 | // the peer will be notified that the tunnel was destroyed via tunnel_destruction_handler | 2304 | // the peer will be notified that the channel was destroyed via channel_destruction_handler |
2305 | // just close the connection, as recommended by Christian | 2305 | // just close the connection, as recommended by Christian |
2306 | return GNUNET_SYSERR; | 2306 | return GNUNET_SYSERR; |
2307 | } | 2307 | } |
@@ -2311,16 +2311,16 @@ invalid_msg: | |||
2311 | * Handle a response we got from another service we wanted to calculate a scalarproduct with. | 2311 | * Handle a response we got from another service we wanted to calculate a scalarproduct with. |
2312 | * | 2312 | * |
2313 | * @param cls closure (set from #GNUNET_MESH_connect) | 2313 | * @param cls closure (set from #GNUNET_MESH_connect) |
2314 | * @param tunnel connection to the other end | 2314 | * @param channel connection to the other end |
2315 | * @param tunnel_ctx place to store local state associated with the tunnel | 2315 | * @param channel_ctx place to store local state associated with the channel |
2316 | * @param message the actual message | 2316 | * @param message the actual message |
2317 | * @return #GNUNET_OK to keep the connection open, | 2317 | * @return #GNUNET_OK to keep the connection open, |
2318 | * #GNUNET_SYSERR to close it (we are done) | 2318 | * #GNUNET_SYSERR to close it (we are done) |
2319 | */ | 2319 | */ |
2320 | static int | 2320 | static int |
2321 | handle_service_response (void *cls, | 2321 | handle_service_response (void *cls, |
2322 | struct GNUNET_MESH_Tunnel * tunnel, | 2322 | struct GNUNET_MESH_Channel * channel, |
2323 | void **tunnel_ctx, | 2323 | void **channel_ctx, |
2324 | const struct GNUNET_MessageHeader * message) | 2324 | const struct GNUNET_MessageHeader * message) |
2325 | { | 2325 | { |
2326 | struct ServiceSession * session; | 2326 | struct ServiceSession * session; |
@@ -2334,7 +2334,7 @@ handle_service_response (void *cls, | |||
2334 | int rc; | 2334 | int rc; |
2335 | 2335 | ||
2336 | GNUNET_assert (NULL != message); | 2336 | GNUNET_assert (NULL != message); |
2337 | session = (struct ServiceSession *) * tunnel_ctx; | 2337 | session = (struct ServiceSession *) * channel_ctx; |
2338 | // are we in the correct state? | 2338 | // are we in the correct state? |
2339 | if (WAITING_FOR_SERVICE_RESPONSE != session->state) { | 2339 | if (WAITING_FOR_SERVICE_RESPONSE != session->state) { |
2340 | goto invalid_msg; | 2340 | goto invalid_msg; |
@@ -2399,13 +2399,13 @@ invalid_msg: | |||
2399 | // send message with product to client | 2399 | // send message with product to client |
2400 | if (ALICE == session->role){ | 2400 | if (ALICE == session->role){ |
2401 | session->state = FINALIZED; | 2401 | session->state = FINALIZED; |
2402 | session->tunnel = NULL; | 2402 | session->channel = NULL; |
2403 | session->client_notification_task = | 2403 | session->client_notification_task = |
2404 | GNUNET_SCHEDULER_add_now (&prepare_client_response, | 2404 | GNUNET_SCHEDULER_add_now (&prepare_client_response, |
2405 | session); | 2405 | session); |
2406 | } | 2406 | } |
2407 | // the tunnel has done its job, terminate our connection and the tunnel | 2407 | // the channel has done its job, terminate our connection and the channel |
2408 | // the peer will be notified that the tunnel was destroyed via tunnel_destruction_handler | 2408 | // the peer will be notified that the channel was destroyed via channel_destruction_handler |
2409 | // just close the connection, as recommended by Christian | 2409 | // just close the connection, as recommended by Christian |
2410 | return GNUNET_SYSERR; | 2410 | return GNUNET_SYSERR; |
2411 | } | 2411 | } |
@@ -2426,11 +2426,11 @@ shutdown_task (void *cls, | |||
2426 | 2426 | ||
2427 | do_shutdown = GNUNET_YES; | 2427 | do_shutdown = GNUNET_YES; |
2428 | 2428 | ||
2429 | // terminate all owned open tunnels. | 2429 | // terminate all owned open channels. |
2430 | for (session = from_client_head; NULL != session; session = session->next) { | 2430 | for (session = from_client_head; NULL != session; session = session->next) { |
2431 | if ((FINALIZED != session->state) && (NULL != session->tunnel)) { | 2431 | if ((FINALIZED != session->state) && (NULL != session->channel)) { |
2432 | GNUNET_MESH_tunnel_destroy (session->tunnel); | 2432 | GNUNET_MESH_channel_destroy (session->channel); |
2433 | session->tunnel = NULL; | 2433 | session->channel = NULL; |
2434 | } | 2434 | } |
2435 | if (GNUNET_SCHEDULER_NO_TASK != session->client_notification_task) { | 2435 | if (GNUNET_SCHEDULER_NO_TASK != session->client_notification_task) { |
2436 | GNUNET_SCHEDULER_cancel (session->client_notification_task); | 2436 | GNUNET_SCHEDULER_cancel (session->client_notification_task); |
@@ -2446,9 +2446,9 @@ shutdown_task (void *cls, | |||
2446 | } | 2446 | } |
2447 | } | 2447 | } |
2448 | for (session = from_service_head; NULL != session; session = session->next) | 2448 | for (session = from_service_head; NULL != session; session = session->next) |
2449 | if (NULL != session->tunnel) { | 2449 | if (NULL != session->channel) { |
2450 | GNUNET_MESH_tunnel_destroy (session->tunnel); | 2450 | GNUNET_MESH_channel_destroy (session->channel); |
2451 | session->tunnel = NULL; | 2451 | session->channel = NULL; |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | if (my_mesh) { | 2454 | if (my_mesh) { |
@@ -2498,8 +2498,8 @@ run (void *cls, | |||
2498 | GNUNET_CRYPTO_get_peer_identity (c, | 2498 | GNUNET_CRYPTO_get_peer_identity (c, |
2499 | &me)); | 2499 | &me)); |
2500 | my_mesh = GNUNET_MESH_connect (c, NULL, | 2500 | my_mesh = GNUNET_MESH_connect (c, NULL, |
2501 | &tunnel_incoming_handler, | 2501 | &channel_incoming_handler, |
2502 | &tunnel_destruction_handler, | 2502 | &channel_destruction_handler, |
2503 | mesh_handlers, ports); | 2503 | mesh_handlers, ports); |
2504 | if (!my_mesh) { | 2504 | if (!my_mesh) { |
2505 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Connect to MESH failed\n")); | 2505 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Connect to MESH failed\n")); |