1 .TH IPSEC_RANGETOSUBNET 3 "8 Sept 2000"
2 .\" RCSID $Id: rangetosubnet.3,v 1.1 2004/03/15 20:35:26 as Exp $
4 ipsec rangetosubnet \- convert address range to subnet
6 .B "#include <freeswan.h>"
8 .B "const char *rangetosubnet(const ip_address *start,"
10 .B "const ip_address *stop, ip_subnet *dst);"
13 accepts two IP addresses which define an address range,
19 and converts this to a subnet if possible.
20 The addresses must both be IPv4 or both be IPv6,
21 and the address family of the resulting subnet is the same.
24 returns NULL for success and
25 a pointer to a string-literal error message for failure;
28 ipsec_initsubnet(3), ipsec_ttosubnet(3)
33 mixed address families;
34 unknown address family;
38 do not define a subnet.
40 Written for the FreeS/WAN project by Henry Spencer.
42 The restriction of error reports to literal strings
43 (so that callers don't need to worry about freeing them or copying them)
44 does limit the precision of error reporting.
46 The error-reporting convention lends itself
47 to slightly obscure code,
48 because many readers will not think of NULL as signifying success.
49 A good way to make it clearer is to write something like:
53 .B "const char *error;"
55 .B "error = rangetosubnet( /* ... */ );"
56 .B "if (error != NULL) {"
57 .B " /* something went wrong */"