/*
 * Copyright (c) 2015-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

option version = "1.1.0";

import "vnet/ip/ip_types.api";

/** \brief Add / del ipsec gre tunnel request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param local_sa_id - local/output SA id
    @param remote_sa_id - remote/input SA id
    @param is_add - 1 if adding the tunnel, 0 if deleting
    @param sw_if_index - software index of the ipsec gre tunnel
                         ignored on create. set in dump/details
    @param src - tunnel source address
    @param dst - tunnel destination address
*/
typedef ipsec_gre_tunnel {
    u32 client_index;
    u32 context;
    u32 local_sa_id;
    u32 remote_sa_id;
    u8 is_add;
    u32 sw_if_index;
    vl_api_ip4_address_t src;
    vl_api_ip4_address_t dst;
};

define ipsec_gre_tunnel_add_del {
    u32 client_index;
    u32 context;
    u8 is_add;
    vl_api_ipsec_gre_tunnel_t tunnel;
};

/** \brief Reply for add / del ipsec gre tunnel request
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param sw_if_index - software index of the new ipsec gre tunnel
*/
define ipsec_gre_tunnel_add_del_reply {
    u32 context;
    i32 retval;
    u32 sw_if_index;
};

/** \brief Dump ipsec gre tunnel table
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param tunnel_index - gre tunnel identifier or -1 in case of all tunnels
*/
define ipsec_gre_tunnel_dump {
    u32 client_index;
    u32 context;
    u32 sw_if_index;
};

/** \brief ipsec gre tunnel operational state response
    @param context - returned sender context, to match reply w/ request
    @param local_sa_id - local SA id
    @param remote_sa_id - remote SA id
    @param src_address - tunnel source address
    @param dst_address - tunnel destination address
*/
define ipsec_gre_tunnel_details {
    u32 context;
    vl_api_ipsec_gre_tunnel_t tunnel;
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
 
