summaryrefslogtreecommitdiff
path: root/doc/manpage.d/ipsec_atoasr.3.html
blob: 7c9e2c4aa36a11af50cf8e93484dcb3fe277a272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
Content-type: text/html

<HTML><HEAD><TITLE>Manpage of IPSEC_ATOASR</TITLE>
</HEAD><BODY>
<H1>IPSEC_ATOASR</H1>
Section: C Library Functions (3)<BR>Updated: 11 June 2001<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>


<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

ipsec atoasr - convert ASCII to Internet address, subnet, or range
<BR>

ipsec rangetoa - convert Internet address range to ASCII
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>

<B>#include &lt;<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>&gt;</B>

<P>
<B>const char *atoasr(const char *src, size_t srclen,</B>

<BR>
&nbsp;
<B>char *type, struct in_addr *addrs);</B>

<BR>

<B>size_t rangetoa(struct in_addr *addrs, int format,</B>

<BR>
&nbsp;
<B>char *dst, size_t dstlen);</B>

<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>

These functions are obsolete;
there is no current equivalent,
because so far they have not proved useful.
<P>

<I>Atoasr</I>

converts an ASCII address, subnet, or address range
into a suitable combination of binary addresses
(in network byte order).
<I>Rangetoa</I>

converts an address range back into ASCII,
using dotted-decimal form for the addresses
(the other reverse conversions are handled by
<I><A HREF="ipsec_addrtoa.3.html">ipsec_addrtoa</A></I>(3)

and
<I><A HREF="ipsec_subnettoa.3.html">ipsec_subnettoa</A></I>(3)).

<P>

A single address can be any form acceptable to
<I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3):

dotted decimal, DNS name, or hexadecimal number.
A subnet
specification uses the form <I>network</I><B>/</B><I>mask</I>
interpreted by
<I><A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A></I>(3).

<P>

An address range is two
<I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3)

addresses separated by a
<B>...</B>

delimiter.
If there are four dots rather than three, the first is taken as
part of the begin address,
e.g. for a complete DNS name which ends with
<B>.</B>

to suppress completion attempts.
The begin address of a range must be
less than or equal to the end address.
<P>

The
<I>srclen</I>

parameter of
<I>atoasr</I>

specifies the length of the ASCII string pointed to by
<I>src</I>;

it is an error for there to be anything else
(e.g., a terminating NUL) within that length.
As a convenience for cases where an entire NUL-terminated string is
to be converted,
a
<I>srclen</I>

value of
<B>0</B>

is taken to mean
<B>strlen(src)</B>.

<P>

The
<I>type</I>

parameter of
<I>atoasr</I>

must point to a
<B>char</B>

variable used to record which form was found.
The
<I>addrs</I>

parameter must point to a two-element array of
<B>struct in_addr</B>

which receives the results.
The values stored into
<B>*type</B>,

and the corresponding values in the array, are:
<P>



<TT>&nbsp;&nbsp;&nbsp;</TT>*typeaddrs[0]addrs[1]<BR>
<P>
address<B>'a'</B>address-<BR>
<BR>

subnet<TT>&nbsp;</TT><B>'s'</B>networkmask<BR>
<BR>

range<TT>&nbsp;&nbsp;</TT><B>'r'</B>beginend<BR>
<P>

The
<I>dstlen</I>

parameter of
<I>rangetoa</I>

specifies the size of the
<I>dst</I>

parameter;
under no circumstances are more than
<I>dstlen</I>

bytes written to
<I>dst</I>.

A result which will not fit is truncated.
<I>Dstlen</I>

can be zero, in which case
<I>dst</I>

need not be valid and no result is written,
but the return value is unaffected;
in all other cases, the (possibly truncated) result is NUL-terminated.
The
<I>freeswan.h</I>

header file defines a constant,
<B>RANGETOA_BUF</B>,

which is the size of a buffer just large enough for worst-case results.
<P>

The
<I>format</I>

parameter of
<I>rangetoa</I>

specifies what format is to be used for the conversion.
The value
<B>0</B>

(not the ASCII character
<B>'0'</B>,

but a zero value)
specifies a reasonable default,
and is in fact the only format currently available.
This parameter is a hedge against future needs.
<P>

<I>Atoasr</I>

returns NULL for success and
a pointer to a string-literal error message for failure;
see DIAGNOSTICS.
<I>Rangetoa</I>

returns
<B>0</B>

for a failure, and otherwise
always returns the size of buffer which would 
be needed to
accommodate the full conversion result, including terminating NUL;
it is the caller's responsibility to check this against the size of
the provided buffer to determine whether truncation has occurred.
<A NAME="lbAE">&nbsp;</A>
<H2>SEE ALSO</H2>

<A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A>(3), <A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A>(3)
<A NAME="lbAF">&nbsp;</A>
<H2>DIAGNOSTICS</H2>

Fatal errors in
<I>atoasr</I>

are:
empty input;
error in
<I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3)

or
<I><A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A></I>(3)

during conversion;
begin address of range exceeds end address.
<P>

Fatal errors in
<I>rangetoa</I>

are:
unknown format.
<A NAME="lbAG">&nbsp;</A>
<H2>HISTORY</H2>

Written for the FreeS/WAN project by Henry Spencer.
<A NAME="lbAH">&nbsp;</A>
<H2>BUGS</H2>

The restriction of error reports to literal strings
(so that callers don't need to worry about freeing them or copying them)
does limit the precision of error reporting.
<P>

The error-reporting convention lends itself
to slightly obscure code,
because many readers will not think of NULL as signifying success.
A good way to make it clearer is to write something like:
<P>

<DL COMPACT><DT><DD>
<PRE>
<B>const char *error;</B>

<B>error = atoasr( /* ... */ );</B>
<B>if (error != NULL) {</B>
<B>        /* something went wrong */</B>
</PRE>

</DL>

<P>

<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">SEE ALSO</A><DD>
<DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
<DT><A HREF="#lbAG">HISTORY</A><DD>
<DT><A HREF="#lbAH">BUGS</A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 21:40:17 GMT, November 11, 2003
</BODY>
</HTML>