1 .TH IPSEC_ATOASR 3 "11 June 2001"
2 .\" RCSID $Id: atoasr.3,v 1.8 2001/06/11 23:08:00 henry Exp $
4 ipsec atoasr \- convert ASCII to Internet address, subnet, or range
6 ipsec rangetoa \- convert Internet address range to ASCII
8 .B "#include <freeswan.h>
10 .B "const char *atoasr(const char *src, size_t srclen,"
12 .B "char *type, struct in_addr *addrs);"
14 .B "size_t rangetoa(struct in_addr *addrs, int format,
16 .B "char *dst, size_t dstlen);"
18 These functions are obsolete;
19 there is no current equivalent,
20 because so far they have not proved useful.
23 converts an ASCII address, subnet, or address range
24 into a suitable combination of binary addresses
25 (in network byte order).
27 converts an address range back into ASCII,
28 using dotted-decimal form for the addresses
29 (the other reverse conversions are handled by
32 .IR ipsec_subnettoa (3)).
34 A single address can be any form acceptable to
35 .IR ipsec_atoaddr (3):
36 dotted decimal, DNS name, or hexadecimal number.
38 specification uses the form \fInetwork\fB/\fImask\fR
40 .IR ipsec_atosubnet (3).
42 An address range is two
44 addresses separated by a
47 If there are four dots rather than three, the first is taken as
48 part of the begin address,
49 e.g. for a complete DNS name which ends with
51 to suppress completion attempts.
52 The begin address of a range must be
53 less than or equal to the end address.
59 specifies the length of the ASCII string pointed to by
61 it is an error for there to be anything else
62 (e.g., a terminating NUL) within that length.
63 As a convenience for cases where an entire NUL-terminated string is
78 variable used to record which form was found.
81 parameter must point to a two-element array of
83 which receives the results.
84 The values stored into
86 and the corresponding values in the array, are:
89 *type addrs[0] addrs[1]
91 address \&\fB'a'\fR address -
93 subnet \&\fB's'\fR network mask
95 range \&\fB'r'\fR begin end
101 specifies the size of the
104 under no circumstances are more than
108 A result which will not fit is truncated.
110 can be zero, in which case
112 need not be valid and no result is written,
113 but the return value is unaffected;
114 in all other cases, the (possibly truncated) result is NUL-terminated.
117 header file defines a constant,
119 which is the size of a buffer just large enough for worst-case results.
125 specifies what format is to be used for the conversion.
128 (not the ASCII character
131 specifies a reasonable default,
132 and is in fact the only format currently available.
133 This parameter is a hedge against future needs.
136 returns NULL for success and
137 a pointer to a string-literal error message for failure;
142 for a failure, and otherwise
143 always returns the size of buffer which would
145 accommodate the full conversion result, including terminating NUL;
146 it is the caller's responsibility to check this against the size of
147 the provided buffer to determine whether truncation has occurred.
149 ipsec_atoaddr(3), ipsec_atosubnet(3)
156 .IR ipsec_atoaddr (3)
158 .IR ipsec_atosubnet (3)
160 begin address of range exceeds end address.
167 Written for the FreeS/WAN project by Henry Spencer.
169 The restriction of error reports to literal strings
170 (so that callers don't need to worry about freeing them or copying them)
171 does limit the precision of error reporting.
173 The error-reporting convention lends itself
174 to slightly obscure code,
175 because many readers will not think of NULL as signifying success.
176 A good way to make it clearer is to write something like:
180 .B "const char *error;"
182 .B "error = atoasr( /* ... */ );"
183 .B "if (error != NULL) {"
184 .B " /* something went wrong */"