Class: Seccomp::Notify::BPF::Program
- Inherits:
-
Object
- Object
- Seccomp::Notify::BPF::Program
- Defined in:
- lib/seccomp/notify/bpf/program.rb
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
Instance Method Summary collapse
-
#initialize(instructions) ⇒ Program
constructor
A new instance of Program.
- #to_binary ⇒ Object
- #to_sock_fprog ⇒ Object
Constructor Details
#initialize(instructions) ⇒ Program
Returns a new instance of Program.
11 12 13 14 15 16 17 18 |
# File 'lib/seccomp/notify/bpf/program.rb', line 11 def initialize(instructions) @instructions = instructions.freeze raise FilterTooLargeError, "BPF program exceeds #{Constants::BPF_MAXINSNS} instructions" if instructions.length > Constants::BPF_MAXINSNS @binary = instructions.map(&:to_binary).join @pointer = Fiddle::Pointer[@binary] @sock_fprog = [instructions.length, @pointer.to_i].pack(Structs::PROGRAM_FORMAT) end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
9 10 11 |
# File 'lib/seccomp/notify/bpf/program.rb', line 9 def instructions @instructions end |
Instance Method Details
#to_binary ⇒ Object
20 21 22 |
# File 'lib/seccomp/notify/bpf/program.rb', line 20 def to_binary @binary end |
#to_sock_fprog ⇒ Object
24 25 26 |
# File 'lib/seccomp/notify/bpf/program.rb', line 24 def to_sock_fprog @sock_fprog end |