internal unsafe DeviceAddress(pcap_addr *pcapAddress) { long num1 = *(long *)((IntPtr)pcapAddress + 8L); SocketAddressFamily socketAddressFamily = (SocketAddressFamily) * (ushort *)num1; switch (socketAddressFamily) { case SocketAddressFamily.Internet: if (num1 != 0L) { this._address = (SocketAddress) new IpV4SocketAddress((sockaddr *)num1); } ulong num2 = (ulong)*(long *)((IntPtr)pcapAddress + 16L); if ((long)num2 != 0L) { this._netmask = (SocketAddress) new IpV4SocketAddress((sockaddr *)num2); } ulong num3 = (ulong)*(long *)((IntPtr)pcapAddress + 24L); if ((long)num3 != 0L) { this._broadcast = (SocketAddress) new IpV4SocketAddress((sockaddr *)num3); } ulong num4 = (ulong)*(long *)((IntPtr)pcapAddress + 32L); if ((long)num4 == 0L) { break; } this._destination = (SocketAddress) new IpV4SocketAddress((sockaddr *)num4); break; case SocketAddressFamily.Internet6: if (num1 != 0L) { this._address = (SocketAddress) new IpV6SocketAddress((sockaddr *)num1); } ulong num5 = (ulong)*(long *)((IntPtr)pcapAddress + 16L); if ((long)num5 != 0L) { this._netmask = (SocketAddress) new IpV6SocketAddress((sockaddr *)num5); } ulong num6 = (ulong)*(long *)((IntPtr)pcapAddress + 24L); if ((long)num6 != 0L) { this._broadcast = (SocketAddress) new IpV6SocketAddress((sockaddr *)num6); } ulong num7 = (ulong)*(long *)((IntPtr)pcapAddress + 32L); if ((long)num7 == 0L) { break; } this._destination = (SocketAddress) new IpV6SocketAddress((sockaddr *)num7); break; default: throw new NotImplementedException("Device of family " + socketAddressFamily.ToString() + " is unsupported"); } }
private unsafe LivePacketDevice(pcap_if *device) { List <DeviceAddress> list = new List <DeviceAddress>(); pcap_addr * pcapAddress = (pcap_addr *)*(long *)((IntPtr)device + 24L); if ((IntPtr)pcapAddress != IntPtr.Zero) { do { DeviceAddress deviceAddress = new DeviceAddress(pcapAddress); list.Add(deviceAddress); pcapAddress = (pcap_addr *)*(long *)pcapAddress; }while ((IntPtr)pcapAddress != IntPtr.Zero); } this._name = new string((sbyte *)*(long *)((IntPtr)device + 8L)); this._description = new string((sbyte *)*(long *)((IntPtr)device + 16L)); this._attributes = (DeviceAttributes) * (int *)((IntPtr)device + 32L); this._addresses = new ReadOnlyCollection <DeviceAddress>((IList <DeviceAddress>)list); }