Beispiel #1
0
int
tun_rtr_process_input_packet(struct sock *sl)
{
    packet_tuple_t tpl;
    lbuf_use_stack(&pkt_buf, &pkt_recv_buf, MAX_IP_PKT_LEN);
    /* Reserve space in case the received packet was IPv6. In this case the IPv6 header is
     * not provided */
    lbuf_reserve(&pkt_buf,LBUF_STACK_OFFSET);

    if (tun_read_and_decap_pkt(sl->fd, &pkt_buf, &(tpl.iid)) != GOOD) {
        return (BAD);
    }

    OOR_LOG(LDBG_3, "Forwarding packet to OUPUT for re-encapsulation");

    lbuf_point_to_l3(&pkt_buf);
    lbuf_reset_ip(&pkt_buf);

    if (pkt_parse_5_tuple(&pkt_buf, &tpl) != GOOD) {
        return (BAD);
    }
    tun_output(&pkt_buf, &tpl);

    return(GOOD);
}
Beispiel #2
0
int
vpnapi_output(lbuf_t *b)
{
    packet_tuple_t tpl;

    if (pkt_parse_5_tuple(b, &tpl) != GOOD) {
        return (BAD);
    }


    LMLOG(LDBG_3,"OUTPUT: Received EID %s -> %s, Proto: %d, Port: %d -> %d ",
            lisp_addr_to_char(&tpl.src_addr), lisp_addr_to_char(&tpl.dst_addr),
            tpl.protocol, tpl.src_port, tpl.dst_port);

    /* If already LISP packet, do not encapsulate again */
    if (is_lisp_packet(&tpl)) {
        LMLOG(LDBG_3,"OUTPUT: Is a lisp packet, do not encapsulate again");
        return (vpnapi_forward_native(b, &tpl.dst_addr));
    }

    vpnapi_output_unicast(b, &tpl);

    return(GOOD);
}