Ejemplo n.º 1
0
static void
do_shutdown (void *cls,
             const struct GNUNET_SCHEDULER_TaskContext *c)
{
    if (mhd_task_id != NULL)
    {
        GNUNET_SCHEDULER_cancel (mhd_task_id);
        mhd_task_id = NULL;
    }
    if (curl_task_id != NULL)
    {
        GNUNET_SCHEDULER_cancel (curl_task_id);
        curl_task_id = NULL;
    }
    if (NULL != mhd)
    {
        MHD_stop_daemon (mhd);
        mhd = NULL;
    }
    if (NULL != identity)
    {
        GNUNET_IDENTITY_disconnect (identity);
        identity = NULL;
    }
    if (NULL != qe)
    {
        GNUNET_NAMESTORE_cancel (qe);
        qe = NULL;
    }
    GNUNET_free_non_null (url);
    url = NULL;
}
Ejemplo n.º 2
0
/**
 * Method called to inform about the egos of this peer.
 *
 * When used with #GNUNET_IDENTITY_connect, this function is
 * initially called for all egos and then again whenever a
 * ego's name changes or if it is deleted.  At the end of
 * the initial pass over all egos, the function is once called
 * with 'NULL' for @a ego. That does NOT mean that the callback won't
 * be invoked in the future or that there was an error.
 *
 * When used with #GNUNET_IDENTITY_create or #GNUNET_IDENTITY_get,
 * this function is only called ONCE, and 'NULL' being passed in
 * @a ego does indicate an error (i.e. name is taken or no default
 * value is known).  If @a ego is non-NULL and if '*ctx'
 * is set in those callbacks, the value WILL be passed to a subsequent
 * call to the identity callback of #GNUNET_IDENTITY_connect (if
 * that one was not NULL).
 *
 * When an identity is renamed, this function is called with the
 * (known) @a ego but the NEW @a name.
 *
 * When an identity is deleted, this function is called with the
 * (known) ego and "NULL" for the @a name.  In this case,
 * the @a ego is henceforth invalid (and the @a ctx should also be
 * cleaned up).
 *
 * @param cls closure
 * @param ego ego handle
 * @param ctx context for application to store data for this ego
 *                 (during the lifetime of this process, initially NULL)
 * @param name name assigned by the user for this ego,
 *                   NULL if the user just deleted the ego and it
 *                   must thus no longer be used
 */
static void
identity_cb (void *cls,
             struct GNUNET_IDENTITY_Ego *ego,
             void **ctx,
             const char *name)
{
    const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key;
    struct GNUNET_GNSRECORD_Data rd;
    char *rd_string;
    char *peername;

    if (NULL == name)
        return;
    if (NULL == ego)
    {
        if (NULL == qe)
        {
            fprintf (stderr,
                     "Failed to find master-zone ego\n");
            GNUNET_SCHEDULER_shutdown ();
            return;
        }
        GNUNET_IDENTITY_disconnect (identity);
        identity = NULL;
        return;
    }
    GNUNET_assert (NULL != name);
    if (0 != strcmp (name,
                     "master-zone"))
    {
        fprintf (stderr,
                 "Unexpected name %s\n",
                 name);
        return;
    }
    zone_key = GNUNET_IDENTITY_ego_get_private_key (ego);
    rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
    peername = GNUNET_strdup (GNUNET_i2s_full (&id));
    GNUNET_asprintf (&rd_string,
                     "6 %s %s",
                     peername,
                     "www");
    GNUNET_free (peername);
    GNUNET_assert (GNUNET_OK ==
                   GNUNET_GNSRECORD_string_to_value (GNUNET_GNSRECORD_TYPE_VPN,
                           rd_string,
                           (void**) &rd.data,
                           &rd.data_size));
    rd.record_type = GNUNET_GNSRECORD_TYPE_VPN;

    qe = GNUNET_NAMESTORE_records_store (namestore,
                                         zone_key,
                                         "www",
                                         1, &rd,
                                         &commence_testing,
                                         NULL);
    GNUNET_free ((void**)rd.data);
    GNUNET_free (rd_string);
}
Ejemplo n.º 3
0
/**
 * Clean up all resources used.
 */
static void
cleanup ()
{
  if (NULL != op)
  {
    GNUNET_IDENTITY_cancel (op);
    op = NULL;
  }
  if (NULL != h)
  {
    GNUNET_IDENTITY_disconnect (h);
    h = NULL;
  }
  GNUNET_SCHEDULER_shutdown ();
}
Ejemplo n.º 4
0
/**
 * Function run on shutdown.
 *
 * @param cls closure
 */
static void
do_shutdown (void *cls)
{
  if (NULL != timeout_task)
  {
    GNUNET_SCHEDULER_cancel (timeout_task);
    timeout_task = NULL;
  }
  if (NULL != op)
  {
    GNUNET_IDENTITY_cancel (op);
    op = NULL;
  }
  if (NULL != call1)
  {
    GNUNET_CONVERSATION_call_stop (call1);
    call1 = NULL;
  }
  if (NULL != call2)
  {
    GNUNET_CONVERSATION_call_stop (call2);
    call2 = NULL;
  }
  if (NULL != phone)
  {
    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n");
    GNUNET_CONVERSATION_phone_destroy (phone);
    phone = NULL;
  }
  if (NULL != id)
  {
    GNUNET_IDENTITY_disconnect (id);
    id = NULL;
  }
  if (NULL != qe)
  {
    GNUNET_NAMESTORE_cancel (qe);
    qe = NULL;
  }
  if (NULL != ns)
  {
    GNUNET_NAMESTORE_disconnect (ns);
    ns = NULL;
  }
}
/**
 * Cleanup task
 */
static void
cleanup()
{
  struct EgoEntry *ego_entry;
  struct EgoEntry *ego_tmp;

  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Cleaning up\n");
  if (NULL != timeout_task)
    GNUNET_SCHEDULER_cancel (timeout_task);
  if (NULL != update_task)
    GNUNET_SCHEDULER_cancel (update_task);
  if (NULL != identity_handle)
    GNUNET_IDENTITY_disconnect (identity_handle);
  if (NULL != ns_it)
    GNUNET_NAMESTORE_zone_iteration_stop (ns_it);
  if (NULL != ns_qe)
    GNUNET_NAMESTORE_cancel (ns_qe);
  if (NULL != ns_handle)
    GNUNET_NAMESTORE_disconnect (ns_handle);
  if (NULL != token)
    GNUNET_free (token);
  if (NULL != label)
    GNUNET_free (label);

  for (ego_entry = ego_head;
       NULL != ego_entry;)
  {
    ego_tmp = ego_entry;
    if (0 != GNUNET_CONTAINER_multihashmap_size (ego_tmp->attr_map))
    {
      GNUNET_CONTAINER_multihashmap_iterate (ego_tmp->attr_map,
                                             &clear_ego_attrs,
                                             ego_tmp);

    }
    GNUNET_CONTAINER_multihashmap_destroy (ego_tmp->attr_map);
    ego_entry = ego_entry->next;
    GNUNET_free (ego_tmp);
  }
}
Ejemplo n.º 6
0
/**
 * Task run on shutdown.
 *
 * @param cls NULL
 */
static void
shutdown_task (void *cls)
{
  if (NULL != set_op)
  {
    GNUNET_IDENTITY_cancel (set_op);
    set_op = NULL;
  }
  if (NULL != create_op)
  {
    GNUNET_IDENTITY_cancel (create_op);
    create_op = NULL;
  }
  if (NULL != delete_op)
  {
    GNUNET_IDENTITY_cancel (delete_op);
    delete_op = NULL;
  }
  GNUNET_IDENTITY_disconnect (sh);
  sh = NULL;
}
/**
 * Signature of the main function of a task.
 *
 * @param cls closure
 * @param tc context information (why was this task triggered now)
 */
static void
end_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
    GNUNET_SCHEDULER_shutdown ();
    if (NULL != op)
    {
        GNUNET_IDENTITY_cancel (op);
        op = NULL;
    }
    if (NULL != call)
    {
        GNUNET_CONVERSATION_call_stop (call);
        call = NULL;
    }
    if (NULL != phone)
    {
        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n");
        GNUNET_CONVERSATION_phone_destroy (phone);
        phone = NULL;
    }
    if (NULL != id)
    {
        GNUNET_IDENTITY_disconnect (id);
        id = NULL;
    }
    if (NULL != qe)
    {
        GNUNET_NAMESTORE_cancel (qe);
        qe = NULL;
    }
    if (NULL != ns)
    {
        GNUNET_NAMESTORE_disconnect (ns);
        ns = NULL;
    }
}
Ejemplo n.º 8
0
/**
 * Task run on shutdown.  Cleans up everything.
 *
 * @param cls unused
 * @param tc scheduler context
 */
static void
do_shutdown (void *cls,
	     const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  if (NULL != get_default)
  {
    GNUNET_IDENTITY_cancel (get_default);
    get_default = NULL;
  }
  if (NULL != idh)
  {
    GNUNET_IDENTITY_disconnect (idh);
    idh = NULL;
  }
  if (NULL != el)
  {
    GNUNET_IDENTITY_ego_lookup_cancel (el);
    el = NULL;
  }
  if (NULL != list_it)
  {
    GNUNET_NAMESTORE_zone_iteration_stop (list_it);
    list_it = NULL;
  }
  if (NULL != add_qe)
  {
    GNUNET_NAMESTORE_cancel (add_qe);
    add_qe = NULL;
  }
  if (NULL != add_qe_uri)
  {
    GNUNET_NAMESTORE_cancel (add_qe_uri);
    add_qe_uri = NULL;
  }
  if (NULL != del_qe)
  {
    GNUNET_NAMESTORE_cancel (del_qe);
    del_qe = NULL;
  }
  if (NULL != ns)
  {
    GNUNET_NAMESTORE_disconnect (ns);
    ns = NULL;
  }
  memset (&zone_pkey, 0, sizeof (zone_pkey));
  if (NULL != uri)
  {
    GNUNET_free (uri);
    uri = NULL;
  }
  if (NULL != zm)
  {
    GNUNET_NAMESTORE_zone_monitor_stop (zm);
    zm = NULL;
  }
  if (NULL != data)
  {
    GNUNET_free (data);
    data = NULL;
  }
}