ipfw from C code

Luigi Rizzo rizzo at icir.org
Tue Jan 13 01:11:19 PST 2004


On Tue, Jan 13, 2004 at 08:39:40AM -0000, tom wrote:
> new
> how do I control ipfw from a proggy ?
> #include <sys/sysctl.h> to start ?
> sorry, I know this might be a basic coding lesson,

i suggest using something like

	system("ipfw add 2345 allow tcp from foo to bar");

the ABI is way too awkward to use it from C (basically it
is microcode if you are using ipfw2, and a large and
overloaded rule descriptor if you are using ipfw1).

In the long term we will have something like

	ipfw_compile(out_buffer, &len, "2345 allow tcp from foo to bar");
	setsockopt(fd, IP_FW_ADD, out_buffer, len); 

and then you can the fork overhead.

	cheers
	luigi
> 
> _______________________________________________
> freebsd-ipfw at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-ipfw
> To unsubscribe, send any mail to "freebsd-ipfw-unsubscribe at freebsd.org"


More information about the freebsd-ipfw mailing list