/// <summary> /// Converts the packet to a string. /// </summary> /// <returns></returns> public override String ToString() { return(base.ToString() + "\r\nIPv6 Packet [\r\n" + "\tIPv6 Source Address: " + SourceAddress.ToString() + ", \r\n" + "\tIPv6 Destination Address: " + DestinationAddress.ToString() + "\r\n" + "]"); // TODO Implement Better ToString }
protected internal override object newInitialMessage(IChannelHandlerContext ctx) { String address = DestinationAddress.ToString(); IFullHttpRequest req = new DefaultFullHttpRequest(Codecs.Http.HttpVersion.Http11, HttpMethod.Connect, address, Unpooled.Empty, false); req.Headers.Set(HttpHeaderNames.Host, address); if (authorization != null) { req.Headers.Remove(HttpHeaderNames.ProxyAuthorization); req.Headers.Set(HttpHeaderNames.ProxyAuthorization, authorization); } if (outboundHeaders != null) { req.Headers.Add(outboundHeaders); } return(req); }
/// <summary cref="Packet.ToString(StringOutputType)" /> public override string ToString(StringOutputType outputFormat) { var buffer = new StringBuilder(); string color = ""; string colorEscape = ""; if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored) { color = Color; colorEscape = AnsiEscapeSequences.Reset; } if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored) { // build the output string buffer.AppendFormat("{0}[IPv4Packet: SourceAddress={2}, DestinationAddress={3}, HeaderLength={4}, Protocol={5}, TimeToLive={6}]{1}", color, colorEscape, SourceAddress, DestinationAddress, HeaderLength, Protocol, TimeToLive); } if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored) { // collect the properties and their value Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add("version", Version.ToString()); // FIXME: Header length output is incorrect properties.Add("header length", HeaderLength + " bytes"); string diffServices = Convert.ToString(DifferentiatedServices, 2).PadLeft(8, '0').Insert(4, " "); properties.Add("differentiated services", "0x" + DifferentiatedServices.ToString("x").PadLeft(2, '0')); properties.Add("", diffServices.Substring(0, 7) + ".. = [" + (DifferentiatedServices >> 2) + "] code point"); properties.Add(" ", ".... .." + diffServices[6] + ". = [" + diffServices[6] + "] ECN"); properties.Add(" ", ".... ..." + diffServices[7] + " = [" + diffServices[7] + "] ECE"); properties.Add("total length", TotalLength.ToString()); properties.Add("identification", "0x" + Id.ToString("x") + " (" + Id + ")"); string flags = Convert.ToString(FragmentFlags, 2).PadLeft(8, '0').Substring(5, 3); properties.Add("flags", "0x" + FragmentFlags.ToString("x").PadLeft(2, '0')); properties.Add(" ", flags[0] + ".. = [" + flags[0] + "] reserved"); properties.Add(" ", "." + flags[1] + ". = [" + flags[1] + "] don't fragment"); properties.Add(" ", ".." + flags[2] + " = [" + flags[2] + "] more fragments"); properties.Add("fragment offset", FragmentOffset.ToString()); properties.Add("time to live", TimeToLive.ToString()); properties.Add("protocol", Protocol.ToString() + " (0x" + Protocol.ToString("x") + ")"); properties.Add("header checksum", "0x" + Checksum.ToString("x") + " [" + (ValidChecksum ? "valid" : "invalid") + "]"); properties.Add("source", SourceAddress.ToString()); properties.Add("destination", DestinationAddress.ToString()); // calculate the padding needed to right-justify the property names int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys)); // build the output string buffer.AppendLine("IP: ******* IPv4 - \"Internet Protocol (Version 4)\" - offset=? length=" + TotalPacketLength); buffer.AppendLine("IP:"); foreach (var property in properties) { if (property.Key.Trim() != "") { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " = " + property.Value); } else { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " " + property.Value); } } buffer.AppendLine("IP:"); } // append the base class output buffer.Append(base.ToString(outputFormat)); return(buffer.ToString()); }
public override string ToString() { return(base.ToString() + $", SourceAddress: {SourceAddress?.ToString() ?? "empty"}, DestinationAddress: {DestinationAddress?.ToString() ?? "empty"}, Version: {Version}, Mdc: {(Mdc != null ? new Hex(Mdc).ToString() : "empty")}"); }
public override string ToString() { return(base.ToString() + $", SourceAddress: {SourceAddress?.ToString() ?? "empty"}, DestinationAddress: {DestinationAddress?.ToString() ?? "empty"}, Version: {Version}, Mdc: {Mdc?.ToHexString() ?? "empty"}"); }
/// <summary> /// Returns the string representation of this frame /// </summary> /// <returns>The string representation of this frame</returns> public override string ToString() { return("IPFrame [version: " + Version.ToString() + ", source: " + SourceAddress.ToString() + ", destination: " + DestinationAddress.ToString() + "]"); }
// Preconditions: No specific restrictions // Postconditions: Returns the data about the letter as a formatted string. public override string ToString() { return(string.Format("Origin Address: " + System.Environment.NewLine + OriginAddress.ToString() + "\n\nDestination Address: " + System.Environment.NewLine + DestinationAddress.ToString() + "\n\nCost: " + CalcCost().ToString("c") + System.Environment.NewLine + "------------------------------------")); }