2011-06-28 11:57:25 +00:00
|
|
|
.\" $OpenBSD: pf.4,v 1.62 2008/09/10 14:57:37 jmc Exp $
|
2004-02-28 16:52:45 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (C) 2001, Kjell Wooding. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. Neither the name of the project nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
2004-04-18 13:59:12 +00:00
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2012-09-18 11:07:19 +00:00
|
|
|
.Dd September 18 2012
|
2004-02-28 16:52:45 +00:00
|
|
|
.Dt PF 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm pf
|
|
|
|
.Nd packet filter
|
|
|
|
.Sh SYNOPSIS
|
2004-04-18 13:59:12 +00:00
|
|
|
.Cd "device pf"
|
2012-09-18 11:07:19 +00:00
|
|
|
.Cd "options PF_DEFAULT_TO_DROP"
|
2004-02-28 16:52:45 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
Packet filtering takes place in the kernel.
|
|
|
|
A pseudo-device,
|
|
|
|
.Pa /dev/pf ,
|
|
|
|
allows userland processes to control the
|
|
|
|
behavior of the packet filter through an
|
|
|
|
.Xr ioctl 2
|
|
|
|
interface.
|
|
|
|
There are commands to enable and disable the filter, load rulesets,
|
|
|
|
add and remove individual rules or state table entries,
|
|
|
|
and retrieve statistics.
|
|
|
|
The most commonly used functions are covered by
|
|
|
|
.Xr pfctl 8 .
|
|
|
|
.Pp
|
|
|
|
Manipulations like loading a ruleset that involve more than a single
|
2005-05-03 16:55:20 +00:00
|
|
|
.Xr ioctl 2
|
|
|
|
call require a so-called
|
|
|
|
.Em ticket ,
|
|
|
|
which prevents the occurrence of
|
2004-02-28 16:52:45 +00:00
|
|
|
multiple concurrent manipulations.
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Fields of
|
|
|
|
.Xr ioctl 2
|
|
|
|
parameter structures that refer to packet data (like
|
2004-02-28 16:52:45 +00:00
|
|
|
addresses and ports) are generally expected in network byte-order.
|
2005-05-03 16:55:20 +00:00
|
|
|
.Pp
|
|
|
|
Rules and address tables are contained in so-called
|
|
|
|
.Em anchors .
|
|
|
|
When servicing an
|
|
|
|
.Xr ioctl 2
|
|
|
|
request, if the anchor field of the argument structure is empty,
|
|
|
|
the kernel will use the default anchor (i.e., the main ruleset)
|
|
|
|
in operations.
|
|
|
|
Anchors are specified by name and may be nested, with components
|
|
|
|
separated by
|
|
|
|
.Sq /
|
|
|
|
characters, similar to how file system hierarchies are laid out.
|
|
|
|
The final component of the anchor path is the anchor under which
|
|
|
|
operations will be performed.
|
Merge the projects/pf/head branch, that was worked on for last six months,
into head. The most significant achievements in the new code:
o Fine grained locking, thus much better performance.
o Fixes to many problems in pf, that were specific to FreeBSD port.
New code doesn't have that many ifdefs and much less OpenBSDisms, thus
is more attractive to our developers.
Those interested in details, can browse through SVN log of the
projects/pf/head branch. And for reference, here is exact list of
revisions merged:
r232043, r232044, r232062, r232148, r232149, r232150, r232298, r232330,
r232332, r232340, r232386, r232390, r232391, r232605, r232655, r232656,
r232661, r232662, r232663, r232664, r232673, r232691, r233309, r233782,
r233829, r233830, r233834, r233835, r233836, r233865, r233866, r233868,
r233873, r234056, r234096, r234100, r234108, r234175, r234187, r234223,
r234271, r234272, r234282, r234307, r234309, r234382, r234384, r234456,
r234486, r234606, r234640, r234641, r234642, r234644, r234651, r235505,
r235506, r235535, r235605, r235606, r235826, r235991, r235993, r236168,
r236173, r236179, r236180, r236181, r236186, r236223, r236227, r236230,
r236252, r236254, r236298, r236299, r236300, r236301, r236397, r236398,
r236399, r236499, r236512, r236513, r236525, r236526, r236545, r236548,
r236553, r236554, r236556, r236557, r236561, r236570, r236630, r236672,
r236673, r236679, r236706, r236710, r236718, r237154, r237155, r237169,
r237314, r237363, r237364, r237368, r237369, r237376, r237440, r237442,
r237751, r237783, r237784, r237785, r237788, r237791, r238421, r238522,
r238523, r238524, r238525, r239173, r239186, r239644, r239652, r239661,
r239773, r240125, r240130, r240131, r240136, r240186, r240196, r240212.
I'd like to thank people who participated in early testing:
Tested by: Florian Smeets <flo freebsd.org>
Tested by: Chekaluk Vitaly <artemrts ukr.net>
Tested by: Ben Wilber <ben desync.com>
Tested by: Ian FREISLICH <ianf cloudseed.co.za>
2012-09-08 06:41:54 +00:00
|
|
|
.Sh SYSCTL VARIABLES AND LOADER TUNABLES
|
|
|
|
The following
|
|
|
|
.Xr loader 8
|
|
|
|
tunables are available.
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Va net.pf.states_hashsize
|
|
|
|
Size of hash tables that store states.
|
|
|
|
Should be power of 2.
|
|
|
|
Default value is 32768.
|
|
|
|
.It Va net.pf.source_nodes_hashsize
|
|
|
|
Size of hash table that store source nodes.
|
|
|
|
Should be power of 2.
|
|
|
|
Default value is 8192.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Read only
|
|
|
|
.Xr sysctl 8
|
|
|
|
variables with matching names are provided to obtain current values
|
|
|
|
at runtime.
|
2012-09-18 11:07:19 +00:00
|
|
|
.Sh KERNEL OPTIONS
|
|
|
|
The following options in the kernel configuration file are related to
|
|
|
|
.Nm
|
|
|
|
operation:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width ".Dv PF_DEFAULT_TO_DROP" -compact
|
|
|
|
.It Dv PF_DEFAULT_TO_DROP
|
|
|
|
Change default policy to drop by default
|
|
|
|
.El
|
2004-02-28 16:52:45 +00:00
|
|
|
.Sh IOCTL INTERFACE
|
2005-05-03 16:55:20 +00:00
|
|
|
.Nm
|
|
|
|
supports the following
|
2004-02-28 16:52:45 +00:00
|
|
|
.Xr ioctl 2
|
2005-05-03 16:55:20 +00:00
|
|
|
commands, available through
|
|
|
|
.Aq Pa net/pfvar.h :
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bl -tag -width xxxxxx
|
|
|
|
.It Dv DIOCSTART
|
2005-05-03 16:55:20 +00:00
|
|
|
Start the packet filter.
|
2004-02-28 16:52:45 +00:00
|
|
|
.It Dv DIOCSTOP
|
2005-05-03 16:55:20 +00:00
|
|
|
Stop the packet filter.
|
2004-02-28 16:52:45 +00:00
|
|
|
.It Dv DIOCSTARTALTQ
|
2005-05-03 16:55:20 +00:00
|
|
|
Start the ALTQ bandwidth control system (see
|
|
|
|
.Xr altq 9 ) .
|
2004-02-28 16:52:45 +00:00
|
|
|
.It Dv DIOCSTOPALTQ
|
2005-05-03 16:55:20 +00:00
|
|
|
Stop the ALTQ bandwidth control system.
|
|
|
|
.It Dv DIOCBEGINADDRS Fa "struct pfioc_pooladdr *pp"
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_pooladdr {
|
|
|
|
u_int32_t action;
|
|
|
|
u_int32_t ticket;
|
|
|
|
u_int32_t nr;
|
|
|
|
u_int32_t r_num;
|
|
|
|
u_int8_t r_action;
|
|
|
|
u_int8_t r_last;
|
|
|
|
u_int8_t af;
|
2005-05-03 16:55:20 +00:00
|
|
|
char anchor[MAXPATHLEN];
|
2004-02-28 16:52:45 +00:00
|
|
|
struct pf_pooladdr addr;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Clear the buffer address pool and get a
|
2004-06-16 23:39:33 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
for subsequent
|
|
|
|
.Dv DIOCADDADDR ,
|
|
|
|
.Dv DIOCADDRULE ,
|
|
|
|
and
|
|
|
|
.Dv DIOCCHANGERULE
|
|
|
|
calls.
|
|
|
|
.It Dv DIOCADDADDR Fa "struct pfioc_pooladdr *pp"
|
2004-06-16 23:39:33 +00:00
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Add the pool address
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va addr
|
|
|
|
to the buffer address pool to be used in the following
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv DIOCADDRULE
|
|
|
|
or
|
|
|
|
.Dv DIOCCHANGERULE
|
|
|
|
call.
|
2004-02-28 16:52:45 +00:00
|
|
|
All other members of the structure are ignored.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCADDRULE Fa "struct pfioc_rule *pr"
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_rule {
|
|
|
|
u_int32_t action;
|
|
|
|
u_int32_t ticket;
|
|
|
|
u_int32_t pool_ticket;
|
|
|
|
u_int32_t nr;
|
2005-05-03 16:55:20 +00:00
|
|
|
char anchor[MAXPATHLEN];
|
|
|
|
char anchor_call[MAXPATHLEN];
|
2004-02-28 16:52:45 +00:00
|
|
|
struct pf_rule rule;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Add
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va rule
|
|
|
|
at the end of the inactive ruleset.
|
2005-05-03 16:55:20 +00:00
|
|
|
This call requires a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
obtained through a preceding
|
|
|
|
.Dv DIOCXBEGIN
|
|
|
|
call and a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va pool_ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
obtained through a
|
|
|
|
.Dv DIOCBEGINADDRS
|
|
|
|
call.
|
|
|
|
.Dv DIOCADDADDR
|
|
|
|
must also be called if any pool addresses are required.
|
2004-02-28 16:52:45 +00:00
|
|
|
The optional
|
|
|
|
.Va anchor
|
2005-05-03 16:55:20 +00:00
|
|
|
name indicates the anchor in which to append the rule.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
|
|
|
and
|
|
|
|
.Va action
|
|
|
|
are ignored.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCADDALTQ Fa "struct pfioc_altq *pa"
|
|
|
|
Add an ALTQ discipline or queue.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_altq {
|
2004-06-16 23:39:33 +00:00
|
|
|
u_int32_t action;
|
2004-02-28 16:52:45 +00:00
|
|
|
u_int32_t ticket;
|
|
|
|
u_int32_t nr;
|
2005-05-03 16:55:20 +00:00
|
|
|
struct pf_altq altq;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETRULES Fa "struct pfioc_rule *pr"
|
|
|
|
Get a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
for subsequent
|
|
|
|
.Dv DIOCGETRULE
|
|
|
|
calls and the number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
|
|
|
of rules in the active ruleset.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETRULE Fa "struct pfioc_rule *pr"
|
|
|
|
Get a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va rule
|
2005-05-03 16:55:20 +00:00
|
|
|
by its number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
2005-05-03 16:55:20 +00:00
|
|
|
using the
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
obtained through a preceding
|
|
|
|
.Dv DIOCGETRULES
|
|
|
|
call.
|
2007-07-03 12:30:03 +00:00
|
|
|
If
|
|
|
|
.Va action
|
|
|
|
is set to
|
|
|
|
.Dv PF_GET_CLR_CNTR ,
|
|
|
|
the per-rule statistics on the requested rule are cleared.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETADDRS Fa "struct pfioc_pooladdr *pp"
|
|
|
|
Get a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
for subsequent
|
|
|
|
.Dv DIOCGETADDR
|
|
|
|
calls and the number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
|
|
|
of pool addresses in the rule specified with
|
|
|
|
.Va r_action ,
|
|
|
|
.Va r_num ,
|
|
|
|
and
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va anchor .
|
|
|
|
.It Dv DIOCGETADDR Fa "struct pfioc_pooladdr *pp"
|
|
|
|
Get the pool address
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va addr
|
2005-05-03 16:55:20 +00:00
|
|
|
by its number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
|
|
|
from the rule specified with
|
|
|
|
.Va r_action ,
|
|
|
|
.Va r_num ,
|
|
|
|
and
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va anchor
|
|
|
|
using the
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
obtained through a preceding
|
|
|
|
.Dv DIOCGETADDRS
|
|
|
|
call.
|
|
|
|
.It Dv DIOCGETALTQS Fa "struct pfioc_altq *pa"
|
|
|
|
Get a
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
for subsequent
|
|
|
|
.Dv DIOCGETALTQ
|
|
|
|
calls and the number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
|
|
|
of queues in the active list.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETALTQ Fa "struct pfioc_altq *pa"
|
|
|
|
Get the queueing discipline
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va altq
|
2005-05-03 16:55:20 +00:00
|
|
|
by its number
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
2005-05-03 16:55:20 +00:00
|
|
|
using the
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
obtained through a preceding
|
|
|
|
.Dv DIOCGETALTQS
|
|
|
|
call.
|
|
|
|
.It Dv DIOCGETQSTATS Fa "struct pfioc_qstats *pq"
|
|
|
|
Get the statistics on a queue.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_qstats {
|
|
|
|
u_int32_t ticket;
|
|
|
|
u_int32_t nr;
|
|
|
|
void *buf;
|
|
|
|
int nbytes;
|
|
|
|
u_int8_t scheduler;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
This call fills in a pointer to the buffer of statistics
|
|
|
|
.Va buf ,
|
2004-02-28 16:52:45 +00:00
|
|
|
of length
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va nbytes ,
|
2004-02-28 16:52:45 +00:00
|
|
|
for the queue specified by
|
|
|
|
.Va nr .
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETRULESETS Fa "struct pfioc_ruleset *pr"
|
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_ruleset {
|
|
|
|
u_int32_t nr;
|
|
|
|
char path[MAXPATHLEN];
|
|
|
|
char name[PF_ANCHOR_NAME_SIZE];
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Get the number
|
|
|
|
.Va nr
|
|
|
|
of rulesets (i.e., anchors) directly attached to the anchor named by
|
|
|
|
.Va path
|
|
|
|
for use in subsequent
|
|
|
|
.Dv DIOCGETRULESET
|
|
|
|
calls.
|
|
|
|
Nested anchors, since they are not directly attached to the given
|
|
|
|
anchor, will not be included.
|
|
|
|
This ioctl returns
|
|
|
|
.Er EINVAL
|
|
|
|
if the given anchor does not exist.
|
|
|
|
.It Dv DIOCGETRULESET Fa "struct pfioc_ruleset *pr"
|
|
|
|
Get a ruleset (i.e., an anchor)
|
|
|
|
.Va name
|
|
|
|
by its number
|
|
|
|
.Va nr
|
|
|
|
from the given anchor
|
|
|
|
.Va path ,
|
|
|
|
the maximum number of which can be obtained from a preceding
|
|
|
|
.Dv DIOCGETRULESETS
|
|
|
|
call.
|
|
|
|
This ioctl returns
|
|
|
|
.Er EINVAL
|
|
|
|
if the given anchor does not exist or
|
|
|
|
.Er EBUSY
|
|
|
|
if another process is concurrently updating a ruleset.
|
|
|
|
.It Dv DIOCADDSTATE Fa "struct pfioc_state *ps"
|
|
|
|
Add a state entry.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_state {
|
2008-12-10 20:59:26 +00:00
|
|
|
struct pfsync_state state;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETSTATE Fa "struct pfioc_state *ps"
|
2008-12-10 20:59:26 +00:00
|
|
|
Extract the entry identified by the
|
|
|
|
.Va id
|
|
|
|
and
|
|
|
|
.Va creatorid
|
|
|
|
fields of the
|
|
|
|
.Va state
|
|
|
|
structure from the state table.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCKILLSTATES Fa "struct pfioc_state_kill *psk"
|
|
|
|
Remove matching entries from the state table.
|
|
|
|
This ioctl returns the number of killed states in
|
2011-07-17 17:33:39 +00:00
|
|
|
.Va psk_killed .
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_state_kill {
|
2011-07-17 17:33:39 +00:00
|
|
|
struct pf_state_cmp psk_pfcmp;
|
2005-05-03 16:55:20 +00:00
|
|
|
sa_family_t psk_af;
|
2004-02-28 16:52:45 +00:00
|
|
|
int psk_proto;
|
|
|
|
struct pf_rule_addr psk_src;
|
|
|
|
struct pf_rule_addr psk_dst;
|
2004-06-16 23:39:33 +00:00
|
|
|
char psk_ifname[IFNAMSIZ];
|
2011-07-17 17:33:39 +00:00
|
|
|
char psk_label[PF_RULE_LABEL_SIZE];
|
|
|
|
u_int psk_killed;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCCLRSTATES Fa "struct pfioc_state_kill *psk"
|
|
|
|
Clear all states.
|
2004-06-16 23:39:33 +00:00
|
|
|
It works like
|
|
|
|
.Dv DIOCKILLSTATES ,
|
2005-05-03 16:55:20 +00:00
|
|
|
but ignores the
|
|
|
|
.Va psk_af ,
|
|
|
|
.Va psk_proto ,
|
|
|
|
.Va psk_src ,
|
|
|
|
and
|
|
|
|
.Va psk_dst
|
|
|
|
fields of the
|
|
|
|
.Vt pfioc_state_kill
|
2004-06-16 23:39:33 +00:00
|
|
|
structure.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCSETSTATUSIF Fa "struct pfioc_if *pi"
|
|
|
|
Specify the interface for which statistics are accumulated.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_if {
|
|
|
|
char ifname[IFNAMSIZ];
|
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETSTATUS Fa "struct pf_status *s"
|
|
|
|
Get the internal packet filter statistics.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pf_status {
|
2004-06-16 23:39:33 +00:00
|
|
|
u_int64_t counters[PFRES_MAX];
|
2005-05-03 16:55:20 +00:00
|
|
|
u_int64_t lcounters[LCNT_MAX];
|
2004-06-16 23:39:33 +00:00
|
|
|
u_int64_t fcounters[FCNT_MAX];
|
|
|
|
u_int64_t scounters[SCNT_MAX];
|
|
|
|
u_int64_t pcounters[2][2][3];
|
|
|
|
u_int64_t bcounters[2][2];
|
|
|
|
u_int32_t running;
|
|
|
|
u_int32_t states;
|
|
|
|
u_int32_t src_nodes;
|
|
|
|
u_int32_t since;
|
|
|
|
u_int32_t debug;
|
|
|
|
u_int32_t hostid;
|
|
|
|
char ifname[IFNAMSIZ];
|
2007-07-03 12:30:03 +00:00
|
|
|
u_int8_t pf_chksum[MD5_DIGEST_LENGTH];
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.It Dv DIOCCLRSTATUS
|
2005-05-03 16:55:20 +00:00
|
|
|
Clear the internal packet filter statistics.
|
|
|
|
.It Dv DIOCNATLOOK Fa "struct pfioc_natlook *pnl"
|
|
|
|
Look up a state table entry by source and destination addresses and ports.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_natlook {
|
|
|
|
struct pf_addr saddr;
|
|
|
|
struct pf_addr daddr;
|
|
|
|
struct pf_addr rsaddr;
|
|
|
|
struct pf_addr rdaddr;
|
|
|
|
u_int16_t sport;
|
|
|
|
u_int16_t dport;
|
|
|
|
u_int16_t rsport;
|
|
|
|
u_int16_t rdport;
|
2004-06-16 23:39:33 +00:00
|
|
|
sa_family_t af;
|
2004-02-28 16:52:45 +00:00
|
|
|
u_int8_t proto;
|
|
|
|
u_int8_t direction;
|
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCSETDEBUG Fa "u_int32_t *level"
|
|
|
|
Set the debug level.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
2005-05-03 16:55:20 +00:00
|
|
|
enum { PF_DEBUG_NONE, PF_DEBUG_URGENT, PF_DEBUG_MISC,
|
|
|
|
PF_DEBUG_NOISY };
|
2004-02-28 16:52:45 +00:00
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETSTATES Fa "struct pfioc_states *ps"
|
|
|
|
Get state table entries.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_states {
|
|
|
|
int ps_len;
|
|
|
|
union {
|
2005-05-03 16:55:20 +00:00
|
|
|
caddr_t psu_buf;
|
2004-02-28 16:52:45 +00:00
|
|
|
struct pf_state *psu_states;
|
|
|
|
} ps_u;
|
|
|
|
#define ps_buf ps_u.psu_buf
|
|
|
|
#define ps_states ps_u.psu_states
|
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Va ps_len
|
2007-07-03 12:30:03 +00:00
|
|
|
is non-zero on entry, as many states as possible that can fit into this
|
|
|
|
size will be copied into the supplied buffer
|
|
|
|
.Va ps_states .
|
|
|
|
On exit,
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va ps_len
|
2007-07-03 12:30:03 +00:00
|
|
|
is always set to the total size required to hold all state table entries
|
|
|
|
(i.e., it is set to
|
2005-05-03 16:55:20 +00:00
|
|
|
.Li sizeof(struct pf_state) * nr ) .
|
|
|
|
.It Dv DIOCCHANGERULE Fa "struct pfioc_rule *pcr"
|
|
|
|
Add or remove the
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va rule
|
|
|
|
in the ruleset specified by
|
|
|
|
.Va rule.action .
|
|
|
|
.Pp
|
|
|
|
The type of operation to be performed is indicated by
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va action ,
|
|
|
|
which can be any of the following:
|
|
|
|
.Bd -literal
|
|
|
|
enum { PF_CHANGE_NONE, PF_CHANGE_ADD_HEAD, PF_CHANGE_ADD_TAIL,
|
|
|
|
PF_CHANGE_ADD_BEFORE, PF_CHANGE_ADD_AFTER,
|
|
|
|
PF_CHANGE_REMOVE, PF_CHANGE_GET_TICKET };
|
|
|
|
.Ed
|
2004-02-28 16:52:45 +00:00
|
|
|
.Pp
|
|
|
|
.Va ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
must be set to the value obtained with
|
|
|
|
.Dv PF_CHANGE_GET_TICKET
|
|
|
|
for all actions except
|
|
|
|
.Dv PF_CHANGE_GET_TICKET .
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va pool_ticket
|
2005-05-03 16:55:20 +00:00
|
|
|
must be set to the value obtained with the
|
|
|
|
.Dv DIOCBEGINADDRS
|
|
|
|
call for all actions except
|
|
|
|
.Dv PF_CHANGE_REMOVE
|
2004-02-28 16:52:45 +00:00
|
|
|
and
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv PF_CHANGE_GET_TICKET .
|
|
|
|
.Va anchor
|
|
|
|
indicates to which anchor the operation applies.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va nr
|
2005-05-03 16:55:20 +00:00
|
|
|
indicates the rule number against which
|
|
|
|
.Dv PF_CHANGE_ADD_BEFORE ,
|
|
|
|
.Dv PF_CHANGE_ADD_AFTER ,
|
|
|
|
or
|
|
|
|
.Dv PF_CHANGE_REMOVE
|
|
|
|
actions are applied.
|
|
|
|
.\" It Dv DIOCCHANGEALTQ Fa "struct pfioc_altq *pcr"
|
|
|
|
.It Dv DIOCCHANGEADDR Fa "struct pfioc_pooladdr *pca"
|
|
|
|
Add or remove the pool address
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va addr
|
2005-05-03 16:55:20 +00:00
|
|
|
from the rule specified by
|
2004-02-28 16:52:45 +00:00
|
|
|
.Va r_action ,
|
|
|
|
.Va r_num ,
|
|
|
|
and
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va anchor .
|
|
|
|
.It Dv DIOCSETTIMEOUT Fa "struct pfioc_tm *pt"
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_tm {
|
|
|
|
int timeout;
|
|
|
|
int seconds;
|
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.Pp
|
|
|
|
Set the state timeout of
|
|
|
|
.Va timeout
|
|
|
|
to
|
|
|
|
.Va seconds .
|
|
|
|
The old value will be placed into
|
|
|
|
.Va seconds .
|
|
|
|
For possible values of
|
|
|
|
.Va timeout ,
|
|
|
|
consult the
|
|
|
|
.Dv PFTM_*
|
|
|
|
values in
|
|
|
|
.Aq Pa net/pfvar.h .
|
|
|
|
.It Dv DIOCGETTIMEOUT Fa "struct pfioc_tm *pt"
|
|
|
|
Get the state timeout of
|
|
|
|
.Va timeout .
|
|
|
|
The value will be placed into the
|
|
|
|
.Va seconds
|
|
|
|
field.
|
2004-02-28 16:52:45 +00:00
|
|
|
.It Dv DIOCCLRRULECTRS
|
|
|
|
Clear per-rule statistics.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCSETLIMIT Fa "struct pfioc_limit *pl"
|
|
|
|
Set the hard limits on the memory pools used by the packet filter.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_limit {
|
|
|
|
int index;
|
|
|
|
unsigned limit;
|
|
|
|
};
|
2005-05-03 16:55:20 +00:00
|
|
|
|
2007-07-03 12:30:03 +00:00
|
|
|
enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,
|
Merge the projects/pf/head branch, that was worked on for last six months,
into head. The most significant achievements in the new code:
o Fine grained locking, thus much better performance.
o Fixes to many problems in pf, that were specific to FreeBSD port.
New code doesn't have that many ifdefs and much less OpenBSDisms, thus
is more attractive to our developers.
Those interested in details, can browse through SVN log of the
projects/pf/head branch. And for reference, here is exact list of
revisions merged:
r232043, r232044, r232062, r232148, r232149, r232150, r232298, r232330,
r232332, r232340, r232386, r232390, r232391, r232605, r232655, r232656,
r232661, r232662, r232663, r232664, r232673, r232691, r233309, r233782,
r233829, r233830, r233834, r233835, r233836, r233865, r233866, r233868,
r233873, r234056, r234096, r234100, r234108, r234175, r234187, r234223,
r234271, r234272, r234282, r234307, r234309, r234382, r234384, r234456,
r234486, r234606, r234640, r234641, r234642, r234644, r234651, r235505,
r235506, r235535, r235605, r235606, r235826, r235991, r235993, r236168,
r236173, r236179, r236180, r236181, r236186, r236223, r236227, r236230,
r236252, r236254, r236298, r236299, r236300, r236301, r236397, r236398,
r236399, r236499, r236512, r236513, r236525, r236526, r236545, r236548,
r236553, r236554, r236556, r236557, r236561, r236570, r236630, r236672,
r236673, r236679, r236706, r236710, r236718, r237154, r237155, r237169,
r237314, r237363, r237364, r237368, r237369, r237376, r237440, r237442,
r237751, r237783, r237784, r237785, r237788, r237791, r238421, r238522,
r238523, r238524, r238525, r239173, r239186, r239644, r239652, r239661,
r239773, r240125, r240130, r240131, r240136, r240186, r240196, r240212.
I'd like to thank people who participated in early testing:
Tested by: Florian Smeets <flo freebsd.org>
Tested by: Chekaluk Vitaly <artemrts ukr.net>
Tested by: Ben Wilber <ben desync.com>
Tested by: Ian FREISLICH <ianf cloudseed.co.za>
2012-09-08 06:41:54 +00:00
|
|
|
PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX };
|
2004-02-28 16:52:45 +00:00
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCGETLIMIT Fa "struct pfioc_limit *pl"
|
|
|
|
Get the hard
|
|
|
|
.Va limit
|
|
|
|
for the memory pool indicated by
|
|
|
|
.Va index .
|
|
|
|
.It Dv DIOCRCLRTABLES Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Clear all tables.
|
2005-05-03 16:55:20 +00:00
|
|
|
All the ioctls that manipulate radix tables
|
2004-02-28 16:52:45 +00:00
|
|
|
use the same structure described below.
|
|
|
|
For
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv DIOCRCLRTABLES ,
|
|
|
|
.Va pfrio_ndel
|
|
|
|
contains on exit the number of tables deleted.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_table {
|
2005-05-03 16:55:20 +00:00
|
|
|
struct pfr_table pfrio_table;
|
|
|
|
void *pfrio_buffer;
|
|
|
|
int pfrio_esize;
|
|
|
|
int pfrio_size;
|
|
|
|
int pfrio_size2;
|
|
|
|
int pfrio_nadd;
|
|
|
|
int pfrio_ndel;
|
|
|
|
int pfrio_nchange;
|
|
|
|
int pfrio_flags;
|
|
|
|
u_int32_t pfrio_ticket;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
#define pfrio_exists pfrio_nadd
|
|
|
|
#define pfrio_nzero pfrio_nadd
|
|
|
|
#define pfrio_nmatch pfrio_nadd
|
|
|
|
#define pfrio_naddr pfrio_size2
|
|
|
|
#define pfrio_setflag pfrio_size2
|
|
|
|
#define pfrio_clrflag pfrio_nadd
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRADDTABLES Fa "struct pfioc_table *io"
|
|
|
|
Create one or more tables.
|
|
|
|
On entry,
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_table
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_table .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_nadd
|
|
|
|
contains the number of tables effectively created.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfr_table {
|
2005-05-03 16:55:20 +00:00
|
|
|
char pfrt_anchor[MAXPATHLEN];
|
|
|
|
char pfrt_name[PF_TABLE_NAME_SIZE];
|
|
|
|
u_int32_t pfrt_flags;
|
|
|
|
u_int8_t pfrt_fback;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRDELTABLES Fa "struct pfioc_table *io"
|
|
|
|
Delete one or more tables.
|
|
|
|
On entry,
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_table
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_table .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_ndel
|
2005-05-03 16:55:20 +00:00
|
|
|
contains the number of tables effectively deleted.
|
|
|
|
.It Dv DIOCRGETTABLES Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Get the list of all tables.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_buffer[pfrio_size]
|
|
|
|
contains a valid writeable buffer for
|
|
|
|
.Vt pfr_table
|
|
|
|
structures.
|
|
|
|
On exit,
|
|
|
|
.Va pfrio_size
|
|
|
|
contains the number of tables written into the buffer.
|
2004-02-28 16:52:45 +00:00
|
|
|
If the buffer is too small, the kernel does not store anything but just
|
|
|
|
returns the required buffer size, without error.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRGETTSTATS Fa "struct pfioc_table *io"
|
|
|
|
This call is like
|
|
|
|
.Dv DIOCRGETTABLES
|
|
|
|
but is used to get an array of
|
|
|
|
.Vt pfr_tstats
|
|
|
|
structures.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfr_tstats {
|
2005-05-03 16:55:20 +00:00
|
|
|
struct pfr_table pfrts_t;
|
|
|
|
u_int64_t pfrts_packets
|
|
|
|
[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
|
|
|
|
u_int64_t pfrts_bytes
|
|
|
|
[PFR_DIR_MAX][PFR_OP_TABLE_MAX];
|
|
|
|
u_int64_t pfrts_match;
|
|
|
|
u_int64_t pfrts_nomatch;
|
|
|
|
long pfrts_tzero;
|
|
|
|
int pfrts_cnt;
|
|
|
|
int pfrts_refcnt[PFR_REFCNT_MAX];
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
2005-05-03 16:55:20 +00:00
|
|
|
#define pfrts_name pfrts_t.pfrt_name
|
|
|
|
#define pfrts_flags pfrts_t.pfrt_flags
|
2004-02-28 16:52:45 +00:00
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRCLRTSTATS Fa "struct pfioc_table *io"
|
|
|
|
Clear the statistics of one or more tables.
|
|
|
|
On entry,
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_table
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_table .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_nzero
|
|
|
|
contains the number of tables effectively cleared.
|
|
|
|
.It Dv DIOCRCLRADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Clear all addresses in a table.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table to clear.
|
|
|
|
On exit,
|
|
|
|
.Va pfrio_ndel
|
|
|
|
contains the number of addresses removed.
|
|
|
|
.It Dv DIOCRADDADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Add one or more addresses to a table.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_addr
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements to add to the table.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_addr .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_nadd
|
|
|
|
contains the number of addresses effectively added.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfr_addr {
|
2005-05-03 16:55:20 +00:00
|
|
|
union {
|
|
|
|
struct in_addr _pfra_ip4addr;
|
|
|
|
struct in6_addr _pfra_ip6addr;
|
|
|
|
} pfra_u;
|
|
|
|
u_int8_t pfra_af;
|
|
|
|
u_int8_t pfra_net;
|
|
|
|
u_int8_t pfra_not;
|
|
|
|
u_int8_t pfra_fback;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
#define pfra_ip4addr pfra_u._pfra_ip4addr
|
|
|
|
#define pfra_ip6addr pfra_u._pfra_ip6addr
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRDELADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Delete one or more addresses from a table.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_addr
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements to delete from the table.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_addr .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_ndel
|
|
|
|
contains the number of addresses effectively deleted.
|
|
|
|
.It Dv DIOCRSETADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Replace the content of a table by a new address list.
|
|
|
|
This is the most complicated command, which uses all the structure members.
|
2005-05-03 16:55:20 +00:00
|
|
|
.Pp
|
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_addr
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements which become the new contents of the table.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_addr .
|
2005-05-03 16:55:20 +00:00
|
|
|
Additionally, if
|
|
|
|
.Va pfrio_size2
|
|
|
|
is non-zero,
|
|
|
|
.Va pfrio_buffer[pfrio_size..pfrio_size2]
|
|
|
|
must be a writeable buffer, into which the kernel can copy the
|
|
|
|
addresses that have been deleted during the replace operation.
|
|
|
|
On exit,
|
|
|
|
.Va pfrio_ndel ,
|
|
|
|
.Va pfrio_nadd ,
|
|
|
|
and
|
|
|
|
.Va pfrio_nchange
|
|
|
|
contain the number of addresses deleted, added, and changed by the
|
|
|
|
kernel.
|
|
|
|
If
|
|
|
|
.Va pfrio_size2
|
|
|
|
was set on entry,
|
|
|
|
.Va pfrio_size2
|
|
|
|
will point to the size of the buffer used, exactly like
|
2004-02-28 16:52:45 +00:00
|
|
|
.Dv DIOCRGETADDRS .
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRGETADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Get all the addresses of a table.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
|
|
|
.Va pfrio_buffer[pfrio_size]
|
|
|
|
contains a valid writeable buffer for
|
|
|
|
.Vt pfr_addr
|
|
|
|
structures.
|
|
|
|
On exit,
|
|
|
|
.Va pfrio_size
|
|
|
|
contains the number of addresses written into the buffer.
|
2004-02-28 16:52:45 +00:00
|
|
|
If the buffer was too small, the kernel does not store anything but just
|
2005-05-03 16:55:20 +00:00
|
|
|
returns the required buffer size, without returning an error.
|
|
|
|
.It Dv DIOCRGETASTATS Fa "struct pfioc_table *io"
|
|
|
|
This call is like
|
|
|
|
.Dv DIOCRGETADDRS
|
|
|
|
but is used to get an array of
|
|
|
|
.Vt pfr_astats
|
|
|
|
structures.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfr_astats {
|
2005-05-03 16:55:20 +00:00
|
|
|
struct pfr_addr pfras_a;
|
|
|
|
u_int64_t pfras_packets
|
|
|
|
[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
|
|
|
|
u_int64_t pfras_bytes
|
|
|
|
[PFR_DIR_MAX][PFR_OP_ADDR_MAX];
|
|
|
|
long pfras_tzero;
|
2004-02-28 16:52:45 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRCLRASTATS Fa "struct pfioc_table *io"
|
|
|
|
Clear the statistics of one or more addresses.
|
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_addr
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements to be cleared from the table.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_addr .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_nzero
|
|
|
|
contains the number of addresses effectively cleared.
|
|
|
|
.It Dv DIOCRTSTADDRS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Test if the given addresses match a table.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_addr
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements, each of which will be tested for a match in the table.
|
|
|
|
.Vt pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_addr .
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit, the kernel updates the
|
|
|
|
.Vt pfr_addr
|
2007-07-03 12:30:03 +00:00
|
|
|
array by setting the
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va pfra_fback
|
2004-02-28 16:52:45 +00:00
|
|
|
member appropriately.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRSETTFLAGS Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Change the
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv PFR_TFLAG_CONST
|
2004-02-28 16:52:45 +00:00
|
|
|
or
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv PFR_TFLAG_PERSIST
|
|
|
|
flags of a table.
|
|
|
|
On entry,
|
2007-07-03 12:30:03 +00:00
|
|
|
.Va pfrio_buffer
|
|
|
|
must point to an array of
|
|
|
|
.Vt struct pfr_table
|
|
|
|
containing at least
|
|
|
|
.Vt pfrio_size
|
|
|
|
elements.
|
|
|
|
.Va pfrio_esize
|
|
|
|
must be the size of
|
|
|
|
.Vt struct pfr_table .
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va pfrio_setflag
|
2007-07-03 12:30:03 +00:00
|
|
|
must contain the flags to add, while
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va pfrio_clrflag
|
2007-07-03 12:30:03 +00:00
|
|
|
must contain the flags to remove.
|
2005-05-03 16:55:20 +00:00
|
|
|
On exit,
|
|
|
|
.Va pfrio_nchange
|
|
|
|
and
|
|
|
|
.Va pfrio_ndel
|
|
|
|
contain the number of tables altered or deleted by the kernel.
|
2004-02-28 16:52:45 +00:00
|
|
|
Yes, tables can be deleted if one removes the
|
2005-05-03 16:55:20 +00:00
|
|
|
.Dv PFR_TFLAG_PERSIST
|
2004-02-28 16:52:45 +00:00
|
|
|
flag of an unreferenced table.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCRINADEFINE Fa "struct pfioc_table *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Defines a table in the inactive set.
|
2005-05-03 16:55:20 +00:00
|
|
|
On entry,
|
|
|
|
.Va pfrio_table
|
|
|
|
contains the table ID and
|
|
|
|
.Va pfrio_buffer[pfrio_size]
|
2007-07-03 12:30:03 +00:00
|
|
|
contains an array of
|
2005-05-03 16:55:20 +00:00
|
|
|
.Vt pfr_addr
|
|
|
|
structures to put in the table.
|
|
|
|
A valid ticket must also be supplied to
|
|
|
|
.Va pfrio_ticket .
|
|
|
|
On exit,
|
|
|
|
.Va pfrio_nadd
|
|
|
|
contains 0 if the table was already defined in the inactive list
|
|
|
|
or 1 if a new table has been created.
|
|
|
|
.Va pfrio_naddr
|
|
|
|
contains the number of addresses effectively put in the table.
|
|
|
|
.It Dv DIOCXBEGIN Fa "struct pfioc_trans *io"
|
2004-06-16 23:39:33 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_trans {
|
2005-05-03 16:55:20 +00:00
|
|
|
int size; /* number of elements */
|
|
|
|
int esize; /* size of each element in bytes */
|
|
|
|
struct pfioc_trans_e {
|
|
|
|
int rs_num;
|
|
|
|
char anchor[MAXPATHLEN];
|
|
|
|
u_int32_t ticket;
|
|
|
|
} *array;
|
2004-06-16 23:39:33 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Clear all the inactive rulesets specified in the
|
|
|
|
.Vt pfioc_trans_e
|
2004-06-16 23:39:33 +00:00
|
|
|
array.
|
2005-05-03 16:55:20 +00:00
|
|
|
For each ruleset, a ticket is returned for subsequent "add rule" ioctls,
|
2004-06-16 23:39:33 +00:00
|
|
|
as well as for the
|
|
|
|
.Dv DIOCXCOMMIT
|
|
|
|
and
|
|
|
|
.Dv DIOCXROLLBACK
|
|
|
|
calls.
|
2005-05-03 16:55:20 +00:00
|
|
|
.Pp
|
|
|
|
Ruleset types, identified by
|
|
|
|
.Va rs_num ,
|
|
|
|
include the following:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width PF_RULESET_FILTER -offset ind -compact
|
|
|
|
.It Dv PF_RULESET_SCRUB
|
|
|
|
Scrub (packet normalization) rules.
|
|
|
|
.It Dv PF_RULESET_FILTER
|
|
|
|
Filter rules.
|
|
|
|
.It Dv PF_RULESET_NAT
|
|
|
|
NAT (Network Address Translation) rules.
|
|
|
|
.It Dv PF_RULESET_BINAT
|
|
|
|
Bidirectional NAT rules.
|
|
|
|
.It Dv PF_RULESET_RDR
|
|
|
|
Redirect rules.
|
|
|
|
.It Dv PF_RULESET_ALTQ
|
|
|
|
ALTQ disciplines.
|
|
|
|
.It Dv PF_RULESET_TABLE
|
|
|
|
Address tables.
|
|
|
|
.El
|
|
|
|
.It Dv DIOCXCOMMIT Fa "struct pfioc_trans *io"
|
2004-06-16 23:39:33 +00:00
|
|
|
Atomically switch a vector of inactive rulesets to the active rulesets.
|
2005-05-03 16:55:20 +00:00
|
|
|
This call is implemented as a standard two-phase commit, which will either
|
|
|
|
fail for all rulesets or completely succeed.
|
2004-06-16 23:39:33 +00:00
|
|
|
All tickets need to be valid.
|
2005-05-03 16:55:20 +00:00
|
|
|
This ioctl returns
|
|
|
|
.Er EBUSY
|
|
|
|
if another process is concurrently updating some of the same rulesets.
|
|
|
|
.It Dv DIOCXROLLBACK Fa "struct pfioc_trans *io"
|
2004-06-16 23:39:33 +00:00
|
|
|
Clean up the kernel by undoing all changes that have taken place on the
|
|
|
|
inactive rulesets since the last
|
|
|
|
.Dv DIOCXBEGIN .
|
|
|
|
.Dv DIOCXROLLBACK
|
|
|
|
will silently ignore rulesets for which the ticket is invalid.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCSETHOSTID Fa "u_int32_t *hostid"
|
|
|
|
Set the host ID, which is used by
|
|
|
|
.Xr pfsync 4
|
|
|
|
to identify which host created state table entries.
|
|
|
|
.It Dv DIOCOSFPFLUSH
|
2004-02-28 16:52:45 +00:00
|
|
|
Flush the passive OS fingerprint table.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCOSFPADD Fa "struct pf_osfp_ioctl *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pf_osfp_ioctl {
|
|
|
|
struct pf_osfp_entry {
|
|
|
|
SLIST_ENTRY(pf_osfp_entry) fp_entry;
|
|
|
|
pf_osfp_t fp_os;
|
|
|
|
char fp_class_nm[PF_OSFP_LEN];
|
|
|
|
char fp_version_nm[PF_OSFP_LEN];
|
|
|
|
char fp_subtype_nm[PF_OSFP_LEN];
|
|
|
|
} fp_os;
|
2005-05-03 16:55:20 +00:00
|
|
|
pf_tcpopts_t fp_tcpopts;
|
2004-02-28 16:52:45 +00:00
|
|
|
u_int16_t fp_wsize;
|
|
|
|
u_int16_t fp_psize;
|
2005-05-03 16:55:20 +00:00
|
|
|
u_int16_t fp_mss;
|
|
|
|
u_int16_t fp_flags;
|
|
|
|
u_int8_t fp_optcnt;
|
2004-02-28 16:52:45 +00:00
|
|
|
u_int8_t fp_wscale;
|
2005-05-03 16:55:20 +00:00
|
|
|
u_int8_t fp_ttl;
|
2004-02-28 16:52:45 +00:00
|
|
|
int fp_getnum;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Add a passive OS fingerprint to the table.
|
|
|
|
Set
|
|
|
|
.Va fp_os.fp_os
|
|
|
|
to the packed fingerprint,
|
|
|
|
.Va fp_os.fp_class_nm
|
|
|
|
to the name of the class (Linux, Windows, etc),
|
|
|
|
.Va fp_os.fp_version_nm
|
|
|
|
to the name of the version (NT, 95, 98), and
|
|
|
|
.Va fp_os.fp_subtype_nm
|
|
|
|
to the name of the subtype or patchlevel.
|
|
|
|
The members
|
|
|
|
.Va fp_mss ,
|
|
|
|
.Va fp_wsize ,
|
|
|
|
.Va fp_psize ,
|
|
|
|
.Va fp_ttl ,
|
2005-05-03 16:55:20 +00:00
|
|
|
.Va fp_optcnt ,
|
2004-02-28 16:52:45 +00:00
|
|
|
and
|
|
|
|
.Va fp_wscale
|
2005-05-03 16:55:20 +00:00
|
|
|
are set to the TCP MSS, the TCP window size, the IP length, the IP TTL,
|
|
|
|
the number of TCP options, and the TCP window scaling constant of the
|
|
|
|
TCP SYN packet, respectively.
|
|
|
|
.Pp
|
2004-02-28 16:52:45 +00:00
|
|
|
The
|
|
|
|
.Va fp_flags
|
2005-05-03 16:55:20 +00:00
|
|
|
member is filled according to the
|
|
|
|
.Aq Pa net/pfvar.h
|
|
|
|
include file
|
|
|
|
.Dv PF_OSFP_*
|
|
|
|
defines.
|
|
|
|
The
|
|
|
|
.Va fp_tcpopts
|
|
|
|
member contains packed TCP options.
|
|
|
|
Each option uses
|
|
|
|
.Dv PF_OSFP_TCPOPT_BITS
|
|
|
|
bits in the packed value.
|
|
|
|
Options include any of
|
|
|
|
.Dv PF_OSFP_TCPOPT_NOP ,
|
|
|
|
.Dv PF_OSFP_TCPOPT_SACK ,
|
|
|
|
.Dv PF_OSFP_TCPOPT_WSCALE ,
|
|
|
|
.Dv PF_OSFP_TCPOPT_MSS ,
|
|
|
|
or
|
|
|
|
.Dv PF_OSFP_TCPOPT_TS .
|
|
|
|
.Pp
|
2004-02-28 16:52:45 +00:00
|
|
|
The
|
|
|
|
.Va fp_getnum
|
2005-05-03 16:55:20 +00:00
|
|
|
member is not used with this ioctl.
|
2004-02-28 16:52:45 +00:00
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
The structure's slack space must be zeroed for correct operation;
|
|
|
|
.Xr memset 3
|
2004-02-28 16:52:45 +00:00
|
|
|
the whole structure to zero before filling and sending to the kernel.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCOSFPGET Fa "struct pf_osfp_ioctl *io"
|
2004-02-28 16:52:45 +00:00
|
|
|
Get the passive OS fingerprint number
|
|
|
|
.Va fp_getnum
|
|
|
|
from the kernel's fingerprint list.
|
|
|
|
The rest of the structure members will come back filled.
|
|
|
|
Get the whole list by repeatedly incrementing the
|
|
|
|
.Va fp_getnum
|
2005-05-03 16:55:20 +00:00
|
|
|
number until the ioctl returns
|
|
|
|
.Er EBUSY .
|
|
|
|
.It Dv DIOCGETSRCNODES Fa "struct pfioc_src_nodes *psn"
|
2004-06-16 23:39:33 +00:00
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_src_nodes {
|
2005-05-03 16:55:20 +00:00
|
|
|
int psn_len;
|
|
|
|
union {
|
|
|
|
caddr_t psu_buf;
|
|
|
|
struct pf_src_node *psu_src_nodes;
|
|
|
|
} psn_u;
|
|
|
|
#define psn_buf psn_u.psu_buf
|
|
|
|
#define psn_src_nodes psn_u.psu_src_nodes
|
2004-06-16 23:39:33 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-05-03 16:55:20 +00:00
|
|
|
Get the list of source nodes kept by sticky addresses and source
|
|
|
|
tracking.
|
2004-06-16 23:39:33 +00:00
|
|
|
The ioctl must be called once with
|
|
|
|
.Va psn_len
|
|
|
|
set to 0.
|
|
|
|
If the ioctl returns without error,
|
|
|
|
.Va psn_len
|
|
|
|
will be set to the size of the buffer required to hold all the
|
|
|
|
.Va pf_src_node
|
|
|
|
structures held in the table.
|
|
|
|
A buffer of this size should then be allocated, and a pointer to this buffer
|
|
|
|
placed in
|
|
|
|
.Va psn_buf .
|
|
|
|
The ioctl must then be called again to fill this buffer with the actual
|
|
|
|
source node data.
|
2005-05-03 16:55:20 +00:00
|
|
|
After that call,
|
2004-06-16 23:39:33 +00:00
|
|
|
.Va psn_len
|
|
|
|
will be set to the length of the buffer actually used.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCCLRSRCNODES
|
2004-06-16 23:39:33 +00:00
|
|
|
Clear the tree of source tracking nodes.
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCIGETIFACES Fa "struct pfioc_iface *io"
|
|
|
|
Get the list of interfaces and interface drivers known to
|
2004-06-16 23:39:33 +00:00
|
|
|
.Nm .
|
2005-05-03 16:55:20 +00:00
|
|
|
All the ioctls that manipulate interfaces
|
2004-06-16 23:39:33 +00:00
|
|
|
use the same structure described below:
|
|
|
|
.Bd -literal
|
|
|
|
struct pfioc_iface {
|
2005-05-03 16:55:20 +00:00
|
|
|
char pfiio_name[IFNAMSIZ];
|
|
|
|
void *pfiio_buffer;
|
|
|
|
int pfiio_esize;
|
|
|
|
int pfiio_size;
|
|
|
|
int pfiio_nzero;
|
|
|
|
int pfiio_flags;
|
2004-06-16 23:39:33 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
If not empty,
|
|
|
|
.Va pfiio_name
|
|
|
|
can be used to restrict the search to a specific interface or driver.
|
|
|
|
.Va pfiio_buffer[pfiio_size]
|
|
|
|
is the user-supplied buffer for returning the data.
|
|
|
|
On entry,
|
|
|
|
.Va pfiio_size
|
2007-07-03 12:30:03 +00:00
|
|
|
contains the number of
|
|
|
|
.Vt pfi_kif
|
2004-06-16 23:39:33 +00:00
|
|
|
entries that can fit into the buffer.
|
|
|
|
The kernel will replace this value by the real number of entries it wants
|
|
|
|
to return.
|
|
|
|
.Va pfiio_esize
|
2005-05-03 16:55:20 +00:00
|
|
|
should be set to
|
2007-07-03 12:30:03 +00:00
|
|
|
.Li sizeof(struct pfi_kif) .
|
|
|
|
.Pp
|
2004-06-16 23:39:33 +00:00
|
|
|
The data is returned in the
|
2007-07-03 12:30:03 +00:00
|
|
|
.Vt pfi_kif
|
2004-06-16 23:39:33 +00:00
|
|
|
structure described below:
|
|
|
|
.Bd -literal
|
2007-07-03 12:30:03 +00:00
|
|
|
struct pfi_kif {
|
|
|
|
RB_ENTRY(pfi_kif) pfik_tree;
|
|
|
|
char pfik_name[IFNAMSIZ];
|
|
|
|
u_int64_t pfik_packets[2][2][2];
|
|
|
|
u_int64_t pfik_bytes[2][2][2];
|
|
|
|
u_int32_t pfik_tzero;
|
|
|
|
int pfik_flags;
|
|
|
|
struct pf_state_tree_lan_ext pfik_lan_ext;
|
|
|
|
struct pf_state_tree_ext_gwy pfik_ext_gwy;
|
|
|
|
TAILQ_ENTRY(pfi_kif) pfik_w_states;
|
|
|
|
void *pfik_ah_cookie;
|
|
|
|
struct ifnet *pfik_ifp;
|
|
|
|
struct ifg_group *pfik_group;
|
|
|
|
int pfik_states;
|
|
|
|
int pfik_rules;
|
|
|
|
TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs;
|
2004-06-16 23:39:33 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2005-05-03 16:55:20 +00:00
|
|
|
.It Dv DIOCSETIFFLAG Fa "struct pfioc_iface *io"
|
2007-07-03 12:30:03 +00:00
|
|
|
Set the user setable flags (described above) of the
|
|
|
|
.Nm
|
|
|
|
internal interface description.
|
2005-05-03 16:55:20 +00:00
|
|
|
The filtering process is the same as for
|
|
|
|
.Dv DIOCIGETIFACES .
|
|
|
|
.Bd -literal
|
2009-08-18 16:13:59 +00:00
|
|
|
#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */
|
2005-05-03 16:55:20 +00:00
|
|
|
.Ed
|
|
|
|
.It Dv DIOCCLRIFFLAG Fa "struct pfioc_iface *io"
|
|
|
|
Works as
|
|
|
|
.Dv DIOCSETIFFLAG
|
|
|
|
above but clears the flags.
|
2009-08-18 16:13:59 +00:00
|
|
|
.It Dv DIOCKILLSRCNODES Fa "struct pfioc_iface *io"
|
|
|
|
Explicitly remove source tracking nodes.
|
2005-05-03 16:55:20 +00:00
|
|
|
.El
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /dev/pf -compact
|
|
|
|
.It Pa /dev/pf
|
|
|
|
packet filtering device.
|
2004-02-28 16:52:45 +00:00
|
|
|
.El
|
|
|
|
.Sh EXAMPLES
|
2005-05-03 16:55:20 +00:00
|
|
|
The following example demonstrates how to use the
|
|
|
|
.Dv DIOCNATLOOK
|
|
|
|
command to find the internal host/port of a NATed connection:
|
2004-02-28 16:52:45 +00:00
|
|
|
.Bd -literal
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <net/pfvar.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
read_address(const char *s)
|
|
|
|
{
|
|
|
|
int a, b, c, d;
|
|
|
|
|
|
|
|
sscanf(s, "%i.%i.%i.%i", &a, &b, &c, &d);
|
|
|
|
return htonl(a << 24 | b << 16 | c << 8 | d);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_address(u_int32_t a)
|
|
|
|
{
|
|
|
|
a = ntohl(a);
|
|
|
|
printf("%d.%d.%d.%d", a >> 24 & 255, a >> 16 & 255,
|
|
|
|
a >> 8 & 255, a & 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct pfioc_natlook nl;
|
|
|
|
int dev;
|
|
|
|
|
|
|
|
if (argc != 5) {
|
|
|
|
printf("%s <gwy addr> <gwy port> <ext addr> <ext port>\\n",
|
|
|
|
argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev = open("/dev/pf", O_RDWR);
|
|
|
|
if (dev == -1)
|
|
|
|
err(1, "open(\\"/dev/pf\\") failed");
|
|
|
|
|
|
|
|
memset(&nl, 0, sizeof(struct pfioc_natlook));
|
|
|
|
nl.saddr.v4.s_addr = read_address(argv[1]);
|
|
|
|
nl.sport = htons(atoi(argv[2]));
|
|
|
|
nl.daddr.v4.s_addr = read_address(argv[3]);
|
|
|
|
nl.dport = htons(atoi(argv[4]));
|
|
|
|
nl.af = AF_INET;
|
|
|
|
nl.proto = IPPROTO_TCP;
|
|
|
|
nl.direction = PF_IN;
|
|
|
|
|
|
|
|
if (ioctl(dev, DIOCNATLOOK, &nl))
|
|
|
|
err(1, "DIOCNATLOOK");
|
|
|
|
|
|
|
|
printf("internal host ");
|
|
|
|
print_address(nl.rsaddr.v4.s_addr);
|
|
|
|
printf(":%u\\n", ntohs(nl.rsport));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr ioctl 2 ,
|
2005-02-07 11:46:36 +00:00
|
|
|
.Xr altq 4 ,
|
2005-09-28 08:11:15 +00:00
|
|
|
.Xr if_bridge 4 ,
|
2004-02-28 16:52:45 +00:00
|
|
|
.Xr pflog 4 ,
|
2009-08-18 16:13:59 +00:00
|
|
|
.Xr pflow 4 ,
|
2004-02-28 16:52:45 +00:00
|
|
|
.Xr pfsync 4 ,
|
2005-05-03 16:55:20 +00:00
|
|
|
.Xr pfctl 8 ,
|
|
|
|
.Xr altq 9
|
2004-02-28 16:52:45 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
packet filtering mechanism first appeared in
|
2011-07-07 23:17:56 +00:00
|
|
|
.Ox 3.0
|
|
|
|
and then
|
|
|
|
.Fx 5.2 .
|
|
|
|
.Pp
|
|
|
|
This implementation matches
|
|
|
|
.Ox 4.5 .
|