/// <summary> /// Returns the Media Access Control (MAC) address for this adapter. /// </summary> /// <returns> /// A System.Net.NetworkInformation.PhysicalAddress object that contains the /// physical address. /// </returns> public PhysicalAddress GetPhysicalAddress() { // get the adapter info if it's not already been done if (m_adapterInfo == null) { m_adapterInfo = GetAdapterInfo(Index); } return(m_adapterInfo.PhysicalAddress); }
/// <summary> /// Returns an object that describes the configuration of this network interface. /// </summary> /// <returns> /// An System.Net.NetworkInformation.IPInterfaceProperties object that describes /// this network interface. /// </returns> /// <remarks>Note that the information in the object returned by this method reflects the interfaces as of the time the array is created. This information is not updated dynamically.</remarks> public IPInterfaceProperties GetIPProperties() { m_adapterInfo = GetAdapterInfo(Index); m_mibifRow = NetworkInterface.GetMibIfRow(Index); IPInterfaceProperties props = new IPInterfaceProperties(m_adapterInfo, m_mibifRow); return(props); }
/// <summary> /// Method called after making some changes to the current /// IP address, subnet mask, etc. This method notifies NDIS /// to rebind the adapter to all protocols, in effect causing /// the current registry settings to be applied rather than /// those which the current configuration represents. Once you /// have rebound an adapter, to get its new configuration, you /// must regenerate the list of adapters. Changes to things /// like the IP address, subnet mask, etc. are not immediately /// returned. /// </summary> public void Rebind() { NDIS.RebindInterface(this.Name); // refresh our adapter info, expecting a possible index change int index = Index; m_adapterInfo = GetAdapterInfo(ref index, Name); Index = index; }
/// <summary> /// Creates a NetworkInterface instance /// </summary> /// <param name="index"></param> /// <param name="interfaceName"></param> internal NetworkInterface(int index, string interfaceName) { Index = index; Name = interfaceName; m_adapterInfo = null; }
/// <summary> /// Refreshes all statistics for the current NetworkInterface /// </summary> public void Refresh() { // just set the members to null so the next query will call the API again m_adapterInfo = null; m_mibifRow = null; }
internal IPInterfaceProperties(IP_ADAPTER_INFO info, MibIfRow mibifRow) { m_info = info; m_mtu = mibifRow.MTU; }