1 Content-type: text/html
3 <HTML><HEAD><TITLE>Manpage of IPSEC_ATOSA</TITLE>
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>
10 <A NAME="lbAB"> </A>
13 ipsec atosa, satoa - convert IPSEC Security Association IDs to and from ASCII
14 <A NAME="lbAC"> </A>
17 <B>#include <<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>></B>
20 <B>const char *atosa(const char *src, size_t srclen,</B>
24 <B>struct sa_id *sa);</B>
28 <B>size_t satoa(struct sa_id sa, int format,</B>
32 <B>char *dst, size_t dstlen);</B>
39 <B>struct in_addr dst;</B>
43 <B>ipsec_spi_t spi;</B>
53 <A NAME="lbAD"> </A>
56 These functions are obsolete; see
57 <I><A HREF="ipsec_ttosa.3.html">ipsec_ttosa</A></I>(3)
59 for their replacements.
64 converts an ASCII Security Association (SA) specifier into an
68 a destination-host address
69 in network byte order,
70 an SPI number in network byte order, and
74 does the reverse conversion, back to an ASCII SA specifier.
77 An SA is specified in ASCII with a mail-like syntax, e.g.
78 <B><A HREF="mailto:esp507@1.2.3.4">esp507@1.2.3.4</A></B>.
80 An SA specifier contains
81 a protocol prefix (currently
89 an unsigned integer SPI number,
91 The SPI number can be decimal or hexadecimal
95 prefix), as accepted by
96 <I><A HREF="ipsec_atoul.3.html">ipsec_atoul</A></I>(3).
98 The IP address can be any form accepted by
99 <I><A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A></I>(3),
101 e.g. dotted-decimal address or DNS name.
104 As a special case, the SA specifier
107 signifies the special SA used to indicate that packets should be
108 passed through unaltered.
109 (At present, this is a synonym for
110 <B><A HREF="mailto:tun0x0@0.0.0.0">tun0x0@0.0.0.0</A></B>,
112 but that is subject to change without notice.)
113 This form is known to both
119 so the internal form of
126 <B><<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>></B>
128 header file supplies the
131 structure, as well as a data type
134 which is an unsigned 32-bit integer.
135 (There is no consistency between kernel and user on what such a type
136 is called, hence the header hides the differences.)
139 The protocol code uses the same numbers that IP does.
140 For user convenience, given the difficulty in acquiring the exact set of
141 protocol names used by the kernel,
142 <B><<A HREF="file:/usr/include/freeswan.h">freeswan.h</A>></B>
152 to have the same values as the kernel names
168 specifies the length of the ASCII string pointed to by
171 it is an error for there to be anything else
172 (e.g., a terminating NUL) within that length.
173 As a convenience for cases where an entire NUL-terminated string is
192 specifies the size of the
196 under no circumstances are more than
202 A result which will not fit is truncated.
205 can be zero, in which case
208 need not be valid and no result is written,
209 but the return value is unaffected;
210 in all other cases, the (possibly truncated) result is NUL-terminated.
214 header file defines a constant,
217 which is the size of a buffer just large enough for worst-case results.
226 specifies what format is to be used for the conversion.
230 (not the ASCII character
234 specifies a reasonable default
236 lowercase protocol prefix, lowercase hexadecimal SPI, dotted-decimal address).
240 causes the SPI to be generated in decimal instead.
249 a pointer to a string-literal error message for failure;
256 for a failure, and otherwise
257 always returns the size of buffer which would
259 accommodate the full conversion result, including terminating NUL;
260 it is the caller's responsibility to check this against the size of
261 the provided buffer to determine whether truncation has occurred.
262 <A NAME="lbAE"> </A>
265 <A HREF="ipsec_atoul.3.html">ipsec_atoul</A>(3), <A HREF="ipsec_atoaddr.3.html">ipsec_atoaddr</A>(3), <A HREF="inet.3.html">inet</A>(3)
266 <A NAME="lbAF"> </A>
274 input too small to be a legal SA specifier;
279 unknown protocol prefix;
292 unknown format; unknown protocol code.
293 <A NAME="lbAG"> </A>
296 Written for the FreeS/WAN project by Henry Spencer.
297 <A NAME="lbAH"> </A>
303 protocol code is a FreeS/WANism which may eventually disappear.
306 The restriction of ASCII-to-binary error reports to literal strings
307 (so that callers don't need to worry about freeing them or copying them)
308 does limit the precision of error reporting.
311 The ASCII-to-binary error-reporting convention lends itself
312 to slightly obscure code,
313 because many readers will not think of NULL as signifying success.
314 A good way to make it clearer is to write something like:
319 <B>const char *error;</B>
321 <B>error = atoaddr( /* ... */ );</B>
322 <B>if (error != NULL) {</B>
323 <B> /* something went wrong */</B>
331 <A NAME="index"> </A><H2>Index</H2>
333 <DT><A HREF="#lbAB">NAME</A><DD>
334 <DT><A HREF="#lbAC">SYNOPSIS</A><DD>
335 <DT><A HREF="#lbAD">DESCRIPTION</A><DD>
336 <DT><A HREF="#lbAE">SEE ALSO</A><DD>
337 <DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
338 <DT><A HREF="#lbAG">HISTORY</A><DD>
339 <DT><A HREF="#lbAH">BUGS</A><DD>
342 This document was created by
343 <A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
344 using the manual pages.<BR>
345 Time: 05:09:32 GMT, June 19, 2001