1 | #ifndef HEADER_CURL_IF2IP_H |
2 | #define |
3 | /*************************************************************************** |
4 | * _ _ ____ _ |
5 | * Project ___| | | | _ \| | |
6 | * / __| | | | |_) | | |
7 | * | (__| |_| | _ <| |___ |
8 | * \___|\___/|_| \_\_____| |
9 | * |
10 | * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. |
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 |
14 | * are also available at https://curl.se/docs/copyright.html. |
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 | * SPDX-License-Identifier: curl |
24 | * |
25 | ***************************************************************************/ |
26 | #include "curl_setup.h" |
27 | |
28 | /* IPv6 address scopes. */ |
29 | #define IPV6_SCOPE_GLOBAL 0 /* Global scope. */ |
30 | #define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */ |
31 | #define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */ |
32 | #define IPV6_SCOPE_UNIQUELOCAL 3 /* Unique local */ |
33 | #define IPV6_SCOPE_NODELOCAL 4 /* Loopback. */ |
34 | |
35 | #ifdef ENABLE_IPV6 |
36 | unsigned int Curl_ipv6_scope(const struct sockaddr *sa); |
37 | #else |
38 | #define Curl_ipv6_scope(x) 0 |
39 | #endif |
40 | |
41 | typedef enum { |
42 | IF2IP_NOT_FOUND = 0, /* Interface not found */ |
43 | IF2IP_AF_NOT_SUPPORTED = 1, /* Int. exists but has no address for this af */ |
44 | IF2IP_FOUND = 2 /* The address has been stored in "buf" */ |
45 | } if2ip_result_t; |
46 | |
47 | if2ip_result_t Curl_if2ip(int af, |
48 | #ifdef ENABLE_IPV6 |
49 | unsigned int remote_scope, |
50 | unsigned int local_scope_id, |
51 | #endif |
52 | const char *interf, |
53 | char *buf, int buf_size); |
54 | |
55 | #ifdef __INTERIX |
56 | |
57 | /* Nedelcho Stanev's work-around for SFU 3.0 */ |
58 | struct ifreq { |
59 | #define IFNAMSIZ 16 |
60 | #define IFHWADDRLEN 6 |
61 | union { |
62 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ |
63 | } ifr_ifrn; |
64 | |
65 | union { |
66 | struct sockaddr ifru_addr; |
67 | struct sockaddr ifru_broadaddr; |
68 | struct sockaddr ifru_netmask; |
69 | struct sockaddr ifru_hwaddr; |
70 | short ifru_flags; |
71 | int ifru_metric; |
72 | int ifru_mtu; |
73 | } ifr_ifru; |
74 | }; |
75 | |
76 | /* This define was added by Daniel to avoid an extra #ifdef INTERIX in the |
77 | C code. */ |
78 | |
79 | #define ifr_name ifr_ifrn.ifrn_name /* interface name */ |
80 | #define ifr_addr ifr_ifru.ifru_addr /* address */ |
81 | #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ |
82 | #define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ |
83 | #define ifr_flags ifr_ifru.ifru_flags /* flags */ |
84 | #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ |
85 | #define ifr_metric ifr_ifru.ifru_metric /* metric */ |
86 | #define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ |
87 | |
88 | #define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ |
89 | |
90 | #endif /* __INTERIX */ |
91 | |
92 | #endif /* HEADER_CURL_IF2IP_H */ |
93 | |