Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / NetworkInformation / SystemIPInterfaceStatistics.cs / 1 / SystemIPInterfaceStatistics.cs
///
/// Provides support for ip configuation information and statistics.
///
///
namespace System.Net.NetworkInformation {
using System.Net.Sockets;
using System;
using System.ComponentModel;
/// IP statistics
internal class SystemIPv4InterfaceStatistics:IPv4InterfaceStatistics {
MibIfRow ifRow = new MibIfRow();
private SystemIPv4InterfaceStatistics(){ }
internal SystemIPv4InterfaceStatistics(long index){
GetIfEntry(index);
}
public override long OutputQueueLength{get {return ifRow.dwOutQLen;}}
public override long BytesSent{get {return ifRow.dwOutOctets;}}
public override long BytesReceived{get {return ifRow.dwInOctets;}}
public override long UnicastPacketsSent{get {return ifRow.dwOutUcastPkts;}}
public override long UnicastPacketsReceived{get { return ifRow.dwInUcastPkts;}}
public override long NonUnicastPacketsSent{get { return ifRow.dwOutNUcastPkts;}}
public override long NonUnicastPacketsReceived{get { return ifRow.dwInNUcastPkts;}}
public override long IncomingPacketsDiscarded{get { return ifRow.dwInDiscards;}}
public override long OutgoingPacketsDiscarded{get { return ifRow.dwOutDiscards;}}
public override long IncomingPacketsWithErrors{get { return ifRow.dwInErrors;}}
public override long OutgoingPacketsWithErrors{get { return ifRow.dwOutErrors;}}
public override long IncomingUnknownProtocolPackets{get { return ifRow.dwInUnknownProtos;}}
internal long Mtu{get { return ifRow.dwMtu;}}
internal OperationalStatus OperationalStatus{
get{
switch (ifRow.operStatus) {
case OldOperationalStatus.NonOperational:
return OperationalStatus.Down;
case OldOperationalStatus.Unreachable:
return OperationalStatus.Down;
case OldOperationalStatus.Disconnected:
return OperationalStatus.Dormant;
case OldOperationalStatus.Connecting:
return OperationalStatus.Dormant;
case OldOperationalStatus.Connected:
return OperationalStatus.Up;
case OldOperationalStatus.Operational:
return OperationalStatus.Up;
}
//state unknow
return OperationalStatus.Unknown;
}
}
internal long Speed{get { return ifRow.dwSpeed;}}
//This method is used to get information for ipv4 specific interfaces
//we should only call this the first time one of the properties
//are accessed.
void GetIfEntry(long index) {
if (index == 0 )
return;
ifRow.dwIndex = (uint)index;
uint result = UnsafeNetInfoNativeMethods.GetIfEntry(ref ifRow);
if (result != IpHelperErrors.Success) {
throw new NetworkInformationException((int)result);
}
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- FrameworkElementAutomationPeer.cs
- StructuredCompositeActivityDesigner.cs
- MembershipSection.cs
- OleDbException.cs
- XmlComment.cs
- XPathQilFactory.cs
- ListContractAdapter.cs
- RegisteredHiddenField.cs
- QilUnary.cs
- ExitEventArgs.cs
- CompositeDataBoundControl.cs
- Missing.cs
- Model3D.cs
- EventBuilder.cs
- MachineKeyConverter.cs
- TextPatternIdentifiers.cs
- OrderedDictionaryStateHelper.cs
- ProviderConnectionPoint.cs
- WindowsIdentity.cs
- Evidence.cs
- ResolveCompletedEventArgs.cs
- SpecialNameAttribute.cs
- SortQuery.cs
- ArgIterator.cs
- InitializationEventAttribute.cs
- QuaternionValueSerializer.cs
- XmlArrayItemAttribute.cs
- DataServiceExpressionVisitor.cs
- WorkflowApplicationException.cs
- DataGridViewAutoSizeModeEventArgs.cs
- PerfProviderCollection.cs
- LOSFormatter.cs
- Semaphore.cs
- Event.cs
- ElementFactory.cs
- Walker.cs
- UnSafeCharBuffer.cs
- DescendantOverDescendantQuery.cs
- WebBrowserHelper.cs
- WebPartTransformer.cs
- XmlAttributes.cs
- DurableOperationAttribute.cs
- SqlTopReducer.cs
- Byte.cs
- UTF32Encoding.cs
- EmptyCollection.cs
- LinkLabel.cs
- DataSourceCacheDurationConverter.cs
- ImagingCache.cs
- ServicePointManager.cs
- MultiTouchSystemGestureLogic.cs
- GeometryModel3D.cs
- IMembershipProvider.cs
- Vector.cs
- WebPartVerbCollection.cs
- PasswordRecoveryDesigner.cs
- FillRuleValidation.cs
- HostUtils.cs
- ManagedWndProcTracker.cs
- UnSafeCharBuffer.cs
- ReadOnlyDataSource.cs
- BrowserDefinitionCollection.cs
- RadioButton.cs
- ListView.cs
- RegexTree.cs
- IncomingWebRequestContext.cs
- Identifier.cs
- ControlValuePropertyAttribute.cs
- AggregateNode.cs
- BinaryWriter.cs
- RootProfilePropertySettingsCollection.cs
- StrongNameMembershipCondition.cs
- XmlSchemaAnnotated.cs
- SoundPlayerAction.cs
- IPAddress.cs
- UniqueID.cs
- Scalars.cs
- CodeDomDecompiler.cs
- EraserBehavior.cs
- MarshalByValueComponent.cs
- ComboBoxAutomationPeer.cs
- DefaultAsyncDataDispatcher.cs
- BridgeDataReader.cs
- SqlDataSourceWizardForm.cs
- ProfileInfo.cs
- Stroke2.cs
- DataGridViewCellEventArgs.cs
- RadioButton.cs
- DisplayNameAttribute.cs
- DataSourceHelper.cs
- XamlInt32CollectionSerializer.cs
- ProfileService.cs
- DataSourceGeneratorException.cs
- FrameworkTemplate.cs
- PrimitiveCodeDomSerializer.cs
- InkPresenterAutomationPeer.cs
- SizeConverter.cs
- COM2IManagedPerPropertyBrowsingHandler.cs
- Reference.cs
- URLIdentityPermission.cs