本文整理汇总了C++中ANNOTATE函数的典型用法代码示例。如果您正苦于以下问题:C++ ANNOTATE函数的具体用法?C++ ANNOTATE怎么用?C++ ANNOTATE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ANNOTATE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ppp_reject_protocol
/*
* Unknown Protocol Handler, sends reject
*/
static void
ppp_reject_protocol(u16_t protocol, u8_t *buffer, u16_t count)
{
u16_t i;
u8_t *dptr, *sptr;
LCPPKT *pkt;
/* first copy rejected packet back, start from end and work forward,
+++ Pay attention to buffer managment when updated. Assumes fixed
PPP blocks. */
ANNOTATE("Rejecting Protocol\n");
if((count + 6) > PPP_RX_BUFFER_SIZE) {
/* This is a fatal error +++ do somthing about it. */
ANNOTATE("Cannot Reject Protocol, PKT to big\n");
return;
}
dptr = buffer + count + 6;
sptr = buffer + count;
for(i = 0; i < count; ++i) {
*dptr-- = *sptr--;
}
pkt = (LCPPKT *)buffer;
pkt->code = PROT_REJ; /* Write Conf_rej */
/*pkt->id = tid++;*/ /* write tid */
pkt->len = uip_htons(count + 6);
*((u16_t *)(&pkt->data)) = uip_htons(protocol);
ahdlc_tx(LCP, buffer, 0, (u16_t)(count + 6), 0);
}
示例2: scan_packet
/* scan_packet(list,buffer,len)
*
* list = list of supported ID's
* *buffer pointer to the first code in the packet
* length of the codespace
*/
u16_t
scan_packet(u16_t protocol, u8_t *list, u8_t *buffer, u8_t *options, u16_t len)
{
u8_t *tlist, *bptr;
u8_t *tptr;
u8_t bad = 0;
u8_t i, j, good;
bptr = tptr = options;
/* scan through the packet and see if it has any unsupported codes */
while(bptr < options + len) {
/* get code and see if it matches somwhere in the list, if not
we don't support it */
i = *bptr++;
/* ANNOTATE("%x - ",i);*/
tlist = list;
good = 0;
while(*tlist) {
/* ANNOTATE("%x ",*tlist);*/
if(i == *tlist++) {
good = 1;
break;
}
}
if(!good) {
/* we don't understand it, write it back */
bad = 1;
*tptr++ = i;
j = *tptr++ = *bptr++;
for(i = 0; i < j - 2; ++i) {
*tptr++ = *bptr++;
}
} else {
/* advance over to next option */
bptr += *bptr - 1;
}
}
/* Bad? if we we need to send a config Reject */
if(bad) {
/* write the config Rej packet we've built above, take on the header */
bptr = buffer;
*bptr++ = CONF_REJ; /* Write Conf_rej */
bptr++; /* skip over ID */
*bptr++ = 0;
*bptr = tptr - buffer;
/* length right here? */
/* write the reject frame */
ANNOTATE("Writing Reject frame --\n");
ahdlc_tx(protocol, buffer, 0, (u16_t)(tptr - buffer), 0);
ANNOTATE("\nEnd writing reject \n");
}
return bad;
}
示例3: dump_ppp_packet
void
dump_ppp_packet(u8_t *buffer, u16_t len)
{
int i;
ANNOTATE("\n");
for(i = 0;i < len; ++i) {
if((i & 0x1f) == 0x10) {
ANNOTATE("\n");
}
ANNOTATE("0x%02x ",buffer[i]);
}
ANNOTATE("\n\n");
}
示例4: uip_ds6_route_add
/*---------------------------------------------------------------------------*/
uip_ds6_route_t *
uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, uip_ipaddr_t *nexthop,
uint8_t metric)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *)uip_ds6_routing_table, UIP_DS6_ROUTE_NB,
sizeof(uip_ds6_route_t), ipaddr, length,
(uip_ds6_element_t **)&locroute) == FREESPACE) {
locroute->isused = 1;
uip_ipaddr_copy(&(locroute->ipaddr), ipaddr);
locroute->length = length;
uip_ipaddr_copy(&(locroute->nexthop), nexthop);
locroute->metric = metric;
#ifdef UIP_DS6_ROUTE_STATE_TYPE
memset(&locroute->state, 0, sizeof(UIP_DS6_ROUTE_STATE_TYPE));
#endif
PRINTF("DS6: adding route: ");
PRINT6ADDR(ipaddr);
PRINTF(" via ");
PRINT6ADDR(nexthop);
PRINTF("\n");
ANNOTATE("#L %u 1;blue\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
}
return locroute;
}
示例5: uip_ds6_defrt_rm
/*---------------------------------------------------------------------------*/
void
uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
{
uip_ds6_defrt_t *d;
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
/* Make sure that the defrt is in the list before we remove it. */
for(d = list_head(defaultrouterlist);
d != NULL;
d = list_item_next(d)) {
if(d == defrt) {
PRINTF("Removing default route\n");
list_remove(defaultrouterlist, defrt);
memb_free(&defaultroutermemb, defrt);
ANNOTATE("#L %u 0\n", defrt->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_RM,
&defrt->ipaddr, &defrt->ipaddr);
#endif
return;
}
}
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
}
示例6: rpl_remove_routes_by_nexthop
/*---------------------------------------------------------------------------*/
void
rpl_remove_routes_by_nexthop(struct in6_addr *nexthop, rpl_dag_t *dag)
{
/* uip_ds6_route_t *r;
r = uip_ds6_route_list_head();
while(r != NULL) {
if(uip_ipaddr_cmp(&r->nexthop, nexthop) &&
r->state.dag == dag) {
uip_ds6_route_rm(r);
r = uip_ds6_route_list_head();
} else {
r = list_item_next(r);
}
}
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
*/
#if 0
uip_ds6_route_t *locroute;
for(locroute = uip_ds6_routing_table;
locroute < uip_ds6_routing_table + UIP_DS6_ROUTE_NB;
locroute++) {
if(locroute->isused
&& uip_ipaddr_cmp(&locroute->nexthop, nexthop)
&& locroute->state.dag == dag) {
locroute->isused = 0;
}
}
ANNOTATE("#L %u 0\n",nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
#endif /* 0 */
}
示例7: uip_ds6_defrt_add
/*---------------------------------------------------------------------------*/
uip_ds6_defrt_t *
uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *)uip_ds6_defrt_list, UIP_DS6_DEFRT_NB,
sizeof(uip_ds6_defrt_t), ipaddr, 128,
(uip_ds6_element_t **)&locdefrt) == FREESPACE) {
locdefrt->isused = 1;
uip_ipaddr_copy(&locdefrt->ipaddr, ipaddr);
if(interval != 0) {
stimer_set(&locdefrt->lifetime, interval);
locdefrt->isinfinite = 0;
} else {
locdefrt->isinfinite = 1;
}
PRINTF("Adding defrouter with ip addr ");
PRINT6ADDR(&locdefrt->ipaddr);
PRINTF("\n");
ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
return locdefrt;
}
return NULL;
}
示例8: uip_ds6_defrt_add
/*---------------------------------------------------------------------------*/
uip_ds6_defrt_t *
uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
uip_ds6_defrt_t *d;
#if _DEBUG_ != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* _DEBUG_ != DEBUG_NONE */
PRINTF("uip_ds6_defrt_add\n");
d = uip_ds6_defrt_lookup(ipaddr);
if(d == NULL) {
d = memb_alloc(&defaultroutermemb);
if(d == NULL) {
PRINTF("uip_ds6_defrt_add: could not add default route to ");
PRINT6ADDR(ipaddr);
PRINTF(", out of memory\n");
return NULL;
} else {
PRINTF("uip_ds6_defrt_add: adding default route to ");
PRINT6ADDR(ipaddr);
PRINTF("\n");
}
list_push(defaultrouterlist, d);
}
if(ipaddr == NULL) {
/* A special case: if uip_ds6_defrt_add() is called with a NULL
route, this is an indication that we want to force packets to
go out to the fallback interface. If so, we add an unspecified
route to the list of default routes. uip_ds6_defrt_choose()
will trap this and ensure that packets go to the fallback
interface. */
uip_create_unspecified(&d->ipaddr);
ipaddr = &d->ipaddr;
} else {
uip_ipaddr_copy(&d->ipaddr, ipaddr);
}
if(interval != 0) {
stimer_set(&d->lifetime, interval);
d->isinfinite = 0;
} else {
d->isinfinite = 1;
}
ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);
#endif
#if _DEBUG_ != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* _DEBUG_ != DEBUG_NONE */
return d;
}
示例9: printip
void
printip(uip_ipaddr_t ip2)
{
#if (UIP_LOGGING == 1) && (DEBUG & DEBUG_ANNOTATE)
unsigned char *ip = (unsigned char *)ip2.u8;
ANNOTATE(" %d:%d:%d:%d ",ip[0],ip[1],ip[2],ip[3]);
#endif
}
示例10: uip_ds6_defrt_rm
/*---------------------------------------------------------------------------*/
void
uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
{
if(defrt != NULL) {
defrt->isused = 0;
ANNOTATE("#L %u 0\n", defrt->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]);
}
return;
}
示例11: ipv6cp_init
/*---------------------------------------------------------------------------*/
void
ipv6cp_init(void)
{
ANNOTATE("ipv6cp init\n");
ipv6cp_state = 0;
ppp_retry = 0;
pppif.ipaddr.u16[0] = pppif.ipaddr.u16[1] = 0;
TIMER_expire();
}
示例12: uip_ds6_defrt_add
/*---------------------------------------------------------------------------*/
uip_ds6_defrt_t *
uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
uip_ds6_defrt_t *d;
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
PRINTF("uip_ds6_defrt_add\n");
d = uip_ds6_defrt_lookup(ipaddr);
if(d == NULL) {
d = memb_alloc(&defaultroutermemb);
if(d == NULL) {
PRINTF("uip_ds6_defrt_add: could not add default route to ");
PRINT6ADDR(ipaddr);
PRINTF(", out of memory\n");
return NULL;
} else {
PRINTF("uip_ds6_defrt_add: adding default route to ");
PRINT6ADDR(ipaddr);
PRINTF("\n");
}
list_push(defaultrouterlist, d);
}
uip_ipaddr_copy(&d->ipaddr, ipaddr);
//ADILA EDIT 03/11/14
//d->parentCh = cc2420_get_channel();
/*if(d->parentCh == 0) {
d->parentCh = 26;
}*/
//printf("\n\nINITIALISE D->PARENTCH %d\n\n", d->parentCh);
//-------------------
if(interval != 0) {
stimer_set(&d->lifetime, interval);
d->isinfinite = 0;
} else {
d->isinfinite = 1;
}
ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);
#endif
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
return d;
}
示例13: uip_ds6_route_rm
/*---------------------------------------------------------------------------*/
void
uip_ds6_route_rm(uip_ds6_route_t *route)
{
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
if(route != NULL && route->routes != NULL) {
PRINTF("uip_ds6_route_rm: removing route: ");
PRINT6ADDR(&route->ipaddr);
PRINTF("\n");
list_remove(route->routes->route_list, route);
if(list_head(route->routes->route_list) == NULL) {
/* If this was the only route using this neighbor, remove the
neibhor from the table */
PRINTF("uip_ds6_route_rm: removing neighbor too\n");
nbr_table_remove(nbr_routes, route->routes->route_list);
}
memb_free(&routememb, route);
num_routes--;
PRINTF("uip_ds6_route_rm num %d\n", num_routes);
#if UIP_DS6_NOTIFICATIONS
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
&route->ipaddr, uip_ds6_route_nexthop(route));
#endif
#if 0 //(DEBUG & DEBUG_ANNOTATE) == DEBUG_ANNOTATE
/* we need to check if this was the last route towards "nexthop" */
/* if so - remove that link (annotation) */
uip_ds6_route_t *r;
for(r = uip_ds6_route_head();
r != NULL;
r = uip_ds6_route_next(r)) {
uip_ipaddr_t *nextr, *nextroute;
nextr = uip_ds6_route_nexthop(r);
nextroute = uip_ds6_route_nexthop(route);
if(nextr != NULL &&
nextroute != NULL &&
uip_ipaddr_cmp(nextr, nextroute)) {
/* we found another link using the specific nexthop, so keep the #L */
return;
}
}
ANNOTATE("#L %u 0\n", uip_ds6_route_nexthop(route)->u8[sizeof(uip_ipaddr_t) - 1]);
#endif
}
#if DEBUG != DEBUG_NONE
assert_nbr_routes_list_sane();
#endif /* DEBUG != DEBUG_NONE */
return;
}
示例14: new_dio_interval
/*---------------------------------------------------------------------------*/
static void
new_dio_interval(rpl_instance_t *instance, int isReset)
{
uint32_t time;
clock_time_t ticks;
/* TODO: too small timer intervals for many cases */
time = 1UL << instance->dio_intcurrent;
/* Convert from milliseconds to CLOCK_TICKS. */
ticks = (time * CLOCK_SECOND) / 1000;
instance->dio_next_delay = ticks;
/* random number between I/2 and I */
ticks = ticks / 2 + (ticks / 2 * (uint32_t)random_rand()) / RANDOM_RAND_MAX;
/* opt trickle*/
/*
if (isReset == 1) {
ticks * (uint32_t)random_rand() / RANDOM_RAND_MAX;
}
else {
ticks = ticks / 2 + (ticks / 2 * (uint32_t)random_rand()) / RANDOM_RAND_MAX;
}
*/
/*
* The intervals must be equally long among the nodes for Trickle to
* operate efficiently. Therefore we need to calculate the delay between
* the randomized time and the start time of the next interval.
*/
instance->dio_next_delay -= ticks;
instance->dio_send = 1;
#if RPL_CONF_STATS
/* keep some stats */
instance->dio_totint++;
instance->dio_totrecv += instance->dio_counter;
ANNOTATE("#A rank=%u.%u(%u),stats=%d %d %d %d,color=%s\n",
DAG_RANK(instance->current_dag->rank, instance),
(10 * (instance->current_dag->rank % instance->min_hoprankinc)) / instance->min_hoprankinc,
instance->current_dag->version,
instance->dio_totint, instance->dio_totsend,
instance->dio_totrecv,instance->dio_intcurrent,
instance->current_dag->rank == ROOT_RANK(instance) ? "BLUE" : "ORANGE");
#endif /* RPL_CONF_STATS */
/* reset the redundancy counter */
instance->dio_counter = 0;
/* schedule the timer */
PRINTF("RPL: Scheduling DIO timer %lu ticks in future (Interval)\n", ticks);
ctimer_set(&instance->dio_timer, ticks, &handle_dio_timer, instance);
}
示例15: rpl_set_root
rpl_dag_t *
rpl_set_root(uip_ipaddr_t *dag_id)
{
rpl_dag_t *dag;
int version;
version = -1;
dag = rpl_get_dag(RPL_DEFAULT_INSTANCE);
if(dag != NULL) {
PRINTF("RPL: Dropping a joined DAG when setting this node as root");
version = dag->version;
rpl_free_dag(dag);
}
dag = rpl_alloc_dag(RPL_DEFAULT_INSTANCE);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG\n");
return NULL;
}
dag->joined = 1;
dag->version = version + 1;
dag->grounded = RPL_GROUNDED;
dag->mop = RPL_MOP_DEFAULT;
dag->of = &RPL_OF;
dag->preferred_parent = NULL;
dag->dtsn_out = 1; /* Trigger DAOs from the beginning. */
memcpy(&dag->dag_id, dag_id, sizeof(dag->dag_id));
dag->dio_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
dag->dio_intmin = DEFAULT_DIO_INTERVAL_MIN;
dag->dio_redundancy = DEFAULT_DIO_REDUNDANCY;
dag->max_rankinc = DEFAULT_MAX_RANKINC;
dag->min_hoprankinc = DEFAULT_MIN_HOPRANKINC;
dag->default_lifetime = RPL_DEFAULT_LIFETIME;
dag->lifetime_unit = RPL_DEFAULT_LIFETIME_UNIT;
dag->rank = ROOT_RANK(dag);
dag->of->update_metric_container(dag);
PRINTF("RPL: Node set to be a DAG root with DAG ID ");
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
ANNOTATE("#A root=%u\n",dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_reset_dio_timer(dag, 1);
return dag;
}