inet.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 1997, 1999, 2000, 2001 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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _ARPA_INET_H
  16. #define _ARPA_INET_H 1
  17. #include <features.h>
  18. #include <netinet/in.h> /* To define `struct in_addr'. */
  19. /* Type for length arguments in socket calls. */
  20. #ifndef __socklen_t_defined
  21. typedef __socklen_t socklen_t;
  22. # define __socklen_t_defined
  23. #endif
  24. __BEGIN_DECLS
  25. /* Convert Internet host address from numbers-and-dots notation in CP
  26. into binary data in network byte order. */
  27. extern in_addr_t inet_addr (__const char *__cp) __THROW;
  28. /* Return the local host address part of the Internet address in IN. */
  29. extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
  30. /* Make Internet host address in network byte order by combining the
  31. network number NET with the local address HOST. */
  32. extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
  33. __THROW;
  34. /* Return network number part of the Internet address IN. */
  35. extern in_addr_t inet_netof (struct in_addr __in) __THROW;
  36. /* Extract the network number in network byte order from the address
  37. in numbers-and-dots natation starting at CP. */
  38. extern in_addr_t inet_network (__const char *__cp) __THROW;
  39. /* Convert Internet number in IN to ASCII representation. The return value
  40. is a pointer to an internal array containing the string. */
  41. extern char *inet_ntoa (struct in_addr __in) __THROW;
  42. /* Recursion-safe flavor */
  43. extern char *inet_ntoa_r (struct in_addr __in, char *__buf) __THROW;
  44. /* Convert from presentation format of an Internet number in buffer
  45. starting at CP to the binary network format and store result for
  46. interface type AF in buffer starting at BUF. */
  47. extern int inet_pton (int __af, __const char *__restrict __cp,
  48. void *__restrict __buf) __THROW;
  49. /* Convert a Internet address in binary network format for interface
  50. type AF in buffer starting at CP to presentation form and place
  51. result in buffer of length LEN astarting at BUF. */
  52. extern __const char *inet_ntop (int __af, __const void *__restrict __cp,
  53. char *__restrict __buf, socklen_t __len)
  54. __THROW;
  55. /* The following functions are not part of XNS 5.2. */
  56. #ifdef __USE_MISC
  57. /* Convert Internet host address from numbers-and-dots notation in CP
  58. into binary data and store the result in the structure INP. */
  59. extern int inet_aton (__const char *__cp, struct in_addr *__inp) __THROW;
  60. /* Format a network number NET into presentation format and place result
  61. in buffer starting at BUF with length of LEN bytes. */
  62. extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
  63. /* Convert network number for interface type AF in buffer starting at
  64. CP to presentation format. The result will specifiy BITS bits of
  65. the number. */
  66. extern char *inet_net_ntop (int __af, __const void *__cp, int __bits,
  67. char *__buf, size_t __len) __THROW;
  68. /* Convert network number for interface type AF from presentation in
  69. buffer starting at CP to network format and store result int
  70. buffer starting at BUF of size LEN. */
  71. extern int inet_net_pton (int __af, __const char *__cp,
  72. void *__buf, size_t __len) __THROW;
  73. /* Convert ASCII representation in hexadecimal form of the Internet
  74. address to binary form and place result in buffer of length LEN
  75. starting at BUF. */
  76. extern unsigned int inet_nsap_addr (__const char *__cp,
  77. unsigned char *__buf, int __len) __THROW;
  78. /* Convert internet address in binary form in LEN bytes starting at CP
  79. a presentation form and place result in BUF. */
  80. extern char *inet_nsap_ntoa (int __len, __const unsigned char *__cp,
  81. char *__buf) __THROW;
  82. #endif
  83. __END_DECLS
  84. #endif /* arpa/inet.h */