Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- WhitespaceRule.cs
- SystemPens.cs
- DataGridAddNewRow.cs
- WindowsGraphicsCacheManager.cs
- AuthorizationRule.cs
- ServiceManagerHandle.cs
- SqlRowUpdatedEvent.cs
- PeerContact.cs
- LinqDataSourceDeleteEventArgs.cs
- KeyTime.cs
- EtwTrackingBehaviorElement.cs
- ProcessingInstructionAction.cs
- GeneralTransform3DGroup.cs
- ConfigWriter.cs
- SchemaCollectionPreprocessor.cs
- ClientSettingsProvider.cs
- CommandDevice.cs
- Interlocked.cs
- SafeSystemMetrics.cs
- ProjectionNode.cs
- ButtonChrome.cs
- __ComObject.cs
- PropertyGeneratedEventArgs.cs
- Cursor.cs
- ObjectListDesigner.cs
- safemediahandle.cs
- EntityContainerEntitySet.cs
- DataGridViewCellStyle.cs
- DBParameter.cs
- AsmxEndpointPickerExtension.cs
- BaseCollection.cs
- SqlUtils.cs
- InplaceBitmapMetadataWriter.cs
- OracleBFile.cs
- ListSortDescription.cs
- EndPoint.cs
- RichTextBox.cs
- SystemInfo.cs
- XmlnsCompatibleWithAttribute.cs
- dtdvalidator.cs
- FrameworkContentElementAutomationPeer.cs
- CollectionBase.cs
- CursorConverter.cs
- ParameterElement.cs
- SignedPkcs7.cs
- AppendHelper.cs
- ListViewAutomationPeer.cs
- MemoryFailPoint.cs
- PersonalizableTypeEntry.cs
- SqlConnectionFactory.cs
- RtType.cs
- DbDataRecord.cs
- GorillaCodec.cs
- CheckableControlBaseAdapter.cs
- IndexerReference.cs
- DefaultObjectSerializer.cs
- EntityDataSourceContextCreatedEventArgs.cs
- ControlParameter.cs
- TokenizerHelper.cs
- AssertSection.cs
- FontWeight.cs
- PerfCounters.cs
- SpotLight.cs
- UriTemplateEquivalenceComparer.cs
- CompModHelpers.cs
- DbParameterCollection.cs
- DesignerActionUIStateChangeEventArgs.cs
- UInt64Converter.cs
- CodeCompileUnit.cs
- MinimizableAttributeTypeConverter.cs
- ClientTarget.cs
- LogExtentCollection.cs
- DetailsViewAutoFormat.cs
- UpdateTracker.cs
- FlowDocumentPage.cs
- CommandTreeTypeHelper.cs
- GridViewEditEventArgs.cs
- HwndSourceKeyboardInputSite.cs
- MessageCredentialType.cs
- LazyTextWriterCreator.cs
- AccessDataSourceView.cs
- ProtocolViolationException.cs
- SHA384Managed.cs
- SelectedDatesCollection.cs
- AssemblyResolver.cs
- AuthenticationModulesSection.cs
- SqlProviderServices.cs
- ScaleTransform3D.cs
- RuleRef.cs
- SimpleMailWebEventProvider.cs
- JsonEncodingStreamWrapper.cs
- ValidationService.cs
- DrawingBrush.cs
- CodeObject.cs
- WizardDesigner.cs
- PenLineCapValidation.cs
- EntitySetDataBindingList.cs
- DrawingState.cs
- DataSourceControlBuilder.cs
- Light.cs