2
0

if2ip.h 2.9 KB

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