aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-13 12:53:00 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-13 12:53:00 +0000
commit30af0b72dd40084d2fa48cffe5e49521b46b4136 (patch)
treea838d121954fa778b9bd7f2143f8bafd385a7feb /src/transport/plugin_transport_wlan.c
parent1ed0918fbadb6fe57c6797e4bc9478e211d71cfa (diff)
downloadgnunet-30af0b72dd40084d2fa48cffe5e49521b46b4136.tar.gz
gnunet-30af0b72dd40084d2fa48cffe5e49521b46b4136.zip
plugin returns inbound session if outbound session is requiered
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 64e2dd092..ec0947648 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -212,6 +212,8 @@ struct Session
212 */ 212 */
213 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 213 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
214 214
215 int inbound;
216
215}; 217};
216 218
217 219
@@ -352,6 +354,11 @@ struct MacEndpoint
352 struct WlanAddress addr; 354 struct WlanAddress addr;
353 355
354 /** 356 /**
357 * Inbound or outbound session
358 */
359 int inbound;
360
361 /**
355 * Message delay for fragmentation context 362 * Message delay for fragmentation context
356 */ 363 */
357 struct GNUNET_TIME_Relative msg_delay; 364 struct GNUNET_TIME_Relative msg_delay;
@@ -718,13 +725,14 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
718 */ 725 */
719static struct Session * 726static struct Session *
720lookup_session (struct MacEndpoint *endpoint, 727lookup_session (struct MacEndpoint *endpoint,
721 const struct GNUNET_PeerIdentity *peer) 728 const struct GNUNET_PeerIdentity *peer,
729 int inbound)
722{ 730{
723 struct Session *session; 731 struct Session *session;
724 732
725 for (session = endpoint->sessions_head; NULL != session; session = session->next) 733 for (session = endpoint->sessions_head; NULL != session; session = session->next)
726 if (0 == memcmp (peer, &session->target, 734 if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)) &&
727 sizeof (struct GNUNET_PeerIdentity))) 735 (session->inbound == inbound))
728 { 736 {
729 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 737 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
730 return session; 738 return session;
@@ -741,7 +749,7 @@ lookup_session (struct MacEndpoint *endpoint,
741 */ 749 */
742static struct Session * 750static struct Session *
743create_session (struct MacEndpoint *endpoint, 751create_session (struct MacEndpoint *endpoint,
744 const struct GNUNET_PeerIdentity *peer) 752 const struct GNUNET_PeerIdentity *peer, int inbound)
745{ 753{
746 struct Session *session; 754 struct Session *session;
747 755
@@ -751,15 +759,19 @@ create_session (struct MacEndpoint *endpoint,
751 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head, 759 GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head,
752 endpoint->sessions_tail, 760 endpoint->sessions_tail,
753 session); 761 session);
762 session->inbound = inbound;
754 session->mac = endpoint; 763 session->mac = endpoint;
755 session->target = *peer; 764 session->target = *peer;
756 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 765 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
757 session->timeout_task = 766 session->timeout_task =
758 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); 767 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session);
759 LOG (GNUNET_ERROR_TYPE_DEBUG, 768 LOG (GNUNET_ERROR_TYPE_DEBUG,
760 "Created new session for peer `%s' with endpoint %s\n", 769 "Created new %s session %p for peer `%s' with endpoint %s\n",
770 (GNUNET_YES == inbound) ? "inbound" : "outbound",
771 session,
761 GNUNET_i2s (peer), 772 GNUNET_i2s (peer),
762 mac_to_string (&endpoint->addr.mac)); 773 mac_to_string (&endpoint->addr.mac));
774
763 return session; 775 return session;
764} 776}
765 777
@@ -773,12 +785,13 @@ create_session (struct MacEndpoint *endpoint,
773 */ 785 */
774static struct Session * 786static struct Session *
775get_session (struct MacEndpoint *endpoint, 787get_session (struct MacEndpoint *endpoint,
776 const struct GNUNET_PeerIdentity *peer) 788 const struct GNUNET_PeerIdentity *peer,
789 int inbound)
777{ 790{
778 struct Session *session; 791 struct Session *session;
779 if (NULL != (session = lookup_session (endpoint, peer))) 792 if (NULL != (session = lookup_session (endpoint, peer, inbound)))
780 return session; 793 return session;
781 return create_session (endpoint, peer); 794 return create_session (endpoint, peer, inbound);
782} 795}
783 796
784 797
@@ -1113,7 +1126,7 @@ wlan_plugin_get_session (void *cls,
1113 GNUNET_i2s (&address->peer), 1126 GNUNET_i2s (&address->peer),
1114 wlan_plugin_address_to_string(NULL, address->address, address->address_length)); 1127 wlan_plugin_address_to_string(NULL, address->address, address->address_length));
1115 endpoint = create_macendpoint (plugin, address->address); 1128 endpoint = create_macendpoint (plugin, address->address);
1116 return get_session (endpoint, &address->peer); 1129 return get_session (endpoint, &address->peer, GNUNET_NO);
1117} 1130}
1118 1131
1119 1132
@@ -1354,9 +1367,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1354 break; 1367 break;
1355 } 1368 }
1356 xmas.endpoint = mas->endpoint; 1369 xmas.endpoint = mas->endpoint;
1357 if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender))) 1370 if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender, GNUNET_YES)))
1358 { 1371 {
1359 xmas.session = create_session (mas->endpoint, &wlanheader->sender); 1372 xmas.session = create_session (mas->endpoint, &wlanheader->sender, GNUNET_YES);
1360 plugin->env->session_start (NULL, &wlanheader->sender, 1373 plugin->env->session_start (NULL, &wlanheader->sender,
1361 PLUGIN_NAME, NULL, 0, xmas.session, NULL, 0); 1374 PLUGIN_NAME, NULL, 0, xmas.session, NULL, 0);
1362 LOG (GNUNET_ERROR_TYPE_DEBUG, 1375 LOG (GNUNET_ERROR_TYPE_DEBUG,