#NEWLINE# def packet_in_filter( cls , args = None , logging = False ) : #NEWLINE# #INDENT# def _packet_in_filter( packet_in_handler ) : #NEWLINE# #INDENT# def __packet_in_filter( self , ev ) : #NEWLINE# #INDENT# pkt = packet . Packet ( ev . msg . data ) #NEWLINE# if ( not packet_in_handler . pkt_in_filter . filter ( pkt ) ) : #NEWLINE# #INDENT# if logging : #NEWLINE# #INDENT# LOG . debug ( 'The packet is discarded by %s: %s' , cls , pkt ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# return packet_in_handler ( self , ev ) #NEWLINE# #UNINDENT# pkt_in_filter = cls ( args ) #NEWLINE# packet_in_handler . pkt_in_filter = pkt_in_filter #NEWLINE# return __packet_in_filter #NEWLINE# #UNINDENT# return _packet_in_filter