Class: PacketGen::Header::IP
- Inherits:
-
Object
- Object
- PacketGen::Header::IP
- Defined in:
- lib/capra/packetgen_extensions.rb
Instance Method Summary collapse
- #external_communication? ⇒ Boolean
- #external_destination? ⇒ Boolean
- #external_source? ⇒ Boolean
- #from_subnet?(cidr) ⇒ Boolean
- #from_subnets?(cidrs) ⇒ Boolean
- #internal_communication_only? ⇒ Boolean
- #internal_destination? ⇒ Boolean
- #internal_source? ⇒ Boolean
- #to_subnet?(cidr) ⇒ Boolean
- #to_subnets?(cidr) ⇒ Boolean
- #within_subnet?(cidr) ⇒ Boolean
Instance Method Details
#external_communication? ⇒ Boolean
78 79 80 |
# File 'lib/capra/packetgen_extensions.rb', line 78 def external_communication? !internal_communication_only? end |
#external_destination? ⇒ Boolean
86 87 88 |
# File 'lib/capra/packetgen_extensions.rb', line 86 def external_destination? !internal_destination? end |
#external_source? ⇒ Boolean
94 95 96 |
# File 'lib/capra/packetgen_extensions.rb', line 94 def external_source? !internal_source? end |
#from_subnet?(cidr) ⇒ Boolean
103 104 105 106 |
# File 'lib/capra/packetgen_extensions.rb', line 103 def from_subnet?(cidr) subnet = IPAddr.new(cidr) subnet.include?(self.src) end |
#from_subnets?(cidrs) ⇒ Boolean
108 109 110 |
# File 'lib/capra/packetgen_extensions.rb', line 108 def from_subnets?(cidrs) cidrs.map { IPAddr.new(cidr) }.include?(self.src) end |
#internal_communication_only? ⇒ Boolean
74 75 76 |
# 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? ⇒ Boolean
82 83 84 |
# File 'lib/capra/packetgen_extensions.rb', line 82 def internal_destination? PRIVATE_IPS.any? { |private_ip| private_ip.include?(self.dst) } end |
#internal_source? ⇒ Boolean
90 91 92 |
# 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) ⇒ Boolean
112 113 114 115 |
# File 'lib/capra/packetgen_extensions.rb', line 112 def to_subnet?(cidr) subnet = IPAddr.new(cidr) subnet.include?(self.dst) end |
#to_subnets?(cidr) ⇒ Boolean
117 118 119 |
# File 'lib/capra/packetgen_extensions.rb', line 117 def to_subnets?(cidr) cidrs.map { IPAddr.new(cidr) }.include?(self.dst) end |
#within_subnet?(cidr) ⇒ Boolean
98 99 100 101 |
# 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 |