inet.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright (C) 1997-2020 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _ARPA_INET_H
  15. #define _ARPA_INET_H 1
  16. #include <features.h>
  17. #include <netinet/in.h> /* To define `struct in_addr'. */
  18. /* Type for length arguments in socket calls. */
  19. #ifndef __socklen_t_defined
  20. typedef __socklen_t socklen_t;
  21. # define __socklen_t_defined
  22. #endif
  23. __BEGIN_DECLS
  24. /* Convert Internet host address from numbers-and-dots notation in CP
  25. into binary data in network byte order. */
  26. extern in_addr_t inet_addr (const char *__cp) __THROW;
  27. /* Return the local host address part of the Internet address in IN. */
  28. extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
  29. /* Make Internet host address in network byte order by combining the
  30. network number NET with the local address HOST. */
  31. extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
  32. __THROW;
  33. /* Return network number part of the Internet address IN. */
  34. extern in_addr_t inet_netof (struct in_addr __in) __THROW;
  35. /* Extract the network number in network byte order from the address
  36. in numbers-and-dots natation starting at CP. */
  37. extern in_addr_t inet_network (const char *__cp) __THROW;
  38. /* Convert Internet number in IN to ASCII representation. The return value
  39. is a pointer to an internal array containing the string. */
  40. extern char *inet_ntoa (struct in_addr __in) __THROW;
  41. /* Convert from presentation format of an Internet number in buffer
  42. starting at CP to the binary network format and store result for
  43. interface type AF in buffer starting at BUF. */
  44. extern int inet_pton (int __af, const char *__restrict __cp,
  45. void *__restrict __buf) __THROW;
  46. /* Convert a Internet address in binary network format for interface
  47. type AF in buffer starting at CP to presentation form and place
  48. result in buffer of length LEN astarting at BUF. */
  49. extern const char *inet_ntop (int __af, const void *__restrict __cp,
  50. char *__restrict __buf, socklen_t __len)
  51. __THROW;
  52. /* The following functions are not part of XNS 5.2. */
  53. #ifdef __USE_MISC
  54. /* Convert Internet host address from numbers-and-dots notation in CP
  55. into binary data and store the result in the structure INP. */
  56. extern int inet_aton (const char *__cp, struct in_addr *__inp) __THROW;
  57. /* Format a network number NET into presentation format and place result
  58. in buffer starting at BUF with length of LEN bytes. */
  59. extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
  60. /* Convert network number for interface type AF in buffer starting at
  61. CP to presentation format. The result will specifiy BITS bits of
  62. the number. */
  63. extern char *inet_net_ntop (int __af, const void *__cp, int __bits,
  64. char *__buf, size_t __len) __THROW;
  65. /* Convert network number for interface type AF from presentation in
  66. buffer starting at CP to network format and store result int
  67. buffer starting at BUF of size LEN. */
  68. extern int inet_net_pton (int __af, const char *__cp,
  69. void *__buf, size_t __len) __THROW;
  70. /* Convert ASCII representation in hexadecimal form of the Internet
  71. address to binary form and place result in buffer of length LEN
  72. starting at BUF. */
  73. extern unsigned int inet_nsap_addr (const char *__cp,
  74. unsigned char *__buf, int __len) __THROW;
  75. /* Convert internet address in binary form in LEN bytes starting at CP
  76. a presentation form and place result in BUF. */
  77. extern char *inet_nsap_ntoa (int __len, const unsigned char *__cp,
  78. char *__buf) __THROW;
  79. #endif
  80. __END_DECLS
  81. #endif /* arpa/inet.h */