blob: fbd715af0472ef1bd62ac0fd3c9ceeacbeef5afd [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* Copyright (C) 1997, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19#ifndef _ARPA_INET_H
20#define _ARPA_INET_H 1
21
22#include <features.h>
23#include <netinet/in.h> /* To define `struct in_addr'. */
24
25/* Type for length arguments in socket calls. */
26#ifndef __socklen_t_defined
27typedef __socklen_t socklen_t;
28# define __socklen_t_defined
29#endif
30
31__BEGIN_DECLS
32
33/* Convert Internet host address from numbers-and-dots notation in CP
34 into binary data in network byte order. */
35extern in_addr_t inet_addr (__const char *__cp) __THROW;
36libc_hidden_proto(inet_addr)
37
38/* Return the local host address part of the Internet address in IN. */
39extern in_addr_t inet_lnaof (struct in_addr __in) __THROW;
40
41/* Make Internet host address in network byte order by combining the
42 network number NET with the local address HOST. */
43extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
44 __THROW;
45libc_hidden_proto(inet_makeaddr)
46
47/* Return network number part of the Internet address IN. */
48extern in_addr_t inet_netof (struct in_addr __in) __THROW;
49libc_hidden_proto(inet_netof)
50
51/* Extract the network number in network byte order from the address
52 in numbers-and-dots natation starting at CP. */
53extern in_addr_t inet_network (__const char *__cp) __THROW;
54libc_hidden_proto(inet_network)
55
56/* Convert Internet number in IN to ASCII representation. The return value
57 is a pointer to an internal array containing the string. */
58extern char *inet_ntoa (struct in_addr __in) __THROW;
59libc_hidden_proto(inet_ntoa)
60#ifdef __UCLIBC__
61/* Recursion-safe flavor */
62extern char *inet_ntoa_r (struct in_addr __in, char *__buf) __THROW;
63libc_hidden_proto(inet_ntoa_r)
64#endif
65
66/* Convert from presentation format of an Internet number in buffer
67 starting at CP to the binary network format and store result for
68 interface type AF in buffer starting at BUF. */
69extern int inet_pton (int __af, __const char *__restrict __cp,
70 void *__restrict __buf) __THROW;
71libc_hidden_proto(inet_pton)
72
73/* Convert a Internet address in binary network format for interface
74 type AF in buffer starting at CP to presentation form and place
75 result in buffer of length LEN astarting at BUF. */
76extern __const char *inet_ntop (int __af, __const void *__restrict __cp,
77 char *__restrict __buf, socklen_t __len)
78 __THROW;
79libc_hidden_proto(inet_ntop)
80
81
82/* The following functions are not part of XNS 5.2. */
83#ifdef __USE_MISC
84/* Convert Internet host address from numbers-and-dots notation in CP
85 into binary data and store the result in the structure INP. */
86extern int inet_aton (__const char *__cp, struct in_addr *__inp) __THROW;
87libc_hidden_proto(inet_aton)
88
89#if 0
90/* Format a network number NET into presentation format and place result
91 in buffer starting at BUF with length of LEN bytes. */
92extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW;
93
94/* Convert network number for interface type AF in buffer starting at
95 CP to presentation format. The result will specifiy BITS bits of
96 the number. */
97extern char *inet_net_ntop (int __af, __const void *__cp, int __bits,
98 char *__buf, size_t __len) __THROW;
99
100/* Convert network number for interface type AF from presentation in
101 buffer starting at CP to network format and store result int
102 buffer starting at BUF of size LEN. */
103extern int inet_net_pton (int __af, __const char *__cp,
104 void *__buf, size_t __len) __THROW;
105
106/* Convert ASCII representation in hexadecimal form of the Internet
107 address to binary form and place result in buffer of length LEN
108 starting at BUF. */
109extern unsigned int inet_nsap_addr (__const char *__cp,
110 unsigned char *__buf, int __len) __THROW;
111
112/* Convert internet address in binary form in LEN bytes starting at CP
113 a presentation form and place result in BUF. */
114extern char *inet_nsap_ntoa (int __len, __const unsigned char *__cp,
115 char *__buf) __THROW;
116#endif
117#endif
118
119__END_DECLS
120
121#endif /* arpa/inet.h */