Esempio n. 1
0
        /// <summary>
        /// Converts sntp message into string object.
        /// </summary>
        public override string ToString()
        {
            string        dateFormat = "MMM d, yyyy HH:mm:ss.fff 'GMT'";
            StringBuilder sb         = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("  SNTP PACKET");
            sb.AppendLine(String.Concat("  Message Timestamp              : ", this.Timestamp.ToString()));
            sb.AppendLine(String.Concat("  Leap Indicator (LI)            : ", LeapIndicatorString.GetName(this.LeapIndicator)));
            sb.AppendLine(String.Concat("  Version Number (VI)            : ", VersionNumberString.GetName(this.VersionNumber)));
            sb.AppendLine(String.Concat("  Mode                           : ", ModeString.GetName(this.Mode)));
            sb.AppendLine(String.Concat("  Stratum                        : ", StratumString.GetName(this.Stratum)));
            sb.AppendLine(String.Concat("  Poll Interval                  : ", this.PollInterval.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Precision                      : ", this.Precision.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Root Delay                     : ", this.RootDelay.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Root Dispersion                : ", this.RootDispersion.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Reference Identifier           : ", ReferenceIdentifierString.GetName(this.ReferenceIdentifier)));
            sb.AppendLine(String.Concat("  Reference IP Address           : ", this.ReferenceIPAddress.ToString()));
            sb.AppendLine(String.Concat("  Reference DateTime             : ", this.ReferenceDateTime.ToString(dateFormat)));
            sb.AppendLine(String.Concat("  Originate DateTime             : ", this.OriginateDateTime.ToString(dateFormat)));
            sb.AppendLine(String.Concat("  Receive DateTime               : ", this.ReceiveDateTime.ToString(dateFormat)));
            sb.AppendLine(String.Concat("  Transmit DateTime              : ", this.TransmitDateTime.ToString(dateFormat)));
            sb.AppendLine(String.Concat("  Destination DateTime           : ", this.DestinationDateTime.ToString(dateFormat)));
            sb.AppendLine(String.Concat("  Local DateTime                 : ", this.LocalDateTime.ToString(dateFormat),
                                        "(", TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString(), ")"));
            sb.AppendLine(String.Concat("  Local Clock Offset             : ", this.LocalClockOffset.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Round Trip Delay               : ", this.RoundTripDelay.ToString(), " second(s)"));
            sb.AppendLine(String.Concat("  Key Identifier                 : ", ByteUtility.PrintBytes(_keyIdentifier, false)));
            sb.AppendLine(String.Concat("  Message Digest                 : ", ByteUtility.PrintBytes(_messageDigest, false)));
            sb.AppendLine();

            return(sb.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Converts dhcp message into string object.
        /// </summary>
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("  DHCP PACKET");
            sb.AppendLine(String.Concat("  Message Timestamp              : ", this.Timestamp.ToLocalTime().ToString()));
            sb.AppendLine(String.Concat("  Message Type (op)              : ", OperationString.GetName(this.Operation)));
            sb.AppendLine(String.Concat("  Hardware Type (htype)          : ", HardwareString.GetName(this.Hardware)));
            sb.AppendLine(String.Concat("  Hops (hops)                    : ", ByteUtility.PrintByte(this.Hops)));
            sb.AppendLine(String.Concat("  Transaction Id (Xid)           : ", this.SessionId.ToHexString("0x")));
            sb.AppendLine(String.Concat("  Seconds Elapsed (secs)         : ", this.SecondsElapsed.ToString()));
            sb.AppendLine(String.Concat("  Flags (flags)                  : 0x", ByteUtility.PrintBytes(this._flags)));
            sb.AppendLine(String.Concat("  Is Broadcast (flags)           : ", this.IsBroadcast.ToString()));
            sb.AppendLine(String.Concat("  Client Address (ciaddr)        : ", this.ClientAddress.ToString()));
            sb.AppendLine(String.Concat("  Assigned Address (yiaddr)      : ", this.AssignedAddress.ToString()));
            sb.AppendLine(String.Concat("  Next Server Address (siaddr)   : ", this.NextServerAddress.ToString()));
            sb.AppendLine(String.Concat("  Relay Agent Address (giaddr)   : ", this.RelayAgentAddress.ToString()));
            sb.AppendLine(String.Concat("  Hardware Address (chaddr)      : ", this.ClientHardwareAddress.ToString()));
            sb.AppendLine(String.Concat("  Server Host Name (sname)       : ", ByteUtility.GetSafeString(this.ServerName)));
            sb.AppendLine(String.Concat("  Boot File Name (file)          : ", ByteUtility.GetSafeString(this.BootFileName)));
            sb.AppendLine(String.Concat("  Option (Message Type)          : ", MessageTypeString.GetName((MessageType)this.GetOptionData(DhcpOption.DhcpMessageType)[0])));
            sb.AppendLine(String.Concat("  Option (Client Id)             : ", ByteUtility.PrintSafeBytes(this.GetOptionData(DhcpOption.ClientId))));
            sb.AppendLine(String.Concat("  Option (Host Name)             : ", ByteUtility.GetSafeString(this.GetOptionData(DhcpOption.Hostname))));
            sb.AppendLine(String.Concat("  Option (Address Request)       : ", new InternetAddress(this.GetOptionData(DhcpOption.AddressRequest)).ToString()));
            sb.AppendLine(String.Concat("  Option (Server Identifier)     : ", new InternetAddress(this.GetOptionData(DhcpOption.ServerIdentifier)).ToString()));
            sb.AppendLine(String.Concat("  Option (Dhcp Message)          : ", ByteUtility.GetSafeString(this.GetOptionData(DhcpOption.DhcpMessage))));

            foreach (DhcpOption option in _options.Keys)
            {
                byte   optionId    = (Byte)option;
                byte[] optionValue = (byte[])_options[option];
                sb.AppendLine(String.Concat("  Option (Binary)                : ", ByteUtility.PrintByte(optionId) + " => " + ByteUtility.PrintBytes(optionValue, false)));
            }

            sb.AppendLine();

            return(sb.ToString());
        }