1
Content-type: text/html
3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<HTML><HEAD><TITLE>Man page of IPSEC_TTOSA</TITLE>
7
Section: C Library Functions (3)<BR>Updated: 26 Nov 2001<BR><A HREF="#index">Index</A>
8
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
11
<A NAME="lbAB"> </A>
14
ipsec ttosa, satot - convert IPsec Security Association IDs to and from text
17
ipsec initsaid - initialize an SA ID
18
<A NAME="lbAC"> </A>
21
<B>#include <<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
24
<B>typedef struct {</B>
28
<B>ip_address dst;</B>
32
<B>ipsec_spi_t spi;</B>
43
<B>const char *ttosa(const char *src, size_t srclen,</B>
51
<B>size_t satot(const ip_said *sa, int format,</B>
55
<B>char *dst, size_t dstlen);</B>
59
<B>void initsaid(const ip_address *addr, ipsec_spi_t spi,</B>
63
<B>int proto, ip_said *dst);</B>
65
<A NAME="lbAD"> </A>
70
converts an ASCII Security Association (SA) specifier into an
74
a destination-host address
75
in network byte order,
76
an SPI number in network byte order, and
80
does the reverse conversion, back to a text SA specifier.
86
from separate items of information.
89
An SA is specified in text with a mail-like syntax, e.g.
90
<B><A HREF="mailto:esp.5a7@1.2.3.4">esp.5a7@1.2.3.4</A></B>.
92
An SA specifier contains
93
a protocol prefix (currently
105
a single character indicating the address family
112
an unsigned integer SPI number in hexadecimal (with no
117
The IP address can be any form accepted by
118
<I><A HREF="/cgi-bin/man/man2html?3+ipsec_ttoaddr">ipsec_ttoaddr</A></I>(3),
120
e.g. dotted-decimal IPv4 address,
121
colon-hex IPv6 address,
125
As a special case, the SA specifier
131
signifies the special SA used to indicate that packets should be
132
passed through unaltered.
133
(At present, these are synonyms for
134
<B><A HREF="mailto:tun.0@0.0.0.0">tun.0@0.0.0.0</A></B>
140
but that is subject to change without notice.)
143
is a historical synonym for
144
<B>%passthrough4</B>.
146
These forms are known to both
152
so the internal representation is never visible.
155
Similarly, the SA specifiers
169
signify special ``magic'' SAs used to indicate that packets should be
170
passed, dropped, rejected (dropped with ICMP notification),
172
and trapped (sent up to
173
<I><A HREF="/cgi-bin/man/man2html?8+ipsec_pluto">ipsec_pluto</A></I>(8),
175
with either of two forms of
178
automatically installed)
180
These forms too are known to both routines,
181
so the internal representation of the magic SAs should never be visible.
185
<B><<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
187
header file supplies the
190
structure, as well as a data type
193
which is an unsigned 32-bit integer.
194
(There is no consistency between kernel and user on what such a type
195
is called, hence the header hides the differences.)
198
The protocol code uses the same numbers that IP does.
199
For user convenience, given the difficulty in acquiring the exact set of
200
protocol names used by the kernel,
201
<B><<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
213
to have the same values as the kernel names
225
<B><<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
233
(reserved by IANA for ``any host internal protocol'')
246
to have the values 256-260 (in <I>host</I> byte order) respectively.
247
These are used in constructing the magic SAs
248
(which always have address
256
encounters an unknown protocol code, e.g. 77,
257
it yields output using a prefix
258
showing the code numerically, e.g. ``unk77''.
273
specifies the length of the string pointed to by
276
it is an error for there to be anything else
277
(e.g., a terminating NUL) within that length.
278
As a convenience for cases where an entire NUL-terminated string is
297
specifies the size of the
301
under no circumstances are more than
307
A result which will not fit is truncated.
310
can be zero, in which case
313
need not be valid and no result is written,
314
but the return value is unaffected;
315
in all other cases, the (possibly truncated) result is NUL-terminated.
317
<B><<A HREF="file:///usr/include/freeswan.h">freeswan.h</A>></B>
319
header file defines a constant,
322
which is the size of a buffer just large enough for worst-case results.
331
specifies what format is to be used for the conversion.
335
(not the ASCII character
339
specifies a reasonable default
341
lowercase protocol prefix, lowercase hexadecimal SPI,
342
dotted-decimal or colon-hex address).
346
is similar except that the SPI is padded with
349
to a fixed 32-bit width, to ease aligning displayed tables.
358
a pointer to a string-literal error message for failure;
365
for a failure, and otherwise
366
always returns the size of buffer which would
368
accommodate the full conversion result, including terminating NUL;
369
it is the caller's responsibility to check this against the size of
370
the provided buffer to determine whether truncation has occurred.
373
There is also, temporarily, support for some obsolete
374
forms of SA specifier which lack the address-family indicator.
375
<A NAME="lbAE"> </A>
378
<A HREF="/cgi-bin/man/man2html?3+ipsec_ttoul">ipsec_ttoul</A>(3), <A HREF="/cgi-bin/man/man2html?3+ipsec_ttoaddr">ipsec_ttoaddr</A>(3), <A HREF="/cgi-bin/man/man2html?3+ipsec_samesaid">ipsec_samesaid</A>(3), <A HREF="/cgi-bin/man/man2html?3+inet">inet</A>(3)
379
<A NAME="lbAF"> </A>
387
input too small to be a legal SA specifier;
392
unknown protocol prefix;
406
<A NAME="lbAG"> </A>
409
Written for the FreeS/WAN project by Henry Spencer.
410
<A NAME="lbAH"> </A>
413
The restriction of text-to-binary error reports to literal strings
414
(so that callers don't need to worry about freeing them or copying them)
415
does limit the precision of error reporting.
418
The text-to-binary error-reporting convention lends itself
419
to slightly obscure code,
420
because many readers will not think of NULL as signifying success.
421
A good way to make it clearer is to write something like:
426
<B>const char *error;</B>
428
<B>error = ttosa( /* ... */ );</B>
429
<B>if (error != NULL) {</B>
430
<B> /* something went wrong */</B>
438
<A NAME="index"> </A><H2>Index</H2>
440
<DT><A HREF="#lbAB">NAME</A><DD>
441
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
442
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
443
<DT><A HREF="#lbAE">SEE ALSO</A><DD>
444
<DT><A HREF="#lbAF">DIAGNOSTICS</A><DD>
445
<DT><A HREF="#lbAG">HISTORY</A><DD>
446
<DT><A HREF="#lbAH">BUGS</A><DD>
449
This document was created by
450
<A HREF="/cgi-bin/man/man2html">man2html</A>,
451
using the manual pages.<BR>
452
Time: 10:29:41 GMT, June 17, 2004