#ifndef NICO_NAT64_SESSION
#define NICO_NAT64_SESSION

/********************** NAT64 sessions   ***********************************/

    /* automatic translations */
    action nat64_tcp_session_translate(
        ipv4_addr_t src_addr,
        bit<16> src_port,
        ipv4_addr_t dst_addr,
        bit<16> dst_port)
    {
		hdr.ipv4.setValid();

        hdr.tcp.src_port = src_port;
        hdr.tcp.dst_port = dst_port;

        nat64_generic(src_addr, dst_addr);
    }

    action nat46_tcp_session_translate(
        ipv6_addr_t src_addr,
        bit<16> src_port,
        ipv6_addr_t dst_addr,
        bit<16> dst_port)
    {
		hdr.ipv6.setValid();

        hdr.tcp.src_port = src_port;
        hdr.tcp.dst_port = dst_port;

        nat46_generic(src_addr, dst_addr);
    }

    /* We are in the right range, need to create a session entry */
    action nat64_tcp_session_create()
    {
        controller_reply(TASK_NAT64_TCP_SESSION);
    }


    /* Used for detecting traffic that should have a session */
    table nat64_session {
        key = {
            hdr.ipv6.dst_addr: lpm;
        }
        actions = {
            controller_debug_table_id;
            NoAction;
        }
        size = NAT64_TABLE_SIZE;
        default_action = controller_debug_table_id(TABLE_NAT64_SESSION);
    }


    table nat64_tcp_session {
        key = {
            hdr.ipv6.src_addr: exact;
            hdr.ipv6.dst_addr: exact;
            hdr.tcp.src_port:  exact;
            hdr.tcp.dst_port:  exact;
        }
        actions = {
            controller_debug_table_id;
            nat64_tcp_session_create;
            nat64_tcp_session_translate;
            NoAction;
        }
        size = NAT64_TABLE_SIZE;
        default_action = nat64_tcp_session_create;
    }

    table nat46_tcp_session {
        key = {
            hdr.ipv6.src_addr: exact;
            hdr.ipv6.dst_addr: exact;
            hdr.tcp.src_port:  exact;
            hdr.tcp.dst_port:  exact;
        }
        actions = {
            controller_debug_table_id;
            nat46_tcp_session_translate;
            NoAction;
        }
        size = NAT64_TABLE_SIZE;
        //default_action = controller_debug_table_id(TABLE_NAT64_TCP);
        default_action = NoAction;
    }


#endif