Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 1 | #ifndef HEADER_CURL_IF2IP_H |
| 2 | #define HEADER_CURL_IF2IP_H |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 3 | /*************************************************************************** |
| 4 | * _ _ ____ _ |
| 5 | * Project ___| | | | _ \| | |
| 6 | * / __| | | | |_) | | |
| 7 | * | (__| |_| | _ <| |___ |
| 8 | * \___|\___/|_| \_\_____| |
| 9 | * |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 10 | * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 11 | * |
| 12 | * This software is licensed as described in the file COPYING, which |
| 13 | * you should have received as part of this distribution. The terms |
Alex Deymo | 8f1a214 | 2016-06-28 14:49:26 -0700 | [diff] [blame] | 14 | * are also available at https://curl.haxx.se/docs/copyright.html. |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 15 | * |
| 16 | * You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 17 | * copies of the Software, and permit persons to whom the Software is |
| 18 | * furnished to do so, under the terms of the COPYING file. |
| 19 | * |
| 20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 21 | * KIND, either express or implied. |
| 22 | * |
| 23 | ***************************************************************************/ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 24 | #include "curl_setup.h" |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 25 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 26 | /* IPv6 address scopes. */ |
| 27 | #define IPV6_SCOPE_GLOBAL 0 /* Global scope. */ |
| 28 | #define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */ |
| 29 | #define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */ |
Elliott Hughes | 82be86d | 2017-09-20 17:00:17 -0700 | [diff] [blame] | 30 | #define IPV6_SCOPE_UNIQUELOCAL 3 /* Unique local */ |
| 31 | #define IPV6_SCOPE_NODELOCAL 4 /* Loopback. */ |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 32 | |
| 33 | unsigned int Curl_ipv6_scope(const struct sockaddr *sa); |
| 34 | |
| 35 | bool Curl_if_is_interface_name(const char *interf); |
| 36 | |
| 37 | typedef enum { |
| 38 | IF2IP_NOT_FOUND = 0, /* Interface not found */ |
| 39 | IF2IP_AF_NOT_SUPPORTED = 1, /* Int. exists but has no address for this af */ |
| 40 | IF2IP_FOUND = 2 /* The address has been stored in "buf" */ |
| 41 | } if2ip_result_t; |
| 42 | |
| 43 | if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope, |
| 44 | unsigned int remote_scope_id, const char *interf, |
| 45 | char *buf, int buf_size); |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 46 | |
| 47 | #ifdef __INTERIX |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 48 | |
| 49 | /* Nedelcho Stanev's work-around for SFU 3.0 */ |
| 50 | struct ifreq { |
| 51 | #define IFNAMSIZ 16 |
| 52 | #define IFHWADDRLEN 6 |
| 53 | union { |
| 54 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
| 55 | } ifr_ifrn; |
| 56 | |
| 57 | union { |
| 58 | struct sockaddr ifru_addr; |
| 59 | struct sockaddr ifru_broadaddr; |
| 60 | struct sockaddr ifru_netmask; |
| 61 | struct sockaddr ifru_hwaddr; |
| 62 | short ifru_flags; |
| 63 | int ifru_metric; |
| 64 | int ifru_mtu; |
| 65 | } ifr_ifru; |
| 66 | }; |
| 67 | |
| 68 | /* This define was added by Daniel to avoid an extra #ifdef INTERIX in the |
| 69 | C code. */ |
| 70 | |
| 71 | #define ifr_name ifr_ifrn.ifrn_name /* interface name */ |
| 72 | #define ifr_addr ifr_ifru.ifru_addr /* address */ |
| 73 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ |
| 74 | #define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ |
| 75 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
| 76 | #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ |
| 77 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ |
| 78 | #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ |
| 79 | |
| 80 | #define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ |
Kristian Monsen | 5ab5018 | 2010-05-14 18:53:44 +0100 | [diff] [blame] | 81 | |
Bertrand SIMONNET | e6cd738 | 2015-07-01 15:39:44 -0700 | [diff] [blame] | 82 | #endif /* __INTERIX */ |
| 83 | |
| 84 | #endif /* HEADER_CURL_IF2IP_H */ |