1 Content-type: text/html
3 <HTML><HEAD><TITLE>Manpage of IPSEC_TTOSA
</TITLE>
6 Section: C Library Functions (
3)
<BR>Updated:
26 Nov
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 ttosa, satot - convert IPsec Security Association IDs to and from text
16 ipsec initsaid - initialize an SA ID
17 <A NAME=
"lbAC"> </A>
20 <B>#include
<<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
23 <B>typedef struct {
</B>
27 <B>ip_address dst;
</B>
31 <B>ipsec_spi_t spi;
</B>
42 <B>const char *ttosa(const char *src, size_t srclen,
</B>
50 <B>size_t satot(const ip_said *sa, int format,
</B>
54 <B>char *dst, size_t dstlen);
</B>
58 <B>void initsaid(const ip_address *addr, ipsec_spi_t spi,
</B>
62 <B>int proto, ip_said *dst);
</B>
64 <A NAME=
"lbAD"> </A>
69 converts an ASCII Security Association (SA) specifier into an
73 a destination-host address
74 in network byte order,
75 an SPI number in network byte order, and
79 does the reverse conversion, back to a text SA specifier.
85 from separate items of information.
88 An SA is specified in text with a mail-like syntax, e.g.
89 <B><A HREF=
"mailto:esp.5a7@1.2.3.4">esp
.5a7@
1.2.3.4</A></B>.
91 An SA specifier contains
92 a protocol prefix (currently
104 a single character indicating the address family
111 an unsigned integer SPI number in hexadecimal (with no
116 The IP address can be any form accepted by
117 <I><A HREF=
"ipsec_ttoaddr.3.html">ipsec_ttoaddr
</A></I>(
3),
119 e.g. dotted-decimal IPv4 address,
120 colon-hex IPv6 address,
124 As a special case, the SA specifier
130 signifies the special SA used to indicate that packets should be
131 passed through unaltered.
132 (At present, these are synonyms for
133 <B><A HREF=
"mailto:tun.0@0.0.0.0">tun
.0@
0.0.0.0</A></B>
139 but that is subject to change without notice.)
142 is a historical synonym for
143 <B>%passthrough4
</B>.
145 These forms are known to both
151 so the internal representation is never visible.
154 Similarly, the SA specifiers
168 signify special ``magic'' SAs used to indicate that packets should be
169 passed, dropped, rejected (dropped with ICMP notification),
171 and trapped (sent up to
172 <I><A HREF=
"ipsec_pluto.8.html">ipsec_pluto
</A></I>(
8),
174 with either of two forms of
177 automatically installed)
179 These forms too are known to both routines,
180 so the internal representation of the magic SAs should never be visible.
184 <B><<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
186 header file supplies the
189 structure, as well as a data type
192 which is an unsigned
32-bit integer.
193 (There is no consistency between kernel and user on what such a type
194 is called, hence the header hides the differences.)
197 The protocol code uses the same numbers that IP does.
198 For user convenience, given the difficulty in acquiring the exact set of
199 protocol names used by the kernel,
200 <B><<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
212 to have the same values as the kernel names
224 <B><<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
232 (reserved by IANA for ``any host internal protocol'')
245 to have the values
256-
260 (in
<I>host
</I> byte order) respectively.
246 These are used in constructing the magic SAs
247 (which always have address
255 encounters an unknown protocol code, e.g.
77,
256 it yields output using a prefix
257 showing the code numerically, e.g. ``unk77''.
272 specifies the length of the string pointed to by
275 it is an error for there to be anything else
276 (e.g., a terminating NUL) within that length.
277 As a convenience for cases where an entire NUL-terminated string is
296 specifies the size of the
300 under no circumstances are more than
306 A result which will not fit is truncated.
309 can be zero, in which case
312 need not be valid and no result is written,
313 but the return value is unaffected;
314 in all other cases, the (possibly truncated) result is NUL-terminated.
316 <B><<A HREF=
"file:/usr/include/freeswan.h">freeswan.h
</A>></B>
318 header file defines a constant,
321 which is the size of a buffer just large enough for worst-case results.
330 specifies what format is to be used for the conversion.
334 (not the ASCII character
338 specifies a reasonable default
340 lowercase protocol prefix, lowercase hexadecimal SPI,
341 dotted-decimal or colon-hex address).
345 is similar except that the SPI is padded with
348 to a fixed
32-bit width, to ease aligning displayed tables.
357 a pointer to a string-literal error message for failure;
364 for a failure, and otherwise
365 always returns the size of buffer which would
367 accommodate the full conversion result, including terminating NUL;
368 it is the caller's responsibility to check this against the size of
369 the provided buffer to determine whether truncation has occurred.
372 There is also, temporarily, support for some obsolete
373 forms of SA specifier which lack the address-family indicator.
374 <A NAME=
"lbAE"> </A>
377 <A HREF=
"ipsec_ttoul.3.html">ipsec_ttoul
</A>(
3),
<A HREF=
"ipsec_ttoaddr.3.html">ipsec_ttoaddr
</A>(
3),
<A HREF=
"ipsec_samesaid.3.html">ipsec_samesaid
</A>(
3),
<A HREF=
"inet.3.html">inet
</A>(
3)
378 <A NAME=
"lbAF"> </A>
386 input too small to be a legal SA specifier;
391 unknown protocol prefix;
405 <A NAME=
"lbAG"> </A>
408 Written for the FreeS/WAN project by Henry Spencer.
409 <A NAME=
"lbAH"> </A>
412 The restriction of text-to-binary error reports to literal strings
413 (so that callers don't need to worry about freeing them or copying them)
414 does limit the precision of error reporting.
417 The text-to-binary error-reporting convention lends itself
418 to slightly obscure code,
419 because many readers will not think of NULL as signifying success.
420 A good way to make it clearer is to write something like:
425 <B>const char *error;
</B>
427 <B>error = ttosa( /* ... */ );
</B>
428 <B>if (error != NULL) {
</B>
429 <B> /* something went wrong */
</B>
437 <A NAME=
"index"> </A><H2>Index
</H2>
439 <DT><A HREF=
"#lbAB">NAME
</A><DD>
440 <DT><A HREF=
"#lbAC">SYNOPSIS
</A><DD>
441 <DT><A HREF=
"#lbAD">DESCRIPTION
</A><DD>
442 <DT><A HREF=
"#lbAE">SEE ALSO
</A><DD>
443 <DT><A HREF=
"#lbAF">DIAGNOSTICS
</A><DD>
444 <DT><A HREF=
"#lbAG">HISTORY
</A><DD>
445 <DT><A HREF=
"#lbAH">BUGS
</A><DD>
448 This document was created by
449 <A HREF=
"http://localhost/cgi-bin/man/man2html">man2html
</A>,
450 using the manual pages.
<BR>
451 Time:
21:
40:
18 GMT, November
11,
2003