ifaddrs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*++
  2. Copyright (c) 2017 Minoca Corp.
  3. This file is licensed under the terms of the GNU Lesser General Public
  4. License version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details.
  6. Module Name:
  7. ifaddrs.h
  8. Abstract:
  9. This header contains definitions for getting network interface addresses in
  10. the C Library.
  11. Author:
  12. Chris Stevens 24-Jan-2017
  13. --*/
  14. #ifndef _IFADDRS_H
  15. #define _IFADDRS_H
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <libcbase.h>
  20. //
  21. // ---------------------------------------------------------------- Definitions
  22. //
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. //
  27. // ------------------------------------------------------ Data Type Definitions
  28. //
  29. /*++
  30. Structure Description:
  31. This structure defines a network interface.
  32. Members:
  33. ifa_next - Stores a pointer to the next interface structure.
  34. ifa_name - Stores the null-terminated name of the interface.
  35. ifa_flags - Stores a bitmask of network interface flags. See IFF_* for
  36. definitions.
  37. ifa_addr - Stores a pointer to the network interface's address.
  38. ifa_netmask - Stores a pointer to the network interface's mask.
  39. ifa_broadaddr - Stores a pointer to the network interface's broadcast
  40. address.
  41. ifa_dstaddr - Stores a pointer to the network interface's P2P destination
  42. address.
  43. ifa_data - Stores a pointer to address family specific data.
  44. --*/
  45. struct ifaddrs {
  46. struct ifaddrs *ifa_next;
  47. char *ifa_name;
  48. u_int ifa_flags;
  49. struct sockaddr *ifa_addr;
  50. struct sockaddr *ifa_netmask;
  51. struct sockaddr *ifa_broadaddr;
  52. struct sockaddr *ifa_dstaddr;
  53. void *ifa_data;
  54. };
  55. //
  56. // -------------------------------------------------------------------- Globals
  57. //
  58. //
  59. // -------------------------------------------------------- Function Prototypes
  60. //
  61. LIBC_API
  62. int
  63. getifaddrs (
  64. struct ifaddrs **Interfaces
  65. );
  66. /*++
  67. Routine Description:
  68. This routine creates a linked list of network interfaces structures
  69. describing all of the network interfaces on the local system.
  70. Arguments:
  71. Interfaces - Supplies a pointer that receives a pointer to the linked list
  72. of network interfaces.
  73. Return Value:
  74. 0 on success.
  75. -1 on failure, and errno will be set to indicate the error.
  76. --*/
  77. LIBC_API
  78. void
  79. freeifaddrs (
  80. struct ifaddrs *Interfaces
  81. );
  82. /*++
  83. Routine Description:
  84. This routine releases a list of network interfaces.
  85. Arguments:
  86. Interfaces - Supplies a pointer to the list of network interfaces to
  87. release.
  88. Return Value:
  89. None.
  90. --*/
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif