pub struct Pf { /* private fields */ }
Implementations§
Source§impl Pf
impl Pf
Sourcepub fn new(pf_dev_path: Option<&str>) -> PfResult<Self>
pub fn new(pf_dev_path: Option<&str>) -> PfResult<Self>
Creates new instance. Opens the pf device in dev.
The file descriptor for the opened PF device will be closed on drop of this instance, so don’t keep it.
Sourcepub fn pfctl_kill_state<H: AsRef<str>>(
&self,
src: H,
dest: Option<H>,
) -> PfResult<()>
pub fn pfctl_kill_state<H: AsRef<str>>( &self, src: H, dest: Option<H>, ) -> PfResult<()>
Kills the state from the state table of the firewall. When host address is added to the table, it is not purged from the state table automatically and the connection will stay alive until the state is not killed.
§Arguments
-
src
- a host IP address to be killed. -
dest
- a destination IP address to match if any.
Sourcepub fn pfctl_table_file<'p, T: AsRef<str>>(
&self,
table_name: T,
cmd: PfCmdFile<'p>,
) -> PfResult<i32>
pub fn pfctl_table_file<'p, T: AsRef<str>>( &self, table_name: T, cmd: PfCmdFile<'p>, ) -> PfResult<i32>
Performs the operation on a specific table from the file.
§Arguments
-
table_name
- a reference to a name of the table on which the operation should be performed. -
cmd
- a PfCmd operation to be performed with the payload data.
§Returns
A PfResult is returned.
-
Result::Ok is returned with the amound of the successfully performed operations (pedends on the amount of the data in payload).
-
Result::Err is returned with error description.
Sourcepub fn pfctl_table<T: AsRef<str>>(
&self,
table_name: T,
cmd: PfCmd,
) -> PfResult<i32>
pub fn pfctl_table<T: AsRef<str>>( &self, table_name: T, cmd: PfCmd, ) -> PfResult<i32>
Performs the operation on a specific table.
§Arguments
-
table_name
- a reference to a name of the table on which the operation should be performed. -
cmd
- a PfCmd operation to be performed with the payload data.
§Returns
A PfResult is returned.
-
Result::Ok is returned with the amound of the successfully performed operations (pedends on the amount of the data in payload).
-
Result::Err is returned with error description.