\section{IP filtering}

\subsection{Introduction}

\subsection{Make a new ip table}

\begin{verbatim}
ip_tables.insert_table = <table_name>
\end{verbatim}

Create a new empty table with the name 'table\_name', with the default
value returned being $0$.

There is currently no use of the generic ip tables commands.


\subsection{Add a new address block}

\begin{verbatim}
ip_tables.add_address = <table_name>, 10.0.0.0/8, <value>
\end{verbatim}

Set <value> for all addresses in the address block, overwriting prior
values.


\subsection{Add a new address block}

\begin{verbatim}
ip_tables.load = <table_name>, ~/foo.txt, <value>
\end{verbatim}

Set <value> for all addresses in the file 'foo.txt' separated by
newline, similar to 'add\_address'.


\subsection{Get value for address}

\begin{verbatim}
ip_tables.get = <table_name>, 10.10.10.10
\end{verbatim}

Returns the value set for an address, or the address block it belongs
to. The default is $0$.


\subsection{Size of data structures}

\begin{verbatim}
ip_tables.size_data = <table_name>
\end{verbatim}

Returns the size in bytes of all data structures for this table,
excluding the root class object itself. Note that the in-memory table
is dynamically consolidated, as such memory use will always be based
on actual fragmentation.

The table is a b-tree with 1024 nodes per branch.


\subsection{IPv4 filtering table}

\begin{verbatim}
ipv4_filter.add_address = 10.0.0.0/8, unwanted
ipv4_filter.add_address = 11.0.0.0/8, preferred
ipv4_filter.load = ~/filters.txt, unwanted
ipv4_filter.get = 10.10.10.10
ipv4_filter.size_data =
\end{verbatim}

The main ip filter, currently supporting 'unwanted' (do not allow
connections) and 'preferred' (currently used only in private code).



\subsection{Constants}

\begin{verbatim}
strings.ip_filter =
=>
{ "unwanted",  PeerInfo::flag_unwanted },
{ "preferred", PeerInfo::flag_preferred },
\end{verbatim}

Constants used by ipv4_filter values.
