summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2017-03-15 06:48:41 +0000
committerintrigeri <intrigeri@boum.org>2017-03-15 06:48:41 +0000
commit9c1809bdacdf6ba0b17a34ec023cdfa38126ffe4 (patch)
treeb4c74cd1bbddd3d5d089c7ffc0976ad732be64ac
parent9d8f69fe4d93f54fb371c24f9a52ca5764ed46ac (diff)
parent97f1eee4eb43c63f6998694f6132515900051f1e (diff)
Merge remote-tracking branch 'origin/stable' into stable
-rw-r--r--features/support/helpers/firewall_helper.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/features/support/helpers/firewall_helper.rb b/features/support/helpers/firewall_helper.rb
index 49e9853..25029a2 100644
--- a/features/support/helpers/firewall_helper.rb
+++ b/features/support/helpers/firewall_helper.rb
@@ -1,5 +1,10 @@
require 'packetfu'
+def looks_like_dhcp_packet?(protocol, sport, dport, ip_packet)
+ protocol == "udp" && sport == 68 && dport == 67 && ip_packet &&
+ ip_packet.ip_saddr == '0.0.0.0' && ip_packet.ip_daddr == "255.255.255.255"
+end
+
# Returns the unique edges (based on protocol, source/destination
# address/port) in the graph of all network flows.
def pcap_connections_helper(pcap_file, opts = {})
@@ -37,13 +42,8 @@ def pcap_connections_helper(pcap_file, opts = {})
raise "Found something that cannot be parsed"
end
- if protocol == "udp" and
- sport == 68 and
- dport == 67 and
- ip_packet.ip_saddr == '0.0.0.0' and
- ip_packet.ip_daddr == "255.255.255.255"
- next if opts[:ignore_dhcp]
- end
+ next if looks_like_dhcp_packet?(protocol, sport, dport, ip_packet) &&
+ opts[:ignore_dhcp]
packet_info = {
mac_saddr: eth_packet.eth_saddr,
@@ -53,7 +53,7 @@ def pcap_connections_helper(pcap_file, opts = {})
dport: dport,
}
# It seems *Packet.parse can return nil despite *Packet.can_parse?
- # returning true.
+ # returning true. (#11508)
if ip_packet
packet_info[:saddr] = ip_packet.ip_saddr
packet_info[:daddr] = ip_packet.ip_daddr