/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 2018 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.
 */

/** \file

    This file defines vpp IP control-plane API messages which are generally
    called through a shared memory interface.
*/

option version = "1.1.0";

import "vnet/ip/ip_types.api";
import "vnet/interface_types.api";

/** \brief IPv6 router advertisement config request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param suppress -
    @param managed -
    @param other -
    @param ll_option -
    @param send_unicast -
    @param cease -
    @param is_no -
    @param default_router -
    @param max_interval -
    @param min_interval -
    @param lifetime -
    @param initial_count -
    @param initial_interval -
*/
autoreply define sw_interface_ip6nd_ra_config
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  u8 suppress;
  u8 managed;
  u8 other;
  u8 ll_option;
  u8 send_unicast;
  u8 cease;
  bool is_no;
  u8 default_router;
  u32 max_interval;
  u32 min_interval;
  u32 lifetime;
  u32 initial_count;
  u32 initial_interval;
};

/** \brief IPv6 router advertisement prefix config request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - The interface the RA prefix information is for
    @param prefix - The prefix to advertise
    @param use_default - Revert to default settings
    @param no_advertise - Do not advertise this prefix
    @param off_link - The prefix is off link (it is not configured on the interface)
                      Configures the L-flag, When set, indicates that this
		      prefix can be used for on-link determination.
    @param no_autoconfig - Setting for the A-flag. When
                           set indicates that this prefix can be used for
                          stateless address configuration.
    @param no_onlink - The prefix is not on link. Make sure this is consistent
                       with the off_link parameter else YMMV
    @param is_no - add/delete
    @param val_lifetime - The length of time in
                     seconds (relative to the time the packet is sent)
                     that the prefix is valid for the purpose of on-link
                     determination.  A value of all one bits
                     (0xffffffff) represents infinity
    @param pref_lifetime - The length of time in
                     seconds (relative to the time the packet is sent)
                     that addresses generated from the prefix via
                     stateless address autoconfiguration remain
                     preferred [ADDRCONF].  A value of all one bits
                     (0xffffffff) represents infinity.
*/
autoreply define sw_interface_ip6nd_ra_prefix
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  vl_api_prefix_t prefix;
  bool use_default;
  bool no_advertise;
  bool off_link;
  bool no_autoconfig;
  bool no_onlink;
  bool is_no;
  u32 val_lifetime;
  u32 pref_lifetime;
};

/** \brief IPv6 Router Advertisements prefix entry
    @param prefix - prefix to advertise
    @param onlink_flag - if true, the prefix can be used for on-link
                         determination
    @param autonomous_flag - if true, the prefix can be used for stateless
                             address configuration
    @param val_lifetime - valid lifetime in seconds (0xffffffff represents
                          infinity)
    @param pref_lifetime - preferred lifetime in seconds (0xffffffff represents
                           infinity)
    @param valid_lifetime_expires - number of seconds in which valid lifetime
                                    expires (zero means never, negative value
                                    means expired this number of seconds ago)
    @param pref_lifetime_expires - number of seconds in which preferred
                                   lifetime expires (zero means never, negative
                                   value means expired this number of seconds
                                   ago)
    @param decrement_lifetime_flag - if true, decrement valid lifetime and
                                     preferred lifetime
    @param no_advertise - if true, the prefix will not be advertised
*/
typedef ip6nd_ra_prefix
{
  vl_api_prefix_t prefix;
  bool onlink_flag;
  bool autonomous_flag;
  u32 val_lifetime;
  u32 pref_lifetime;
  f64 valid_lifetime_expires;
  f64 pref_lifetime_expires;
  bool decrement_lifetime_flag;
  bool no_advertise;
};

/** \brief Dump IPv6 Router Advertisements details on a per-interface basis
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface index to use as a filter (0xffffffff
                         represents all interfaces)
*/
define sw_interface_ip6nd_ra_dump
{
  option in_progress;
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  option vat_help = "[(<if-name>|sw_if_index <if-idx>)]";
};

/** \brief Details on IPv6 Router Advertisements for a single interface
    @param context - returned sender context, to match reply w/ request
    @param sw_if_index - interface index the details are belong to
    @param cur_hop_limit - current hop limit
    @param adv_managed_flag - if true, enable DHCP for address
    @param adv_other_flag - if true, Enable DHCP for other information
    @param adv_router_lifetime - lifetime associated with the default router in
                                 seconds (zero indicates that the router is not
				 a default router)
    @param adv_neighbor_reachable_time - number of milliseconds within which a
                                         neighbor is assumed to be reachable
                                         (zero means unspecified)
    @param adv_retransmit_interval - number of milliseconds between
                                     retransmitted Neighbor Solicitation
                                     messages (zero means unspecified)
    @param adv_link_mtu - MTU that all the nodes on a link use
    @param send_radv - if true, send periodic Router Advertisements
    @param cease_radv - if true, cease to send periodic Router Advertisements
    @param send_unicast - if true, destination address of a Router
                          Advertisement message will use the source address of
                          the Router Solicitation message (when available).
                          Otherwise, multicast address will be used
    @param adv_link_layer_address - if true, add link layer address option
    @param max_radv_interval - maximum time in seconds allowed between sending
                               unsolicited multicast Router Advertisements
    @param min_radv_interval - minimum time in seconds allowed between sending
                               unsolicited multicast Router Advertisements
    @param last_radv_time - number of seconds since the last time a solicited
                            Router Advertisement message was sent (zero means
                            never)
    @param last_multicast_time - number of seconds since the last time a
                                 multicast Router Advertisements message was
                                 sent (zero means never)
    @param next_multicast_time - number of seconds within which next time a
                                 multicast Router Advertisement message will be
                                 sent (zero means never)
    @param initial_adverts_count - number of initial Router Advertisement
                                   messages to send
    @param initial_adverts_interval - number of seconds between initial Router
                                      Advertisement messages
    @param initial_adverts_sent - if true, all initial Router Advertisement
                                  messages were sent
    @param n_advertisements_sent - number of Router Advertisements sent
    @param n_solicitations_rcvd - number of Router Solicitations received
    @param n_solicitations_dropped - number of Router Solicitations dropped
    @param n_prefixes - number of prefix entries
    @param prefixes - array of prefix entries
*/
define sw_interface_ip6nd_ra_details
{
  option in_progress;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  u8 cur_hop_limit;
  bool adv_managed_flag;
  bool adv_other_flag;
  u16 adv_router_lifetime;
  u32 adv_neighbor_reachable_time;
  u32 adv_retransmit_interval;
  u32 adv_link_mtu;
  bool send_radv;
  bool cease_radv;
  bool send_unicast;
  bool adv_link_layer_address;
  f64 max_radv_interval;
  f64 min_radv_interval;
  f64 last_radv_time;
  f64 last_multicast_time;
  f64 next_multicast_time;
  u32 initial_adverts_count;
  f64 initial_adverts_interval;
  bool initial_adverts_sent;
  u32 n_advertisements_sent;
  u32 n_solicitations_rcvd;
  u32 n_solicitations_dropped;
  u32 n_prefixes;
  vl_api_ip6nd_ra_prefix_t prefixes[n_prefixes];
};

/** \brief IPv6 ND (mirror) proxy
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - The interface the host is on
    @param is_enable - enable or disable
*/
autoreply define ip6nd_proxy_enable_disable
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool is_enable;
};

/** \brief IPv6 ND proxy config
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - The interface the host is on
    @param ip - The address of the host for which to proxy for
    @param is_add - Adding or deleting
*/
autoreply define ip6nd_proxy_add_del
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool is_add;
  vl_api_ip6_address_t ip;
};

/** \brief IPv6 ND proxy details returned after request
    @param context - sender context, to match reply w/ request
    @param sw_if_index - The interface the host is on
    @param ip - The address of the host for which to proxy for
*/
define ip6nd_proxy_details
{
  u32 context;
  vl_api_interface_index_t sw_if_index;
  vl_api_ip6_address_t ip;
};

/** \brief IPv6 ND proxy dump request
    @param context - sender context, to match reply w/ request
*/
define ip6nd_proxy_dump
{
  u32 client_index;
  u32 context;
};

/** \brief Start / stop sending router solicitation
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param irt - initial retransmission time
    @param mrt - maximum retransmission time
    @param mrc - maximum retransmission count
    @param mrd - maximum retransmission duration
    @param sw_if_index - software interface index of interface
                         for sending router solicitation
    @param stop - if non-zero then stop sending router solicitation,
                  otherwise start sending router solicitation
*/
autoreply define ip6nd_send_router_solicitation
{
  u32 client_index;
  u32 context;
  u32 irt;
  u32 mrt;
  u32 mrc;
  u32 mrd;
  vl_api_interface_index_t sw_if_index;
  bool stop;
};

service {
  rpc want_ip6_ra_events returns want_ip6_ra_events_reply
    events ip6_ra_event;
};

/** \brief Register for ip6 router advertisement events
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param enable - 1 => register for events, 0 => cancel registration
    @param pid - sender's pid
*/
autoreply define want_ip6_ra_events
{
  u32 client_index;
  u32 context;
  bool enable;
  u32 pid;
};

/** \brief Struct representing RA prefix info
    @param prefix - RA prefix info destination address
    @param flags - RA prefix info flags
    @param valid_time - RA prefix info valid time
    @param preferred_time - RA prefix info preferred time
*/
typedef ip6_ra_prefix_info
{
  vl_api_prefix_t prefix;
  u8 flags;
  u32 valid_time;
  u32 preferred_time;
};

/** \brief Tell client about a router advertisement event
    @param client_index - opaque cookie to identify the sender
    @param pid - client pid registered to receive notification
    @param current_hop_limit - RA current hop limit
    @param flags - RA flags
    @param router_lifetime_in_sec - RA lifetime in seconds
    @param router_addr - The router's address
    @param neighbor_reachable_time_in_msec - RA neighbor reachable time in msec
    @param time_in_msec_between_retransmitted_neighbor_solicitations -
               time in msec between retransmitted neighbor solicitations
    @param n_prefixes -
    @param prefixes -
*/
define ip6_ra_event
{
  u32 client_index;
  u32 pid;
  vl_api_interface_index_t sw_if_index;
  vl_api_ip6_address_t router_addr;
  u8 current_hop_limit;
  u8 flags;
  u16 router_lifetime_in_sec;
  u32 neighbor_reachable_time_in_msec;
  u32 time_in_msec_between_retransmitted_neighbor_solicitations;
  u32 n_prefixes;
  vl_api_ip6_ra_prefix_info_t prefixes[n_prefixes];
};


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