1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
4
<!-- lifted from troff+man by doclifter -->
7
<refentrytitle>IPSEC_RANGETOSUBNET</refentrytitle>
8
<manvolnum>3</manvolnum>
9
<refmiscinfo class='date'>8 Sept 2000</refmiscinfo>
11
<refnamediv id='name'>
12
<refname>ipsec rangetosubnet</refname>
13
<refpurpose>convert address range to subnet</refpurpose>
15
<!-- body begins here -->
16
<refsynopsisdiv id='synopsis'>
19
#include <freeswan.h>
23
<funcdef>const char *<function>rangetosubnet</function></funcdef>
24
<paramdef>const ip_address * <parameter>start</parameter></paramdef>
25
<paramdef>const ip_address * <parameter>stop</parameter></paramdef>
26
<paramdef>ip_subnet * <parameter>dst</parameter></paramdef>
32
<refsect1 id='description'><title>DESCRIPTION</title>
33
<para><emphasis remap='I'>Rangetosubnet</emphasis>
34
accepts two IP addresses which define an address range,
36
<varname role='parameter'>start</varname>
38
<varname role='parameter'>stop</varname>
40
and converts this to a subnet if possible.
41
The addresses must both be IPv4 or both be IPv6,
42
and the address family of the resulting subnet is the same.</para>
44
<para><emphasis remap='I'>Rangetosubnet</emphasis>
45
returns NULL for success and
46
a pointer to a string-literal error message for failure;
47
see DIAGNOSTICS.</para>
50
<refsect1 id='see_also'><title>SEE ALSO</title>
51
<para><citerefentry><refentrytitle>ipsec_initsubnet</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>ipsec_ttosubnet</refentrytitle><manvolnum>3</manvolnum></citerefentry></para>
54
<refsect1 id='diagnostics'><title>DIAGNOSTICS</title>
56
<function>rangetosubnet</function>
58
mixed address families;
59
unknown address family;
60
<varname role='parameter'>start</varname>
62
<varname role='parameter'>stop</varname>
63
do not define a subnet.</para>
66
<refsect1 id='history'><title>HISTORY</title>
67
<para>Written for the FreeS/WAN project by Henry Spencer.</para>
70
<refsect1 id='bugs'><title>BUGS</title>
71
<para>The restriction of error reports to literal strings
72
(so that callers don't need to worry about freeing them or copying them)
73
does limit the precision of error reporting.</para>
75
<para>The error-reporting convention lends itself
76
to slightly obscure code,
77
because many readers will not think of NULL as signifying success.
78
A good way to make it clearer is to write something like:</para>
81
<literallayout remap='.nf'>
82
<emphasis remap='B'>const char *error;</emphasis>
84
<emphasis remap='B'>error = rangetosubnet( /* ... */ );</emphasis>
85
<emphasis remap='B'>if (error != NULL) {</emphasis>
86
<emphasis remap='B'> /* something went wrong */</emphasis>
87
</literallayout> <!-- .fi -->