+/**
+ * We've received a typemap message from a peer, update ours.
+ * Notifies clients about the session.
+ *
+ * @param peer peer this is about
+ * @param msg typemap update message
+ */
+void
+GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct Session *session;
+ struct GSC_TypeMap *nmap;
+
+ nmap = GSC_TYPEMAP_get_from_message (msg);
+ if (NULL == nmap)
+ return; /* malformed */
+ session = find_session (peer);
+ if (NULL == session)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ GSC_CLIENTS_notify_clients_about_neighbour (peer, NULL, 0, /* FIXME: ATS */
+ session->tmap, nmap);
+ GSC_TYPEMAP_destroy (session->tmap);
+ session->tmap = nmap;
+}
+
+
+/**
+ * The given peer send a message of the specified type. Make sure the
+ * respective bit is set in its type-map and that clients are notified
+ * about the session.
+ *
+ * @param peer peer this is about
+ * @param type type of the message
+ */
+void
+GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
+ uint16_t type)
+{
+ struct Session *session;
+ struct GSC_TypeMap *nmap;
+
+ if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity)))
+ return;
+ session = find_session (peer);
+ GNUNET_assert (NULL != session);
+ if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap, &type, 1))
+ return; /* already in it */
+ nmap = GSC_TYPEMAP_extend (session->tmap, &type, 1);
+ GSC_CLIENTS_notify_clients_about_neighbour (peer, NULL, 0, /* FIXME: ATS */
+ session->tmap, nmap);
+ GSC_TYPEMAP_destroy (session->tmap);
+ session->tmap = nmap;
+}
+
+