int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* get overhead */ nodedata->overhead = GET_HEADER_SIZE(&c0); return 0; }
int get_header_size(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); if (nodedata->overhead == -1) { call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; nodedata->overhead = GET_HEADER_SIZE(&c0); } return nodedata->overhead + sizeof(struct routing_header); }
/* ************************************************** */ int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; int nb_neigh = 0; nb_neigh=nb_neigh; /* Get mac header overhead */ nodedata->overhead = GET_HEADER_SIZE(&c0); /* Find all the node's neighbors (i.e. the one in range) */ nb_neigh = find_neighbors(c); PRINT_ROUTING("Node %d has %d neighbors\n", c->node, nb_neigh); return 0; }
/* ************************************************** */ int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* get mac header overhead */ nodedata->overhead = GET_HEADER_SIZE(&c0); /* hello packet */ if (nodedata->period > 0) { uint64_t start = get_time() + nodedata->start + get_random_double() * nodedata->period; scheduler_add_callback(start, c, advert_callback, NULL); } return 0; }
int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); struct protocoleData *entitydata = get_entity_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* get mac header overhead */ nodedata->overhead = GET_HEADER_SIZE(&c0); broadcast_hello(c, NULL); uint64_t at=get_time_now()+time_seconds_to_nanos(3); scheduler_add_callback(at, c, init_rbop, NULL); return 0; }
void* malloc(size_t size) { /* if memory_init hasn't been called yet, we need to get libc's malloc address */ if (!libmalloc) { if(malloc_protect_on) /* protection flag says that malloc is already trying to retrieve the address of malloc. * if we call dlsym now, there will be an infinite recursion, so let's allocate * memory 'by hand' */ return hand_made_malloc(size); /* set the protection flag and retrieve the address of malloc. * if dlsym calls malloc, memory will be allocated 'by hand' */ malloc_protect_on = 1; libmalloc = dlsym(RTLD_NEXT, "malloc"); char* error; if ((error = dlerror()) != NULL) { fputs(error, stderr); exit(1); } /* it is now safe to call libmalloc */ malloc_protect_on = 0; } EZTRACE_PROTECT { void* pptr = libmalloc(size + GET_HEADER_SIZE()); struct mem_block_info *p_block = NULL; INIT_MEM_INFO(p_block, pptr, size, 1); p_block->mem_type = MEM_TYPE_MALLOC; EZTRACE_EVENT2(FUT_MEMORY_MALLOC, p_block->size, p_block->u_ptr); #if 0 /* for debugging purpose only */ uint32_t* canary = p_block->u_ptr-sizeof(uint32_t); if(*canary != MAGIC_PATTERN) { fprintf(stderr, "warning: canary = %x instead of %x\n", *canary, MAGIC_PATTERN); } #endif return p_block->u_ptr; } return libmalloc(size); }
int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); entityid_t *down = get_entity_links_down(c); call_t c0 = {down[0], c->node, c->entity}; uint64_t schedule = get_time() + nodedata->h_start + get_random_double() * nodedata->h_period; /* get overhead */ if ((get_entity_type(&c0) != MODELTYPE_ROUTING) && (get_entity_type(&c0) != MODELTYPE_MAC)) { nodedata->overhead = 0; } else { nodedata->overhead = GET_HEADER_SIZE(&c0); } /* scheduler first hello */ if (nodedata->h_nbr == -1 || nodedata->h_nbr > 0) { scheduler_add_callback(schedule, c, hello_callback, NULL); } return 0; }
int bootstrap(call_t *c) { struct nodedata *nodedata = get_node_private_data(c); struct protocoleData *entitydata = get_entity_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* get mac header overhead */ nodedata->overhead = GET_HEADER_SIZE(&c0); int i; for(i = 0 ; i < get_node_count() ; i++) { nodedata->lastIDs[i] = -1; nodedata->energiesRem[i] = battery_remaining(c) - 2*getCoutFromDistance(getRange(c), entitydata->alpha, entitydata->c); } broadcast_hello(c, NULL); uint64_t at=get_time_now()+time_seconds_to_nanos(2); scheduler_add_callback(at, c, broadcast_hello2, NULL); return 0; }