using iWareCommon.Utils; using iWarePod.Cache.Entity; using iWarePod.Properties; using System; using System.Runtime.InteropServices; using System.Text; namespace iWarePod.Utils { public class IpHelper { [DllImport("Iphlpapi.dll")] static extern int SendARP(Int32 DestIP, Int32 SrcIP, ref Int64 MacAddr, ref Int32 PhyAddrLen); [DllImport("Ws2_32.dll")] static extern Int32 inet_addr(string ipaddr); /// /// SendArp获取MAC地址 /// ///目标机器的IP地址如(192.168.1.1) ///目标机器的mac 地址 public static string GetMacAddress(string remoteIP) { try { var mapIp = CacheEntity.ControlCenterWcfServiceClient.GetIp(remoteIP); LogTextHelper.WriteLine(Resources.LogDir, "remoteIP = {0}, mapIp = {1}", remoteIP, mapIp); return mapIp; } catch(Exception ex) { LogTextHelper.WriteLog(Resources.LogDir, "IpHelper", "GetMacAddress", ex.Message); return remoteIP; } } } }