Skip to content
Browse files

fix in pdev_filter creation

  • Loading branch information...
1 parent 2b9862d commit 6ca29b21af41afc2b9d04be31b8c436361c816cc @seuffert committed May 10, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 XBSlink/xbs_sniffer.cs
View
12 XBSlink/xbs_sniffer.cs
@@ -53,6 +53,7 @@ class xbs_sniffer
private const String pdev_filter_template_include = "{include_filters}";
private const String pdev_filter_template_exclude = "{exlude_filters}";
private String pdev_filter_template = "(" + pdev_filter_template_include + ") and not (" + pdev_filter_template_exclude + ")";
+ private String pdev_filter_template_only_include = "(" + pdev_filter_template_include + ")";
private String pdev_filter_gameconsoles = "(udp and ((ip host 0.0.0.1) or (dst portrange 3074-3075))) ";
private String pdev_filter_gateways = "";
@@ -400,7 +401,9 @@ public void setPdevFilter()
List<String> include_filter_list = new List<string>();
// always exclude local sniffing interface
- exclude_filter_list.Add("ether host "+PhysicalAddressToString(pdev.MacAddress));
+ String local_mac = PhysicalAddressToString(pdev.MacAddress);
+ if (local_mac.Length>0)
+ exclude_filter_list.Add("ether host "+PhysicalAddressToString(pdev.MacAddress));
// exclude gatway IPs, just to be on the safe side
if (pdev_filter_exclude_gatway_ips && pdev_filter_gateways.Length > 0)
exclude_filter_list.Add(pdev_filter_gateways);
@@ -437,9 +440,10 @@ public void setPdevFilter()
String exlude_filter_string = "( "+ String.Join(" ) or (", exclude_filter_list.ToArray()) + " ) ";
String include_filter_string = "( " + String.Join(" ) or (", include_filter_list.ToArray()) + " ) ";
- String f;
- f = pdev_filter_template.Replace(pdev_filter_template_include, include_filter_string);
- f = f.Replace(pdev_filter_template_exclude, exlude_filter_string);
+ String f = (exclude_filter_list.Count>0) ? pdev_filter_template : pdev_filter_template_only_include;
+ f = f.Replace(pdev_filter_template_include, include_filter_string);
+ if (exclude_filter_list.Count>0)
+ f = f.Replace(pdev_filter_template_exclude, exlude_filter_string);
#if DEBUG
xbs_messages.addInfoMessage("- pdev filter: " + f);
#endif

0 comments on commit 6ca29b2

Please sign in to comment.
Something went wrong with that request. Please try again.