#NEWLINE# @ classmethod #NEWLINE# def _new_aspaths( cls , data , asn4 , klass = None ) : #NEWLINE# #INDENT# as_set = [ ] #NEWLINE# as_seq = [ ] #NEWLINE# as_cset = [ ] #NEWLINE# as_cseq = [ ] #NEWLINE# backup = data #NEWLINE# unpacker = { #NEWLINE# #INDENT# False : '!H' , #NEWLINE# True : '!L' , #NEWLINE# #UNINDENT# } #NEWLINE# size = { #NEWLINE# #INDENT# False : 2 , #NEWLINE# True : 4 , #NEWLINE# #UNINDENT# } #NEWLINE# as_choice = { #NEWLINE# #INDENT# ASPath . AS_SEQUENCE : as_seq , #NEWLINE# ASPath . AS_SET : as_set , #NEWLINE# ASPath . AS_CONFED_SEQUENCE : as_cseq , #NEWLINE# ASPath . AS_CONFED_SET : as_cset , #NEWLINE# #UNINDENT# } #NEWLINE# upr = unpacker [ asn4 ] #NEWLINE# length = backup [ asn4 ] #NEWLINE# try : #NEWLINE# #INDENT# while data : #NEWLINE# #INDENT# stype = ord ( data [ 0 ] ) #NEWLINE# slen = ord ( data [ 1 ] ) #NEWLINE# if ( stype not in ( ASPath . AS_SET , ASPath . AS_SEQUENCE , ASPath . AS_CONFED_SEQUENCE , ASPath . AS_CONFED_SET ) ) : #NEWLINE# #INDENT# raise Notify ( 3 , 11 , ( 'invalid AS Path type sent %d' % stype ) ) #NEWLINE# #UNINDENT# end = ( 2 + ( slen * length ) ) #NEWLINE# sdata = data [ 2 : end ] #NEWLINE# data = data [ end : ] #NEWLINE# asns = as_choice . get ( stype , [ ] ) #NEWLINE# for _ in range ( slen ) : #NEWLINE# #INDENT# asn = unpack ( upr , sdata [ : length ] ) [ 0 ] #NEWLINE# asns . append ( ASN ( asn ) ) #NEWLINE# sdata = sdata [ length : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise Notify ( 3 , 11 , 'not enough data to decode AS_PATH or AS4_PATH' ) #NEWLINE# #UNINDENT# except error : #NEWLINE# #INDENT# raise Notify ( 3 , 11 , 'not enough data to decode AS_PATH or AS4_PATH' ) #NEWLINE# #UNINDENT# if klass : #NEWLINE# #INDENT# return klass ( as_seq , as_set , as_cseq , as_cset , backup ) #NEWLINE# #UNINDENT# return cls ( as_seq , as_set , as_cseq , as_cset , backup )