OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / doc / manpage.d / ipsec_rangetoa.3.html
1 Content-type: text/html
2
3 <HTML><HEAD><TITLE>Manpage of IPSEC_ATOASR</TITLE>
4 </HEAD><BODY>
5 <H1>IPSEC_ATOASR</H1>
6 Section: C Library Functions (3)<BR>Updated: 11 June 2001<BR><A HREF="#index">Index</A>
7 <A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
8
9
10 <A NAME="lbAB">&nbsp;</A>
11 <H2>NAME</H2>
12
13 ipsec atoasr - convert ASCII to Internet address, subnet, or range
14 <BR>
15
16 ipsec rangetoa - convert Internet address range to ASCII
17 <A NAME="lbAC">&nbsp;</A>
18 <H2>SYNOPSIS</H2>
19
20 <B>#include &lt;<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>&gt;</B>
21
22 <P>
23 <B>const char *atoasr(const char *src, size_t srclen,</B>
24
25 <BR>
26 &nbsp;
27 <B>char *type, struct in_addr *addrs);</B>
28
29 <BR>
30
31 <B>size_t rangetoa(struct in_addr *addrs, int format,</B>
32
33 <BR>
34 &nbsp;
35 <B>char *dst, size_t dstlen);</B>
36
37 <A NAME="lbAD">&nbsp;</A>
38 <H2>DESCRIPTION</H2>
39
40 These functions are obsolete;
41 there is no current equivalent,
42 because so far they have not proved useful.
43 <P>
44
45 <I>Atoasr</I>
46
47 converts an ASCII address, subnet, or address range
48 into a suitable combination of binary addresses
49 (in network byte order).
50 <I>Rangetoa</I>
51
52 converts an address range back into ASCII,
53 using dotted-decimal form for the addresses
54 (the other reverse conversions are handled by
55 <I><A HREF="ipsec_addrtoa.3.html">ipsec_addrtoa</A></I>(3)
56
57 and
58 <I><A HREF="ipsec_subnettoa.3.html">ipsec_subnettoa</A></I>(3)).
59
60 <P>
61
62 A single address can be any form acceptable to
63 <I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3):
64
65 dotted decimal, DNS name, or hexadecimal number.
66 A subnet
67 specification uses the form <I>network</I><B>/</B><I>mask</I>
68 interpreted by
69 <I><A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A></I>(3).
70
71 <P>
72
73 An address range is two
74 <I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3)
75
76 addresses separated by a
77 <B>...</B>
78
79 delimiter.
80 If there are four dots rather than three, the first is taken as
81 part of the begin address,
82 e.g. for a complete DNS name which ends with
83 <B>.</B>
84
85 to suppress completion attempts.
86 The begin address of a range must be
87 less than or equal to the end address.
88 <P>
89
90 The
91 <I>srclen</I>
92
93 parameter of
94 <I>atoasr</I>
95
96 specifies the length of the ASCII string pointed to by
97 <I>src</I>;
98
99 it is an error for there to be anything else
100 (e.g., a terminating NUL) within that length.
101 As a convenience for cases where an entire NUL-terminated string is
102 to be converted,
103 a
104 <I>srclen</I>
105
106 value of
107 <B>0</B>
108
109 is taken to mean
110 <B>strlen(src)</B>.
111
112 <P>
113
114 The
115 <I>type</I>
116
117 parameter of
118 <I>atoasr</I>
119
120 must point to a
121 <B>char</B>
122
123 variable used to record which form was found.
124 The
125 <I>addrs</I>
126
127 parameter must point to a two-element array of
128 <B>struct in_addr</B>
129
130 which receives the results.
131 The values stored into
132 <B>*type</B>,
133
134 and the corresponding values in the array, are:
135 <P>
136
137
138
139 <TT>&nbsp;&nbsp;&nbsp;</TT>*typeaddrs[0]addrs[1]<BR>
140 <P>
141 address<B>'a'</B>address-<BR>
142 <BR>
143
144 subnet<TT>&nbsp;</TT><B>'s'</B>networkmask<BR>
145 <BR>
146
147 range<TT>&nbsp;&nbsp;</TT><B>'r'</B>beginend<BR>
148 <P>
149
150 The
151 <I>dstlen</I>
152
153 parameter of
154 <I>rangetoa</I>
155
156 specifies the size of the
157 <I>dst</I>
158
159 parameter;
160 under no circumstances are more than
161 <I>dstlen</I>
162
163 bytes written to
164 <I>dst</I>.
165
166 A result which will not fit is truncated.
167 <I>Dstlen</I>
168
169 can be zero, in which case
170 <I>dst</I>
171
172 need not be valid and no result is written,
173 but the return value is unaffected;
174 in all other cases, the (possibly truncated) result is NUL-terminated.
175 The
176 <I>freeswan.h</I>
177
178 header file defines a constant,
179 <B>RANGETOA_BUF</B>,
180
181 which is the size of a buffer just large enough for worst-case results.
182 <P>
183
184 The
185 <I>format</I>
186
187 parameter of
188 <I>rangetoa</I>
189
190 specifies what format is to be used for the conversion.
191 The value
192 <B>0</B>
193
194 (not the ASCII character
195 <B>'0'</B>,
196
197 but a zero value)
198 specifies a reasonable default,
199 and is in fact the only format currently available.
200 This parameter is a hedge against future needs.
201 <P>
202
203 <I>Atoasr</I>
204
205 returns NULL for success and
206 a pointer to a string-literal error message for failure;
207 see DIAGNOSTICS.
208 <I>Rangetoa</I>
209
210 returns
211 <B>0</B>
212
213 for a failure, and otherwise
214 always returns the size of buffer which would 
215 be needed to
216 accommodate the full conversion result, including terminating NUL;
217 it is the caller's responsibility to check this against the size of
218 the provided buffer to determine whether truncation has occurred.
219 <A NAME="lbAE">&nbsp;</A>
220 <H2>SEE ALSO</H2>
221
222 <A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A>(3), <A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A>(3)
223 <A NAME="lbAF">&nbsp;</A>
224 <H2>DIAGNOSTICS</H2>
225
226 Fatal errors in
227 <I>atoasr</I>
228
229 are:
230 empty input;
231 error in
232 <I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3)
233
234 or
235 <I><A HREF="ipsec_atosubnet.3.html">ipsec_atosubnet</A></I>(3)
236
237 during conversion;
238 begin address of range exceeds end address.
239 <P>
240
241 Fatal errors in
242 <I>rangetoa</I>
243
244 are:
245 unknown format.
246 <A NAME="lbAG">&nbsp;</A>
247 <H2>HISTORY</H2>
248
249 Written for the FreeS/WAN project by Henry Spencer.
250 <A NAME="lbAH">&nbsp;</A>
251 <H2>BUGS</H2>
252
253 The restriction of error reports to literal strings
254 (so that callers don't need to worry about freeing them or copying them)
255 does limit the precision of error reporting.
256 <P>
257
258 The error-reporting convention lends itself
259 to slightly obscure code,
260 because many readers will not think of NULL as signifying success.
261 A good way to make it clearer is to write something like:
262 <P>
263
264 <DL COMPACT><DT><DD>
265 <PRE>
266 <B>const char *error;</B>
267
268 <B>error = atoasr( /* ... */ );</B>
269 <B>if (error != NULL) {</B>
270 <B>        /* something went wrong */</B>
271 </PRE>
272
273 </DL>
274
275 <P>
276
277 <HR>
278 <A NAME="index">&nbsp;</A><H2>Index</H2>
279 <DL>
280 <DT><A HREF="#lbAB">NAME</A><DD>
281 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
282 <DT><A HREF="#lbAD">DESCRIPTION</A><DD>
283 <DT><A HREF="#lbAE">SEE ALSO</A><DD>
284 <DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
285 <DT><A HREF="#lbAG">HISTORY</A><DD>
286 <DT><A HREF="#lbAH">BUGS</A><DD>
287 </DL>
288 <HR>
289 This document was created by
290 <A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
291 using the manual pages.<BR>
292 Time: 05:09:32 GMT, June 19, 2001
293 </BODY>
294 </HTML>