Date: Mon, 21 Apr 2014 19:34:12 +0400 From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: bycn82 <bycn82@gmail.com> Cc: freebsd-ipfw@freebsd.org Subject: Re: how does it pass in the rule sets Message-ID: <53553A74.4000405@FreeBSD.org> In-Reply-To: <535535C7.1050707@gmail.com> References: <5352298C.2090902@gmail.com> <53552C83.7060008@FreeBSD.org> <535535C7.1050707@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 21.04.2014 19:14, bycn82 wrote: > On 4/21/14 22:34, Andrey V. Elsukov wrote: >> On 19.04.2014 11:45, bycn82 wrote: >>> Hi, >>> can someone help to explain how does the user land command `ipfw` pass >>> the rule set into the hook function in the kernel? I assume that it must >>> be hardcoded in somewhere, but I did not find it yet. >> ipfw(8) uses raw socket and setsockopt(2)/getsockopt(2) functions to >> interact with kernel. In particular, do_cmd() function from ipfw2.c does it. >> > Thanks very much, > Actually I saw the source already, the ipfw_ctl() method. I would like > to call it as "an event handler" > But why it will triggered? where are the code to register this method > as listener? > Sorry for using Java terminologies ;) You need to improve your grep-fu :) When you load ipfw.ko kernel module, vnet_ipfw_init() initializes V_ip_fw_ctl_ptr = ipfw_ctl. When you call setsockopt() for raw socket, it invokes ctloutput method for RAW IP - rip_ctloutput() (netinet/raw_ip.c). It calls ipfw_ctl() via V_ip_fw_ctl_ptr pointer. -- WBR, Andrey V. Elsukov
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53553A74.4000405>