Class: Seccomp::Notify::BPF::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/seccomp/notify/bpf/program.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#instructionsObject (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_binaryObject



20
21
22
# File 'lib/seccomp/notify/bpf/program.rb', line 20

def to_binary
  @binary
end

#to_sock_fprogObject



24
25
26
# File 'lib/seccomp/notify/bpf/program.rb', line 24

def to_sock_fprog
  @sock_fprog
end