/*
 * Copyright (c) 2017 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 configure global parameter for LLDP
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param system_name - VPP system name
    @param tx_hold - multiplier for tx_interval when setting time-to-live (TTL)
                     value in the LLDP packets
    @param tx_interval - time interval, in seconds, between each LLDP frames
*/
autoreply define lldp_config
{
  u32 client_index;
  u32 context;
  u8 system_name[256];
  u32 tx_hold;
  u32 tx_interval;
};

/** \brief Interface set LLDP request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface for which to enable/disable LLDP
    @param port_desc - local port description
    @param enable - if non-zero enable, else disable
*/
autoreply define sw_interface_set_lldp
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u8 port_desc[256];
  u8 enable;
};
