private void Button_Click(object sender, RoutedEventArgs e) { IPv4Address ip = null; if (lastArp != null) { arpAnswers.Items.Clear(); } try { ip = new IPv4Address(ipToResolve.Text); lastArp = ip; if (IPv4Address.IsInSameSubnet(Client.Configuration.IpAddress, ip, Client.Configuration.SubnetMask)) { Client.Arp.SendArpResolutionPacket(ip); } else { Client.Arp.SendArpResolutionPacket(Client.Configuration.DefaultGateway); } } catch { MessageBox.Show("\"" + ipToResolve.Text + "\" is not a valid IP address."); } }
void Arp_ArpReplyReceived(IPv4Address ip, MacAddress mac) { IPv4Address myip = null; string myText = ""; this.Dispatcher.Invoke(() => { myText = ipToResolve.Text; }); try { myip = new IPv4Address(myText); if (ip.AsString == myip.AsString || !IPv4Address.IsInSameSubnet(myip, ip, Client.Configuration.SubnetMask)) { this.Dispatcher.Invoke(() => { arpAnswers.Items.Add(mac.ToString()); }); } } catch { } }