- GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# established sessions"),
- GNUNET_CONTAINER_multihashmap_size (sessions),
- GNUNET_NO);
- /* FIXME: we should probably do this periodically (in case
- type map message is lost...) */
- hdr = GSC_TYPEMAP_compute_type_map_message ();
- GSC_KX_encrypt_and_transmit (kx,
- hdr,
- ntohs (hdr->size));
- GNUNET_free (hdr);
+ GNUNET_STATISTICS_set (GSC_stats,
+ gettext_noop ("# peers connected"),
+ GNUNET_CONTAINER_multipeermap_size (sessions),
+ GNUNET_NO);
+ GSC_CLIENTS_notify_clients_about_neighbour (peer,
+ NULL,
+ session->tmap);
+ start_typemap_task (session);
+}
+
+
+/**
+ * The other peer has indicated that he 'lost' the session
+ * (KX down), reinitialize the session on our end, in particular
+ * this means to restart the typemap transmission.
+ *
+ * @param peer peer that is now connected
+ */
+void
+GSC_SESSIONS_reinit (const struct GNUNET_PeerIdentity *peer)
+{
+ struct Session *session;
+
+ session = find_session (peer);
+ if (NULL == session)
+ {
+ /* KX/session is new for both sides; thus no need to restart what
+ has not yet begun */
+ return;
+ }
+ start_typemap_task (session);
+}
+
+
+/**
+ * The other peer has confirmed receiving our type map,
+ * check if it is current and if so, stop retransmitting it.
+ *
+ * @param peer peer that confirmed the type map
+ * @param msg confirmation message we received
+ */
+void
+GSC_SESSIONS_confirm_typemap (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *msg)
+{
+ const struct TypeMapConfirmationMessage *cmsg;
+ struct Session *session;
+
+ session = find_session (peer);
+ if (NULL == session)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ if (ntohs (msg->size) != sizeof (struct TypeMapConfirmationMessage))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ cmsg = (const struct TypeMapConfirmationMessage *) msg;
+ if (GNUNET_YES !=
+ GSC_TYPEMAP_check_hash (&cmsg->tm_hash))
+ {
+ /* our typemap has changed in the meantime, do not
+ accept confirmation */
+ GNUNET_STATISTICS_update (GSC_stats,
+ 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);
+ session->typemap_task = NULL;
+ }
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop
+ ("# valid typemap confirmations received"),
+ 1, GNUNET_NO);