class PacketGen::Header::IP

Public Instance Methods

external_communication?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 78
def external_communication?
  !internal_communication_only?
end
external_destination?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 86
def external_destination?
  !internal_destination?
end
external_source?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 94
def external_source?
  !internal_source? 
end
from_subnet?(cidr) click to toggle source
# File lib/capra/packetgen_extensions.rb, line 103
def from_subnet?(cidr)
  subnet = IPAddr.new(cidr)
  subnet.include?(self.src)
end
from_subnets?(cidrs) click to toggle source
# File lib/capra/packetgen_extensions.rb, line 108
def from_subnets?(cidrs)
  cidrs.map { IPAddr.new(cidr) }.include?(self.src)
end
internal_communication_only?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 74
def internal_communication_only?
  PRIVATE_IPS.any? { |private_ip| private_ip.include?(self.src) } and PRIVATE_IPS.any? { |private_ip| private_ip.include?(self.dst) }
end
internal_destination?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 82
def internal_destination?
  PRIVATE_IPS.any? { |private_ip| private_ip.include?(self.dst) }
end
internal_source?() click to toggle source
# File lib/capra/packetgen_extensions.rb, line 90
def internal_source?
  PRIVATE_IPS.any? { |private_ip| private_ip.include?(self.src) }
end
to_subnet?(cidr) click to toggle source
# File lib/capra/packetgen_extensions.rb, line 112
def to_subnet?(cidr)
  subnet = IPAddr.new(cidr)
  subnet.include?(self.dst)
end
to_subnets?(cidr) click to toggle source
# File lib/capra/packetgen_extensions.rb, line 117
def to_subnets?(cidr)
  cidrs.map { IPAddr.new(cidr) }.include?(self.dst)
end
within_subnet?(cidr) click to toggle source
# File lib/capra/packetgen_extensions.rb, line 98
def within_subnet?(cidr)
  subnet = IPAddr.new(cidr)
  subnet.include?(self.src) or subnet.include?(self.dst)
end