I'd like to build a daemon based process that configure the network kernel module firewall capabilities.
Currently, I can control this kernel firewall using pfctl
and various configuration files that describe the filtering rules. However, I wish to inject the rules to packet first directly using C++/Objective-C API.
For example, To block IP address from any network interface in my setup, requires adding block from any to <ip_addr>
to /etc/pf.conf
file and reload the firewall by sudo pfctl -d
and then sudo pfctl -e -f /etc/pf.conf
Is there any option to use ioctl
or other system-call to communicate directly with the kernel firewall ?
EDIT: The source code of pfctl is here, but I still trying to decipher how to generate proper ioctl command in order to set new rule..