fn from(rule: SeccompRule) -> Self {
        // Rule is built backwards, last statement is the action of the rule.
        // The offset to the next rule is 1.
        let mut accumulator =
            Vec::with_capacity(rule.conditions.len() * CONDITION_MAX_LEN as usize);
        let mut rule_len = 1;
        let mut offset = 1;
        accumulator.push(vec![BPF_STMT(BPF_RET + BPF_K, u32::from(rule.action))]);

        // Conditions are translated into BPF statements and prepended to the rule.
        rule.conditions.into_iter().for_each(|condition| {
            SeccompRule::append_condition(condition, &mut accumulator, &mut rule_len, &mut offset)
        });

        // The two initial jump statements are prepended to the rule.
        let rule_jumps = vec![
            BPF_STMT(BPF_JMP + BPF_JA, 1),
            BPF_STMT(BPF_JMP + BPF_JA, u32::from(offset) + 1),
        ];
        rule_len += rule_jumps.len();
        accumulator.push(rule_jumps);

        // Finally, builds the translated rule by consuming the accumulator.
        let mut result = Vec::with_capacity(rule_len);
        accumulator
            .into_iter()
            .rev()
            .for_each(|mut instructions| result.append(&mut instructions));

        result
    }
/// Translates a rule into BPF statements.
///
/// Each rule starts with 2 jump statements:
/// * The first jump enters the rule, attempting a match.
/// * The second jump points to the end of the rule chain for one syscall, into the rule chain
///   for the next syscall or the default action if the current syscall is the last one. It
///   essentially jumps out of the current rule chain.
Translates a rule into BPF statements.
Each rule starts with 2 jump statements:
The first jump enters the rule, attempting a match.
The second jump points to the end of the rule chain for one syscall, into the rule chain
for the next syscall or the default action if the current syscall is the last one. It
essentially jumps out of the current rule chain.
Translates a rule into BPF statements . Each rule starts with 2 jump statements : The first jump enters the rule attempting a match . The second jump points to the end of the rule chain for one syscall into the rule chain for the next syscall or the default action if the current syscall is the last one . It essentially jumps out of the current rule chain .
fn from(rule: SeccompRule) -> Self {
        // Rule is built backwards, last statement is the action of the rule.
        // The offset to the next rule is 1.
        let mut accumulator =
            Vec::with_capacity(rule.conditions.len() * CONDITION_MAX_LEN as usize);
        let mut rule_len = 1;
        let mut offset = 1;
        accumulator.push(vec![BPF_STMT(BPF_RET + BPF_K, u32::from(rule.action))]);
        // Conditions are translated into BPF statements and prepended to the rule.
        rule.conditions.into_iter().for_each(|condition| {
            SeccompRule::append_condition(condition, &mut accumulator, &mut rule_len, &mut offset)
        });
        // The two initial jump statements are prepended to the rule.
        let rule_jumps = vec![
            BPF_STMT(BPF_JMP + BPF_JA, 1),
            BPF_STMT(BPF_JMP + BPF_JA, u32::from(offset) + 1),
        ];
        rule_len += rule_jumps.len();
        accumulator.push(rule_jumps);
        // Finally, builds the translated rule by consuming the accumulator.
        let mut result = Vec::with_capacity(rule_len);
        accumulator
            .into_iter()
            .rev()
            .for_each(|mut instructions| result.append(&mut instructions));
        result
    }
fn from ( rule : SeccompRule ) -> Self { // Rule is built backwards, last statement is the action of the rule. // The offset to the next rule is 1. let mut accumulator = Vec :: with_capacity ( rule . conditions . len ( ) * CONDITION_MAX_LEN as usize ) ; let mut rule_len = 1 ; let mut offset = 1 ; accumulator . push ( vec ! [ BPF_STMT ( BPF_RET BPF_K u32 from ( rule action ) ) ] ) ; // Conditions are translated into BPF statements and prepended to the rule. rule . conditions . into_iter ( ) . for_each ( | condition | { SeccompRule :: append_condition ( condition , & mut accumulator , & mut rule_len , & mut offset ) } ) ; // The two initial jump statements are prepended to the rule. let rule_jumps = vec ! [ BPF_STMT ( BPF_JMP BPF_JA 1 ) BPF_STMT ( BPF_JMP BPF_JA u32 from ( offset ) 1 ) ] ; rule_len += rule_jumps . len ( ) ; accumulator . push ( rule_jumps ) ; // Finally, builds the translated rule by consuming the accumulator. let mut result = Vec :: with_capacity ( rule_len ) ; accumulator . into_iter ( ) . rev ( ) . for_each ( | mut instructions | result . append ( & mut instructions ) ) ; result }
Translates a rule into BPF statements.
Translates a rule into BPF statements .
rule
SeccompRule
rule
SeccompRule