Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- GridViewRowPresenter.cs
- HtmlHistory.cs
- HashCodeCombiner.cs
- TemplateXamlParser.cs
- WebPartEditorOkVerb.cs
- cookiecontainer.cs
- SamlAudienceRestrictionCondition.cs
- UnaryNode.cs
- StringReader.cs
- EndpointIdentity.cs
- WorkflowMarkupSerializerMapping.cs
- TypedTableBaseExtensions.cs
- WindowsToolbarItemAsMenuItem.cs
- _HeaderInfo.cs
- PerfCounters.cs
- DynamicMethod.cs
- LicenseContext.cs
- ZipFileInfo.cs
- DbXmlEnabledProviderManifest.cs
- BindingsCollection.cs
- RelatedPropertyManager.cs
- AssemblyCache.cs
- RawContentTypeMapper.cs
- HttpClientCertificate.cs
- RSAPKCS1SignatureFormatter.cs
- MultitargetUtil.cs
- XmlSchemaProviderAttribute.cs
- ObjectConverter.cs
- EntityDesignerBuildProvider.cs
- ServiceInfoCollection.cs
- _AutoWebProxyScriptHelper.cs
- ConnectionsZoneAutoFormat.cs
- ConnectionsZoneAutoFormat.cs
- SmiContext.cs
- HandleExceptionArgs.cs
- _HeaderInfoTable.cs
- LogicalExpr.cs
- IsolatedStorageFileStream.cs
- WebMessageBodyStyleHelper.cs
- CompiledIdentityConstraint.cs
- DocumentPage.cs
- XPathSelectionIterator.cs
- ManifestSignedXml.cs
- CodeNamespaceCollection.cs
- DbXmlEnabledProviderManifest.cs
- COM2AboutBoxPropertyDescriptor.cs
- Propagator.cs
- DateTimeOffsetStorage.cs
- DeviceContext2.cs
- XmlDataSourceView.cs
- CryptographicAttribute.cs
- GeometryDrawing.cs
- DataGridLengthConverter.cs
- ChameleonKey.cs
- WorkflowItemPresenter.cs
- DataGridViewToolTip.cs
- FeatureSupport.cs
- ServiceInfoCollection.cs
- TitleStyle.cs
- AvTraceDetails.cs
- SchemaElementLookUpTableEnumerator.cs
- AddressingVersion.cs
- ColumnWidthChangingEvent.cs
- ClusterSafeNativeMethods.cs
- MDIWindowDialog.cs
- SQLBinaryStorage.cs
- XmlAtomicValue.cs
- ConfigXmlElement.cs
- MultipartContentParser.cs
- PathFigureCollection.cs
- QueryContext.cs
- SafeNativeMethods.cs
- EFDataModelProvider.cs
- AggregateException.cs
- TableCell.cs
- MaterialGroup.cs
- CompilerGlobalScopeAttribute.cs
- RegexFCD.cs
- BaseHashHelper.cs
- ByteFacetDescriptionElement.cs
- EventProxy.cs
- ActivityMarkupSerializer.cs
- TcpActivation.cs
- ObjectAnimationUsingKeyFrames.cs
- XmlSchemaValidationException.cs
- SerializationEventsCache.cs
- HelpInfo.cs
- Vector3DAnimationBase.cs
- SafeRegistryKey.cs
- ScalarType.cs
- HttpCookieCollection.cs
- DataGridRelationshipRow.cs
- Queue.cs
- ScrollItemPatternIdentifiers.cs
- FieldNameLookup.cs
- SqlOuterApplyReducer.cs
- HttpResponseMessageProperty.cs
- DesignerAttributeInfo.cs
- OdbcDataAdapter.cs
- ActiveXHelper.cs