1IPSEC_INITADDR(3)          Library Functions Manual          IPSEC_INITADDR(3)
2
3
4

NAME

6       ipsec initaddr - initialize an ip_address
7       ipsec addrtypeof - get address type of an ip_address
8       ipsec addrlenof - get length of address within an ip_address
9       ipsec addrbytesof - get copy of address within an ip_address
10       ipsec addrbytesptr - get pointer to address within an ip_address
11

SYNOPSIS

13       #include <freeswan.h>
14
15       const char *initaddr(const char *src, size_t srclen,
16           int af, ip_address *dst);
17       int addrtypeof(const ip_address *src);
18       size_t addrlenof(const ip_address *src);
19       size_t addrbytesof(const ip_address *src,
20           unsigned char *dst, size_t dstlen);
21       size_t addrbytesptr(const ip_address *src,
22           const unsigned char **dst);
23

DESCRIPTION

25       The  <freeswan.h>  library  uses an internal type ip_address to contain
26       one of the (currently two) types of IP address.  These  functions  pro‐
27       vide basic tools for creating and examining this type.
28
29       Initaddr initializes a variable *dst of type ip_address from an address
30       (in network byte order, indicated by a pointer src and a length srclen)
31       and  an  address family af (typically AF_INET or AF_INET6).  The length
32       must be consistent with the address family.
33
34       Addrtypeof returns the address type of an address, normally AF_INET  or
35       AF_INET6.  (The <freeswan.h> header file arranges to include the neces‐
36       sary headers for these names to be known.)
37
38       Addrlenof returns  the  size  (in  bytes)  of  the  address  within  an
39       ip_address, to permit storage allocation etc.
40
41       Addrbytesof  copies the address within the ip_address src to the buffer
42       indicated by the pointer dst and the length  dstlen,  and  returns  the
43       address  length (in bytes).  If the address will not fit, as many bytes
44       as will fit are copied; the returned length is still the  full  length.
45       It is the caller's responsibility to check the returned value to ensure
46       that there was enough room.
47
48       Addrbytesptr sets *dst to a pointer to the internal address within  the
49       ip_address, and returns the address length (in bytes).  If dst is NULL,
50       it just returns the address length.  The pointer  points  to  const  to
51       discourage misuse.
52
53       Initaddr  returns  NULL  for  success and a pointer to a string-literal
54       error message for failure; see DIAGNOSTICS.
55
56       The functions which return size_t return 0 for a failure.
57

SEE ALSO

59       inet(3), ipsec_ttoaddr(3)
60

DIAGNOSTICS

62       An unknown address family is a fatal error for any of  these  functions
63       except  addrtypeof.  An address-size mismatch is a fatal error for ini‐
64       taddr.
65

HISTORY

67       Written for the FreeS/WAN project by Henry Spencer.
68

BUGS

70       Addrtypeof should probably have been named addrfamilyof.
71
72
73
74                                 11 Sept 2000                IPSEC_INITADDR(3)
Impressum