/// <summary> Generate string with contents describing this UDP packet.</summary> /// <param name="colored">whether or not the string should contain ansi /// color escape sequences. /// </param> public override System.String ToColoredString(bool colored) { System.Text.StringBuilder buffer = new System.Text.StringBuilder(); buffer.Append('['); if (colored) { buffer.Append(Color); } buffer.Append("UDPPacket"); if (colored) { buffer.Append(AnsiEscapeSequences_Fields.RESET); } buffer.Append(": "); buffer.Append(SourceAddress); buffer.Append('.'); buffer.Append(IPPort.getName(SourcePort)); buffer.Append(" -> "); buffer.Append(DestinationAddress); buffer.Append('.'); buffer.Append(IPPort.getName(DestinationPort)); buffer.Append(" l=" + UDPFields_Fields.UDP_HEADER_LEN + "," + (Length - UDPFields_Fields.UDP_HEADER_LEN)); buffer.Append(']'); return(buffer.ToString()); }
/// <summary> Generate string with contents describing this TCP packet.</summary> /// <param name="colored">whether or not the string should contain ansi /// color escape sequences. /// </param> public override System.String ToColoredString(bool colored) { System.Text.StringBuilder buffer = new System.Text.StringBuilder(); buffer.Append('['); if (colored) { buffer.Append(Color); } buffer.Append("TCPPacket"); if (colored) { buffer.Append(AnsiEscapeSequences_Fields.RESET); } buffer.Append(": "); buffer.Append(SourceAddress); buffer.Append('.'); buffer.Append(IPPort.getName(SourcePort)); buffer.Append(" -> "); buffer.Append(DestinationAddress); buffer.Append('.'); buffer.Append(IPPort.getName(DestinationPort)); if (Urg) { buffer.Append(" urg[0x" + System.Convert.ToString(getUrgentPointer(), 16) + "]"); } if (Ack) { buffer.Append(" ack[0x" + System.Convert.ToString(AcknowledgmentNumber, 16) + "]"); } if (Psh) { buffer.Append(" psh"); } if (Rst) { buffer.Append(" rst"); } if (Syn) { buffer.Append(" syn[0x" + System.Convert.ToString(SequenceNumber, 16) + "," + SequenceNumber + "]"); } if (Fin) { buffer.Append(" fin"); } buffer.Append(" l=" + TCPHeaderLength + "," + PayloadDataLength); buffer.Append(']'); // append the base class output buffer.Append(base.ToColoredString(colored)); return(buffer.ToString()); }