/* Add curve to path. */ static void glyphCurve(abfGlyphCallbacks *cb, float x1, float y1, float x2, float y2, float x3, float y3) { abfMetricsCtx h = cb->direct_ctx; Rect ep; /* End-point bounds */ Rect cp; /* Control-point bounds */ float x0 = h->x; float y0 = h->y; if (h->flags & ABF_MTX_TRANSFORM) { /* Transform curve */ float xt; xt = x0; x0 = TX(xt, y0); y0 = TY(xt, y0); xt = x1; x1 = TX(xt, y1); y1 = TY(xt, y1); xt = x2; x2 = TX(xt, y2); y2 = TY(xt, y2); xt = x3; x3 = TX(xt, y3); y3 = TY(xt, y3); } setLineBounds(&ep, x0, y0, x3, y3); setLineBounds(&cp, x1, y1, x2, y2); if (ep.left < h->real_mtx.left || ep.bottom < h->real_mtx.bottom || ep.right > h->real_mtx.right || ep.top > h->real_mtx.top || cp.left < h->real_mtx.left || cp.bottom < h->real_mtx.bottom || cp.right > h->real_mtx.right || cp.top > h->real_mtx.top) { /* Curve may extend bounds */ if (cp.left < ep.left || cp.right > ep.right) /* Grow left and/or right bounds */ setBezLimits(x0, x1, x2, x3, &ep.left, &ep.right); if (cp.bottom < ep.bottom || cp.top > ep.top) /* Grow top and/or bottom bounds */ setBezLimits(y0, y1, y2, y3, &ep.bottom, &ep.top); boundPoint(h, ep.left, ep.bottom); boundPoint(h, ep.right, ep.top); } h->x = x3; h->y = y3; }
/* Add move to path. */ static void glyphMove(abfGlyphCallbacks *cb, float x0, float y0) { abfMetricsCtx h = cb->direct_ctx; float x; float y; if (h->flags & ABF_MTX_TRANSFORM) { x = TX(x0, y0); y = TY(x0, y0); } else { x = x0; y = y0; } if (h->flags & SEEN_MOVE) boundPoint(h, x, y); else { /* Set bounds to first point */ h->real_mtx.left = h->real_mtx.right = x; h->real_mtx.bottom = h->real_mtx.top = y; } h->x = x0; h->y = y0; h->flags |= SEEN_MOVE; }
void rx_source_adv(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); struct source_adv_p *source = (struct source_adv_p *) (packet->data + nodedata->overhead); struct sensor_adv_p *sensor; packet_t *packet0; destination_t dst = {BROADCAST_ADDR, {-1, -1, -1}}; call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* check adv sequence */ if (source->s_seq <= nodedata->s_seq[source->source]) { /* old request */ packet_dealloc(packet); return; } nodedata->s_seq[source->source] = source->s_seq; /* reply */ packet0 = packet_create(c, nodedata->overhead + sizeof(struct sensor_adv_p), -1); sensor = (struct sensor_adv_p *) (packet0->data + nodedata->overhead); if (SET_HEADER(&c0, packet0, &dst) == -1) { packet_dealloc(packet); packet_dealloc(packet0); return; } sensor->type = SENSOR_ADV_TYPE; sensor->sensor = c->node; sensor->source = source->source; sensor->s_seq = source->s_seq; TX(&c0, packet0); packet_dealloc(packet); return; }
static void f() { pthread_t td; int r; pthread_mutexattr_t mtx_a; pthread_mutex_t mtx; struct timespec ts; T(r, pthread_barrier_init(&barrier2, 0, 2)); T(r, pthread_mutexattr_init(&mtx_a)); T(r, pthread_mutexattr_setrobust(&mtx_a, PTHREAD_MUTEX_ROBUST)); if (pshared) T(r, pthread_mutexattr_setpshared(&mtx_a, PTHREAD_PROCESS_SHARED)); T(r, pthread_mutex_init(&mtx, &mtx_a)); T(r, pthread_create(&td, 0, start_lock, &mtx)); T(r, pthread_detach(td)); pthread_barrier_wait(&barrier2); pthread_barrier_destroy(&barrier2); // enough time to ensure that the detached thread is dead clock_gettime(CLOCK_REALTIME, &ts); ts.tv_nsec += 100*1000*1000; if (ts.tv_nsec >= 1000*1000*1000) { ts.tv_sec++; ts.tv_nsec -= 1000*1000*1000; } TX(r, pthread_mutex_timedlock(&mtx, &ts), EOWNERDEAD); }
/* ************************************************** */ void tx(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; nodedata->data_tx++; TX(&c0, packet); }
// ENVOI DE PACKET HELLO int init_one_hop(call_t *c, void *args) { struct nodedata *nodedata = get_node_private_data(c); //recuperer le support de communication DOWN entityid_t *down = get_entity_links_down(c); call_t c0 = {down[0], c->node}; //destination de paquet destination_t destination = {BROADCAST_ADDR, {-1, -1, -1}}; //creation de paquet et initialisation de son data packet_t *packet = packet_alloc(c, nodedata->overhead[0] + sizeof(struct packet_hello)); struct packet_hello *hello = (struct packet_hello *) (packet->data + nodedata->overhead[0]); //initilailser les données hello->type=HELLO; hello->source=c->node; if (SET_HEADER(&c0, packet, &destination) == -1) { packet_dealloc(packet); return -1; } DEBUG; /*printf("Node %d (%lf %lf %lf) broadcast a packet hello, at %lf\n", c->node, //id de Noeud get_node_position(c->node)->x,get_node_position(c->node)->y,get_node_position(c->node)->z, //la postion x, y,z de Noeud get_time_now_second());//*/ //l'instant d'envoi. //L'envoi TX(&c0,packet); //tous c'est bien passé return 1; }
// Send Decimal number thru UART static void TXDec(uint32_t v) { if (!v) { TX('0'); return; } char nbrs[14]; char *p = &nbrs[0]; while (v != 0) { *p++ = '0' + (v % 10); v /= 10; } do { p--; TX(*p); } while (p != &nbrs[0]); }
void UnwPrintf(const char* format, ...) { char dest[256]; va_list argptr; va_start(argptr, format); vsprintf(dest, format, argptr); va_end(argptr); TX(&dest[0]); }
void IRQ3ISR() { int dismiss; dismiss = inportb(COM2_IOBASE+IIR); // dismiss irq3 switch(dismiss) //switch read result { // call TX() and break(send char to terminal) case IIR_TXRDY: TX(); break; //call RX() and break(send char from terminal) case IIR_RXRDY: RX(); break; } if(port_data.TXRDY ==1) //if TXRDY in port data equals to 1************** TX(); //call TX() (check if can use it now to trasmit out a char) }
//RECEPTION et REPONDRE AU PACKET HELLO int rx_one_hop(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); //RECEPTION DE PACKET HELLO struct packet_hello *hello = (struct packet_hello *) (packet->data + nodedata->overhead[0]); DEBUG; /*printf("NOde %d a recu un HELLO de %d (%lf %lf %lf) at %lf\n",c->node, hello->source, get_node_position(hello->source)->x,get_node_position(hello->source)->y,get_node_position(hello->source)->z, get_time_now_second());//*/ //l'ajoute de voisin if(!list_recherche(nodedata->N1,hello->source)) list_insert(&nodedata->N1,hello->source); //REPONSE DE PAKET HELLO //recuperer le support de communication MAC entityid_t *down = get_entity_links_down(c); call_t c0 = {down[0], c->node}; //destination de paquet destination_t destination = {hello->source, {get_node_position(hello->source)->x,get_node_position(hello->source)->y,get_node_position(hello->source)->z}}; //creation de paquet et initialisation de son data packet_t *rpacket = packet_alloc(c, nodedata->overhead[0] + sizeof(struct packet_hello)); struct packet_hello *rhello = (struct packet_hello *) (rpacket->data + nodedata->overhead[0]); //initilailser les données rhello->type = REP_HELLO; rhello->source = c->node; if (SET_HEADER(&c0, rpacket, &destination) == -1) { packet_dealloc(rpacket); return -1; } DEBUG; /*printf("Node %d (%lf %lf %lf) repond a %d packet hello, at %lf\n", c->node, //id de Noeud de noeud encours get_node_position(c->node)->x,get_node_position(c->node)->y,get_node_position(c->node)->z, //la postion x, y,z de Noeud hello->source, //id de noued de destination get_time_now_second()); //*/ //l'instant d'envoi. //L'envoi TX(&c0,rpacket); //liberer le packet packet_dealloc(packet); //tous c'est bien passé return 1; }
int main(void) { DDRB=0xFF;//0b00001011; DDRD=0xFB;//0b10000000; PORTB=0x02;//0b00000000; PORTD=0x00; TCCR0 = 0x7d;//0b01101101; TCCR2 = 0x04;//0b00000000; OCR0=OCR_val;///2)*-5)-1; //TCNT0=55; //TCCR1B = 0x04; //256 //TCNT1 = 65535; // TIMSK = 0x41; //using Time1 16bit timer MCUCR = 0x03; GICR = 0x40; UCSRA = 0x00; UCSRB = 0x18; UCSRC = 0x06; UBRRH = 0x00; UBRRL = 103; //9600 baud rate //DDRD=0x02; //Rx:Input, Tx:Output SREG = 0x80; while(1) { RX(); //recieve data from computer TX(temp); //return data to computer TX(' '); } return 0; }
void Uart_U16Bit_PutNum(U16 NumData) { U16 TempData; TempData = NumData/10000; TX(TempData+48); // 10000 자리 무조건 출력 TempData = (NumData%10000)/1000; TX(TempData+48); // 1000 자리 무조건 출력 TempData = (NumData%1000)/100; TX(TempData+48); // 100 자리 무조건 출력 TempData = (NumData%100)/10; TX(TempData+48); // 10 자리 무조건 출력 TempData = NumData%10; TX(TempData+48); // 1 자리 무조건 출력 }
void __attribute__((noreturn)) usb_recv_task(struct vcom * vcom) { struct serial_dev * serial = vcom->serial; usb_cdc_class_t * cdc = vcom->cdc; uint8_t buf[VCOM_BUF_SIZE]; int len; DCC_LOG1(LOG_TRACE, "[%d] started.", thinkos_thread_self()); DCC_LOG2(LOG_TRACE, "vcom->%p, cdc->%p", vcom, cdc); for (;;) { len = usb_cdc_read(cdc, buf, VCOM_BUF_SIZE, 1000); if (vcom->mode == VCOM_MODE_CONVERTER) { if (len > 0) { led_flash(LED_RED, 50); serial_write(serial, buf, len); #if RAW_TRACE if (len == 1) DCC_LOG1(LOG_TRACE, "TX: %02x", buf[0]); else if (len == 2) DCC_LOG2(LOG_TRACE, "TX: %02x %02x", buf[0], buf[1]); else if (len == 3) DCC_LOG3(LOG_TRACE, "TX: %02x %02x %02x", buf[0], buf[1], buf[2]); else if (len == 4) DCC_LOG4(LOG_TRACE, "TX: %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3]); else if (len == 5) DCC_LOG5(LOG_TRACE, "TX: %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4]); else if (len == 6) DCC_LOG6(LOG_TRACE, "TX: %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); else if (len == 7) DCC_LOG7(LOG_TRACE, "TX: %02x %02x %02x %02x %02x %02x %02x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); else DCC_LOG8(LOG_TRACE, "TX: %02x %02x %02x %02x %02x %02x " "%02x %02x ...", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); #endif #if SDU_TRACE TX(buf, len); #endif // dbg_write(buf, len); } } else { // forward to service input vcom_service_input(vcom, buf, len); } } }
int main() { TRISA = 0; TRISB = BIT(0)|BIT(1)|BIT(3)|BIT(7)|BIT(12); TRISC = 0; OUTER_LED = OFF; INNER_LED = OFF; init_pll(); peripheral_pin_config(); init_uart1(); init_spi(); init_adc(); init_timer1(); TX_string("Wait\r\n"); delay(1000); TX_string("Start\r\n"); T1CONbits.TON = 1; //remove first trash reading tiltX = accelRead(XINCL); gRead = gyroRead(GRATE); while(1) { if( newData == TRUE) { TX_snum5(gRead); TX('\t'); TX_snum5(tilt); TX('\t'); TX_snum5(x_00); TX_string("\r\n"); OUTER_LED = OFF; newData = FALSE; } } return 0; };
void tx( call_t *c , packet_t * packet ) { struct nodedata *nodedata = get_node_private_data(c); struct protocoleData *entitydata = get_entity_private_data(c); if(entitydata->debug) DBG("LBOP BROADCAST - ON %d WITH RANGE %.2lf At %lf \n",c->node,get_range_Tr(c), get_time_now_second()); entityid_t *down = get_entity_links_down(c); call_t c0 = {down[0], c->node}; TX(&c0,packet); }
void tx( call_t *c , packet_t * packet ) { struct nodedata *nodedata = get_node_private_data(c); packet_PROTOCOLE *data = (packet_PROTOCOLE *) (packet->data + nodedata->overhead); //printf("DLBIP - Paquet de type %d envoye depuis %d par %d a %d (at %lf s).\n", data->type, data->src, c->node, data->dst, get_time_now_second()); //retransmettre call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; TX(&c0,packet); }
// Dump a backtrace entry static bool UnwReportOut(void* ctx, const UnwReport* bte) { int* p = (int*)ctx; (*p)++; TX('#'); TXDec(*p); TX(" : "); TX(bte->name?bte->name:"unknown"); TX('@'); TXHex(bte->function); TX('+'); TXDec(bte->address - bte->function); TX(" PC:");TXHex(bte->address); TX('\n'); return true; }
/* Add line to path. */ static void glyphLine(abfGlyphCallbacks *cb, float x1, float y1) { abfMetricsCtx h = cb->direct_ctx; if (h->flags & ABF_MTX_TRANSFORM) boundPoint(h, TX(x1, y1), TY(x1, y1)); else boundPoint(h, x1, y1); h->x = x1; h->y = y1; }
void PXIN() { char databuf[4]; char *test; databuf[0] = P1IN; databuf[1] = P2IN; databuf[2] = 'A'; databuf[3] = 0; test = databuf; TX(test); } // End Function
/* ************************************************** */ void forward(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; struct routing_header *header = (struct routing_header *) (packet->data + nodedata->overhead); struct neighbor *n_hop = get_nexthop(c, &(header->dst_pos)); destination_t destination; /* delivers packet to application layer */ if (n_hop == NULL) { array_t *up = get_entity_bindings_up(c); int i = up->size; while (i--) { call_t c_up = {up->elts[i], c->node, c->entity}; packet_t *packet_up; if (i > 0) { packet_up = packet_clone(packet); } else { packet_up = packet; } RX(&c_up, packet_up); } return; } /* update hop count */ header->hop--; if (header->hop == 0) { nodedata->data_hop++; packet_dealloc(packet); return; } /* set mac header */ destination.id = n_hop->id; destination.position.x = -1; destination.position.y = -1; destination.position.z = -1; if (SET_HEADER(&c0, packet, &destination) == -1) { packet_dealloc(packet); return; } /* forwarding packet */ nodedata->data_tx++; TX(&c0, packet); }
bool SystemFile::postDeviceSection( ANetNode * NN ) { if( hasPostDeviceSection ) { QFile Fl( TemplDir + Name + "/postdevicesection" ); if( ! Fl.open( IO_ReadOnly ) ) return 0; // error QTextStream TX( &Fl ); QString Out; QString S = TX.readLine(); while( ! TX.eof() ) { Out = S.arg(NN->name()); (*this) << Out << endl; S = TX.readLine(); } } return 1; }
bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { if( hasPreNodeSection ) { QFile Fl( TemplDir + Name + "/prenodesection" ); if( ! Fl.open( IO_ReadOnly ) ) return 0; // error QTextStream TX( &Fl ); QString Out; QString S = TX.readLine(); while( ! TX.eof() ) { Out = S. arg(NNI->nodeClass()->name()); (*this) << Out << endl; S = TX.readLine(); } } return 1; }
/* Periodic exchange of hello packets */ int hello_callback(call_t *c, void *args) { struct entitydata *entitydata = get_entity_private_data(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}; destination_t destination = {BROADCAST_ADDR, {-1, -1, -1}}; packet_t *packet = packet_create(c, nodedata->overhead + sizeof(struct xy_hello_p), -1); struct xy_hello_p *hello = (struct xy_hello_p *) (packet->data + nodedata->overhead); position_t *pos = get_node_position(c->node); /* set mac header */ if (SET_HEADER(&c0, packet, &destination) == -1) { packet_dealloc(packet); return -1; } /* set header */ hello->type = XY_HELLO_TYPE; hello->src = c->node; hello->position.x = pos->x; hello->position.y = pos->y; hello->position.z = pos->z; TX(&c0, packet); entitydata->TX_hello++; /* check neighbors timeout */ if (nodedata->h_timeout > 0) { das_selective_delete(nodedata->neighbors, neighbor_timeout, (void *) c); } /* schedules hello */ if (nodedata->h_nbr > 0) { nodedata->h_nbr --; } if (nodedata->h_nbr == -1 || nodedata->h_nbr > 0) { scheduler_add_callback(get_time() + nodedata->h_period, c, hello_callback, NULL); } return 0; }
__interrupt void USCI0RX_ISR(void) { if((IFG2 & UCA0RXIFG)) { buffer = UCA0RXBUF; switch (comm_p) { case 0: command = buffer; comm_p++; if (buffer == '1') { TX("PING"); comm_p = 0; command = 0; } break; case 1: data1 = buffer; comm_p++; break; case 2: data2 = buffer; Command_Ready = true; comm_p++; break; default: Command_Ready = false; } // End Switch } if((IFG2 & UCB0RXIFG)) { // while (!(IFG2 & UCB0TXIFG)); // USCI_A0 TX buffer ready? recieved_data[j] = UCB0RXBUF; } }
void rx_source_data(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); struct source_data_p *data = (struct source_data_p *) (packet->data + nodedata->overhead); struct gossip_data_p *gossip; packet_t *packet0; destination_t dst = {BROADCAST_ADDR, {-1, -1, -1}}; call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* check sensor */ if (data->sensor != c->node) { /* not for us */ packet_dealloc(packet); return; } /* check data sequence */ if (data->d_seq <= nodedata->d_seq[data->metadata]) { /* old data */ packet_dealloc(packet); return; } nodedata->d_seq[data->metadata] = data->d_seq; nodedata->d_source[data->metadata] = data->source; nodedata->d_value[data->metadata] = data->d_value; /* start gossip */ packet0 = packet_create(c, nodedata->overhead + sizeof(struct gossip_data_p), -1); gossip = (struct gossip_data_p *) (packet0->data + nodedata->overhead); if (SET_HEADER(&c0, packet0, &dst) == -1) { packet_dealloc(packet); packet_dealloc(packet0); return; } gossip->type = GOSSIP_DATA_TYPE; gossip->source = data->source; gossip->metadata = data->metadata; gossip->d_seq = data->d_seq; gossip->d_value = data->d_value; TX(&c0, packet0); packet_dealloc(packet); return; }
void rx_sink_adv(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); struct sink_adv_p *sink = (struct sink_adv_p *) (packet->data + nodedata->overhead); struct sensor_data_p *data; packet_t *packet0; destination_t dst = {BROADCAST_ADDR, {-1, -1, -1}}; call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* check request sequence */ if (sink->r_seq <= nodedata->r_seq[sink->sink]) { /* old request */ packet_dealloc(packet); return; } nodedata->r_seq[sink->sink] = sink->r_seq; /* check wether we have the data */ if (sink->d_seq > nodedata->d_seq[sink->metadata]) { /* our data is not up to date */ packet_dealloc(packet); return; } /* reply */ packet0 = packet_create(c, nodedata->overhead + sizeof(struct sensor_data_p), -1); data = (struct sensor_data_p *) (packet0->data + nodedata->overhead); if (SET_HEADER(&c0, packet0, &dst) == -1) { packet_dealloc(packet); packet_dealloc(packet0); return; } data->type = SENSOR_DATA_TYPE; data->metadata = sink->metadata; data->sink = sink->sink; data->r_seq = sink->r_seq; data->source = nodedata->d_source[sink->metadata]; data->d_seq = nodedata->d_seq[sink->metadata]; data->d_value = nodedata->d_value[sink->metadata]; TX(&c0, packet0); packet_dealloc(packet); return; }
/* ************************************************** */ void forward(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; struct routing_header *header = (struct routing_header *) (packet->data + nodedata->overhead); struct route *route = hadas_get(nodedata->routes, (void *) ((unsigned long) (header->dst))); destination_t destination; if (route == NULL) { packet_dealloc(packet); return; } destination.id = route->n_hop; if (SET_HEADER(&c0, packet, (void *) &destination) == -1) { packet_dealloc(packet); return; } TX(&c0, packet); }
/* ************************************************** */ void forward(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; struct routing_header *header = (struct routing_header *) (packet->data + nodedata->overhead); struct neighbor *n_hop = get_nexthop(c, header->dst); destination_t destination; /* No route available */ if (n_hop == NULL) { packet_dealloc(packet); return; } /* Update hop count */ header->hop--; /* Hop count reached */ if (header->hop == 0) { packet_dealloc(packet); return; } /* Set MAC header */ destination.id = n_hop->id; destination.position.x = -1; destination.position.y = -1; destination.position.z = -1; if (SET_HEADER(&c0, packet, &destination) == -1) { packet_dealloc(packet); return; } /* Forwarding packet */ PRINT_ROUTING("forward: Node %d forwards a packet " "(from %d to %d, hop limit %d)\n", c->node, header->src, header->dst, header->hop); TX(&c0, packet); }
void rx_gossip_data(call_t *c, packet_t *packet) { struct nodedata *nodedata = get_node_private_data(c); struct gossip_data_p *data = (struct gossip_data_p *) (packet->data + nodedata->overhead); destination_t dst = {BROADCAST_ADDR, {-1, -1, -1}}; call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; /* check data sequence */ if (data->d_seq <= nodedata->d_seq[data->metadata]) { /* old data */ packet_dealloc(packet); return; } nodedata->d_seq[data->metadata] = data->d_seq; nodedata->d_source[data->metadata] = data->source; nodedata->d_value[data->metadata] = data->d_value; /* forward gossip */ if (SET_HEADER(&c0, packet, &dst) == -1) { packet_dealloc(packet); return; } TX(&c0, packet); }
int advert_callback(call_t *c, void *args) { struct nodedata *nodedata = get_node_private_data(c); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; destination_t destination = {BROADCAST_ADDR, {-1, -1, -1}}; packet_t *packet = packet_create(c, nodedata->overhead + sizeof(struct routing_header), -1); struct routing_header *header = (struct routing_header*) (packet->data + nodedata->overhead); /* set mac header */ if (SET_HEADER(&c0, packet, &destination) == -1) { packet_dealloc(packet); return -1; } /* set routing header */ header->dst = BROADCAST_ADDR; header->dst_pos.x = -1; header->dst_pos.y = -1; header->dst_pos.z = -1; header->src = c->node; header->src_pos.x = get_node_position(c->node)->x; header->src_pos.y = get_node_position(c->node)->y; header->src_pos.z = get_node_position(c->node)->z; header->type = HELLO_PACKET; header->hop = 1; /* send hello */ TX(&c0, packet); nodedata->hello_tx++; /* check neighbors timeout */ das_selective_delete(nodedata->neighbors, neighbor_timeout, (void *) c); /* schedules hello */ scheduler_add_callback(get_time() + nodedata->period, c, advert_callback, NULL); return 0; }