def __repr__(self): """Represents the payload of the message""" message = '' for header_name, header_value in self.headers.iteritems(): message += '\t%s: %s\\r\\n\n' % (header_name, header_value) message += '\t\\r\\n\n' if self.headers['Content-Type'] != "application/x-msnmsgrp2p": message += '\t' + debug.escape_string(self.body).\ replace("\r\n", "\\r\\n\n\t") else: tlp_header = self.body[:48] tlp_footer = self.body[-4:] tlp_flags = struct.unpack("<L", self.body[28:32])[0] body = self.body[48:-4] message += "\t" + debug.hexify_string(tlp_header).replace("\r\n", "\n\t") if tlp_flags == 0: message += "\n\t" + debug.escape_string(body).\ replace("\r\n", "\\r\\n\n\t") elif len(body) > 0: message += "\n\t" + "[%d bytes of data]" % len(body) message += "\n\t" + debug.hexify_string(tlp_footer) return message.rstrip("\n\t")
def __repr__(self): """Represents the payload of the message""" message = '' for header_name, header_value in self.headers.iteritems(): message += '\t%s: %s\\r\\n\n' % (header_name, header_value) message += '\t\\r\\n\n' if self.headers['Content-Type'] != "application/x-msnmsgrp2p": message += '\t' + debug.escape_string(self.body).\ replace("\r\n", "\\r\\n\n\t") else: tlp_header = self.body[:48] tlp_footer = self.body[-4:] tlp_session_id = struct.unpack("<L", self.body[0:4])[0] tlp_flags = struct.unpack("<L", self.body[28:32])[0] body = self.body[48:-4] message += "\t" + debug.hexify_string(tlp_header).replace( "\r\n", "\n\t") if tlp_flags == 0 or tlp_session_id == 0: message += "\n\t" + debug.escape_string(body).\ replace("\r\n", "\\r\\n\n\t") elif len(body) > 0: message += "\n\t" + "[%d bytes of data]" % len(body) message += "\n\t" + debug.hexify_string(tlp_footer) return message.rstrip("\n\t")
def __repr__(self): """Represents the payload of the message""" message = '' for header_name, header_value in self.headers.iteritems(): message += '\t%s: %s\\r\\n\n' % (header_name, repr(header_value)) if self.headers['Content-Type'] != "application/x-msnmsgrp2p": message += '\t\\r\\n\n' message += '\t' + escape_string(self.body).\ replace("\r\n", "\\r\\n\n\t") else: message += "\t[P2P message (%d bytes)]" % (len(self.body) - 4) return message.rstrip("\n\t")
def __repr__(self): string = "TLPv1 chunk 0x%x: " % self.id string += "blob %i, " % self.blob_id if self.session_id: string += "session %d, " % self.session_id if self.is_ack_chunk(): string += "ACK 0x%x 0x%x" % self.acked_id elif self.is_nak_chunk(): string += "NAK 0x%x 0x%x" % self.acked_id if self.size > 0: if self.session_id: string += "data [%d bytes]" % self.size else: string += "SLP Message" string += "\n\t" + debug.escape_string(self.body).\ replace("\r\n", "\\r\\n\n\t") return string
def __repr__(self): string = "TLPv2 chunk 0x%x: " % self.id string += "blob %i, " % self.blob_id if self.session_id: string += "session %d, " % self.session_id if self.is_ack_chunk(): string += "ACK 0x%x, " % self.acked_id if self.is_nak_chunk(): string += "NAK 0x%x, " % self.naked_id if self.require_ack(): string += "RAK, " if self.header.op_code & TLPFlag.SYN: string += "SYN, " if self.size > 0: if self.session_id: string += "data [%d bytes]" % self.size else: string += "SLP Message" string += "\n\t" + debug.escape_string(self.body).replace("\r\n", "\\r\\n\n\t") return string
def __repr__(self): string = "TLPv2 chunk 0x%x: " % self.id string += "blob %i, " % self.blob_id if self.session_id: string += "session %d, " % self.session_id if self.is_ack_chunk(): string += "ACK 0x%x, " % self.acked_id if self.is_nak_chunk(): string += "NAK 0x%x, " % self.naked_id if self.require_ack(): string += "RAK, " if self.header.op_code & TLPFlag.SYN: string += "SYN, " if self.size > 0: if self.session_id: string += "data [%d bytes]" % self.size else: string += "SLP Message" string += "\n\t" + debug.escape_string(self.body).\ replace("\r\n", "\\r\\n\n\t") return string