aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_udp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-16 05:33:01 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-16 05:33:01 +0100
commitd23a815951413af100c74b38cdd09a01ca1c280a (patch)
tree5fd6a3eae1cd4497dc728917362067a8aded3151 /src/transport/plugin_transport_udp.c
parenta3acd27f0acf30a6c4803ec933c4fe7650bc296c (diff)
downloadgnunet-d23a815951413af100c74b38cdd09a01ca1c280a.tar.gz
gnunet-d23a815951413af100c74b38cdd09a01ca1c280a.zip
removing dead/legacy server/connection logic, except for in tcp/wlan/bt plugins (which will be updated 'later')
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r--src/transport/plugin_transport_udp.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index eb48341b7..3a9013a5a 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -159,6 +159,11 @@ struct GNUNET_ATS_Session
159 struct GNUNET_PeerIdentity target; 159 struct GNUNET_PeerIdentity target;
160 160
161 /** 161 /**
162 * Tokenizer for inbound messages.
163 */
164 struct GNUNET_MessageStreamTokenizer *mst;
165
166 /**
162 * Plugin this session belongs to. 167 * Plugin this session belongs to.
163 */ 168 */
164 struct Plugin *plugin; 169 struct Plugin *plugin;
@@ -626,6 +631,11 @@ free_session (struct GNUNET_ATS_Session *s)
626 GNUNET_free (s->frag_ctx); 631 GNUNET_free (s->frag_ctx);
627 s->frag_ctx = NULL; 632 s->frag_ctx = NULL;
628 } 633 }
634 if (NULL != s->mst)
635 {
636 GNUNET_MST_destroy (s->mst);
637 s->mst = NULL;
638 }
629 GNUNET_free (s); 639 GNUNET_free (s);
630} 640}
631 641
@@ -2499,18 +2509,16 @@ read_process_ack (struct Plugin *plugin,
2499 * Message tokenizer has broken up an incomming message. Pass it on 2509 * Message tokenizer has broken up an incomming message. Pass it on
2500 * to the service. 2510 * to the service.
2501 * 2511 *
2502 * @param cls the `struct Plugin *` 2512 * @param cls the `struct GNUNET_ATS_Session *`
2503 * @param client the `struct GNUNET_ATS_Session *`
2504 * @param hdr the actual message 2513 * @param hdr the actual message
2505 * @return #GNUNET_OK (always) 2514 * @return #GNUNET_OK (always)
2506 */ 2515 */
2507static int 2516static int
2508process_inbound_tokenized_messages (void *cls, 2517process_inbound_tokenized_messages (void *cls,
2509 void *client,
2510 const struct GNUNET_MessageHeader *hdr) 2518 const struct GNUNET_MessageHeader *hdr)
2511{ 2519{
2512 struct Plugin *plugin = cls; 2520 struct GNUNET_ATS_Session *session = cls;
2513 struct GNUNET_ATS_Session *session = client; 2521 struct Plugin *plugin = session->plugin;
2514 2522
2515 if (GNUNET_YES == session->in_destroy) 2523 if (GNUNET_YES == session->in_destroy)
2516 return GNUNET_OK; 2524 return GNUNET_OK;
@@ -2626,6 +2634,8 @@ udp_plugin_create_session (void *cls,
2626 struct GNUNET_ATS_Session *s; 2634 struct GNUNET_ATS_Session *s;
2627 2635
2628 s = GNUNET_new (struct GNUNET_ATS_Session); 2636 s = GNUNET_new (struct GNUNET_ATS_Session);
2637 s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages,
2638 s);
2629 s->plugin = plugin; 2639 s->plugin = plugin;
2630 s->address = GNUNET_HELLO_address_copy (address); 2640 s->address = GNUNET_HELLO_address_copy (address);
2631 s->target = address->peer; 2641 s->target = address->peer;
@@ -2792,12 +2802,11 @@ process_udp_message (struct Plugin *plugin,
2792 GNUNET_free (address); 2802 GNUNET_free (address);
2793 2803
2794 s->rc++; 2804 s->rc++;
2795 GNUNET_SERVER_mst_receive (plugin->mst, 2805 GNUNET_MST_from_buffer (s->mst,
2796 s, 2806 (const char *) &msg[1],
2797 (const char *) &msg[1], 2807 ntohs (msg->header.size) - sizeof(struct UDPMessage),
2798 ntohs (msg->header.size) - sizeof(struct UDPMessage), 2808 GNUNET_YES,
2799 GNUNET_YES, 2809 GNUNET_NO);
2800 GNUNET_NO);
2801 s->rc--; 2810 s->rc--;
2802 if ( (0 == s->rc) && 2811 if ( (0 == s->rc) &&
2803 (GNUNET_YES == s->in_destroy) ) 2812 (GNUNET_YES == s->in_destroy) )
@@ -3990,8 +3999,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
3990 p->sessions = GNUNET_CONTAINER_multipeermap_create (16, 3999 p->sessions = GNUNET_CONTAINER_multipeermap_create (16,
3991 GNUNET_NO); 4000 GNUNET_NO);
3992 p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 4001 p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
3993 p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages,
3994 p);
3995 GNUNET_BANDWIDTH_tracker_init (&p->tracker, 4002 GNUNET_BANDWIDTH_tracker_init (&p->tracker,
3996 NULL, 4003 NULL,
3997 NULL, 4004 NULL,
@@ -4008,7 +4015,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
4008 _("Failed to create UDP network sockets\n")); 4015 _("Failed to create UDP network sockets\n"));
4009 GNUNET_CONTAINER_multipeermap_destroy (p->sessions); 4016 GNUNET_CONTAINER_multipeermap_destroy (p->sessions);
4010 GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs); 4017 GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs);
4011 GNUNET_SERVER_mst_destroy (p->mst);
4012 if (NULL != p->nat) 4018 if (NULL != p->nat)
4013 GNUNET_NAT_unregister (p->nat); 4019 GNUNET_NAT_unregister (p->nat);
4014 GNUNET_free (p); 4020 GNUNET_free (p);
@@ -4120,11 +4126,6 @@ libgnunet_plugin_transport_udp_done (void *cls)
4120 GNUNET_CONTAINER_heap_destroy (plugin->defrag_ctxs); 4126 GNUNET_CONTAINER_heap_destroy (plugin->defrag_ctxs);
4121 plugin->defrag_ctxs = NULL; 4127 plugin->defrag_ctxs = NULL;
4122 } 4128 }
4123 if (NULL != plugin->mst)
4124 {
4125 GNUNET_SERVER_mst_destroy (plugin->mst);
4126 plugin->mst = NULL;
4127 }
4128 while (NULL != (udpw = plugin->ipv4_queue_head)) 4129 while (NULL != (udpw = plugin->ipv4_queue_head))
4129 { 4130 {
4130 dequeue (plugin, 4131 dequeue (plugin,