Content-type: text/html Man page of IPSEC_TTOSA

IPSEC_TTOSA

Section: C Library Functions (3)
Updated: 26 Nov 2001
Index Return to Main Contents
 

NAME

ipsec ttosa, satot - convert IPsec Security Association IDs to and from text
ipsec initsaid - initialize an SA ID  

SYNOPSIS

#include <freeswan.h>

typedef struct {
  ip_address dst;
  ipsec_spi_t spi;
  int proto;
} ip_said;

const char *ttosa(const char *src, size_t srclen,
  ip_said *sa);
size_t satot(const ip_said *sa, int format,
  char *dst, size_t dstlen);
void initsaid(const ip_address *addr, ipsec_spi_t spi,
  int proto, ip_said *dst);  

DESCRIPTION

Ttosa converts an ASCII Security Association (SA) specifier into an ip_said structure (containing a destination-host address in network byte order, an SPI number in network byte order, and a protocol code). Satot does the reverse conversion, back to a text SA specifier. Initsaid initializes an ip_said from separate items of information.

An SA is specified in text with a mail-like syntax, e.g. esp.5a7@1.2.3.4. An SA specifier contains a protocol prefix (currently ah, esp, tun, comp, or int), a single character indicating the address family (. for IPv4, : for IPv6), an unsigned integer SPI number in hexadecimal (with no 0x prefix), and an IP address. The IP address can be any form accepted by ipsec_ttoaddr(3), e.g. dotted-decimal IPv4 address, colon-hex IPv6 address, or DNS are more than dstlen bytes of result written to dst. Dstlen can be zero, in which case dst need not be valid and no result bytes are written at all.

The base parameter of ttodata and ttodatav specifies what format the input is in; normally it should be 0 to signify that this gets figured out from the prefix. Values of 16, 64, and 256 respectively signify hexadecimal, base64, and character-text formats without prefixes.

The format parameter of datatot, a single character used as a type code, specifies which text format is wanted. The value 0 (not ASCII '0', but a zero value) specifies a reasonable default. Other currently-supported values are:

'x'
continuous lower-case hexadecimal with a 0x prefix
'h'
lower-case hexadecimal with a 0x prefix and a _ every eight digits
':'
lower-case hexadecimal with no prefix and a : (colon) every two digits
16
lower-case hexadecimal with no prefix or _
's'
continuous base64 with a 0s prefix
64
continuous base64 with no prefix

The default format is currently 'h'.

Ttodata returns NULL for success and a pointer to a string-literal error message for failure; see DIAGNOSTICS. On success, if and only if lenp is non-NULL, *lenp is set to the number of bytes required to contain the full untruncated result. It is the caller's responsibility to check this against dstlen to determine whether he has obtained a complete result. The *lenp value is correct even if dstlen is zero, which offers a way to determine how much space would be needed before having to allocate any.

Ttodatav is just like ttodata except that in certain cases, if errp is non-NULL, the buffer pointed to by errp (whose length is given by errlen) is used to hold a more detailed error message. The return value is NULL for success, and is either errp or a pointer to a string literal for failure. If the size of the error-message buffer is inadequate for the desired message, ttodatav will fall back on returning a pointer to a literal string instead. The freeswan.h header file defines a constant TTODATAV_BUF which is the size of a buffer large enough for worst-case results.

The normal return value of datatot is the number of bytes required to contain the full untruncated result. It is the caller's responsibility to check this against dstlen to determine whether he has obtained a complete result. The return value is correct even if dstlen is zero, which offers a way to determine how much space would be needed before having to allocate any. A return value of 0 signals a fatal error of some kind (see DIAGNOSTICS).

A zero value for srclen in ttodata (but not datatot!) is synonymous with strlen(src). A non-zero srclen in ttodata must not include the terminating NUL.

Unless dstlen is zero, the result supplied by datatot is always NUL-terminated, and its needed-size return value includes space for the terminating NUL.

Several obsolete variants of these functions (atodata, datatoa, atobytes, and bytestoa) are temporarily also supported.  

SEE ALSO

sprintf(3), ipsec_atoaddr(3)  

DIAGNOSTICS

Fatal errors in ttodata and ttodatav are: unknown characters in the input; unknown or missing prefix; unknown base; incomplete digit group; non-zero padding in a base64 less-than-three-bytes digit group; zero-length input.

Fatal errors in datatot are: unknown format code; zero-length input.  

HISTORY

Written for the FreeS/WAN project by Henry Spencer.  

BUGS

Datatot should have a format code to produce character-text output.

The 0s and 0t prefixes are the author's inventions and are not a standard of any kind. They have been chosen to avoid collisions with existing practice (some C implementations use 0b for binary) and possible confusion with unprefixed hexadecimal.


 

Index

NAME
SYNOPSIS
DESCRIPTION
SEE ALSO
DIAGNOSTICS
HISTORY
BUGS

This document was created by man2html, using the manual pages.
Time: 21:05:06 GMT, October 01, 2009 ./usr/share/doc/openswan/doc/manpage.d/ipsec_ttosa.3.html0000644000000000000000000002046511261214602022170 0ustar rootrootContent-type: text/html Man page of IPSEC_TTOSA

IPSEC_TTOSA

Section: C Library Functions (3)
Updated: 26 Nov 2001
Index Return to Main