#NEWLINE# @ classmethod #NEWLINE# def unpack_nlri( cls , afi , safi , bgp , action , addpath ) : #NEWLINE# #INDENT# ( length , bgp ) = ( ord ( bgp [ 0 ] ) , bgp [ 1 : ] ) #NEWLINE# if ( ( length & 240 ) == 240 ) : #NEWLINE# #INDENT# ( extra , bgp ) = ( ord ( bgp [ 0 ] ) , bgp [ 1 : ] ) #NEWLINE# length = ( ( ( length & 15 ) << 16 ) + extra ) #NEWLINE# #UNINDENT# if ( length > len ( bgp ) ) : #NEWLINE# #INDENT# raise Notify ( 3 , 10 , 'invalid length at the start of the the flow' ) #NEWLINE# #UNINDENT# over = bgp [ length : ] #NEWLINE# bgp = bgp [ : length ] #NEWLINE# nlri = Flow ( afi , safi , action ) #NEWLINE# if ( safi == SAFI . flow_vpn ) : #NEWLINE# #INDENT# nlri . rd = RouteDistinguisher ( bgp [ : 8 ] ) #NEWLINE# bgp = bgp [ 8 : ] #NEWLINE# #UNINDENT# seen = [ ] #NEWLINE# while bgp : #NEWLINE# #INDENT# ( what , bgp ) = ( ord ( bgp [ 0 ] ) , bgp [ 1 : ] ) #NEWLINE# if ( what not in decode . get ( afi , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) : #NEWLINE# #INDENT# raise Notify ( 3 , 10 , ( 'unknown flowspec component received for address family %d' % what ) ) #NEWLINE# #UNINDENT# seen . append ( what ) #NEWLINE# if ( sorted ( seen ) != seen ) : #NEWLINE# #INDENT# raise Notify ( 3 , 10 , ( 'components are not sent in the right order %s' % seen ) ) #NEWLINE# #UNINDENT# decoded = decode [ afi ] [ what ] #NEWLINE# klass = factory [ afi ] [ what ] #NEWLINE# if ( decoded == 'prefix' ) : #NEWLINE# #INDENT# ( adding , bgp ) = klass . make ( bgp ) #NEWLINE# if ( not nlri . add ( adding ) ) : #NEWLINE# #INDENT# raise Notify ( 3 , 10 , ( 'components are incompatible (two sources, two destinations, mix ipv4/ipv6) %s' % seen ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# end = False #NEWLINE# while ( not end ) : #NEWLINE# #INDENT# ( byte , bgp ) = ( ord ( bgp [ 0 ] ) , bgp [ 1 : ] ) #NEWLINE# end = CommonOperator . eol ( action ) #NEWLINE# operator = CommonOperator . operator ( byte ) #NEWLINE# length = CommonOperator . length ( byte ) #NEWLINE# ( value , bgp ) = ( bgp [ : length ] , bgp [ length : ] ) #NEWLINE# adding = klass . decoder ( value ) #NEWLINE# nlri . add ( klass ( operator , adding ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( nlri , ( bgp + over ) )