1IPSEC_RANGETOSUBNET(3) Library Functions Manual IPSEC_RANGETOSUBNET(3)
2
3
4
6 ipsec rangetosubnet - convert address range to subnet
7
9 #include <freeswan.h>
10
11 const char *rangetosubnet(const ip_address *start,
12 const ip_address *stop, ip_subnet *dst);
13
15 Rangetosubnet accepts two IP addresses which define an address range,
16 from start to stop inclusive, and converts this to a subnet if possi‐
17 ble. The addresses must both be IPv4 or both be IPv6, and the address
18 family of the resulting subnet is the same.
19
20 Rangetosubnet returns NULL for success and a pointer to a string-lit‐
21 eral error message for failure; see DIAGNOSTICS.
22
24 ipsec_initsubnet(3), ipsec_ttosubnet(3)
25
27 Fatal errors in rangetosubnet are: mixed address families; unknown
28 address family; start and stop do not define a subnet.
29
31 Written for the FreeS/WAN project by Henry Spencer.
32
34 The restriction of error reports to literal strings (so that callers
35 don't need to worry about freeing them or copying them) does limit the
36 precision of error reporting.
37
38 The error-reporting convention lends itself to slightly obscure code,
39 because many readers will not think of NULL as signifying success. A
40 good way to make it clearer is to write something like:
41
42 const char *error;
43
44 error = rangetosubnet( /* ... */ );
45 if (error != NULL) {
46 /* something went wrong */
47
48
49
50 8 Sept 2000 IPSEC_RANGETOSUBNET(3)