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
- DataTableNewRowEvent.cs
- IndexedWhereQueryOperator.cs
- DateRangeEvent.cs
- IsolatedStorageFile.cs
- EarlyBoundInfo.cs
- AttributeQuery.cs
- DataBoundControlHelper.cs
- OptimalBreakSession.cs
- BufferedStream.cs
- PathFigureCollection.cs
- EventLog.cs
- ExecutedRoutedEventArgs.cs
- EndpointAddressMessageFilter.cs
- Rotation3DAnimation.cs
- TypeContext.cs
- ClientFormsAuthenticationMembershipProvider.cs
- ItemList.cs
- GeometryValueSerializer.cs
- UpdateExpressionVisitor.cs
- BitmapImage.cs
- CacheAxisQuery.cs
- SkewTransform.cs
- SettingsAttributeDictionary.cs
- FontFamilyConverter.cs
- _HeaderInfoTable.cs
- FastEncoder.cs
- SslStream.cs
- TraceFilter.cs
- QualifiedCellIdBoolean.cs
- Graph.cs
- RenderOptions.cs
- DependsOnAttribute.cs
- ProjectedWrapper.cs
- ValueUnavailableException.cs
- ForeignConstraint.cs
- CorruptingExceptionCommon.cs
- JsonWriter.cs
- IfElseDesigner.xaml.cs
- HttpApplication.cs
- XpsImageSerializationService.cs
- XmlSchemaProviderAttribute.cs
- PointValueSerializer.cs
- RC2.cs
- WebConfigurationManager.cs
- SchemaDeclBase.cs
- BitmapSource.cs
- ScriptingAuthenticationServiceSection.cs
- MetadataPropertyCollection.cs
- GroupBox.cs
- DBCommand.cs
- SqlInternalConnectionTds.cs
- WindowsListViewGroup.cs
- CodeDOMProvider.cs
- StdValidatorsAndConverters.cs
- SqlMethodAttribute.cs
- FileDialog_Vista.cs
- AdCreatedEventArgs.cs
- ComplexPropertyEntry.cs
- Classification.cs
- NullableDecimalMinMaxAggregationOperator.cs
- PriorityQueue.cs
- EmptyImpersonationContext.cs
- FileDialog_Vista_Interop.cs
- ConvertEvent.cs
- DateTimePicker.cs
- MasterPageCodeDomTreeGenerator.cs
- MultipleCopiesCollection.cs
- NumberSubstitution.cs
- XmlLinkedNode.cs
- XmlSequenceWriter.cs
- ScriptRef.cs
- XhtmlTextWriter.cs
- XsdDataContractExporter.cs
- BindingMAnagerBase.cs
- DocumentViewerBaseAutomationPeer.cs
- ImageList.cs
- ChangePasswordDesigner.cs
- WebBaseEventKeyComparer.cs
- EnumerableRowCollectionExtensions.cs
- ServiceNameElementCollection.cs
- DefinitionUpdate.cs
- BypassElement.cs
- MappableObjectManager.cs
- CharacterMetrics.cs
- KerberosTicketHashIdentifierClause.cs
- Button.cs
- GeneratedCodeAttribute.cs
- RegexCompiler.cs
- FontFaceLayoutInfo.cs
- XpsColorContext.cs
- EnumDataContract.cs
- TemplateColumn.cs
- PageCatalogPart.cs
- AncestorChangedEventArgs.cs
- Tokenizer.cs
- FlowDocumentView.cs
- XmlReflectionMember.cs
- TableItemPattern.cs
- AsyncDataRequest.cs
- DynamicValueConverter.cs