本文整理汇总了C++中GNUNET_i2s函数的典型用法代码示例。如果您正苦于以下问题:C++ GNUNET_i2s函数的具体用法?C++ GNUNET_i2s怎么用?C++ GNUNET_i2s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GNUNET_i2s函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notify_receive
static void
notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
struct PeerContext *t = NULL;
if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
t = p1;
if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
t = p2;
GNUNET_assert (t != NULL);
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n",
p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
GNUNET_i2s (&t->id));
GNUNET_free (ps);
if (0 >= p1_c)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Peer 1 did not receive validation callbacks for peer 2\n");
}
if (0 >= p2_c)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Peer 2 did not receive validation callbacks for peer 1\n");
}
if ((0 >= p1_c) || (0 >= p2_c))
{
if (NULL != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
}
else
end ();
}
示例2: notify_ready
static size_t
notify_ready (void *cls, size_t size, void *buf)
{
struct PeerContext *p = cls;
struct GNUNET_MessageHeader *hdr;
th = NULL;
if (buf == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout occurred while waiting for transmit_ready\n");
if (NULL != die_task)
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
ok = 42;
return 0;
}
GNUNET_assert (size >= TEST_MESSAGE_SIZE);
memset (buf, '\0', TEST_MESSAGE_SIZE);
hdr = buf;
hdr->size = htons (TEST_MESSAGE_SIZE);
hdr->type = htons (TEST_MESSAGE_TYPE);
{
char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n",
p2->no,
ps,
ntohs (hdr->type),
ntohs (hdr->size),
p->no,
GNUNET_i2s (&p->id));
GNUNET_free (ps);
}
return TEST_MESSAGE_SIZE;
}
示例3: restart_task
static void
restart_task ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%s') restarting, \n",
p->no,
GNUNET_i2s (&p->id));
GNUNET_TRANSPORT_TESTING_restart_peer (p,
NULL,
&restart_cb,
p);
}
示例4: print_info
static void
print_info (const struct GNUNET_PeerIdentity *id, const char *transport,
const char *addr, enum GNUNET_TRANSPORT_PeerState state,
struct GNUNET_TIME_Absolute state_timeout)
{
if ((GNUNET_YES == iterate_all) || (GNUNET_YES == monitor_connections) )
{
FPRINTF (stdout, _("Peer `%s': %s %s in state `%s' until %s\n"),
GNUNET_i2s (id),
(NULL == transport) ? "<none>" : transport,
(NULL == transport) ? "<none>" : addr,
GNUNET_TRANSPORT_ps2s (state),
GNUNET_STRINGS_absolute_time_to_string (state_timeout));
}
else
{
/* Only connected peers, skip state */
FPRINTF (stdout, _("Peer `%s': %s %s\n"), GNUNET_i2s (id), transport, addr);
}
}
示例5: monitor_notify_disconnect
/**
* Function called to notify transport users that another
* peer disconnected from us.
*
* @param cls closure
* @param peer the peer that disconnected
*/
static void
monitor_notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
GNUNET_assert(monitor_connect_counter > 0);
monitor_connect_counter--;
FPRINTF (stdout, _("%24s: %-17s %4s (%u connections in total)\n"), now_str,
_("Disconnected from"), GNUNET_i2s (peer), monitor_connect_counter);
}
示例6: stream_timeout
/**
* Task called when it is time to destroy an inactive stream.
*
* @param cls the 'struct StreamHandle' to tear down
* @param tc scheduler context, unused
*/
static void
stream_timeout (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct StreamHandle *sh = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Timeout on stream to %s\n",
GNUNET_i2s (&sh->target));
sh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
destroy_stream_handle (sh);
}
示例7: handle_transport_notify_excess_bw
/**
* One of our neighbours has excess bandwidth, remember this.
*
* @param cls NULL
* @param pid identity of the peer with excess bandwidth
*/
static void
handle_transport_notify_excess_bw (void *cls,
const struct GNUNET_PeerIdentity *pid)
{
struct Neighbour *n;
n = find_neighbour (pid);
if (NULL == n)
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Peer %s not found\n",
GNUNET_i2s (pid));
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s has excess bandwidth available\n",
GNUNET_i2s (pid));
n->has_excess_bandwidth = GNUNET_YES;
GSC_SESSIONS_solicit (pid);
}
示例8: start_cb
static void
start_cb (struct PeerContext *p, void *cls)
{
static int started;
started++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%s') started\n", p->no,
GNUNET_i2s (&p->id));
if (started != 2)
return;
char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (sender_c);
cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb,
NULL);
}
示例9: reset_address_it
static int
reset_address_it (void *cls, const GNUNET_HashCode * key, void *value)
{
struct ATS_Address *aa = value;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Resetting interval for peer `%s' address %p from %llu to 0\n", GNUNET_i2s (&aa->peer), aa, aa->block_interval);
aa->blocked_until = GNUNET_TIME_UNIT_ZERO_ABS;
aa->block_interval = GNUNET_TIME_UNIT_ZERO;
return GNUNET_OK;
}
示例10: notify_disconnect
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
GNUNET_i2s (peer));
GNUNET_free (ps);
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
if (shutdown_ == GNUNET_YES)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n");
GNUNET_SCHEDULER_add_now (&end, NULL);
}
}
示例11: GNUNET_ATS_peer_change_preference
/**
* Obtain statistics and/or change preferences for the given peer.
*
* @param h core handle
* @param peer identifies the peer
* @param amount reserve N bytes for receiving, negative
* amounts can be used to undo a (recent) reservation;
* @param preference increase incoming traffic share preference by this amount;
* in the absence of "amount" reservations, we use this
* preference value to assign proportional bandwidth shares
* to all connected peers
* @param info function to call with the resulting configuration information
* @param info_cls closure for info
* @return NULL on error
*/
struct GNUNET_ATS_InformationRequestContext *
GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_SchedulingHandle *h,
const struct GNUNET_PeerIdentity *peer,
int32_t amount, uint64_t preference,
GNUNET_ATS_PeerConfigurationInfoCallback
info, void *info_cls)
{
struct GNUNET_ATS_InformationRequestContext *irc;
struct PeerRecord *pr;
struct RequestInfoMessage *rim;
struct ControlMessage *cm;
pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &peer->hashPubKey);
if (NULL == pr)
{
/* attempt to change preference on peer that is not connected */
GNUNET_assert (0);
return NULL;
}
if (pr->pcic != NULL)
{
/* second change before first one is done */
GNUNET_break (0);
return NULL;
}
irc = GNUNET_malloc (sizeof (struct GNUNET_ATS_InformationRequestContext));
irc->h = h;
irc->pr = pr;
cm = GNUNET_malloc (sizeof (struct ControlMessage) +
sizeof (struct RequestInfoMessage));
cm->cont = &change_preference_send_continuation;
cm->cont_cls = irc;
irc->cm = cm;
rim = (struct RequestInfoMessage *) &cm[1];
rim->header.size = htons (sizeof (struct RequestInfoMessage));
rim->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_REQUEST_INFO);
rim->rim_id = htonl (pr->rim_id = h->rim_id_gen++);
rim->reserved = htonl (0);
rim->reserve_inbound = htonl (amount);
rim->preference_change = GNUNET_htonll (preference);
rim->peer = *peer;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Queueing CHANGE PREFERENCE request for peer `%s' with RIM %u\n",
GNUNET_i2s (peer), (unsigned int) pr->rim_id);
GNUNET_CONTAINER_DLL_insert_tail (h->control_pending_head,
h->control_pending_tail, cm);
pr->pcic = info;
pr->pcic_cls = info_cls;
pr->pcic_ptr = irc; /* for free'ing irc */
if (NULL != h->client)
trigger_next_request (h, GNUNET_NO);
return irc;
}
示例12: notify_disconnect
static void
notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", p->no,
GNUNET_i2s (peer));
if (th != NULL)
GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
th = NULL;
}
示例13: disconnect_cores
static void
disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct TestMessageContext *pos = cls;
/* Disconnect from the respective cores */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n",
GNUNET_i2s (&pos->peer1->id));
if (pos->peer1handle != NULL)
GNUNET_CORE_disconnect (pos->peer1handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n",
GNUNET_i2s (&pos->peer2->id));
if (pos->peer2handle != NULL)
GNUNET_CORE_disconnect (pos->peer2handle);
/* Set handles to NULL so test case can be ended properly */
pos->peer1handle = NULL;
pos->peer2handle = NULL;
pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
/* Decrement total connections so new can be established */
total_server_connections -= 2;
}
示例14: notify_connect
static void
notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *p = cls;
char *p2_s;
struct PeerContext *p2;
GNUNET_assert (NULL != p);
GNUNET_assert (NULL != p->tth);
p2 = find_peer_context (p->tth, peer);
if (p->nc != NULL)
p->nc (p->cb_cls, peer);
if (p2 != NULL)
GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
else
GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
"Peers %s connected to peer %u (`%s')\n", p2_s, p->no,
GNUNET_i2s (&p->id));
GNUNET_free (p2_s);
/* Find ConnectingContext */
struct ConnectingContext *cc = find_connecting_context (p->tth, p, p2);
if (cc == NULL)
return;
if (p == cc->p1)
cc->p1_c = GNUNET_YES;
if (p == cc->p2)
cc->p2_c = GNUNET_YES;
if ((cc->p1_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
{
cc->cb (cc->p1, cc->p2, cc->cb_cls);
GNUNET_TRANSPORT_TESTING_connect_peers_cancel (p->tth, cc);
}
}
示例15: connect_notify_peers
/**
* Method called whenever a given peer connects.
*
* @param cls closure
* @param peer peer identity this notification is about
* @param atsi performance data for the connection
* @param atsi_count number of records in 'atsi'
*/
static void
connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_ATS_Information *atsi,
unsigned int atsi_count)
{
struct TestMessageContext *pos = cls;
if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity)))
{
pos->peer1notified = GNUNET_YES;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' notified of connection to peer `%s'\n",
GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
}
else
return;
if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
GNUNET_i2s (&pos->peer2->id),
GNUNET_h2s (&pos->peer1->id.hashPubKey));
if (NULL ==
GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0,
TIMEOUT, &pos->peer2->id,
sizeof (struct GNUNET_TestMessage),
&transmit_ready, pos))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
GNUNET_i2s (&pos->peer2->id));
transmit_ready_failed++;
}
else
{
transmit_ready_scheduled++;
}
}
}