aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-15 10:42:47 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-15 10:42:47 +0000
commitdb5db687e8c841097350d151aedf63c2054d8e8f (patch)
treebe4436d89fe0c6564c2fccad0355cd6060ed431f /src/transport
parent13706acdb98d7f78420b4a3ab50ffeb634dff5da (diff)
downloadgnunet-db5db687e8c841097350d151aedf63c2054d8e8f.tar.gz
gnunet-db5db687e8c841097350d151aedf63c2054d8e8f.zip
remove inbound outbound notion from wlan plugin
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_wlan.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index ea65838eb..77bb28ebc 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -216,9 +216,6 @@ struct Session
216 * Timeout task (for the session). 216 * Timeout task (for the session).
217 */ 217 */
218 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 218 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
219
220 int inbound;
221
222}; 219};
223 220
224 221
@@ -359,11 +356,6 @@ struct MacEndpoint
359 struct WlanAddress wlan_addr; 356 struct WlanAddress wlan_addr;
360 357
361 /** 358 /**
362 * Inbound or outbound session
363 */
364 int inbound;
365
366 /**
367 * Message delay for fragmentation context 359 * Message delay for fragmentation context
368 */ 360 */
369 struct GNUNET_TIME_Relative msg_delay; 361 struct GNUNET_TIME_Relative msg_delay;
@@ -747,19 +739,16 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
747 * 739 *
748 * @param endpoint pointer to the mac endpoint of the peer 740 * @param endpoint pointer to the mac endpoint of the peer
749 * @param peer peer identity to use for this session 741 * @param peer peer identity to use for this session
750 * @param inbound inbound session?
751 * @return returns the session or NULL 742 * @return returns the session or NULL
752 */ 743 */
753static struct Session * 744static struct Session *
754lookup_session (struct MacEndpoint *endpoint, 745lookup_session (struct MacEndpoint *endpoint,
755 const struct GNUNET_PeerIdentity *peer, 746 const struct GNUNET_PeerIdentity *peer)
756 int inbound)
757{ 747{
758 struct Session *session; 748 struct Session *session;
759 749
760 for (session = endpoint->sessions_head; NULL != session; session = session->next) 750 for (session = endpoint->sessions_head; NULL != session; session = session->next)
761 if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)) && 751 if (0 == memcmp (peer, &session->target, sizeof (struct GNUNET_PeerIdentity)))
762 (session->inbound == inbound))
763 { 752 {
764 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 753 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
765 return session; 754 return session;
@@ -772,12 +761,11 @@ lookup_session (struct MacEndpoint *endpoint,
772 * 761 *
773 * @param endpoint pointer to the mac endpoint of the peer 762 * @param endpoint pointer to the mac endpoint of the peer
774 * @param peer peer identity to use for this session 763 * @param peer peer identity to use for this session
775 * @param inbound inbound session?
776 * @return returns the session or NULL 764 * @return returns the session or NULL
777 */ 765 */
778static struct Session * 766static struct Session *
779create_session (struct MacEndpoint *endpoint, 767create_session (struct MacEndpoint *endpoint,
780 const struct GNUNET_PeerIdentity *peer, int inbound) 768 const struct GNUNET_PeerIdentity *peer)
781{ 769{
782 struct Session *session; 770 struct Session *session;
783 771
@@ -789,16 +777,14 @@ create_session (struct MacEndpoint *endpoint,
789 session); 777 session);
790 session->address = GNUNET_HELLO_address_allocate (peer, PLUGIN_NAME, 778 session->address = GNUNET_HELLO_address_allocate (peer, PLUGIN_NAME,
791 &endpoint->wlan_addr, sizeof (endpoint->wlan_addr), 779 &endpoint->wlan_addr, sizeof (endpoint->wlan_addr),
792 (GNUNET_YES == inbound) ? GNUNET_HELLO_ADDRESS_INFO_INBOUND : GNUNET_HELLO_ADDRESS_INFO_NONE); 780 GNUNET_HELLO_ADDRESS_INFO_NONE);
793 session->inbound = inbound;
794 session->mac = endpoint; 781 session->mac = endpoint;
795 session->target = *peer; 782 session->target = *peer;
796 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 783 session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
797 session->timeout_task = 784 session->timeout_task =
798 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); 785 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session);
799 LOG (GNUNET_ERROR_TYPE_DEBUG, 786 LOG (GNUNET_ERROR_TYPE_DEBUG,
800 "Created new %s session %p for peer `%s' with endpoint %s\n", 787 "Created new session %p for peer `%s' with endpoint %s\n",
801 (GNUNET_YES == inbound) ? "inbound" : "outbound",
802 session, 788 session,
803 GNUNET_i2s (peer), 789 GNUNET_i2s (peer),
804 mac_to_string (&endpoint->wlan_addr.mac)); 790 mac_to_string (&endpoint->wlan_addr.mac));
@@ -812,18 +798,16 @@ create_session (struct MacEndpoint *endpoint,
812 * 798 *
813 * @param endpoint pointer to the mac endpoint of the peer 799 * @param endpoint pointer to the mac endpoint of the peer
814 * @param peer peer identity to use for this session 800 * @param peer peer identity to use for this session
815 * @param inbound inbound session?
816 * @return returns the session 801 * @return returns the session
817 */ 802 */
818static struct Session * 803static struct Session *
819get_session (struct MacEndpoint *endpoint, 804get_session (struct MacEndpoint *endpoint,
820 const struct GNUNET_PeerIdentity *peer, 805 const struct GNUNET_PeerIdentity *peer)
821 int inbound)
822{ 806{
823 struct Session *session; 807 struct Session *session;
824 if (NULL != (session = lookup_session (endpoint, peer, inbound))) 808 if (NULL != (session = lookup_session (endpoint, peer)))
825 return session; 809 return session;
826 return create_session (endpoint, peer, inbound); 810 return create_session (endpoint, peer);
827} 811}
828 812
829 813
@@ -1162,7 +1146,7 @@ wlan_plugin_get_session (void *cls,
1162 GNUNET_i2s (&address->peer), 1146 GNUNET_i2s (&address->peer),
1163 wlan_plugin_address_to_string(NULL, address->address, address->address_length)); 1147 wlan_plugin_address_to_string(NULL, address->address, address->address_length));
1164 endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address); 1148 endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address);
1165 return get_session (endpoint, &address->peer, GNUNET_NO); 1149 return get_session (endpoint, &address->peer);
1166} 1150}
1167 1151
1168 1152
@@ -1311,7 +1295,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1311 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", 1295 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1312 (unsigned int) msize, 1296 (unsigned int) msize,
1313 GNUNET_i2s (&tmpsource), 1297 GNUNET_i2s (&tmpsource),
1314 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, sizeof (mas->endpoint->wlan_addr))); 1298 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr,
1299 sizeof (mas->endpoint->wlan_addr)));
1315 1300
1316 GNUNET_STATISTICS_update (plugin->env->stats, 1301 GNUNET_STATISTICS_update (plugin->env->stats,
1317 _("# HELLO messages received via WLAN"), 1, 1302 _("# HELLO messages received via WLAN"), 1,
@@ -1325,8 +1310,6 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1325 plugin->env->update_address_metrics (plugin->env->cls, 1310 plugin->env->update_address_metrics (plugin->env->cls,
1326 address, mas->session, &ats, 1); 1311 address, mas->session, &ats, 1);
1327 GNUNET_HELLO_address_free (address); 1312 GNUNET_HELLO_address_free (address);
1328
1329
1330 break; 1313 break;
1331 case GNUNET_MESSAGE_TYPE_FRAGMENT: 1314 case GNUNET_MESSAGE_TYPE_FRAGMENT:
1332 if (NULL == mas->endpoint) 1315 if (NULL == mas->endpoint)
@@ -1415,15 +1398,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1415 break; 1398 break;
1416 } 1399 }
1417 xmas.endpoint = mas->endpoint; 1400 xmas.endpoint = mas->endpoint;
1418 if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender, GNUNET_YES))) 1401 if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender)))
1419 { 1402 {
1420 xmas.session = create_session (mas->endpoint, &wlanheader->sender, GNUNET_YES); 1403 xmas.session = create_session (mas->endpoint, &wlanheader->sender);
1421 address = GNUNET_HELLO_address_allocate (&wlanheader->sender, PLUGIN_NAME, 1404 address = GNUNET_HELLO_address_allocate (&wlanheader->sender, PLUGIN_NAME,
1422 &mas->endpoint->wlan_addr, sizeof (struct WlanAddress), 1405 &mas->endpoint->wlan_addr, sizeof (struct WlanAddress),
1423 GNUNET_HELLO_ADDRESS_INFO_NONE); 1406 GNUNET_HELLO_ADDRESS_INFO_NONE);
1424 plugin->env->session_start (NULL, address, xmas.session, NULL, 0); 1407 plugin->env->session_start (NULL, address, xmas.session, NULL, 0);
1425 LOG (GNUNET_ERROR_TYPE_DEBUG, 1408 LOG (GNUNET_ERROR_TYPE_DEBUG,
1426 "Notifying transport about peer `%s''s new inbound session %p \n", 1409 "Notifying transport about peer `%s''s new session %p \n",
1427 GNUNET_i2s (&wlanheader->sender), xmas.session); 1410 GNUNET_i2s (&wlanheader->sender), xmas.session);
1428 GNUNET_HELLO_address_free (address); 1411 GNUNET_HELLO_address_free (address);
1429 } 1412 }