#NEWLINE# def unpack( self , buf ) : #NEWLINE# #INDENT# dpkt . Packet . unpack ( buf , buf ) #NEWLINE# if ( self . opcode in ( OP_RRQ , OP_WRQ ) ) : #NEWLINE# #INDENT# l = self . data . split ( '\x00' ) #NEWLINE# self . filename = l [ 0 ] #NEWLINE# self . mode = l [ 1 ] #NEWLINE# self . data = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . opcode in ( OP_DATA , OP_ACK ) ) : #NEWLINE# #INDENT# self . block = struct . unpack ( '>H' , self . data [ : 2 ] ) #NEWLINE# self . data = self . data [ 2 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . opcode == OP_ERR ) : #NEWLINE# #INDENT# self . errcode = struct . unpack ( '>H' , self . data [ : 2 ] ) #NEWLINE# self . errmsg = self . data [ 2 : ] . split ( '\x00' ) [ 0 ] #NEWLINE# self . data = ''