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

/** \brief DHCP Proxy config add / del request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param rx_vrf_id - Rx/interface vrf id
    @param server_vrf_id - server vrf id
    @param if_ipv6 - ipv6 if non-zero, else ipv4
    @param is_add - add the config if non-zero, else delete
    @param insert_circuit_id - option82 suboption 1 fib number
    @param dhcp_server[] - server address
    @param dhcp_src_address[] - <fix this, need details>
*/
autoreply define dhcp_proxy_config
{
  u32 client_index;
  u32 context;
  u32 rx_vrf_id;
  u32 server_vrf_id;
  u8 is_ipv6;
  u8 is_add;
  u8 dhcp_server[16];
  u8 dhcp_src_address[16];
};

/** \brief DHCP Proxy set / unset vss request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param tbl_id - table id
    @param oui - first part of vpn id
    @param fib_id - second part of vpn id
    @param is_ipv6 - ip6 if non-zero, else ip4
    @param is_add - set vss if non-zero, else delete
*/
autoreply define dhcp_proxy_set_vss
{
  u32 client_index;
  u32 context;
  u32 tbl_id;
  u32 oui;
  u32 fib_id;
  u8 is_ipv6;
  u8 is_add;
};

/** \brief DHCP Client config add / del request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - index of the interface for DHCP client
    @param hostname - hostname
    @param client_id - Client ID - option 61
    @param is_add - add the config if non-zero, else delete
    @param want_dhcp_event - DHCP event sent to the sender
           via dhcp_compl_event API message if non-zero
    @param pid - sender's pid
*/
autoreply define dhcp_client_config
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u8 hostname[64];
  u8 client_id[64];
  u8 is_add;
  u8 want_dhcp_event;
  u32 pid;
};

/** \brief Tell client about a DHCP completion event
    @param client_index - opaque cookie to identify the sender
    @param pid - client pid registered to receive notification
    @param is_ipv6 - if non-zero the address is ipv6, else ipv4
    @param mask_width - The length of the subnet mask assigned
    @param host_address - Host IP address
    @param router_address - Router IP address
    @param host_mac - Host MAC address
*/
define dhcp_compl_event
{
  u32 client_index;
  u32 pid;
  u8 hostname[64];
  u8 is_ipv6;
  u8 mask_width;
  u8 host_address[16];
  u8 router_address[16];
  u8 host_mac[6];
};

/** \brief Dump DHCP proxy table
    @param client_index - opaque cookie to identify the sender
    @param True for IPv6 proxy table
*/
define dhcp_proxy_dump
{
  u32 client_index;
  u32 context;
  u8  is_ip6;
};

typeonly manual_print manual_endian define dhcp_server
{
  u32 server_vrf_id;
  u8 dhcp_server[16];
};

/** \brief Tell client about a DHCP completion event
    @param client_index - opaque cookie to identify the sender
*/
manual_endian manual_print define dhcp_proxy_details
{
  u32 context;
  u32 rx_vrf_id;
  u32 vss_oui;
  u32 vss_fib_id;
  u8 is_ipv6;
  u8 dhcp_src_address[16];
  u8 count;
  vl_api_dhcp_server_t servers[count];
};

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