xref: /freebsd/share/man/man4/ng_ipfw.4 (revision 14cb4a2f664f2784a7915f5ec4813e12a55bdaa6)
114cb4a2fSGleb Smirnoff.\" Copyright (c) 2005 Gleb Smirnoff
214cb4a2fSGleb Smirnoff.\" All rights reserved.
314cb4a2fSGleb Smirnoff.\"
414cb4a2fSGleb Smirnoff.\" Redistribution and use in source and binary forms, with or without
514cb4a2fSGleb Smirnoff.\" modification, are permitted provided that the following conditions
614cb4a2fSGleb Smirnoff.\" are met:
714cb4a2fSGleb Smirnoff.\" 1. Redistributions of source code must retain the above copyright
814cb4a2fSGleb Smirnoff.\"    notice, this list of conditions and the following disclaimer.
914cb4a2fSGleb Smirnoff.\" 2. Redistributions in binary form must reproduce the above copyright
1014cb4a2fSGleb Smirnoff.\"    notice, this list of conditions and the following disclaimer in the
1114cb4a2fSGleb Smirnoff.\"    documentation and/or other materials provided with the distribution.
1214cb4a2fSGleb Smirnoff.\"
1314cb4a2fSGleb Smirnoff.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1414cb4a2fSGleb Smirnoff.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1514cb4a2fSGleb Smirnoff.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1614cb4a2fSGleb Smirnoff.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1714cb4a2fSGleb Smirnoff.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1814cb4a2fSGleb Smirnoff.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1914cb4a2fSGleb Smirnoff.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2014cb4a2fSGleb Smirnoff.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2114cb4a2fSGleb Smirnoff.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2214cb4a2fSGleb Smirnoff.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2314cb4a2fSGleb Smirnoff.\" SUCH DAMAGE.
2414cb4a2fSGleb Smirnoff.\"
2514cb4a2fSGleb Smirnoff.\" $FreeBSD$
2614cb4a2fSGleb Smirnoff.\"
2714cb4a2fSGleb Smirnoff.Dd February 5, 2005
2814cb4a2fSGleb Smirnoff.Dt NG_IPFW 4
2914cb4a2fSGleb Smirnoff.Os
3014cb4a2fSGleb Smirnoff.Sh NAME
3114cb4a2fSGleb Smirnoff.Nm ng_ipfw
3214cb4a2fSGleb Smirnoff.Nd interface between netgraph and IP firewall
3314cb4a2fSGleb Smirnoff.Sh SYNOPSIS
3414cb4a2fSGleb Smirnoff.In netgraph/ng_ipfw.h
3514cb4a2fSGleb Smirnoff.Sh DESCRIPTION
3614cb4a2fSGleb SmirnoffThe
3714cb4a2fSGleb Smirnoff.Nm ipfw
3814cb4a2fSGleb Smirnoffnode implements an interface between
3914cb4a2fSGleb Smirnoff.Xr ipfw 4
4014cb4a2fSGleb Smirnoffand
4114cb4a2fSGleb Smirnoff.Xr netgraph 4
4214cb4a2fSGleb Smirnoffsubsystems.
4314cb4a2fSGleb Smirnoff.Sh HOOKS
4414cb4a2fSGleb SmirnoffThe
4514cb4a2fSGleb Smirnoff.Nm ipfw
4614cb4a2fSGleb Smirnoffnode supports an arbitrary number of hooks,
4714cb4a2fSGleb Smirnoffwhich must be named using only numeric characters.
4814cb4a2fSGleb Smirnoff.Sh OPERATION
4914cb4a2fSGleb SmirnoffOnce
5014cb4a2fSGleb Smirnoff.Nm
5114cb4a2fSGleb Smirnoffmodule is loaded into the kernel, a single node named
5214cb4a2fSGleb Smirnoff.Qq ipfw
5314cb4a2fSGleb Smirnoffis automatically created.
5414cb4a2fSGleb SmirnoffNo more
5514cb4a2fSGleb Smirnoff.Nm ipfw
5614cb4a2fSGleb Smirnoffnodes can be created.
5714cb4a2fSGleb SmirnoffOnce destroyed, the only way to recreate node is reload
5814cb4a2fSGleb Smirnoff.Nm
5914cb4a2fSGleb Smirnoffmodule.
6014cb4a2fSGleb Smirnoff.Pp
6114cb4a2fSGleb SmirnoffPackets can be injected into netgraph using either
6214cb4a2fSGleb Smirnoff.Cm netgraph
6314cb4a2fSGleb Smirnoffor
6414cb4a2fSGleb Smirnoff.Cm ngtee
6514cb4a2fSGleb Smirnoffcommands of
6614cb4a2fSGleb Smirnoff.Xr ipfw 8
6714cb4a2fSGleb Smirnoffutility.
6814cb4a2fSGleb SmirnoffThese commands require a numeric cookie to be supplied as argument.
6914cb4a2fSGleb SmirnoffPackets are sent out of the hook, which name is equal cookie value.
7014cb4a2fSGleb SmirnoffIf no hook matches, packets are discarded.
7114cb4a2fSGleb SmirnoffPackets injected via
7214cb4a2fSGleb Smirnoff.Cm netgraph
7314cb4a2fSGleb Smirnoffcommand are tagged with
7414cb4a2fSGleb Smirnoff.Vt "struct ng_ipfw_tag" .
7514cb4a2fSGleb SmirnoffThe tag contains information, which helps node to reenter packet into
7614cb4a2fSGleb Smirnoff.Xr ipfw 4
7714cb4a2fSGleb Smirnoffprocessing, if the packet will come back to node from netgraph.
7814cb4a2fSGleb Smirnoff.Bd -literal -offset 4n
7914cb4a2fSGleb Smirnoffstruct ng_ipfw_tag {
8014cb4a2fSGleb Smirnoff	struct m_tag	mt;		/* tag header */
8114cb4a2fSGleb Smirnoff	struct ip_fw	*rule;		/* matching rule */
8214cb4a2fSGleb Smirnoff        struct ifnet	*ifp;		/* interface, for ip_output */
8314cb4a2fSGleb Smirnoff	int		dir;		/* packet direction */
8414cb4a2fSGleb Smirnoff#define	NG_IPFW_OUT	0
8514cb4a2fSGleb Smirnoff#define	NG_IPFW_IN	1
8614cb4a2fSGleb Smirnoff	int		flags;		/* flags, for ip_output() */
8714cb4a2fSGleb Smirnoff};
8814cb4a2fSGleb Smirnoff.Ed
8914cb4a2fSGleb Smirnoff.Pp
9014cb4a2fSGleb SmirnoffPackets received by node from netgraph must be tagged with
9114cb4a2fSGleb Smirnoff.Vt "struct ng_ipfw_tag"
9214cb4a2fSGleb Smirnofftag.
9314cb4a2fSGleb SmirnoffPackets reenter IP firewall processing at the next rule.
9414cb4a2fSGleb SmirnoffIf no tag is supplied, packets are discarded.
9514cb4a2fSGleb Smirnoff.Sh CONTROL MESSAGES
9614cb4a2fSGleb SmirnoffThe
9714cb4a2fSGleb Smirnoff.Nm ipfw
9814cb4a2fSGleb Smirnoffnode does not have any type specific control messages.
9914cb4a2fSGleb Smirnoff.Sh SHUTDOWN
10014cb4a2fSGleb SmirnoffThis node shuts down upon receipt of a
10114cb4a2fSGleb Smirnoff.Dv NGM_SHUTDOWN
10214cb4a2fSGleb Smirnoffcontrol message.
10314cb4a2fSGleb SmirnoffDon't do this, since new
10414cb4a2fSGleb Smirnoff.Nm ipfw
10514cb4a2fSGleb Smirnoffnode can be created only reloading
10614cb4a2fSGleb Smirnoff.Nm
10714cb4a2fSGleb Smirnoffmodule.
10814cb4a2fSGleb Smirnoff.Sh SEE ALSO
10914cb4a2fSGleb Smirnoff.Xr netgraph 4 ,
11014cb4a2fSGleb Smirnoff.Xr ipfw 4 ,
11114cb4a2fSGleb Smirnoff.Xr ipfw 8 ,
11214cb4a2fSGleb Smirnoff.Xr mbuf_tags 8
11314cb4a2fSGleb Smirnoff.Sh HISTORY
11414cb4a2fSGleb SmirnoffThe
11514cb4a2fSGleb Smirnoff.Nm ipfw
11614cb4a2fSGleb Smirnoffnode type was implemented in
11714cb4a2fSGleb Smirnoff.Fx 6.0 .
11814cb4a2fSGleb Smirnoff.Sh AUTHORS
11914cb4a2fSGleb Smirnoff.An -nosplit
12014cb4a2fSGleb SmirnoffThe
12114cb4a2fSGleb Smirnoff.Nm ipfw
12214cb4a2fSGleb Smirnoffnode was written by
12314cb4a2fSGleb Smirnoff.An "Gleb Smirnoff" Aq glebius@FreeBSD.org .
124