Пример #1
0
void *tun_reader_f(void *args)
{
    unsigned char data[BUFFER_SIZE];
    size_t bytes;

    while (1) {
        bytes = read(tun_fd, (void *)data, BUFFER_SIZE);

        if (bytes > 0) {
            bytes = tun_to_serial_packet(tun_in_buf, (uint8_t *)data, bytes);
            flowcontrol_send_over_tty((border_packet_t *)tun_in_buf, bytes);
        }
    }
}
Пример #2
0
void multiplex_send_addr_over_tty(struct in6_addr *addr)
{
    border_addr_packet_t *packet = (border_addr_packet_t *)get_serial_out_buffer(0);

    packet->empty = 0;
    packet->type = BORDER_PACKET_CONF_TYPE;
    packet->conftype = BORDER_CONF_IPADDR;
    memcpy(
        &packet->addr,
        addr,
        sizeof(struct in6_addr)
    );

    flowcontrol_send_over_tty(
        (border_packet_t *) packet,
        sizeof(border_addr_packet_t)
    );
}
Пример #3
0
void multiplex_send_context_over_tty(const border_context_t *context)
{
    border_context_packet_t *con_packet = (border_context_packet_t *)get_serial_out_buffer(0);

    con_packet->empty = 0;
    con_packet->type = BORDER_PACKET_CONF_TYPE;
    con_packet->conftype = BORDER_CONF_CONTEXT;
    memcpy(
        &con_packet->context,
        context,
        sizeof(border_context_t)
    );

    flowcontrol_send_over_tty(
        (border_packet_t *) con_packet,
        sizeof(border_context_packet_t)
    );
}
Пример #4
0
void multiplex_send_ipv6_over_tty(const struct ip6_hdr *packet)
{
    border_l3_header_t *l3_hdr = (border_l3_header_t *)get_serial_out_buffer(0);
    size_t packet_size = sizeof(struct ip6_hdr) + packet->ip6_plen;

    l3_hdr->empty = 0;
    l3_hdr->type = BORDER_PACKET_L3_TYPE;
    l3_hdr->ethertype = ETHERTYPE_IPV6;
    memcpy(
        get_serial_out_buffer(0) + sizeof(border_l3_header_t),
        packet,
        packet_size
    );

    flowcontrol_send_over_tty(
        (border_packet_t *) l3_hdr,
        sizeof(border_l3_header_t) + packet_size
    );
}