113498266Sopenharmony_ci#ifndef HEADER_CURL_IF2IP_H 213498266Sopenharmony_ci#define HEADER_CURL_IF2IP_H 313498266Sopenharmony_ci/*************************************************************************** 413498266Sopenharmony_ci * _ _ ____ _ 513498266Sopenharmony_ci * Project ___| | | | _ \| | 613498266Sopenharmony_ci * / __| | | | |_) | | 713498266Sopenharmony_ci * | (__| |_| | _ <| |___ 813498266Sopenharmony_ci * \___|\___/|_| \_\_____| 913498266Sopenharmony_ci * 1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 1113498266Sopenharmony_ci * 1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which 1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms 1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html. 1513498266Sopenharmony_ci * 1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell 1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is 1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file. 1913498266Sopenharmony_ci * 2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 2113498266Sopenharmony_ci * KIND, either express or implied. 2213498266Sopenharmony_ci * 2313498266Sopenharmony_ci * SPDX-License-Identifier: curl 2413498266Sopenharmony_ci * 2513498266Sopenharmony_ci ***************************************************************************/ 2613498266Sopenharmony_ci#include "curl_setup.h" 2713498266Sopenharmony_ci 2813498266Sopenharmony_ci/* IPv6 address scopes. */ 2913498266Sopenharmony_ci#define IPV6_SCOPE_GLOBAL 0 /* Global scope. */ 3013498266Sopenharmony_ci#define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */ 3113498266Sopenharmony_ci#define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */ 3213498266Sopenharmony_ci#define IPV6_SCOPE_UNIQUELOCAL 3 /* Unique local */ 3313498266Sopenharmony_ci#define IPV6_SCOPE_NODELOCAL 4 /* Loopback. */ 3413498266Sopenharmony_ci 3513498266Sopenharmony_ci#ifdef ENABLE_IPV6 3613498266Sopenharmony_ciunsigned int Curl_ipv6_scope(const struct sockaddr *sa); 3713498266Sopenharmony_ci#else 3813498266Sopenharmony_ci#define Curl_ipv6_scope(x) 0 3913498266Sopenharmony_ci#endif 4013498266Sopenharmony_ci 4113498266Sopenharmony_citypedef enum { 4213498266Sopenharmony_ci IF2IP_NOT_FOUND = 0, /* Interface not found */ 4313498266Sopenharmony_ci IF2IP_AF_NOT_SUPPORTED = 1, /* Int. exists but has no address for this af */ 4413498266Sopenharmony_ci IF2IP_FOUND = 2 /* The address has been stored in "buf" */ 4513498266Sopenharmony_ci} if2ip_result_t; 4613498266Sopenharmony_ci 4713498266Sopenharmony_ciif2ip_result_t Curl_if2ip(int af, 4813498266Sopenharmony_ci#ifdef ENABLE_IPV6 4913498266Sopenharmony_ci unsigned int remote_scope, 5013498266Sopenharmony_ci unsigned int local_scope_id, 5113498266Sopenharmony_ci#endif 5213498266Sopenharmony_ci const char *interf, 5313498266Sopenharmony_ci char *buf, int buf_size); 5413498266Sopenharmony_ci 5513498266Sopenharmony_ci#ifdef __INTERIX 5613498266Sopenharmony_ci 5713498266Sopenharmony_ci/* Nedelcho Stanev's work-around for SFU 3.0 */ 5813498266Sopenharmony_cistruct ifreq { 5913498266Sopenharmony_ci#define IFNAMSIZ 16 6013498266Sopenharmony_ci#define IFHWADDRLEN 6 6113498266Sopenharmony_ci union { 6213498266Sopenharmony_ci char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 6313498266Sopenharmony_ci } ifr_ifrn; 6413498266Sopenharmony_ci 6513498266Sopenharmony_ci union { 6613498266Sopenharmony_ci struct sockaddr ifru_addr; 6713498266Sopenharmony_ci struct sockaddr ifru_broadaddr; 6813498266Sopenharmony_ci struct sockaddr ifru_netmask; 6913498266Sopenharmony_ci struct sockaddr ifru_hwaddr; 7013498266Sopenharmony_ci short ifru_flags; 7113498266Sopenharmony_ci int ifru_metric; 7213498266Sopenharmony_ci int ifru_mtu; 7313498266Sopenharmony_ci } ifr_ifru; 7413498266Sopenharmony_ci}; 7513498266Sopenharmony_ci 7613498266Sopenharmony_ci/* This define was added by Daniel to avoid an extra #ifdef INTERIX in the 7713498266Sopenharmony_ci C code. */ 7813498266Sopenharmony_ci 7913498266Sopenharmony_ci#define ifr_name ifr_ifrn.ifrn_name /* interface name */ 8013498266Sopenharmony_ci#define ifr_addr ifr_ifru.ifru_addr /* address */ 8113498266Sopenharmony_ci#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ 8213498266Sopenharmony_ci#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ 8313498266Sopenharmony_ci#define ifr_flags ifr_ifru.ifru_flags /* flags */ 8413498266Sopenharmony_ci#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ 8513498266Sopenharmony_ci#define ifr_metric ifr_ifru.ifru_metric /* metric */ 8613498266Sopenharmony_ci#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ 8713498266Sopenharmony_ci 8813498266Sopenharmony_ci#define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ 8913498266Sopenharmony_ci 9013498266Sopenharmony_ci#endif /* __INTERIX */ 9113498266Sopenharmony_ci 9213498266Sopenharmony_ci#endif /* HEADER_CURL_IF2IP_H */ 93