void serial_reader_f(void) { int main_pid = 0; int bytes; msg_t m; border_packet_t *uart_buf; posix_open(uart0_handler_pid, 0); msg_receive(&m); main_pid = m.sender_pid; while(1) { posix_open(uart0_handler_pid, 0); bytes = readpacket(get_serial_in_buffer(0), BORDER_BUFFER_SIZE); if(bytes < 0) { switch(bytes) { case(-SIXLOWERROR_ARRAYFULL): { printf("ERROR: Array was full\n"); break; } default: { printf("ERROR: unknown\n"); break; } } continue; } uart_buf = (border_packet_t *)get_serial_in_buffer(0); if(uart_buf->empty == 0) { if(uart_buf->type == BORDER_PACKET_CONF_TYPE) { border_conf_header_t *conf_packet = (border_conf_header_t *)uart_buf; if(conf_packet->conftype == BORDER_CONF_SYN) { m.content.ptr = (char *)conf_packet; msg_send(&m, main_pid, 1); continue; } } flowcontrol_deliver_from_uart(uart_buf, bytes); } } }
void multiplex_send_addr_over_uart(ipv6_addr_t *addr) { border_addr_packet_t *serial_buf; serial_buf = (border_addr_packet_t *)get_serial_in_buffer(0); serial_buf->empty = 0; serial_buf->type = BORDER_PACKET_CONF_TYPE; serial_buf->conftype = BORDER_CONF_IPADDR; memcpy(&serial_buf->addr, addr, sizeof(ipv6_addr_t)); flowcontrol_send_over_uart((border_packet_t *) serial_buf, sizeof(border_addr_packet_t)); }
void multiplex_send_ipv6_over_uart(ipv6_hdr_t *packet) { border_l3_header_t *serial_buf; serial_buf = (border_l3_header_t *)get_serial_out_buffer(0); serial_buf->empty = 0; serial_buf->type = BORDER_PACKET_L3_TYPE; serial_buf->ethertype = BORDER_ETHERTYPE_IPV6; memcpy(get_serial_in_buffer(0) + sizeof(border_l3_header_t), packet, IPV6_HDR_LEN + packet->length); flowcontrol_send_over_uart((border_packet_t *) serial_buf, sizeof(border_l3_header_t)); }