/*
 * 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>
*/
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 config response
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
*/
define dhcp_proxy_config_reply
{
  u32 context;
  i32 retval;
};

/** \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
*/
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 proxy set / unset vss response
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
*/
define dhcp_proxy_set_vss_reply
{
  u32 context;
  i32 retval;
};

/** \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 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
*/
define dhcp_client_config
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u8 hostname[64];
  u8 is_add;
  u8 want_dhcp_event;
  u32 pid;
};

/** \brief DHCP Client config response
    @param context - sender context, to match reply w/ request
    @param retval - return code for the request
*/
define dhcp_client_config_reply
{
  u32 context;
  i32 retval;
};

/** \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 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 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;
};

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

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