MCPcopy Create free account
hub / github.com/PowerShell/DSC / profiles_from_mask

Function profiles_from_mask

resources/windows_firewall/src/firewall.rs:179–196  ·  view source on GitHub ↗

Converts a bitmask of firewall profile flags to a list of profile name strings. `NET_FW_PROFILE2_ALL` is `0x7FFFFFFF` (a sentinel meaning all profiles), while the combination of the three individual profile bits is `0x7`. Both are normalized to `["All"]`.

(mask: i32)

Source from the content-addressed store, hash-verified

177/// `NET_FW_PROFILE2_ALL` is `0x7FFFFFFF` (a sentinel meaning all profiles), while the
178/// combination of the three individual profile bits is `0x7`. Both are normalized to `["All"]`.
179fn profiles_from_mask(mask: i32) -> Vec<String> {
180 let all_bits = NET_FW_PROFILE2_DOMAIN.0 | NET_FW_PROFILE2_PRIVATE.0 | NET_FW_PROFILE2_PUBLIC.0;
181 if mask == NET_FW_PROFILE2_ALL.0 || mask == all_bits {
182 return vec!["All".to_string()];
183 }
184
185 let mut profiles = Vec::new();
186 if mask & NET_FW_PROFILE2_DOMAIN.0 != 0 {
187 profiles.push("Domain".to_string());
188 }
189 if mask & NET_FW_PROFILE2_PRIVATE.0 != 0 {
190 profiles.push("Private".to_string());
191 }
192 if mask & NET_FW_PROFILE2_PUBLIC.0 != 0 {
193 profiles.push("Public".to_string());
194 }
195 profiles
196}
197
198fn profiles_to_mask(values: &[String]) -> Result<i32, FirewallError> {
199 if values.is_empty() {

Callers 1

rule_to_modelFunction · 0.85

Calls 1

newFunction · 0.50

Tested by

no test coverage detected