This file is part of GNUnet.
Copyright (C) 2009-2014, 2016 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
*/
struct SessionMessageEntry *prev;
+ /**
+ * How important is this message.
+ */
+ enum GNUNET_CORE_Priority priority;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap message.
+ */
+ int is_typemap;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap confirmation message.
+ */
+ int is_typemap_confirm;
+
/**
* Deadline for transmission, 1s after we received it (if we
* are not corking), otherwise "now". Note that this message
*/
size_t size;
- /**
- * How important is this message.
- */
- enum GNUNET_CORE_Priority priority;
-
};
*/
struct GNUNET_TIME_Relative typemap_delay;
- /**
- * Is the neighbour queue empty and thus ready for us
- * to transmit an encrypted message?
- */
- int ready_to_transmit;
-
/**
* Is this the first time we're sending the typemap? If so,
* we want to send it a bit faster the second time. 0 if
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TIME_Relative delay;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
session->typemap_delay = GNUNET_TIME_STD_BACKOFF (session->typemap_delay);
delay = session->typemap_delay;
/* randomize a bit to avoid spont. sync */
delay.rel_value_us +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay,
- &transmit_typemap_task, session);
+ &transmit_typemap_task,
+ session);
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# type map refreshes sent"),
1,
struct Session *session;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating session for peer `%4s'\n",
+ "Creating session for peer `%s'\n",
GNUNET_i2s (peer));
session = GNUNET_new (struct Session);
session->tmap = GSC_TYPEMAP_create ();
/**
- * The other peer has indicated that he 'lost' the session
+ * The other peer has indicated that it 'lost' the session
* (KX down), reinitialize the session on our end, in particular
* this means to restart the typemap transmission.
*
gettext_noop
("# outdated typemap confirmations received"),
1, GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got outdated typemap confirmated from peer `%s'\n",
+ GNUNET_i2s (session->peer));
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got typemap confirmation from peer `%s'\n",
+ GNUNET_i2s (session->peer));
if (NULL != session->typemap_task)
{
GNUNET_SCHEDULER_cancel (session->typemap_task);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received client transmission request. queueing\n");
- GNUNET_CONTAINER_DLL_insert (session->active_client_request_head,
- session->active_client_request_tail,
- car);
+ GNUNET_CONTAINER_DLL_insert_tail (session->active_client_request_head,
+ session->active_client_request_tail,
+ car);
try_transmission (session);
}
enum GNUNET_CORE_Priority maxpc;
struct GSC_ClientActiveRequest *car;
int excess;
-
- if (GNUNET_YES != session->ready_to_transmit)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Not yet ready to transmit, not evaluating queue\n");
- return;
- }
+
msize = 0;
min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
/* if the peer has excess bandwidth, background traffic is allowed,
while ( (NULL != (pos = session->sme_head)) &&
(used + pos->size <= msize) )
{
- GNUNET_memcpy (&pbuf[used], &pos[1], pos->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding message of type %d (%d/%d) to payload for %s\n",
+ ntohs (((const struct GNUNET_MessageHeader *)&pos[1])->type),
+ pos->is_typemap,
+ pos->is_typemap_confirm,
+ GNUNET_i2s (session->peer));
+ GNUNET_memcpy (&pbuf[used],
+ &pos[1],
+ pos->size);
used += pos->size;
GNUNET_CONTAINER_DLL_remove (session->sme_head,
session->sme_tail,
total_bytes / total_msgs,
GNUNET_NO);
/* now actually transmit... */
- session->ready_to_transmit = GNUNET_NO;
GSC_KX_encrypt_and_transmit (session->kx,
pbuf,
used);
struct SessionMessageEntry *sme;
uint16_t size;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarting sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
size = ntohs (hdr->size);
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
+ sme->is_typemap = GNUNET_YES;
GNUNET_memcpy (&sme[1],
hdr,
size);
{
struct Session *session;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transport solicits for %s\n",
+ GNUNET_i2s (pid));
session = find_session (pid);
if (NULL == session)
return;
- session->ready_to_transmit = GNUNET_YES;
try_transmission (session);
}
nmap = GSC_TYPEMAP_get_from_message (msg);
if (NULL == nmap)
+ {
+ GNUNET_break_op (0);
return; /* malformed */
+ }
session = find_session (peer);
if (NULL == session)
{
+ GSC_TYPEMAP_destroy (nmap);
GNUNET_break (0);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received TYPEMAP from %s\n",
+ GNUNET_i2s (session->peer));
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap_confirm)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) +
sizeof (struct TypeMapConfirmationMessage));
sme->deadline = GNUNET_TIME_absolute_get ();
sme->size = sizeof (struct TypeMapConfirmationMessage);
sme->priority = GNUNET_CORE_PRIO_CRITICAL_CONTROL;
+ sme->is_typemap_confirm = GNUNET_YES;
tmc = (struct TypeMapConfirmationMessage *) &sme[1];
tmc->header.size = htons (sizeof (struct TypeMapConfirmationMessage));
tmc->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP);
return;
session = find_session (peer);
GNUNET_assert (NULL != session);
- if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap, &type, 1))
+ if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap,
+ &type, 1))
return; /* already in it */
- nmap = GSC_TYPEMAP_extend (session->tmap, &type, 1);
+ nmap = GSC_TYPEMAP_extend (session->tmap,
+ &type,
+ 1);
GSC_CLIENTS_notify_clients_about_neighbour (peer,
- session->tmap, nmap);
+ session->tmap,
+ nmap);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = nmap;
}