/* Hey Emacs use -*- mode: C -*- */
/*
 * Copyright (c) 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 = "3.0.0";

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

/** \brief Reply to l2_xconnect_dump
    @param context - sender context which was passed in the request
    @param rx_sw_if_index - Receive interface index
    @param tx_sw_if_index - Transmit interface index
 */
define l2_xconnect_details
{
  u32 context;
  vl_api_interface_index_t rx_sw_if_index;
  vl_api_interface_index_t tx_sw_if_index;
};

/** \brief Dump L2 XConnects
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define l2_xconnect_dump
{
  u32 client_index;
  u32 context;
};

/** \brief l2 fib table details structure
    @param bd_id - the l2 fib / bridge domain table id
    @param mac - the entry's mac address
    @param sw_if_index - index of the interface
    @param static_mac - the entry is statically configured.
    @param filter_mac - the entry is a mac filter entry.
    @param bvi_mac - the mac address is a bridge virtual interface
*/
define l2_fib_table_details
{
  u32 context;
  u32 bd_id;
  vl_api_mac_address_t mac;
  vl_api_interface_index_t sw_if_index;
  bool static_mac;
  bool filter_mac;
  bool bvi_mac;
};

/** \brief Dump l2 fib (aka bridge domain) table
    @param client_index - opaque cookie to identify the sender
    @param bd_id - the l2 fib / bridge domain table identifier
*/
define l2_fib_table_dump
{
  u32 client_index;
  u32 context;
  u32 bd_id;
};

/** \brief L2 fib clear table request, clear all mac entries in the l2 fib
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
autoreply define l2_fib_clear_table
{
  u32 client_index;
  u32 context;
};

/** \brief L2 FIB flush all  entries
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
autoreply define l2fib_flush_all
{
  u32 client_index;
  u32 context;
};

/** \brief L2 FIB flush bridge domain entries
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bd_id - the entry's bridge domain id
*/
autoreply define l2fib_flush_bd
{
  u32 client_index;
  u32 context;
  u32 bd_id;
};

/** \brief L2 FIB flush interface entries
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bd_id - the entry's bridge domain id
*/
autoreply define l2fib_flush_int
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
};

/** \brief L2 FIB add entry request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mac - the entry's mac address
    @param bd_id - the entry's bridge domain id
    @param sw_if_index - the interface
    @param is_add - If non zero add the entry, else delete it
    @param static_mac -
    @param filter_mac -
    @param bvi_mac -
*/
autoreply define l2fib_add_del
{
  u32 client_index;
  u32 context;
  vl_api_mac_address_t mac;
  u32 bd_id;
  vl_api_interface_index_t sw_if_index;
  bool is_add [default=true];
  bool static_mac;
  bool filter_mac;
  bool bvi_mac;
};

/** \brief Register to receive L2 MAC events for learned and aged MAC
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param learn_limit - MAC learn limit
    @param scan_delay - event scan delay in 10 msec unit
    @param max_macs_in_event - in units of 10 mac entries
    @param enable_disable - 1 => register for MAC events, 0 => cancel registration
    @param pid - sender's pid
*/
autoreply define want_l2_macs_events
{
  u32 client_index;
  u32 context;
  u32 learn_limit [default=1000];
  u8  scan_delay [default=10];
  u8  max_macs_in_event [default=10];
  bool enable_disable [default=true];
  u32 pid;
};

enum mac_event_action
{
	MAC_EVENT_ACTION_API_ADD = 0,
	MAC_EVENT_ACTION_API_DELETE = 1,
	MAC_EVENT_ACTION_API_MOVE = 2,
};

/** \brief Entry for learned or aged MAC in L2 MAC Events
    @param sw_if_index - sw_if_index in the domain
    @param mac_addr - mac_address
    @param action - 0 => newly learned MAC, 1 => MAC deleted by ager
                    2 => MAC move (sw_if_index changed)
    @param flags - flag bits to provide other info, not yet used
*/
typedef mac_entry
{
  vl_api_interface_index_t sw_if_index;
  vl_api_mac_address_t mac_addr;
  vl_api_mac_event_action_t action;
  u8 flags;
};

/** \brief L2 MAC event for a list of learned or aged MACs
    @param client_index - opaque cookie to identify the sender
    @param pid - client pid registered to receive notification
    @param n_macs - number of learned/aged MAC entries
    @param mac - array of learned/aged MAC entries
*/
define l2_macs_event
{
  u32 client_index;
  u32 pid;
  u32 n_macs;
  vl_api_mac_entry_t mac[n_macs];
};

service {
  rpc want_l2_macs_events returns want_l2_macs_events_reply
    events l2_macs_event;
};

/** \brief Set interface L2 flags (such as L2_LEARN, L2_FWD,
    L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits). This can be used
    to disable one or more of the features represented by the
    flag bits on an interface to override what is set as default
    for all interfaces in the bridge domain
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface
    @param is_set - if non-zero, set the bits, else clear them
    @param feature_bitmap - non-zero bits (as above) to set or clear
*/
define l2_flags
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool is_set;
  u32 feature_bitmap;
};

/** \brief Set interface L2 flags response
    @param context - sender context, to match reply w/ request
    @param retval - return code for the set l2 bits request
    @param resulting_feature_bitmap - the internal l2 feature bitmap after the request is implemented
*/
define l2_flags_reply
{
  u32 context;
  i32 retval;
  u32 resulting_feature_bitmap;
};

/** \brief L2 bridge domain set mac age
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bd_id - the bridge domain to create
    @param mac_age - mac aging time in min, 0 for disabled
*/
autoreply define bridge_domain_set_mac_age
{
  u32 client_index;
  u32 context;
  u32 bd_id;
  u8 mac_age;
};

/** \brief L2 bridge domain add or delete request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bd_id - the bridge domain to create
    @param flood - enable/disable bcast/mcast flooding in the bd
    @param uu_flood - enable/disable unknown unicast flood in the bd
    @param forward - enable/disable forwarding on all interfaces in the bd
    @param learn - enable/disable learning on all interfaces in the bd
    @param arp_term - enable/disable arp termination in the bd
    @param arp_ufwd - enable/disab<style>.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="cm">/*</span>
<span class="cm"> * Copyright (c) 2017 Cisco and/or its affiliates.</span>
<span class="cm"> * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="cm"> * you may not use this file except in compliance with the License.</span>
<span class="cm"> * You may obtain a copy of the License at:</span>
<span class="cm"> *</span>
<span class="cm"> *     http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="cm"> *</span>
<span class="cm"> * Unless required by applicable law or agreed to in writing, software</span>
<span class="cm"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="cm"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>

<span class="cm"> */</span>

<span class="cp">#ifndef __included_warnings_h__</span>
<span class="cp">#define __included_warnings_h__</span>

<span class="cm">/* Macros to check compiler version */</span>
<span class="cp">#if defined(__GNUC__)</span>
<span class="cp">#define COMPILER_VERSION_GTE(major, minor) \</span>
<span class="cp">  (__GNUC__ &gt; (major) || (__GNUC__ == (major) &amp;&amp; __GNUC_MINOR__ &gt;= (minor)))</span>
<span class="cp">#elif defined(__clang__)</span>
<span class="cp">#define COMPILER_VERSION_GTE(major, minor) \</span>
<span class="cp">  (__clang_major__ &gt; (major) ||            \</span>
<span class="cp">   (__clang_major__ == (major) &amp;&amp; __clang_minor__ &gt;= (minor)))</span>
<span class="cp">#else </span><span class="cm">/* disable all warning customization for all other compilers */</span><span class="cp"></span>
<span class="cp">#define COMPILER_VERSION_GTE(maj, min) 0</span>
<span class="cp">#endif</span>

<span class="cm">/* &#39;#&#39; needs to preceed a macro parameter */</span>
<span class="cp">#define WARN_TOSTR(x) #x</span>

<span class="cm">/*</span>
<span class="cm"> * Macros to toggle off/on warnings</span>
<span class="cm"> *</span>
<span class="cm"> * Start by silenging pragma warnings so that we can explicitely silence</span>
<span class="cm"> * a warning introduced on some compiler version and not get a warning on older</span>
<span class="cm"> * versions of that same compiler.</span>
<span class="cm"> *</span>
<span class="cm"> * gcc corresponding warnign is &quot;Wpargma&quot;</span>
<span class="cm"> * clang corresponding warnign is &quot;Wunknown-warning-option&quot;</span>
<span class="cm"> *</span>
<span class="cm"> * For example, Wtautological-compare is introduced in gcc-6 and this would</span>
<span class="cm"> * trigger a Wpargma warning on gcc-5.</span>
<span class="cm"> *</span>
<span class="cm"> * Example usage to disable -Wtautological-compare warning:</span>
<span class="cm"> *   WARN_OFF(tautological-compare)</span>
<span class="cm"> *   if (...) {</span>
<span class="cm"> *   WARN_ON(tautological-compare)</span>
<span class="cm"> *     ; // conditional code</span>
<span class="cm"> *   }</span>
<span class="cm"> */</span>
<span class="cp">#if defined(__GNUC__) &amp;&amp; COMPILER_VERSION_GTE(4, 6)</span>
<span class="cm">/*</span>
<span class="cm"> * GCC option to locally ignore warning was introduced in gcc-4.6</span>
<span class="cm"> * gcc.gnu.org/gcc-4.6/changes.html</span>
<span class="cm"> */</span>
<span class="cp">#define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (GCC diagnostic x))</span>
<span class="cp">#define WARN_OFF(x)                                    \</span>
<span class="cp">  WARN_PRAGMA (push) WARN_PRAGMA (ignored &quot;-Wpragmas&quot;) \</span>
<span class="cp">  WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x))</span>
<span class="cp">#define WARN_ON(x)  \</span>
<span class="cp">  WARN_PRAGMA (pop) \</span>
<span class="cp">  WARN_PRAGMA (pop)</span>

<span class="cp">#elif defined(__clang__) &amp;&amp; COMPILER_VERSION_GTE(3, 3)</span>
<span class="cm">/*</span>
<span class="cm"> * clang option to locally ignore warning was introduced in clang-3.3</span>
<span class="cm"> * releases.llvm.org/3.3/tools/clang/docs/UsersManual.html#controlling-diagnostics-via-pragmas</span>
<span class="cm"> */</span>
<span class="cp">#define WARN_PRAGMA(x) _Pragma (WARN_TOSTR (clang diagnostic x))</span>
<span class="cp">#define WARN_OFF(x)                                                   \</span>
<span class="cp">  WARN_PRAGMA (push) WARN_PRAGMA (ignored &quot;-Wunknown-warning-option&quot;) \</span>
<span class="cp">  WARN_PRAGMA (push) WARN_PRAGMA (ignored WARN_TOSTR (-W##x))</span>
<span class="cp">#define WARN_ON(x)  \</span>
<span class="cp">  WARN_PRAGMA (pop) \</span>
<span class="cp">  WARN_PRAGMA (pop)</span>
<span class="cp">#else</span>
<span class="cm">/* Ignore WARN_* instruction for all other compilers */</span>
<span class="cp">#define WARN_OFF(x)</span>
<span class="cp">#define WARN_ON(x)</span>
<span class="cp">#endif</span>

<span class="cm">/*</span>
<span class="cm"> * Clang supports a wider range of warnings than gcc.</span>
<span class="cm"> * Use those specific macros for the warnings that are only supported by clang</span>
<span class="cm"> */</span>
<span class="cp">#ifdef __clang__</span>
<span class="cp">#define WARN_OFF_CLANG(x) WARN_OFF (x)</span>
<span class="cp">#define WARN_ON_CLANG(x) WARN_ON (x)</span>
<span class="cp">#else</span>
<span class="cp">#define WARN_OFF_CLANG(x)</span>
<span class="cp">#define WARN_ON_CLANG(x)</span>
<span class="cp">#endif</span>

<span class="cm">/*</span>
<span class="cm"> * fd.io coding-style-patch-verification: ON</span>
<span class="cm"> *</span>
<span class="cm"> * Local Variables:</span>
<span class="cm"> * eval: (c-set-style &quot;gnu&quot;)</span>
<span class="cm"> * End:</span>
<span class="cm"> */</span>
<span class="cp">#endif </span><span class="cm">/* __included_warnings_h__ */</span><span class="cp"></span>
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div id="lfcollabprojects-footer">
  <div class="gray-diagonal">
    <div class="footer-inner">
      <p>
        &copy; 2016 <a href="https://www.fd.io/">FD.io</a> a Linux Foundation
        Collaborative Project. All Rights Reserved.
      </p>
      <p>
        Linux Foundation is a registered trademark of The Linux Foundation.
        Linux is a registered
        <a
          href="http://www.linuxfoundation.org/programs/legal/trademark"
          title="Linux Mark Institute"
          >trademark</a
        >
        of Linus Torvalds.
      </p>
      <p>
        Please see our
        <a href="http://www.linuxfoundation.org/privacy">privacy policy</a> and
        <a href="http://www.linuxfoundation.org/terms">terms of use</a>
      </p>
    </div>
  </div>
</div>
</div> <!-- id=cgit -->
</body>
</html>
red to receive notification
    @param ip - IP address of new ARP term entry
    @param sw_if_index - interface of new ARP term entry
    @param mac - MAC address of new ARP term entry
*/
define l2_arp_term_event
{
  u32 client_index;
  u32 pid;
  vl_api_address_t ip;
  vl_api_interface_index_t sw_if_index;
  vl_api_mac_address_t mac;
};

service {
  rpc want_l2_arp_term_events returns want_l2_arp_term_events_reply
    events l2_arp_term_event;
};

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