コード例 #1
0
		/// <summary>
		/// Clears and reconstructs the list of adapters,
		/// based on the current hardware connections to the
		/// device.
		/// </summary>
		unsafe void Refresh()
		{
			// Clear the existing list, if any.
			this.Clear();

			// Get the list of adapters, in the form of an
			// IP_ADAPTER_INFO object.
			IP_ADAPTER_INFO	ipinfo = new IP_ADAPTER_INFO();

			// For each adapter index, get the adapter 
			// information.  This is done in the fixed 
			// context, as the base address is saved when
			// you do this.
			Adapter	adap = ipinfo.FirstAdapter();
			while ( adap != null )
			{
				// Add the new item to our list.
				this.List.Add( adap );

				// Get the next adapter information.
				adap = ipinfo.NextAdapter();
			}
		}
コード例 #2
0
ファイル: Adapter.cs プロジェクト: JeffreyZksun/gpstranslator
		internal Adapter( IP_ADAPTER_INFO info ) : base(DEVICE_NAME)
		{
			this.FromIP_ADAPTER_INFO( info );
		}
コード例 #3
0
ファイル: Adapter.cs プロジェクト: JeffreyZksun/gpstranslator
		public Adapter NextAdapter()
		{
			// Starting at the current offset in our 'data'
			// member, get the Next field, subtrace its pointer
			// from the initial pointer value to find the
			// new offset, and create an adapter starting
			// at that point in the 'data' member.

			if ( data == null )
				return null;

			// Handle no more case.
			if ( firstnextOffset == 0 )
				return null;

			IP_ADAPTER_INFO	newinfo = new IP_ADAPTER_INFO( data, 
				firstnextOffset );

			firstnextIndex++;

			// Now, use the Next field of the new info 
			// structure to update where we find the next
			// one after that in our list.
			if ( newinfo.Next == 0 )
				firstnextOffset = 0;
			else
				firstnextOffset = newinfo.Next - ourBase;

			return new Adapter( newinfo );
		}
コード例 #4
0
ファイル: Adapter.cs プロジェクト: JeffreyZksun/gpstranslator
		internal void FromIP_ADAPTER_INFO( IP_ADAPTER_INFO info )
		{
			// Copy the name, description, index, etc.
			name = info.AdapterName;
			description = info.Description;
			index = info.Index;

			// The adapter type should not change, so we
			// can store that.
			type = info.Type;

			// The hardware address should not change, so
			// we can store that, too.
			hwaddress = info.PhysAddress;

			// Get the flag concerning whether DHCP is enabled
			// or not.
			dhcpenabled = info.DHCPEnabled;

			// Get the current IP address and subnet mask.
			currentIp = info.CurrentIpAddress;
			currentsubnet = info.CurrentSubnetMask;

			// Get the gateway address and the DHCP server.
			gateway = info.Gateway;
			dhcpserver = info.DHCPServer;

			// Get the WINS information.
			havewins = info.HaveWINS;
			primarywinsserver = info.PrimaryWINSServer;
			secondarywinsserver = info.SecondaryWINSServer;

			// DHCP lease information.
			leaseobtained = info.LeaseObtained;
			leaseexpires = info.LeaseExpires;
		}