*
* Copyright (c) 2023 Brad House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/
#ifndef __ARES__IFACE_IPS_H
#define __ARES__IFACE_IPS_H
typedef enum {
ARES_IFACE_IP_V4 = 1 << 0,
* this flag is set ARES_IFACE_IP_V6
* is not, will only enumerate v4
* addresses. */
ARES_IFACE_IP_V6 = 1 << 1,
* this flag is set ARES_IFACE_IP_V4
* is not, will only enumerate v6
* addresses. */
ARES_IFACE_IP_LOOPBACK = 1 << 2,
ARES_IFACE_IP_OFFLINE = 1 << 3,
ARES_IFACE_IP_LINKLOCAL = 1 << 4,
ARES_IFACE_IP_DEFAULT = (ARES_IFACE_IP_V4 | ARES_IFACE_IP_V6 |
ARES_IFACE_IP_LOOPBACK | ARES_IFACE_IP_LINKLOCAL)
} ares__iface_ip_flags_t;
struct ares__iface_ips;
typedef struct ares__iface_ips ares__iface_ips_t;
*
* \param[in] ips Initialized IP address enumeration structure
*/
void ares__iface_ips_destroy(ares__iface_ips_t *ips);
*
* \param[out] ips Returns initialized ip address structure
* \param[in] flags Flags for enumeration
* \param[in] name Interface name to enumerate, or NULL to enumerate all
* \return ARES_ENOMEM on out of memory, ARES_ENOTIMP if not supported on
* the system, ARES_SUCCESS on success
*/
ares_status_t ares__iface_ips(ares__iface_ips_t **ips,
ares__iface_ip_flags_t flags, const char *name);
*
* \param[in] ips Initialized IP address enumeration structure
* \return count
*/
size_t ares__iface_ips_cnt(const ares__iface_ips_t *ips);
*
* \param[in] ips Initialized IP address enumeration structure
* \param[in] idx Index of entry to pull
* \return interface name
*/
const char *ares__iface_ips_get_name(const ares__iface_ips_t *ips, size_t idx);
*
* \param[in] ips Initialized IP address enumeration structure
* \param[in] idx Index of entry to pull
* \return interface address
*/
const struct ares_addr *ares__iface_ips_get_addr(const ares__iface_ips_t *ips,
size_t idx);
*
* \param[in] ips Initialized IP address enumeration structure
* \param[in] idx Index of entry to pull
* \return interface address flags
*/
ares__iface_ip_flags_t ares__iface_ips_get_flags(const ares__iface_ips_t *ips,
size_t idx);
*
* \param[in] ips Initialized IP address enumeration structure
* \param[in] idx Index of entry to pull
* \return interface address netmask
*/
unsigned char ares__iface_ips_get_netmask(const ares__iface_ips_t *ips,
size_t idx);
*
* \param[in] ips Initialized IP address enumeration structure
* \param[in] idx Index of entry to pull
* \return interface ipv6 link local scope
*/
unsigned int ares__iface_ips_get_ll_scope(const ares__iface_ips_t *ips,
size_t idx);
* name.
*
* \param[in] name Interface name
* \return 0 on failure, index otherwise
*/
unsigned int ares__if_nametoindex(const char *name);
*
* \param[in] index Interface index (> 0)
* \param[in] name Buffer to hold name
* \param[in] name_len Length of provided buffer, must be at least IF_NAMESIZE
* \return NULL on failure, or pointer to name on success
*/
const char *ares__if_indextoname(unsigned int index, char *name,
size_t name_len);
#endif