Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / NetworkInformation / SystemIPInterfaceStatistics.cs / 1 / SystemIPInterfaceStatistics.cs
////// namespace System.Net.NetworkInformation { using System.Net.Sockets; using System; using System.ComponentModel; /// /// Provides support for ip configuation information and statistics. /// 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); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. ////// namespace System.Net.NetworkInformation { using System.Net.Sockets; using System; using System.ComponentModel; /// /// Provides support for ip configuation information and statistics. /// 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); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AlphabeticalEnumConverter.cs
- SmtpNegotiateAuthenticationModule.cs
- KnownTypesHelper.cs
- ButtonBase.cs
- SecurityContext.cs
- MatrixStack.cs
- SpellerStatusTable.cs
- RequestCacheEntry.cs
- SqlUdtInfo.cs
- TableMethodGenerator.cs
- ButtonRenderer.cs
- Point3DCollectionValueSerializer.cs
- SecurityTokenRequirement.cs
- QuaternionAnimationBase.cs
- XPathAncestorQuery.cs
- wmiprovider.cs
- _DisconnectOverlappedAsyncResult.cs
- EventProviderBase.cs
- SafeNativeMethodsMilCoreApi.cs
- LinkDescriptor.cs
- WebConfigurationHostFileChange.cs
- Currency.cs
- UpdateCommand.cs
- NotSupportedException.cs
- ToolStripDropDownItemDesigner.cs
- ConvertEvent.cs
- NotificationContext.cs
- OperationExecutionFault.cs
- ObjectViewListener.cs
- Label.cs
- InsufficientMemoryException.cs
- ServiceModelExtensionCollectionElement.cs
- SessionStateItemCollection.cs
- HtmlLink.cs
- CqlLexer.cs
- GlyphRunDrawing.cs
- StylusLogic.cs
- SocketPermission.cs
- ScrollBar.cs
- AttributeUsageAttribute.cs
- XmlSchemaSimpleContentRestriction.cs
- safex509handles.cs
- OdbcEnvironment.cs
- __ComObject.cs
- AddInAdapter.cs
- RoleService.cs
- ProcessThread.cs
- TypeUtils.cs
- WriteableBitmap.cs
- CompositionAdorner.cs
- Vector3DAnimationUsingKeyFrames.cs
- XamlFigureLengthSerializer.cs
- TextOnlyOutput.cs
- DataViewListener.cs
- ObjectConverter.cs
- SmtpException.cs
- WorkflowQueueInfo.cs
- ProfilePropertyNameValidator.cs
- ResourceProperty.cs
- PixelShader.cs
- InsufficientMemoryException.cs
- SQLString.cs
- AxHostDesigner.cs
- DefaultClaimSet.cs
- Header.cs
- ArraySubsetEnumerator.cs
- GenericXmlSecurityTokenAuthenticator.cs
- SqlExpressionNullability.cs
- InputMethodStateChangeEventArgs.cs
- Gdiplus.cs
- SHA256.cs
- JsonFormatReaderGenerator.cs
- OrderingQueryOperator.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- BidirectionalDictionary.cs
- GridViewRowPresenterBase.cs
- SizeIndependentAnimationStorage.cs
- Matrix3DStack.cs
- PageClientProxyGenerator.cs
- EntityUtil.cs
- QueryStringParameter.cs
- SafeNativeMethodsMilCoreApi.cs
- FixedFindEngine.cs
- AnyAllSearchOperator.cs
- PlatformCulture.cs
- Int32RectConverter.cs
- UserPreferenceChangingEventArgs.cs
- figurelength.cs
- Context.cs
- MultiPropertyDescriptorGridEntry.cs
- DataGridViewBindingCompleteEventArgs.cs
- DocumentPageHost.cs
- ListViewEditEventArgs.cs
- DataGridViewRowCancelEventArgs.cs
- ProxyWebPartManager.cs
- FreezableDefaultValueFactory.cs
- DetailsViewInsertedEventArgs.cs
- TextDpi.cs
- DecryptRequest.cs
- PageVisual.cs