Skip to content

Commit 68978f0

Browse files
authored
Merge pull request BornToBeRoot#61 from BornToBeRoot/arp-table
ARP-Table added
2 parents 60b69a2 + 2a55df4 commit 68978f0

16 files changed

Lines changed: 634 additions & 158 deletions

‎Source/NETworkManager/Helpers/IPNetTableHelper.cs‎

Lines changed: 0 additions & 128 deletions
This file was deleted.

‎Source/NETworkManager/Helpers/IPv4AddressHelper.cs‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace NETworkManager.Helpers
77
{
88
public static class IPv4AddressHelper
99
{
10+
public const int IPv4MulticastStart = -536870912;
11+
public const int IPv4MulticastEnd = -268435457;
12+
1013
/// <summary>
1114
/// Convert a binary IPv4-Address into a human readable string.
1215
/// </summary>
@@ -42,7 +45,8 @@ public static int ConvertToInt32(IPAddress ipAddress)
4245
{
4346
byte[] bytes = ipAddress.GetAddressBytes();
4447

45-
Array.Reverse(bytes);
48+
if (BitConverter.IsLittleEndian)
49+
Array.Reverse(bytes);
4650

4751
return BitConverter.ToInt32(bytes, 0);
4852
}
@@ -51,7 +55,8 @@ public static IPAddress ConvertFromInt32(int i)
5155
{
5256
byte[] bytes = BitConverter.GetBytes(i);
5357

54-
Array.Reverse(bytes);
58+
if (BitConverter.IsLittleEndian)
59+
Array.Reverse(bytes);
5560

5661
return new IPAddress(bytes);
5762
}
@@ -65,5 +70,12 @@ public static IPAddress DecrementIPv4Address(IPAddress ipAddress, int i)
6570
{
6671
return ConvertFromInt32(ConvertToInt32(ipAddress) - i);
6772
}
73+
74+
public static bool IsMulticast(IPAddress ipAddress)
75+
{
76+
int ip = ConvertToInt32(ipAddress);
77+
78+
return (ip >= IPv4MulticastStart && ip <= IPv4MulticastEnd);
79+
}
6880
}
6981
}

‎Source/NETworkManager/MainWindow.xaml.cs‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,13 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
351351
NetworkInterfaceView networkInterfaceView;
352352
IPScannerView ipScannerView;
353353
PortScannerView portScannerView;
354-
SubnetCalculatorView subnetCalculatorView;
355-
WakeOnLANView wakeOnLANView;
356354
PingView pingView;
357355
TracerouteView tracerouteView;
358356
DNSLookupView dnsLookupView;
359357
RemoteDesktopView remoteDesktopView;
358+
WakeOnLANView wakeOnLANView;
359+
SubnetCalculatorView subnetCalculatorView;
360+
ARPTableView arpTableView;
360361
WikiView wikiView;
361362

362363
private ApplicationViewManager.Name? currentApplicationViewName = null;
@@ -386,18 +387,6 @@ private void ChangeApplicationView(ApplicationViewManager.Name name)
386387

387388
contentControlApplication.Content = portScannerView;
388389
break;
389-
case ApplicationViewManager.Name.SubnetCalculator:
390-
if (subnetCalculatorView == null)
391-
subnetCalculatorView = new SubnetCalculatorView();
392-
393-
contentControlApplication.Content = subnetCalculatorView;
394-
break;
395-
case ApplicationViewManager.Name.WakeOnLAN:
396-
if (wakeOnLANView == null)
397-
wakeOnLANView = new WakeOnLANView();
398-
399-
contentControlApplication.Content = wakeOnLANView;
400-
break;
401390
case ApplicationViewManager.Name.Ping:
402391
if (pingView == null)
403392
pingView = new PingView();
@@ -422,6 +411,24 @@ private void ChangeApplicationView(ApplicationViewManager.Name name)
422411

423412
contentControlApplication.Content = remoteDesktopView;
424413
break;
414+
case ApplicationViewManager.Name.WakeOnLAN:
415+
if (wakeOnLANView == null)
416+
wakeOnLANView = new WakeOnLANView();
417+
418+
contentControlApplication.Content = wakeOnLANView;
419+
break;
420+
case ApplicationViewManager.Name.SubnetCalculator:
421+
if (subnetCalculatorView == null)
422+
subnetCalculatorView = new SubnetCalculatorView();
423+
424+
contentControlApplication.Content = subnetCalculatorView;
425+
break;
426+
case ApplicationViewManager.Name.ARPTable:
427+
if (arpTableView == null)
428+
arpTableView = new ARPTableView();
429+
430+
contentControlApplication.Content = arpTableView;
431+
break;
425432
case ApplicationViewManager.Name.Wiki:
426433
if (wikiView == null)
427434
wikiView = new WikiView();

0 commit comments

Comments
 (0)