\hypertarget{ng__ipfw_8c_source}{}\doxysection{ng\+\_\+ipfw.\+c}
\label{ng__ipfw_8c_source}\index{netgraph/ng\_ipfw.c@{netgraph/ng\_ipfw.c}}
\mbox{\hyperlink{ng__ipfw_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00004}00004 \textcolor{comment}{ * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00027}00027 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00028}00028 \textcolor{comment}{ * \$FreeBSD\$}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00029}00029 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00031}00031 \textcolor{preprocessor}{\#include "{}opt\_inet.h"{}}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00032}00032 \textcolor{preprocessor}{\#include "{}opt\_inet6.h"{}}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00033}00033 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/mbuf.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/ctype.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/errno.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/rwlock.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/socket.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/syslog.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00045}00045 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <net/if.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <net/if\_var.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00048}00048 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00049}00049 \textcolor{preprocessor}{\#include <netinet/in.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00050}00050 \textcolor{preprocessor}{\#include <netinet/in\_systm.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <netinet/in\_var.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00052}00052 \textcolor{preprocessor}{\#include <netinet/ip\_var.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00053}00053 \textcolor{preprocessor}{\#include <netinet/ip\_fw.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00054}00054 \textcolor{preprocessor}{\#include <netinet/ip.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00055}00055 \textcolor{preprocessor}{\#include <netinet/ip6.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00056}00056 \textcolor{preprocessor}{\#include <netinet6/ip6\_var.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00058}00058 \textcolor{preprocessor}{\#include <netpfil/ipfw/ip\_fw\_private.h>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00060}00060 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{ng__message_8h}{netgraph/ng\_message.h}}>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00061}00061 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{ng__parse_8h}{netgraph/ng\_parse.h}}>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00062}00062 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{ng__ipfw_8h}{netgraph/ng\_ipfw.h}}>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00063}00063 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{netgraph_8h}{netgraph/netgraph.h}}>}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00064}00064 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00065}00065 \textcolor{keyword}{static} \textcolor{keywordtype}{int}              \mbox{\hyperlink{ng__ipfw_8c_a4c4e7af60a1ce8e85a69c65697c12882}{ng\_ipfw\_mod\_event}}(module\_t mod, \textcolor{keywordtype}{int} \mbox{\hyperlink{ng__ubt__var_8h_aeef6900f411bc223febdd92c9435693b}{event}}, \textcolor{keywordtype}{void} *\mbox{\hyperlink{ng__ubt__var_8h_a7f897df1949af68456ee830f2468e476}{data}});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00066}\mbox{\hyperlink{ng__ipfw_8c_a9c0dba9b26dd073b841b02bf6d0ee764}{00066}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_abb75b9ed2849e15851d6402d2ab5b899}{ng\_constructor\_t}} \mbox{\hyperlink{ng__ipfw_8c_a9c0dba9b26dd073b841b02bf6d0ee764}{ng\_ipfw\_constructor}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00067}\mbox{\hyperlink{ng__ipfw_8c_a26ac1de42ae7b8bb2af9dfbe66068e8c}{00067}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_aab0a679789a1af312a7f856b4668ad74}{ng\_shutdown\_t}}       \mbox{\hyperlink{ng__ipfw_8c_a26ac1de42ae7b8bb2af9dfbe66068e8c}{ng\_ipfw\_shutdown}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00068}\mbox{\hyperlink{ng__ipfw_8c_a26f99dd0ad803bde55e4ac98940ddb09}{00068}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_afa50639df4ed6eb400f8220a890d56e6}{ng\_newhook\_t}} \mbox{\hyperlink{ng__ipfw_8c_a26f99dd0ad803bde55e4ac98940ddb09}{ng\_ipfw\_newhook}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00069}\mbox{\hyperlink{ng__ipfw_8c_a1da925cb7eaa2b17032b958716a7092d}{00069}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_a0e4a4a62e48409635e5f33c548baaea7}{ng\_connect\_t}} \mbox{\hyperlink{ng__ipfw_8c_a1da925cb7eaa2b17032b958716a7092d}{ng\_ipfw\_connect}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00070}\mbox{\hyperlink{ng__ipfw_8c_afd278f3165f89d32fec1af1265412b6c}{00070}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_a424ace511760adfb045f80357770866c}{ng\_findhook\_t}}       \mbox{\hyperlink{ng__ipfw_8c_afd278f3165f89d32fec1af1265412b6c}{ng\_ipfw\_findhook}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00071}\mbox{\hyperlink{ng__ipfw_8c_a9183b04bc7839712d1e6b6d16540032c}{00071}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_aa87ef7415b345b801747ceaf99de6c43}{ng\_rcvdata\_t}} \mbox{\hyperlink{ng__ipfw_8c_a9183b04bc7839712d1e6b6d16540032c}{ng\_ipfw\_rcvdata}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00072}\mbox{\hyperlink{ng__ipfw_8c_a40ed411bf5b8d7898b74eb35dcb40537}{00072}} \textcolor{keyword}{static} \mbox{\hyperlink{netgraph_8h_a669e1783335f933b4a4f90f17d22f381}{ng\_disconnect\_t}}   \mbox{\hyperlink{ng__ipfw_8c_a40ed411bf5b8d7898b74eb35dcb40537}{ng\_ipfw\_disconnect}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00073}00073 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00074}00074 \textcolor{keyword}{static} \mbox{\hyperlink{structng__hook}{hook\_p}}             \mbox{\hyperlink{ng__ipfw_8c_aaa113fcaf18c83b15fa30725c6045c97}{ng\_ipfw\_findhook1}}(\mbox{\hyperlink{structng__node}{node\_p}}, u\_int16\_t );}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00075}00075 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      \mbox{\hyperlink{ng__ipfw_8c_a9e110ecf88f8208fc5dbf9f09b36c94b}{ng\_ipfw\_input}}(\textcolor{keyword}{struct} mbuf **, \textcolor{keyword}{struct} ip\_fw\_args *, \textcolor{keywordtype}{bool});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00076}00076 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00077}00077 \textcolor{comment}{/* We have only one node */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00078}\mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{00078}} \textcolor{keyword}{static} \mbox{\hyperlink{structng__node}{node\_p}}     \mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{fw\_node}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00079}00079 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00080}00080 \textcolor{comment}{/* Netgraph node type descriptor */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00081}\mbox{\hyperlink{ng__ipfw_8c_a2e6edecec9310935cdb60c0ac68aefb8}{00081}} \textcolor{keyword}{static} \textcolor{keyword}{struct }\mbox{\hyperlink{structng__type}{ng\_type}} \mbox{\hyperlink{ng__ipfw_8c_a2e6edecec9310935cdb60c0ac68aefb8}{ng\_ipfw\_typestruct}} = \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00082}00082         .\mbox{\hyperlink{structng__type_adbc1c8884ff0e625c19c4b513262fd0e}{version}} =       \mbox{\hyperlink{netgraph_8h_acc6b5f853e8058f4d5a8ca825ee60c97}{NG\_ABI\_VERSION}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00083}00083         .name =         \mbox{\hyperlink{ng__ipfw_8h_a5ed4160c1c6547a315b81d34c9c307e1}{NG\_IPFW\_NODE\_TYPE}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00084}00084         .mod\_event =    \mbox{\hyperlink{ng__ipfw_8c_a4c4e7af60a1ce8e85a69c65697c12882}{ng\_ipfw\_mod\_event}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00085}00085         .constructor =  \mbox{\hyperlink{ng__ipfw_8c_a9c0dba9b26dd073b841b02bf6d0ee764}{ng\_ipfw\_constructor}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00086}00086         .shutdown =     \mbox{\hyperlink{ng__ipfw_8c_a26ac1de42ae7b8bb2af9dfbe66068e8c}{ng\_ipfw\_shutdown}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00087}00087         .newhook =      \mbox{\hyperlink{ng__ipfw_8c_a26f99dd0ad803bde55e4ac98940ddb09}{ng\_ipfw\_newhook}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00088}00088         .connect =      \mbox{\hyperlink{ng__ipfw_8c_a1da925cb7eaa2b17032b958716a7092d}{ng\_ipfw\_connect}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00089}00089         .findhook =     \mbox{\hyperlink{ng__ipfw_8c_afd278f3165f89d32fec1af1265412b6c}{ng\_ipfw\_findhook}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00090}00090         .rcvdata =      \mbox{\hyperlink{ng__ipfw_8c_a9183b04bc7839712d1e6b6d16540032c}{ng\_ipfw\_rcvdata}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00091}00091         .disconnect =   \mbox{\hyperlink{ng__ipfw_8c_a40ed411bf5b8d7898b74eb35dcb40537}{ng\_ipfw\_disconnect}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00092}00092 \};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00093}\mbox{\hyperlink{ng__ipfw_8c_a1002dfc015db37316be50fa358404d55}{00093}} \mbox{\hyperlink{ng__ipfw_8c_a1002dfc015db37316be50fa358404d55}{NETGRAPH\_INIT}}(ipfw, \&\mbox{\hyperlink{ng__ipfw_8c_a2e6edecec9310935cdb60c0ac68aefb8}{ng\_ipfw\_typestruct}});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00094}\mbox{\hyperlink{ng__ipfw_8c_ac0f74c4cfad5beb9b3bb702b016369ac}{00094}} \mbox{\hyperlink{ng__ipfw_8c_ac0f74c4cfad5beb9b3bb702b016369ac}{MODULE\_DEPEND}}(ng\_ipfw, ipfw, 3, 3, 3);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00095}00095 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00096}00096 \textcolor{comment}{/* Information we store for each hook */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00097}\mbox{\hyperlink{structng__ipfw__hook__priv}{00097}} \textcolor{keyword}{struct }\mbox{\hyperlink{structng__ipfw__hook__priv}{ng\_ipfw\_hook\_priv}} \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00098}\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{00098}}         \mbox{\hyperlink{structng__hook}{hook\_p}}            \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00099}\mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{00099}}         u\_int16\_t       \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00100}00100 \};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00101}\mbox{\hyperlink{ng__ipfw_8c_ac5c742327d20436cd60a17c56eb6ebdd}{00101}} \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\mbox{\hyperlink{structng__ipfw__hook__priv}{ng\_ipfw\_hook\_priv}} *\mbox{\hyperlink{ng__ipfw_8c_ac5c742327d20436cd60a17c56eb6ebdd}{hpriv\_p}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00102}00102 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00103}00103 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00104}\mbox{\hyperlink{ng__ipfw_8c_a4c4e7af60a1ce8e85a69c65697c12882}{00104}} \mbox{\hyperlink{ng__ipfw_8c_a4c4e7af60a1ce8e85a69c65697c12882}{ng\_ipfw\_mod\_event}}(module\_t mod, \textcolor{keywordtype}{int} \mbox{\hyperlink{ng__ubt__var_8h_aeef6900f411bc223febdd92c9435693b}{event}}, \textcolor{keywordtype}{void} *\mbox{\hyperlink{ng__ubt__var_8h_a7f897df1949af68456ee830f2468e476}{data}})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00105}00105 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00106}00106         \textcolor{keywordtype}{int} error = 0;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00107}00107 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00108}00108         \textcolor{keywordflow}{switch} (\mbox{\hyperlink{ng__ubt__var_8h_aeef6900f411bc223febdd92c9435693b}{event}}) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00109}00109         \textcolor{keywordflow}{case} MOD\_LOAD:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00110}00110 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00111}00111                 \textcolor{keywordflow}{if} (ng\_ipfw\_input\_p != NULL) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00112}00112                         error = EEXIST;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00113}00113                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00114}00114                 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00115}00115 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00116}00116                 \textcolor{comment}{/* Setup node without any private data */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00117}00117                 \textcolor{keywordflow}{if} ((error = \mbox{\hyperlink{netgraph_8h_aba2cbbfc891d71bd283ce2368c8392db}{ng\_make\_node\_common}}(\&\mbox{\hyperlink{ng__ipfw_8c_a2e6edecec9310935cdb60c0ac68aefb8}{ng\_ipfw\_typestruct}}, \&\mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{fw\_node}}))}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00118}00118                     != 0) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00119}00119                         log(LOG\_ERR, \textcolor{stringliteral}{"{}\%s: can't create ng\_ipfw node"{}}, \_\_func\_\_);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00120}00120                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00121}00121                 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00122}00122 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00123}00123                 \textcolor{comment}{/* Try to name node */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00124}00124                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{netgraph_8h_abae5851c9f312eebd398b1cd085fe067}{ng\_name\_node}}(\mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{fw\_node}}, \textcolor{stringliteral}{"{}ipfw"{}}) != 0)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00125}00125                         log(LOG\_WARNING, \textcolor{stringliteral}{"{}\%s: failed to name node \(\backslash\)"{}ipfw\(\backslash\)"{}"{}},}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00126}00126                             \_\_func\_\_);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00127}00127 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00128}00128                 \textcolor{comment}{/* Register hook */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00129}00129                 ng\_ipfw\_input\_p = \mbox{\hyperlink{ng__ipfw_8c_a9e110ecf88f8208fc5dbf9f09b36c94b}{ng\_ipfw\_input}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00130}00130                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00131}00131 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00132}00132         \textcolor{keywordflow}{case} MOD\_UNLOAD:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00133}00133                  \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00134}00134 \textcolor{comment}{                  * This won't happen if a node exists.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00135}00135 \textcolor{comment}{                  * ng\_ipfw\_input\_p is already cleared.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00136}00136 \textcolor{comment}{                  */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00137}00137                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00139}00139         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00140}00140                 error = EOPNOTSUPP;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00141}00141                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00142}00142         \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00143}00143 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00144}00144         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00145}00145 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00146}00146 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00147}00147 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00148}\mbox{\hyperlink{ng__ipfw_8c_a73ae2e13e78e61e72edc9096607e696a}{00148}} \mbox{\hyperlink{ng__ipfw_8c_a9c0dba9b26dd073b841b02bf6d0ee764}{ng\_ipfw\_constructor}}(\mbox{\hyperlink{structng__node}{node\_p}} node)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00149}00149 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00150}00150         \textcolor{keywordflow}{return} (EINVAL);        \textcolor{comment}{/* Only one node */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00151}00151 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00152}00152 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00153}00153 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00154}\mbox{\hyperlink{ng__ipfw_8c_a0d6b9149181eabcc8f5b2ae3bc12c49a}{00154}} \mbox{\hyperlink{ng__ipfw_8c_a26f99dd0ad803bde55e4ac98940ddb09}{ng\_ipfw\_newhook}}(\mbox{\hyperlink{structng__node}{node\_p}} node, \mbox{\hyperlink{structng__hook}{hook\_p}} \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}}, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00155}00155 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00156}00156         \mbox{\hyperlink{structhpriv__p}{hpriv\_p}}  hpriv;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00157}00157         u\_int16\_t \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00158}00158         \textcolor{keyword}{const} \textcolor{keywordtype}{char} *cp;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00159}00159         \textcolor{keywordtype}{char} *endptr;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00160}00160 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00161}00161         \textcolor{comment}{/* Protect from leading zero */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00162}00162         \textcolor{keywordflow}{if} (\mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}}[0] == \textcolor{charliteral}{'0'} \&\& \mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}}[1] != \textcolor{charliteral}{'\(\backslash\)0'})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00163}00163                 \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00164}00164 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00165}00165         \textcolor{comment}{/* Check that name contains only digits */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00166}00166         \textcolor{keywordflow}{for} (cp = \mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}}; *cp != \textcolor{charliteral}{'\(\backslash\)0'}; cp++)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00167}00167                 \textcolor{keywordflow}{if} (!isdigit(*cp))}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00168}00168                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00170}00170         \textcolor{comment}{/* Convert it to integer */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00171}00171         \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}} = (u\_int16\_t)strtol(\mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}}, \&endptr, 10);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00172}00172         \textcolor{keywordflow}{if} (*endptr != \textcolor{charliteral}{'\(\backslash\)0'})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00173}00173                 \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00174}00174 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00175}00175         \textcolor{comment}{/* Allocate memory for this hook's private data */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00176}00176         hpriv = malloc(\textcolor{keyword}{sizeof}(*hpriv), M\_NETGRAPH, M\_NOWAIT | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00177}00177         \textcolor{keywordflow}{if} (hpriv== NULL)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00178}00178                 \textcolor{keywordflow}{return} (ENOMEM);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00179}00179 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00180}00180         hpriv-\/>hook = \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00181}00181         hpriv-\/>rulenum = \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00182}00182 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00183}00183         \mbox{\hyperlink{netgraph_8h_a8167c04e701189ca4bc1bc3af5454ce6}{NG\_HOOK\_SET\_PRIVATE}}(\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}}, hpriv);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00184}00184 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00185}00185         \textcolor{keywordflow}{return}(0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00186}00186 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00187}00187 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00188}00188 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00189}00189 \textcolor{comment}{ * Set hooks into queueing mode, to avoid recursion between}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00190}00190 \textcolor{comment}{ * netgraph layer and ip\_\{input,output\}.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00191}00191 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00192}00192 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00193}\mbox{\hyperlink{ng__ipfw_8c_ad13cc20b9d5f70e5a739eff0cba90539}{00193}} \mbox{\hyperlink{ng__ipfw_8c_a1da925cb7eaa2b17032b958716a7092d}{ng\_ipfw\_connect}}(\mbox{\hyperlink{structng__hook}{hook\_p}} \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00194}00194 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00195}00195         \mbox{\hyperlink{netgraph_8h_aa1237a32cabb47ae66cce0f75d2baceb}{NG\_HOOK\_FORCE\_QUEUE}}(\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00196}00196         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00197}00197 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00198}00198 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00199}00199 \textcolor{comment}{/* Look up hook by name */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00200}00200 \textcolor{keyword}{static} \mbox{\hyperlink{structng__hook}{hook\_p}}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00201}\mbox{\hyperlink{ng__ipfw_8c_a3947035e8a029641ecb8039d5ebbcd92}{00201}} \mbox{\hyperlink{ng__ipfw_8c_afd278f3165f89d32fec1af1265412b6c}{ng\_ipfw\_findhook}}(\mbox{\hyperlink{structng__node}{node\_p}} node, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *\mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00202}00202 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00203}00203         u\_int16\_t n;    \textcolor{comment}{/* numeric representation of hook */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00204}00204         \textcolor{keywordtype}{char} *endptr;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00205}00205 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00206}00206         n = (u\_int16\_t)strtol(\mbox{\hyperlink{ng__ppp_8c_ab2adbf48c2df32ccf9cced3bc8c3dc26}{name}}, \&endptr, 10);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00207}00207         \textcolor{keywordflow}{if} (*endptr != \textcolor{charliteral}{'\(\backslash\)0'})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00208}00208                 \textcolor{keywordflow}{return} NULL;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00209}00209         \textcolor{keywordflow}{return} \mbox{\hyperlink{ng__ipfw_8c_aaa113fcaf18c83b15fa30725c6045c97}{ng\_ipfw\_findhook1}}(node, n);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00210}00210 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00211}00211 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00212}00212 \textcolor{comment}{/* Look up hook by rule number */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00213}00213 \textcolor{keyword}{static} \mbox{\hyperlink{structng__hook}{hook\_p}}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00214}\mbox{\hyperlink{ng__ipfw_8c_aaa113fcaf18c83b15fa30725c6045c97}{00214}} \mbox{\hyperlink{ng__ipfw_8c_aaa113fcaf18c83b15fa30725c6045c97}{ng\_ipfw\_findhook1}}(\mbox{\hyperlink{structng__node}{node\_p}} node, u\_int16\_t \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}})}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00215}00215 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00216}00216         \mbox{\hyperlink{structng__hook}{hook\_p}}    \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00217}00217         \mbox{\hyperlink{structhpriv__p}{hpriv\_p}}  hpriv;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00218}00218 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00219}00219         LIST\_FOREACH(\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}}, \&node-\/>nd\_hooks, hk\_hooks) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00220}00220                 hpriv = \mbox{\hyperlink{netgraph_8h_afe8dccb32c473a2098104a16179e754b}{NG\_HOOK\_PRIVATE}}(\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00221}00221                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{netgraph_8h_ac8409b5ecd2c70db4911cc5d9fe66901}{NG\_HOOK\_IS\_VALID}}(\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}}) \&\& (hpriv-\/>rulenum == \mbox{\hyperlink{structng__ipfw__hook__priv_a82cc8773987e768b2895a72288c10aa9}{rulenum}}))}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00222}00222                         \textcolor{keywordflow}{return} (\mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}});}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00223}00223         \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00224}00224 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00225}00225         \textcolor{keywordflow}{return} (NULL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00226}00226 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00227}00227 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00228}00228 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00229}\mbox{\hyperlink{ng__ipfw_8c_a25a56f765c2257b001f619fdb99af771}{00229}} \mbox{\hyperlink{ng__ipfw_8c_a9183b04bc7839712d1e6b6d16540032c}{ng\_ipfw\_rcvdata}}(\mbox{\hyperlink{structng__hook}{hook\_p}} \mbox{\hyperlink{structng__ipfw__hook__priv_a5d820e45d89cd322dabe22a1c033aced}{hook}}, \mbox{\hyperlink{structng__item}{item\_p}} item)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00230}00230 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00231}00231         \textcolor{keyword}{struct }m\_tag *tag;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00232}00232         \textcolor{keyword}{struct }ipfw\_rule\_ref *\mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00233}00233         \textcolor{keyword}{struct }mbuf *m;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00234}00234         \textcolor{keyword}{struct }ip *ip;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00235}00235 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00236}00236         \mbox{\hyperlink{netgraph_8h_abbb0acb5f480576cff9901caddeef57f}{NGI\_GET\_M}}(item, m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00237}00237         \mbox{\hyperlink{netgraph_8h_ab1451f92a5ed6715897d40bf802b06d5}{NG\_FREE\_ITEM}}(item);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00238}00238 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00239}00239         tag = m\_tag\_locate(m, MTAG\_IPFW\_RULE, 0, NULL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00240}00240         \textcolor{keywordflow}{if} (tag == NULL) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00241}00241                 \mbox{\hyperlink{netgraph_8h_a2461bfcdc9e024484ed8037d386620e3}{NG\_FREE\_M}}(m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00242}00242                 \textcolor{keywordflow}{return} (EINVAL);        \textcolor{comment}{/* XXX: find smth better */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00243}00243         \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00244}00244 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00245}00245         \textcolor{keywordflow}{if} (m-\/>m\_len < \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} ip) \&\&}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00246}00246             (m = m\_pullup(m, \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} ip))) == NULL)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00247}00247                 \textcolor{keywordflow}{return} (ENOBUFS);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00248}00248 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00249}00249         ip = mtod(m, \textcolor{keyword}{struct} ip *);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00250}00250 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00251}00251         \mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}} = (\textcolor{keyword}{struct }ipfw\_rule\_ref *)(tag + 1);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00252}00252         \textcolor{keywordflow}{if} (\mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}}-\/>info \& IPFW\_INFO\_IN) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00253}00253                 \textcolor{keywordflow}{switch} (ip-\/>ip\_v) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00254}00254 \textcolor{preprocessor}{\#ifdef INET}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00255}00255                 \textcolor{keywordflow}{case} IPVERSION:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00256}00256                         ip\_input(m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00257}00257                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00258}00258 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00259}00259 \textcolor{preprocessor}{\#ifdef INET6}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00260}00260                 \textcolor{keywordflow}{case} IPV6\_VERSION >> 4:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00261}00261                         ip6\_input(m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00262}00262                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00263}00263 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00264}00264                 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00265}00265         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00266}00266                 \textcolor{keywordflow}{switch} (ip-\/>ip\_v) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00267}00267 \textcolor{preprocessor}{\#ifdef INET}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00268}00268                 \textcolor{keywordflow}{case} IPVERSION:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00269}00269                         \textcolor{keywordflow}{return} (ip\_output(m, NULL, NULL, IP\_FORWARDING,}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00270}00270                             NULL, NULL));}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00271}00271 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00272}00272 \textcolor{preprocessor}{\#ifdef INET6}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00273}00273                 \textcolor{keywordflow}{case} IPV6\_VERSION >> 4:}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00274}00274                         \textcolor{keywordflow}{return} (ip6\_output(m, NULL, NULL, 0, NULL,}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00275}00275                             NULL, NULL));}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00276}00276 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00277}00277                 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00278}00278         \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00279}00279 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00280}00280         \textcolor{comment}{/* unknown IP protocol version */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00281}00281         \mbox{\hyperlink{netgraph_8h_a2461bfcdc9e024484ed8037d386620e3}{NG\_FREE\_M}}(m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00282}00282         \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00283}00283 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00284}00284 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00285}00285 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00286}\mbox{\hyperlink{ng__ipfw_8c_a9e110ecf88f8208fc5dbf9f09b36c94b}{00286}} \mbox{\hyperlink{ng__ipfw_8c_a9e110ecf88f8208fc5dbf9f09b36c94b}{ng\_ipfw\_input}}(\textcolor{keyword}{struct} mbuf **m0, \textcolor{keyword}{struct} ip\_fw\_args *fwa, \textcolor{keywordtype}{bool} tee)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00287}00287 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00288}00288         \textcolor{keyword}{struct }mbuf *m;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00289}00289         \mbox{\hyperlink{structng__hook}{hook\_p}}    hook;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00290}00290         \textcolor{keywordtype}{int} error = 0;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00291}00291 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00292}00292         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00293}00293 \textcolor{comment}{         * Node must be loaded and corresponding hook must be present.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00294}00294 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00295}00295         \textcolor{keywordflow}{if} (\mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{fw\_node}} == NULL || }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00296}00296            (hook = \mbox{\hyperlink{ng__ipfw_8c_aaa113fcaf18c83b15fa30725c6045c97}{ng\_ipfw\_findhook1}}(\mbox{\hyperlink{ng__ipfw_8c_ae260188238f88be6f3166bec2377d6d1}{fw\_node}}, fwa-\/>rule.info)) == NULL)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00297}00297                 \textcolor{keywordflow}{return} (ESRCH);         \textcolor{comment}{/* no hook associated with this rule */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00298}00298 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00299}00299         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00300}00300 \textcolor{comment}{         * We have two modes: in normal mode we add a tag to packet, which is}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00301}00301 \textcolor{comment}{         * important to return packet back to IP stack. In tee mode we make}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00302}00302 \textcolor{comment}{         * a copy of a packet and forward it into netgraph without a tag.}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00303}00303 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00304}00304         \textcolor{keywordflow}{if} (tee == \textcolor{keyword}{false}) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00305}00305                 \textcolor{keyword}{struct }m\_tag *tag;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00306}00306                 \textcolor{keyword}{struct }ipfw\_rule\_ref *\mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}};}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00307}00307                 m = *m0;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00308}00308                 *m0 = NULL;     \textcolor{comment}{/* it belongs now to netgraph */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00309}00309 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00310}00310                 tag = m\_tag\_alloc(MTAG\_IPFW\_RULE, 0, \textcolor{keyword}{sizeof}(*\mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}}),}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00311}00311                         M\_NOWAIT|M\_ZERO);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00312}00312                 \textcolor{keywordflow}{if} (tag == NULL) \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00313}00313                         m\_freem(m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00314}00314                         \textcolor{keywordflow}{return} (ENOMEM);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00315}00315                 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00316}00316                 \mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}} = (\textcolor{keyword}{struct }ipfw\_rule\_ref *)(tag + 1);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00317}00317                 *\mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}} = fwa-\/>rule;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00318}00318                 \mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}}-\/>info \&= IPFW\_ONEPASS;  \textcolor{comment}{/* keep this info */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00319}00319                 \mbox{\hyperlink{netflow_8h_a419295e5f62f822c864628ed8fcf0928}{r}}-\/>info |= (fwa-\/>flags \& IPFW\_ARGS\_IN) ?}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00320}00320                     IPFW\_INFO\_IN : IPFW\_INFO\_OUT;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00321}00321                 m\_tag\_prepend(m, tag);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00322}00322 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00323}00323         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00324}00324                 \textcolor{keywordflow}{if} ((m = m\_dup(*m0, M\_NOWAIT)) == NULL)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00325}00325                         \textcolor{keywordflow}{return} (ENOMEM);        \textcolor{comment}{/* which is ignored */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00326}00326 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00327}00327         \textcolor{keywordflow}{if} (m-\/>m\_len < \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} ip) \&\&}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00328}00328             (m = m\_pullup(m, \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} ip))) == NULL)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00329}00329                 \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00330}00330 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00331}00331         \mbox{\hyperlink{netgraph_8h_a8c5e877ed70dff86bb57062afe4cee38}{NG\_SEND\_DATA\_ONLY}}(error, hook, m);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00332}00332 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00333}00333         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00334}00334 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00335}00335 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00336}00336 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00337}\mbox{\hyperlink{ng__ipfw_8c_a05a50c137b95285c69d0283ce19d054d}{00337}} \mbox{\hyperlink{ng__ipfw_8c_a26ac1de42ae7b8bb2af9dfbe66068e8c}{ng\_ipfw\_shutdown}}(\mbox{\hyperlink{structng__node}{node\_p}} node)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00338}00338 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00339}00339 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00340}00340         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00341}00341 \textcolor{comment}{         * After our single node has been removed,}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00342}00342 \textcolor{comment}{         * the only thing that can be done is}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00343}00343 \textcolor{comment}{         * 'kldunload ng\_ipfw.ko'}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00344}00344 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00345}00345         ng\_ipfw\_input\_p = NULL;}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00346}00346         \mbox{\hyperlink{netgraph_8h_a7e3862fa34646a9c66c9b02ac5383d1a}{NG\_NODE\_UNREF}}(node);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00347}00347         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00348}00348 \}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00349}00349 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00350}00350 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00351}\mbox{\hyperlink{ng__ipfw_8c_a29dfed630d9d6b1cab6751f558f5e91d}{00351}} \mbox{\hyperlink{ng__ipfw_8c_a40ed411bf5b8d7898b74eb35dcb40537}{ng\_ipfw\_disconnect}}(\mbox{\hyperlink{structng__hook}{hook\_p}} hook)}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00352}00352 \{}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00353}00353         \textcolor{keyword}{const} \mbox{\hyperlink{structhpriv__p}{hpriv\_p}} hpriv = \mbox{\hyperlink{netgraph_8h_afe8dccb32c473a2098104a16179e754b}{NG\_HOOK\_PRIVATE}}(hook);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00354}00354 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00355}00355         free(hpriv, M\_NETGRAPH);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00356}00356         \mbox{\hyperlink{netgraph_8h_a8167c04e701189ca4bc1bc3af5454ce6}{NG\_HOOK\_SET\_PRIVATE}}(hook, NULL);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00357}00357 }
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00358}00358         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ng__ipfw_8c_source_l00359}00359 \}}

\end{DoxyCode}
