/* 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.
 */

 /** \brief Enable/Disable span to mirror traffic from one interface to another
    @param client_index - opaque cookie to identify the sender
    @param context - sender context which was passed in the request
    @param sw_if_index_from - interface to be mirorred
    @param sw_if_index_to - interface where the traffic is mirrored
    @param state - 0 = disabled, 1 = rx enabled, 2 = tx enabled, 3 tx & rx enabled
*/
autoreply define sw_interface_span_enable_disable {
    u32 client_index;
    u32 context;
    u32 sw_if_index_from;
    u32 sw_if_index_to;
    u8  state;
};

/** \brief SPAN dump request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define sw_interface_span_dump {
    u32 client_index;
    u32 context;
};

/** \brief Reply to SPAN dump request
    @param context - sender context which was passed in the request
    @param sw_if_index_from - mirorred interface
    @param sw_if_index_to - interface where the traffic is mirrored
    @param state - 0 = disabled, 1 = rx enabled, 2 = tx enabled, 3 tx & rx enabled
*/
define sw_interface_span_details {
    u32 context;
    u32 sw_if_index_from;
    u32 sw_if_index_to;
    u8 state;
};
