summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2017-03-13 23:07:30 +0100
committeranonym <anonym@riseup.net>2017-03-13 23:07:30 +0100
commit82f063836ae9398df56184620c4e2e7f4ae273a1 (patch)
tree332857afcc5f7ef09a196e5491164f8ace3e8fb7
parent7dc82144a6ca605b94b23726cffa58bbeaa5f089 (diff)
parent97f1eee4eb43c63f6998694f6132515900051f1e (diff)
Merge remote-tracking branch 'origin/stable' into devel
-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