pfctl/rule/
state_policy.rs

1// Copyright 2025 Mullvad VPN AB.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use crate::ffi;
10
11#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
12pub enum StatePolicy {
13    #[default]
14    None,
15    Keep,
16    Modulate,
17    SynProxy,
18}
19
20impl From<StatePolicy> for u8 {
21    fn from(state_policy: StatePolicy) -> Self {
22        match state_policy {
23            StatePolicy::None => 0,
24            StatePolicy::Keep => ffi::pfvar::PF_STATE_NORMAL as u8,
25            StatePolicy::Modulate => ffi::pfvar::PF_STATE_MODULATE as u8,
26            StatePolicy::SynProxy => ffi::pfvar::PF_STATE_SYNPROXY as u8,
27        }
28    }
29}