本文整理汇总了C++中GNUNET_i2s函数的典型用法代码示例。如果您正苦于以下问题:C++ GNUNET_i2s函数的具体用法?C++ GNUNET_i2s怎么用?C++ GNUNET_i2s使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GNUNET_i2s函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 ();
}
开发者ID:tg-x,项目名称:gnunet,代码行数:41,代码来源:test_transport_api_monitor_validation.c
示例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;
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:41,代码来源:test_transport_api_manipulation_recv_tcp.c
示例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);
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:12,代码来源:test_transport_testing_restart.c
示例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);
}
}
开发者ID:claudiuolteanu,项目名称:gnunet-1,代码行数:21,代码来源:gnunet-transport.c
示例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);
}
开发者ID:claudiuolteanu,项目名称:gnunet-1,代码行数:19,代码来源:gnunet-transport.c
示例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);
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:18,代码来源:gnunet-service-fs_stream.c
示例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);
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:27,代码来源:gnunet-service-core_neighbours.c
示例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);
}
开发者ID:tg-x,项目名称:gnunet,代码行数:21,代码来源:test_transport_api_disconnect.c
示例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;
}
开发者ID:h4ck3rm1k3,项目名称:gnunet-debian,代码行数:12,代码来源:gnunet-service-ats_addresses.c
示例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);
}
}
开发者ID:tg-x,项目名称:gnunet,代码行数:21,代码来源:test_transport_api_disconnect.c
示例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;
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:68,代码来源:ats_api_peer_change_preference.c
示例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;
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:12,代码来源:test_quota_compliance.c
示例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;
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:21,代码来源:test_transport_api_dv.c
示例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);
}
}
开发者ID:claudiuolteanu,项目名称:gnunet-1,代码行数:40,代码来源:transport-testing.c
示例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++;
}
}
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:48,代码来源:test_testing_topology.c
示例16: is_connection_allowed
/**
* Check if an additional connection from the given peer is allowed.
*
* @param peer connection to check
* @return GNUNET_OK if the connection is allowed
*/
static int
is_connection_allowed (struct Peer *peer)
{
if (0 ==
memcmp (&my_identity, &peer->pid, sizeof (struct GNUNET_PeerIdentity)))
return GNUNET_SYSERR; /* disallow connections to self */
if (peer->is_friend)
return GNUNET_OK;
if (GNUNET_YES == friends_only)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Determined that `%s' is not allowed to connect (not a friend)\n",
GNUNET_i2s (&peer->pid));
return GNUNET_SYSERR;
}
if (friend_count >= minimum_friend_count)
return GNUNET_OK;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Determined that `%s' is not allowed to connect (not enough connected friends)\n",
GNUNET_i2s (&peer->pid));
return GNUNET_SYSERR;
}
开发者ID:schanzen,项目名称:gnunet-mirror,代码行数:28,代码来源:gnunet-daemon-topology.c
示例17: perf_update_address
/**
* Perform an update for an address
*
* @param cur the address to update
*/
static void
perf_update_address (struct ATS_Address *cur)
{
int r_type;
int abs_val;
double rel_val;
r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2);
switch (r_type)
{
case 0:
abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
rel_val = (100 + (double) abs_val) / 100;
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"Updating peer `%s' address %p type %s abs val %u rel val %.3f\n",
GNUNET_i2s (&cur->peer), cur,
"GNUNET_ATS_QUALITY_NET_DELAY",
abs_val, rel_val);
ph.sf->s_address_update_property (ph.sf->cls, cur,
GNUNET_ATS_QUALITY_NET_DELAY,
abs_val, rel_val);
break;
case 1:
abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10);
rel_val = (100 + (double) abs_val) / 100;
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"Updating peer `%s' address %p type %s abs val %u rel val %.3f\n",
GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE",
abs_val, rel_val);
ph.sf->s_address_update_property (ph.sf->cls, cur,
GNUNET_ATS_QUALITY_NET_DISTANCE,
abs_val, rel_val);
break;
default:
break;
}
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:44,代码来源:perf_ats_solver.c
示例18: handle_friend
/**
* Process friend found in FRIENDS file.
*
* @param cls pointer to an `unsigned int` to be incremented per friend found
* @param pid identity of the friend
*/
static void
handle_friend (void *cls,
const struct GNUNET_PeerIdentity *pid)
{
unsigned int *entries_found = cls;
struct Peer *fl;
if (0 == memcmp (pid,
&my_identity,
sizeof (struct GNUNET_PeerIdentity)))
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Found myself `%s' in friend list (useless, ignored)\n"),
GNUNET_i2s (pid));
return;
}
(*entries_found)++;
fl = make_peer (pid, NULL, GNUNET_YES);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Found friend `%s' in configuration\n"),
GNUNET_i2s (&fl->pid));
}
开发者ID:GNUnet,项目名称:gnunet,代码行数:28,代码来源:gnunet-daemon-topology.c
示例19: testing_connect_cb
static void
testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
{
if (cls == cc1)
{
cc1 = NULL;
GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
}
if (cls == cc2)
{
cc2 = NULL;
GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc1);
}
char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n",
p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
GNUNET_free (p1_c);
send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
}
开发者ID:amatus,项目名称:gnunet-debian,代码行数:22,代码来源:test_transport_api_bidirectional_connect.c
示例20: restart_cb
static void
restart_cb (struct PeerContext *p, void *cls)
{
static int c;
c++;
if (c != 2)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Restarted peer %u (`%4s'), issuing reconnect\n", p->no,
GNUNET_i2s (&p->id));
reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p);
}
开发者ID:amatus,项目名称:gnunet-debian,代码行数:13,代码来源:test_transport_api_restart_2peers.c
注:本文中的GNUNET_i2s函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论