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

NAME

6       ipsec atoasr - convert ASCII to Internet address, subnet, or range
7       ipsec rangetoa - convert Internet address range to ASCII
8

SYNOPSIS

10       #include <freeswan.h>
11
12       const char *atoasr(const char *src, size_t srclen,
13           char *type, struct in_addr *addrs);
14       size_t rangetoa(struct in_addr *addrs, int format,
15           char *dst, size_t dstlen);
16

DESCRIPTION

18       These  functions  are obsolete; there is no current equivalent, because
19       so far they have not proved useful.
20
21       Atoasr converts an ASCII address, subnet, or address range into a suit‐
22       able combination of binary addresses (in network byte order).  Rangetoa
23       converts an address range back into ASCII,  using  dotted-decimal  form
24       for  the  addresses  (the  other  reverse  conversions  are  handled by
25       ipsec_addrtoa(3) and ipsec_subnettoa(3)).
26
27       A single address can be any form acceptable to ipsec_atoaddr(3): dotted
28       decimal,  DNS name, or hexadecimal number.  A subnet specification uses
29       the form network/mask interpreted by ipsec_atosubnet(3).
30
31       An address range is two ipsec_atoaddr(3) addresses separated by  a  ...
32       delimiter.   If  there  are  four  dots rather than three, the first is
33       taken as part of the begin address, e.g. for a complete DNS name  which
34       ends  with  .  to suppress completion attempts.  The begin address of a
35       range must be less than or equal to the end address.
36
37       The srclen parameter of atoasr specifies the length of the ASCII string
38       pointed  to by src; it is an error for there to be anything else (e.g.,
39       a terminating NUL) within that length.   As  a  convenience  for  cases
40       where  an  entire  NUL-terminated  string  is to be converted, a srclen
41       value of 0 is taken to mean strlen(src).
42
43       The type parameter of atoasr must point to  a  char  variable  used  to
44       record  which form was found.  The addrs parameter must point to a two-
45       element array of struct in_addr which receives the results.  The values
46       stored into *type, and the corresponding values in the array, are:
47
48                   *type   addrs[0]    addrs[1]
49
50       address     'a'     address     -
51       subnet      's'     network     mask
52       range       'r'     begin       end
53
54       The  dstlen parameter of rangetoa specifies the size of the dst parame‐
55       ter; under no circumstances are more than dstlen bytes written to  dst.
56       A result which will not fit is truncated.  Dstlen can be zero, in which
57       case dst need not be valid and no result is  written,  but  the  return
58       value  is  unaffected;  in  all  other  cases, the (possibly truncated)
59       result is NUL-terminated.  The freeswan.h header file  defines  a  con‐
60       stant,  RANGETOA_BUF,  which  is the size of a buffer just large enough
61       for worst-case results.
62
63       The format parameter of rangetoa specifies what format is  to  be  used
64       for  the  conversion.   The value 0 (not the ASCII character '0', but a
65       zero value) specifies a reasonable default, and is  in  fact  the  only
66       format  currently  available.  This parameter is a hedge against future
67       needs.
68
69       Atoasr returns NULL for success and a pointer to a string-literal error
70       message  for  failure; see DIAGNOSTICS.  Rangetoa returns 0 for a fail‐
71       ure, and otherwise always returns the size of  buffer  which  would  be
72       needed to accommodate the full conversion result, including terminating
73       NUL; it is the caller's responsibility to check this against  the  size
74       of the provided buffer to determine whether truncation has occurred.
75

SEE ALSO

77       ipsec_atoaddr(3), ipsec_atosubnet(3)
78

DIAGNOSTICS

80       Fatal  errors  in atoasr are: empty input; error in ipsec_atoaddr(3) or
81       ipsec_atosubnet(3) during conversion; begin address  of  range  exceeds
82       end address.
83
84       Fatal errors in rangetoa are: unknown format.
85

HISTORY

87       Written for the FreeS/WAN project by Henry Spencer.
88

BUGS

90       The  restriction  of  error reports to literal strings (so that callers
91       don't need to worry about freeing them or copying them) does limit  the
92       precision of error reporting.
93
94       The  error-reporting  convention lends itself to slightly obscure code,
95       because many readers will not think of NULL as signifying  success.   A
96       good way to make it clearer is to write something like:
97
98              const char *error;
99
100              error = atoasr( /* ... */ );
101              if (error != NULL) {
102                      /* something went wrong */
103
104
105
106                                 11 June 2001                  IPSEC_ATOASR(3)
Impressum