コード例 #1
0
static void
run (void *cls, char *const *args, const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
{
  die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);

  s_started = GNUNET_NO;
  s_connected = GNUNET_NO;
  s_sending = GNUNET_NO;

  p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1,
                                            &notify_receive, &notify_connect,
                                            &notify_disconnect, &start_cb,
                                            NULL);
  vmc_p1 = GNUNET_TRANSPORT_monitor_validation_entries (p1->cfg, NULL, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, &monitor1_cb, NULL);

  p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2,
                                            &notify_receive, &notify_connect,
                                            &notify_disconnect, &start_cb,
                                            NULL);
  vmc_p2 = GNUNET_TRANSPORT_monitor_validation_entries (p2->cfg, NULL, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_REL, &monitor2_cb, NULL);

  if ((p1 == NULL) || (p2 == NULL))
  {
    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fail! Could not start peers!\n");
    if (die_task != NULL)
      GNUNET_SCHEDULER_cancel (die_task);
    die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
    return;
  }
}
コード例 #2
0
ファイル: NetworkManager.cpp プロジェクト: bratao/cangote
/**
 * Function to call to start our services
 */
void NetworkManager::start(struct GNUNET_CONFIGURATION_Handle *config)
{
    m_config = config;


    //Connect to peerinfo
    if (NULL == (m_peerInfo = GNUNET_PEERINFO_connect (config)))
    {
        qWarning("Failed to connect to PeerInfo service");
    }

    //Initialize transport plugins
    m_gnunetTransportPlugins = new GnunetTransportPlugins(config,this);

    //Connect to peerinfo notifications
    m_peerInfoNotify =   GNUNET_PEERINFO_notify (config, NULL, peerinfoProcessorCallback, this);
    if (m_peerInfoNotify == NULL) {
        qWarning("Failed to connect to PeerInfo Notify service");
    }

    //Connect to the ats service
    m_ats = GNUNET_ATS_performance_init (config, ATSstatusChangeCallback, this);
    if (m_ats == NULL) {
        qWarning("Failed to connect to ATS service");
    }

    //Monitor peer for connected transports
    m_peerMonitoring = GNUNET_TRANSPORT_monitor_peers (config,
                                                       NULL,
                                                       GNUNET_NO,
                                                       GNUNET_TIME_UNIT_FOREVER_REL,
                                                       &transportPeerChangeCallback,
                                                       NULL);

    //Monitor peer for validated transports
    m_peerTransportValidation = GNUNET_TRANSPORT_monitor_validation_entries (config,
                                                                             NULL,
                                                                             GNUNET_NO,
                                                                             GNUNET_TIME_UNIT_FOREVER_REL,
                                                                             &validationMonitorCallback,
                                                                             NULL);

    //Connect to core to receive all income and outcome messages ( for bandwidth calculation)
    m_core = GNUNET_CORE_connect (m_config, this, NULL,
                                  notifyConnectCallback, notifyDisconnectCallback,
                                  incomeMsgCallback, GNUNET_YES, outcomeMsgCallback, GNUNET_YES, NULL);

    //Inicialize NSE
    struct GNUNET_NSE_Handle *nse;
    nse = GNUNET_NSE_connect (config, checkNseMessageCallback, this);






    if(m_peerInfoNotify && m_ats && nse)
    {
        //status->setOkState();
    }



}