Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / NetworkInformation / SystemIPInterfaceStatistics.cs / 1305376 / 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
- ListViewSelectEventArgs.cs
- RegisteredExpandoAttribute.cs
- TabletDevice.cs
- NumberFormatInfo.cs
- PropertyPathConverter.cs
- ToolStripScrollButton.cs
- QueryContinueDragEvent.cs
- DataServiceResponse.cs
- AuthenticateEventArgs.cs
- ButtonBase.cs
- InternalCache.cs
- DocumentPageView.cs
- SqlDependency.cs
- XPathScanner.cs
- FtpCachePolicyElement.cs
- StateWorkerRequest.cs
- LOSFormatter.cs
- ValidationHelpers.cs
- DynamicUpdateCommand.cs
- DocumentScope.cs
- CacheOutputQuery.cs
- PassportAuthenticationEventArgs.cs
- TableFieldsEditor.cs
- PageRequestManager.cs
- ArrayElementGridEntry.cs
- EmptyQuery.cs
- DynamicResourceExtensionConverter.cs
- LayoutInformation.cs
- SecurityUniqueId.cs
- Triangle.cs
- HierarchicalDataSourceControl.cs
- ModelFunction.cs
- QueryTaskGroupState.cs
- SourceSwitch.cs
- DefaultHttpHandler.cs
- DirtyTextRange.cs
- LogRecordSequence.cs
- MessageDirection.cs
- CallbackDebugBehavior.cs
- SharedConnectionWorkflowTransactionService.cs
- InfoCardKeyedHashAlgorithm.cs
- ButtonStandardAdapter.cs
- ISAPIWorkerRequest.cs
- ApplicationHost.cs
- ChameleonKey.cs
- HostSecurityManager.cs
- SHA1Cng.cs
- XmlMembersMapping.cs
- ExpressionBindingCollection.cs
- BinHexEncoding.cs
- XmlNodeReader.cs
- CustomErrorCollection.cs
- DescendantBaseQuery.cs
- TileModeValidation.cs
- OpCellTreeNode.cs
- StorageRoot.cs
- Messages.cs
- DefaultExpressionVisitor.cs
- TrayIconDesigner.cs
- EncoderParameters.cs
- CompensationHandlingFilter.cs
- CompositeControlDesigner.cs
- TreeViewImageGenerator.cs
- _ScatterGatherBuffers.cs
- TextBox.cs
- SrgsGrammarCompiler.cs
- FormDesigner.cs
- JoinElimination.cs
- ForeignConstraint.cs
- RoleBoolean.cs
- DeviceOverridableAttribute.cs
- HttpConfigurationSystem.cs
- GreaterThanOrEqual.cs
- DEREncoding.cs
- XmlAnyElementAttributes.cs
- ChannelManager.cs
- TranslateTransform.cs
- OracleMonthSpan.cs
- ObservableCollection.cs
- DataListItemCollection.cs
- Quad.cs
- HighlightVisual.cs
- MatrixTransform.cs
- DurableInstanceProvider.cs
- ColorComboBox.cs
- SoapClientProtocol.cs
- QueryResponse.cs
- AssociatedControlConverter.cs
- SqlCacheDependency.cs
- ZoneLinkButton.cs
- Predicate.cs
- Int32Converter.cs
- ZoomingMessageFilter.cs
- TreeNodeBinding.cs
- SyndicationFeedFormatter.cs
- WindowsClaimSet.cs
- SplayTreeNode.cs
- SingleKeyFrameCollection.cs
- Int32RectConverter.cs
- DiscreteKeyFrames.cs