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

/** \brief enable/disable name resolution

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_enable - 1 = enable, 0 = disable
*/
autoreply define dns_enable_disable {
    u32 client_index;
    u32 context;
    u8 enable;
};

/** \brief add or delete an upstream name server

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_ip6 - an ip6 name server
    @param is_add - add = 1, delete = 0
    @param server_address - server ip address
*/
autoreply define dns_name_server_add_del {
    u32 client_index;
    u32 context;
    u8 is_ip6;
    u8 is_add;
    u8 server_address[16];
};

/** \brief DNS name resolution request

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param name - the name to resolve
*/
define dns_resolve_name {
    u32 client_index;
    u32 context;
    u8 name[256];
 };

/** \brief DNS name resolution reply

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param retval - return value, 0 => success
    @param ip4_set - indicates that the ip4 address is valid
    @param ip6_set - indicates that the ip6 address is valid
    @param ip4_address - the ip4 name resolution reply
    @param ip6_address - the ip6 name resolution reply
*/
define dns_resolve_name_reply {
    u32 context;
    i32 retval;
    u8 ip4_set;
    u8 ip6_set;
    u8 ip4_address[4];
    u8 ip6_address[16];
};

/** \brief DNS IP -> name resolution request

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_ip6 - set if the reverse-DNS request is an ip6 address
    @param address - the address to map to a name
*/
define dns_resolve_ip {
    u32 client_index;
    u32 context;
    u8 is_ip6;
    u8 address[16];
 };

/** \brief DNS ip->name resolution reply

    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param retval - return value, 0 => success
    @param name - canonical name for the indicated IP address
*/
define dns_resolve_ip_reply {
    u32 context;
    i32 retval;
    u8 name[256];
};

