Exemplo n.º 1
0
        /// <summary>
        /// Formats as block-formatted string of an <see cref="IWirelessPeerInfo" />.
        /// </summary>
        /// <param name="wirelessPeerInfo">The data to format.</param>
        /// <returns>The formatted string.</returns>
        public string Format(IWirelessPeerInfo wirelessPeerInfo)
        {
            if (wirelessPeerInfo == null)
            {
                return("<null>");
            }

            StringBuilder returnBuilder = new StringBuilder(256);

            returnBuilder.Append("Peer ").Append(wirelessPeerInfo.RemoteMacString).AppendLine(":");
            returnBuilder.Append("  - Mode           : ").AppendLine(wirelessPeerInfo.IsAccessPoint.HasValue ? (wirelessPeerInfo.IsAccessPoint.Value ? "AP" : "Client") : NotAvailableString);
            returnBuilder.Append("  - On interface ID: ").AppendLine(wirelessPeerInfo.InterfaceId.HasValue ? wirelessPeerInfo.InterfaceId.Value.ToString() : NotAvailableString);
            returnBuilder.Append("  - Link Uptime    : ").AppendLine(wirelessPeerInfo.LinkUptime.ToString());
            returnBuilder.Append("  - RX signal [dBm]: ").AppendLine(wirelessPeerInfo.RxSignalStrength.ToString("0.0 dBm"));
            returnBuilder.Append("  - TX signal [dBm]: ").AppendLine(wirelessPeerInfo.TxSignalStrength.ToString("0.0 dBm"));
            returnBuilder.Append("  - CCQ            : ").Append(wirelessPeerInfo.Ccq?.ToString("0") ?? "not available");

            return(returnBuilder.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copy-construct
        /// </summary>
        /// <param name="peerInfo">The peer info to copy.</param>
        public SerializableWirelessPeerInfo(IWirelessPeerInfo peerInfo)
        {
            if (peerInfo is null)
            {
                throw new ArgumentNullException(nameof(peerInfo), "The IWirelessPeerInfo to make serializable is null");
            }

            // as we'll anyway need all values, we trigger immediate aquisition hoping for better performance
            peerInfo.ForceEvaluateAll();

            this.RemoteMacString = peerInfo.RemoteMacString;
            this.InterfaceId     = peerInfo.InterfaceId;
            this.IsAccessPoint   = peerInfo.IsAccessPoint;
            this.DeviceAddress   = peerInfo.DeviceAddress;
            this.DeviceModel     = peerInfo.DeviceModel;
            this.Oids            = peerInfo.Oids;
            this.NumberOfClients = peerInfo.NumberOfClients;

            // we're intentionally not setting signal levels, uptime, OIDs and query duration
            // those would change continuously and require re-querying or wouldn't make sense at all
        }
 /// <summary>
 /// Initialize with all parameters.
 /// </summary>
 /// <param name="interfaceDetail1">The interface details of side #1.</param>
 /// <param name="interfaceDetail2">The interface details of side #2</param>
 /// <param name="wirelessPeerInfo1">The wireless peer info of side #1.</param>
 /// <param name="wirelessPeerInfo2">The wireless peer info of side #2.</param>
 public LinkRelatedResultCollection(IInterfaceDetail interfaceDetail1, IInterfaceDetail interfaceDetail2, IWirelessPeerInfo wirelessPeerInfo1, IWirelessPeerInfo wirelessPeerInfo2)
 {
     this.WirelessPeerInfo1 = wirelessPeerInfo1;
     this.WirelessPeerInfo2 = wirelessPeerInfo2;
     this.InterfaceDetail1  = interfaceDetail1;
     this.InterfaceDetail2  = interfaceDetail2;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Formats a generic object if it's of one of the supported types.
        /// </summary>
        /// <param name="someObject">The object to format.</param>
        /// <returns>The formatted text.</returns>
        public string Format(object someObject)
        {
            if (someObject == null)
            {
                return("<null>");
            }

            IDeviceSystemData asDevSysData = someObject as IDeviceSystemData;

            if (asDevSysData != null)
            {
                return(this.Format(asDevSysData));
            }

            IInterfaceDetails asIfDetails = someObject as IInterfaceDetails;

            if (asIfDetails != null)
            {
                return(this.Format(asIfDetails));
            }

            IInterfaceDetail asIfDetail = someObject as IInterfaceDetail;

            if (asIfDetail != null)
            {
                return(this.Format(asIfDetail));
            }

            IWirelessPeerInfos asWiPeerInfos = someObject as IWirelessPeerInfos;

            if (asWiPeerInfos != null)
            {
                return(this.Format(asWiPeerInfos));
            }

            IWirelessPeerInfo asWiPeerInfo = someObject as IWirelessPeerInfo;

            if (asWiPeerInfo != null)
            {
                return(this.Format(asWiPeerInfo));
            }

            ILinkDetails asLinkDetails = someObject as ILinkDetails;

            if (asLinkDetails != null)
            {
                return(this.Format(asLinkDetails));
            }

            IBgpPeers asBgpPeers = someObject as IBgpPeers;

            if (asBgpPeers != null)
            {
                return(this.Format(asBgpPeers));
            }

            IBgpPeer asBgpPeer = someObject as IBgpPeer;

            if (asBgpPeer != null)
            {
                return(this.Format(asBgpPeer));
            }

            ITracerouteResult asTracerouteResult = someObject as ITracerouteResult;

            if (asTracerouteResult != null)
            {
                return(this.Format(asTracerouteResult));
            }

            ITracerouteHop asTracerouteHop = someObject as ITracerouteHop;

            if (asTracerouteHop != null)
            {
                return(this.Format(asTracerouteHop));
            }

            // fallback: call the object's ToString
            return(someObject.ToString());
        }
Exemplo n.º 5
0
 public VolatileFetchingWirelessPeerInfo(IWirelessPeerInfo underlyingPeerInfo, ISnmpLowerLayer lowerLayer)
 {
     this.underlyingPeerInfo = underlyingPeerInfo ?? throw new System.ArgumentNullException(nameof(underlyingPeerInfo));
     this.lowerLayer         = lowerLayer ?? throw new System.ArgumentNullException(nameof(lowerLayer));
 }