
    h                       d Z ddlZddlZddlZddlmZ ddlmZmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z'm(Z( dd	l)m*Z*m+Z+ dd
l,m-Z-  G d de(          Z. e.            Z/dZ0dZ1dZ2dZ3dZ4dZ5d Z6 G d de          Z7 G d de          Z8d Z9d Z: G d de          Z; G d de          Z< G d de;          Z= G d  d!e<          Z> G d" d#e          Z? G d$ d%e@          ZAe'jB        fd&ZCd'd(d)d*d+d,d-ZDi dd.d/d0dd1dd2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJddKi dLdMdNdOddPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvd.dwZEi dd.d/dxddydd.d3dzd5d{d7d|d9d}d;d~ddddddddddddddddndddddddd.dZFddddddZG G d de          ZHd ZI G d de          ZJ G d deJeH          ZKd.dddZLi dd.d/dddddd3dd5dd7dddddddddddddddddddddddiZMddddddddZNd ZOi ZPd ZQ G d deR          ZS G dÄ deSe          ZT G dń deeTǦ          ZU G dȄ deU          ZV G dɄ deU          ZWd.ddd̜ZXddddМZY G dф de          ZZ G dӄ de          Z[ G dՄ deU          Z\ddiZ] G dׄ deU          Z^ G d؄ deU          Z_ G dل de          Z` G dۄ de          Za G d݄ de          Zb G d߄ deJ          Zci dd.d/dddddd3dd5dd7dd9dd;dd=dd?ddAddCddEddGddIdddi dLddNddddQddSddUddWddYdd[dd]dd_ddaddcddddd ddddZdi d/dddddd3dd5dd7dd9dd;dd=dd?ddAddCddEddGddIddddLdddddddddddddddddZe G d de          Zf G d d	e          Zgd
ddddZh G d de          Zi G d de          Zj G d de          Zk G d de          Zl G d de          Zm G d de          Zn G d de          Zo G d de          Zpdd d!d"d#d$d%d&d'd(d)d*d+d,Zq G d- d.e          Zr G d/ d0e          Zs G d1 d2e          Zti dd3d/d4dd5dd6d3d7d5d8d7d9d9d:d;d;dd<dd=dd>dd?dd7dd@dAdBddCZudDdEdFdGdHdIdJdKdLZvdMdNd:dOdPdQdRdSdTZwdUdVdWZxdMdNdXdOdPdQdYdZZyd3dXiZzdMdNdOd[dRd\d]dSd^d_	Z{i Z|d`dːdadbdcdddedfdgdhdidjdkZ}dld`dmZ~dndodpdqdrdsdtdudvdw	Zd;dxiZd;dyiZdzd{d|ZdMdNd}d\d~dSdd^dZi Zewe{eye}evexe|eze~eeedZ G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zededededededededededi
Z G d de          Z G d de          Zd Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zi d/d	ddddd3dd5dd7dd9dd;d.d=d0d?d2dGddIddddLdd[dddZ G d de          Z G d de          Z G dÄ deJ          ZdĐdŐdƐdǐdȐdɐdʐd˜Zi d̐d͐dΐdϐdМd.dѐdҐdӐdԐdՐd֐dאdLd.dؐdِdڐdېdܐdݐdސdߐddddi dddddМdddddddddd	d.ddmdLZ G d deJ          ZdddZddddZdddmZd/ad/ad Z G d de          Z G d de          Z G d  de          Z G d de          Z G d de          Z G d de          Zdd	d
d.dZ G d deJ          Z e	e#eJd            e	e#eJd            e	eHecdd/i            e	eHeddi            e	eHeddi            e	eHeKdd3i            e	eHedd5i            e-j        de/j                   dS (  z 
BGP (Border Gateway Protocol).
    N)	pton_ntop)PacketPacket_metaclassbind_layers)FieldBitFieldBitEnumField	XBitField	ByteFieldByteEnumField
ShortFieldShortEnumFieldIntFieldIntEnumField	LongFieldIEEEFloatFieldStrFieldStrLenFieldStrFixedLenFieldFieldLenFieldFieldListFieldPacketFieldPacketListFieldIPField
FlagsFieldConditionalFieldMultiEnumField)TCP)IP6Field)conf	ConfClass)orbchb)log_runtimec                       e Zd ZdZdZdS )BGPConfz#
    BGP module configuration.
    TN)__name__
__module____qualname____doc__use_2_bytes_asn     U/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/contrib/bgp.pyr&   r&   %   s         
 OOOr-   r&   i      s            c                     | dz   dz  S )zl
    Helper function that returns the numbers of bytes necessary to store the
    given number of bits.
          r,   )length_in_bitss    r.   _bits_to_bytes_lenr7   P   s     Q1$$r-   c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )BGPFieldIPv4z
    IPv4 Field (CIDR)
    c                     |dz   dz  S z(Get the IP field mask length (in bytes).r4   r5   r,   selfmasks     r.   
mask2iplenzBGPFieldIPv4.mask2iplen^       qQr-   c                 T    t          j        d|          \  }}t          |          |fS )z'x.x.x.x/y to "internal" representation./resplitintr=   pkthipr>   s        r.   h2izBGPFieldIPv4.h2ib   '    8C##D4yy"}r-   c                 6    |\  }}|dz   t          |          z   S )zH"Internal" representation to "human" representation
        (x.x.x.x/y).rB   strr=   rH   ir>   rJ   s        r.   i2hzBGPFieldIPv4.i2hg   s"     bCx#d))##r-   c                 .    |                      ||          S NrR   r=   rH   rQ   s      r.   i2reprzBGPFieldIPv4.i2reprm       xxQr-   c                 <    |\  }}|                      |          dz   S N   r?   )r=   rH   rQ   r>   _s        r.   i2lenzBGPFieldIPv4.i2lenp   s"    at$$q((r-   c                     |\  }}t          j        |          }t          j        d|          |d|                     |                   z   S )zJ"Internal" (IP as bytes, mask as int) to "machine"
        representation.>BN)socket	inet_atonstructpackr?   rP   s        r.   i2mzBGPFieldIPv4.i2mt   sK     bb!!{4&&,BT__T-B-B,B)CCCr-   c                 4    ||                      ||          z   S rT   re   r=   rH   svals       r.   addfieldzBGPFieldIPv4.addfield{       488C%%%%r-   c                     |                      t          |d                             dz   }||d          |                     ||d |                   fS Nr   r[   r?   r"   m2ir=   rH   ri   lengths       r.   getfieldzBGPFieldIPv4.getfield~   K    QqT++a/z488C7F74444r-   c                     t          d                   }|                     |          d                    fdt          d          D                       }|t	          j        |          fS )Nr   r-   c              3   H   K   | ]}|k     r|d z   |dz            ndV  dS r[   r1       Nr,   ).0rQ   mmask2iplen_ress     r.   	<genexpr>z#BGPFieldIPv4.m2i.<locals>.<genexpr>   sA      ZZAN(:(:aAa!ennZZZZZZr-      )r"   r?   joinrangera   	inet_ntoa)r=   rH   rz   r>   rJ   r{   s     `  @r.   rp   zBGPFieldIPv4.m2i   sm    1Q4yy..XXZZZZZQVWXQYQYZZZZZf&r**++r-   Nr'   r(   r)   r*   r?   rK   rR   rW   r^   re   rk   rs   rp   r,   r-   r.   r9   r9   Y   s             
$ $ $     ) ) )D D D& & &5 5 5, , , , ,r-   r9   c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )BGPFieldIPv6zIPv6 Field (CIDR)c                     |dz   dz  S r;   r,   r<   s     r.   r?   zBGPFieldIPv6.mask2iplen   r@   r-   c                 T    t          j        d|          \  }}t          |          |fS )z%x.x.x.x/y to internal representation.rB   rC   rG   s        r.   rK   zBGPFieldIPv6.h2i   rL   r-   c                 6    |\  }}|dz   t          |          z   S )z4"Internal" representation to "human" representation.rB   rN   rP   s        r.   rR   zBGPFieldIPv6.i2h   s     bCx#d))##r-   c                 .    |                      ||          S rT   rU   rV   s      r.   rW   zBGPFieldIPv6.i2repr   rX   r-   c                 <    |\  }}|                      |          dz   S rZ   r\   rP   s        r.   r^   zBGPFieldIPv6.i2len   s"    bt$$q((r-   c                     |\  }}t          j        t          j        |          }t	          j        d|          |d|                     |                   z   S )zB"Internal" (IP as bytes, mask as int) to "machine" representation.r`   N)r   	inet_ptonra   AF_INET6rc   rd   r?   rP   s        r.   re   zBGPFieldIPv6.i2m   sM    b "55{4&&,BT__T-B-B,B)CCCr-   c                 4    ||                      ||          z   S rT   rg   rh   s       r.   rk   zBGPFieldIPv6.addfield   rl   r-   c                     |                      t          |d                             dz   }||d          |                     ||d |                   fS rn   ro   rq   s       r.   rs   zBGPFieldIPv6.getfield   rt   r-   c                      t          d                   d                     fdt          d          D                       }t          j        t
          j        |          fS )Nr   r-   c              3   n   K   | ]/}|                               k     r|d z   |dz            ndV  0dS rw   r\   )ry   rQ   rz   r>   r=   s     r.   r|   z#BGPFieldIPv6.m2i.<locals>.<genexpr>   sN      bbSTDOOD,A,A(A(AaAa!ennwbbbbbbr-   r0   )r"   r~   r   r   	inet_ntopra   r   )r=   rH   rz   rJ   r>   s   ` ` @r.   rp   zBGPFieldIPv6.m2i   sd    1Q4yyXXbbbbbbX]^`XaXabbbbbi)&/2>>??r-   Nr   r,   r-   r.   r   r      s            
$ $ $
     ) ) )D D D& & &5 5 5@ @ @ @ @r-   r   c                 (    | t           z  t           k    S )zN
    Used in BGPPathAttr to check if the extended-length flag is
    set.
    )_BGP_PA_EXTENDED_LENGTH)flagss    r.   has_extended_lengthr      s     **.EEEr-   c                    d}|dz   t          |           k     r|dz  }t          | |                   }||k    rdS |dz   dz  }|d|z   z  }|t          |           k    rdS |dz  r#t          | |dz
                     d|dz  z	  z  rdS |dz   t          |           k     d}|dz   t          |           k     rt          | |                   }|dk    rt          |           dk    rdS ||k    rdS |dz   dz  }|d|z   z  }|t          |           k    rdS |dz  r#t          | |dz
                     d|dz  z	  z  rdS |dz   t          |           k     dS )	a@  
    Detect IPv4/IPv6 prefixes conform to BGP Additional Path but NOT conform
    to standard BGP..

    This is an adapted version of wireshark's detect_add_path_prefix46
    https://github.com/wireshark/wireshark/blob/ed9e958a2ed506220fdab320738f1f96a3c2ffbb/epan/dissectors/packet-bgp.c#L2905
    Kudos to them !
    r   r}   Fr4   r5   r[      T)lenr"   )ri   max_bit_lengthrQ   
prefix_lenaddr_lens        r.   detect_add_path_prefix46r      s    	
A
a%#a&&..	Q1YY
&&5Nq(	Q\s1vv::5> 	1QU8}}a 89 u a%#a&&.. 	
A
a%#a&&..1YY
??s1vvzz4&&4Nq(	Q\s1vv::4> 	1QU8}}a 89 t a%#a&&.. 5r-   c                   6    e Zd ZdZdZ edd          gZd ZdS )BGPNLRI_IPv4z+
    Packet handling IPv4 NLRI fields.
    z	IPv4 NLRIprefix	0.0.0.0/0c                     t           j        S rT   r    padding_layerr=   payloads     r.   default_payload_classz"BGPNLRI_IPv4.default_payload_class       !!r-   N)r'   r(   r)   r*   namer9   fields_descr   r,   r-   r.   r   r      sH          D<+667K" " " " "r-   r   c                   6    e Zd ZdZdZ edd          gZd ZdS )BGPNLRI_IPv6z+
    Packet handling IPv6 NLRI fields.
    z	IPv6 NLRIr   ::/0c                     t           j        S rT   r   r   s     r.   r   z"BGPNLRI_IPv6.default_payload_class   r   r-   N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r   r      sH          D<&112K" " " " "r-   r   c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPNLRI_IPv4_APzC
    Packet handling IPv4 NLRI fields WITH BGP ADDITIONAL PATH
    zIPv4 NLRI (Additional Path)nlri_path_idr   r   r   N)r'   r(   r)   r*   r   r   r9   r   r,   r-   r.   r   r      sD          )D8NA..<+668KKKr-   r   c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPNLRI_IPv6_APzC
    Packet handling IPv6 NLRI fields WITH BGP ADDITIONAL PATH
    zIPv6 NLRI (Additional Path)r   r   r   r   N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r   r     sD          )D8NA..<&113KKKr-   r   c                   4     e Zd ZdZg dZ fdZ fdZ xZS )BGPNLRIPacketListFieldz/
    PacketListField handling NLRI fields.
    )r   	cls_group	no_lengthc                      t          t          |           j        ||t          fi | dt          t
          gfdt          t          gfd|         \  | _        | _	        d|v| _
        d S )N       )IPv4IPv6length_from)superr   __init__r   r   r   r   r   r   r   r   )r=   r   defaultip_modekwargs	__class__s        r.   r   zBGPNLRIPacketListField.__init__  s    4$d++4'6	
 	
%+	
 	
 	
 ,89<9:/
 /
 /+T^ 'f4r-   c                    | j         r4|                    t                    dk    r|g fS dk    r
fd| _        | j        r|d |                     |                   n|}| j        t          || j                           fd| _        t          t          |           
                    ||          }| j         rd | _        |S )Nr   c                     S rT   r,   )rH   indexs    r.   <lambda>z1BGPNLRIPacketListField.getfield.<locals>.<lambda>&  s    u r-   c                      S rT   r,   )argsclss    r.   r   z1BGPNLRIPacketListField.getfield.<locals>.<lambda>,  s     r-   )r   find_BGP_HEADER_MARKERr   r   r   r   next_cls_cbr   r   rs   )r=   rH   ri   remainresr   r   r   s        @@r.   rs   zBGPNLRIPacketListField.getfield   s    > 	5FF-..Ezz"u{{#4#4#4#4 .2.>E)D$$S)))**An$VT-@AA
 -,,,*D11::3BB> 	$#D
r-   )r'   r(   r)   r*   	__slots__r   rs   __classcell__r   s   @r.   r   r     sh          =<<I5 5 5 5 5        r-   r   c                       e Zd ZdZd ZdS )_BGPInvalidDataExceptionz]
    Raised when it is not possible to instantiate a BGP packet with the given
    data.
    c                 B    t                               | d|z              d S )Nz.Impossible to build packet from the given data)	Exceptionr   )r=   detailss     r.   r   z!_BGPInvalidDataException.__init__9  s/    <wF	
 	
 	
 	
 	
r-   N)r'   r(   r)   r*   r   r,   r-   r.   r   r   3  s-         

 
 
 
 
r-   r   c                 F    t                                          | |          S )zJ
    Returns class named "name" if it exists, fallback_cls otherwise.
    )globalsget)r   fallback_clss     r.   _get_clsr   @  s    
 99==|,,,r-   NONEOPENUPDATENOTIFICATION	KEEPALIVEROUTE-REFRESH)r   r[   r1   r2   r}      Reservedr[   zIP (IP version 4)zIP6 (IP version 6)NSAPr}   zHDLC (8-bit multidrop)r   zBBN 1822   z=802 (includes all 802 media plus Ethernet "canonical format")r4   zE.163r5   zE.164 (SMDS, Frame Relay, ATM)	   zF.69 (Telex)
   zX.121 (X.25, Frame Relay)   IPX   	Appletalk   z	Decnet IV   zBanyan Vines   z!E.164 with NSAP format subaddresszDNS (Domain Name System)   zDistinguished Name   z	AS NumberzXTP over IP version 4   zXTP over IP version 6   zXTP native mode XTP   z"Fibre Channel World-Wide Port Name   z"Fibre Channel World-Wide Node Name   GWID   zAFI for L2VPN information   z#MPLS-TP Section Endpoint Identifier   zMPLS-TP LSP Endpoint Identifier   z&MPLS-TP Pseudowire Endpoint Identifier   z"MT IP: Multi-Topology IP version 4   z$MT IPv6: Multi-Topology IP version 6i @  zEIGRP Common Service Familyi@  zEIGRP IPv4 Service Familyi@  zEIGRP IPv6 Service Familyz$LISP Canonical Address Format (LCAF)zBGP-LSz
48-bit MACz
64-bit MACOUIzMAC/24zMAC/40zIPv6/64zRBridge Port IDzTRILL Nickname)i@  i@  i@  i@  i@  i@  i	@  i
@  i@  i@  i  zBNetwork Layer Reachability Information used for unicast forwardingzDNetwork Layer Reachability Information used for multicast forwardingz>Network Layer Reachability Information (NLRI) with MPLS Labelsz	MCAST-VPNzeNetwork Layer Reachability Information used for Dynamic Placement of        Multi-Segment PseudowireszEncapsulation SAFIz
MCAST-VPLS@   zTunnel SAFIA   z"Virtual Private LAN Service (VPLS)B   zBGP MDT SAFIC   zBGP 4over6 SAFID   zBGP 6over4 SAFIE   z&Layer-1 VPN auto-discovery informationF   z	BGP EVPNsG   z
BGP-LS-VPNzMPLS-labeled VPN addressz9Multicast for BGP/MPLS IP Virtual Private Networks (VPNs)zRoute Target constraintz.IPv4 dissemination of flow specification rulesz/VPNv4 dissemination of flow specification ruleszVPN auto-discovery)H   r                  r   BGPOpen	BGPUpdateBGPNotificationBGPKeepAliveBGPRouteRefresh)r[   r1   r2   r}   r   c                       e Zd ZdZdZ eddd           edd           edd	e          gZ	e
dd
            Zd Zd ZdS )	BGPHeaderzA
    The header of any BGP message.
    References: RFC 4271
    HEADERmarkerl	    r   r   Ntyper}   c                      t          |          S z=
        Returns the right class for the given data.
        _bgp_dispatcherr   _pktr   kargss       r.   dispatch_hookzBGPHeader.dispatch_hook       t$$$r-   c                     | j         Nt          |          }|r|t          |          z   }|d d         t          j        d|          z   |dd          z   }||z   S )Nr0   !Hr   )r   rc   rd   r=   ppayrr   s       r.   
post_buildzBGPHeader.post_build  sa    8VVF +#c((*#2#T6222QrssV;A3wr-   c                     t          t                              | j        t          j                  t          j                  S rT   )r   _bgp_cls_by_typer   r  r    	raw_layerr   s     r.   guess_payload_classzBGPHeader.guess_payload_class  s)    (,,TYGGXXXr-   rT   )r'   r(   r)   r*   r   r
   r   r   _bgp_message_typesr   classmethodr  r$  r(  r,   r-   r.   r  r    s         
 D	.	
 	

 	
5$fa!344K % % % [%  Y Y Y Y Yr-   r  c                 "   t           j        }| t          dt           j                  }net          |           t          k    rM| dd         t
          k    r:t          | d                   }|dk    rt          d          }nt          d          }|S )z:
    Returns the right class for a given BGP message.
    Nr  r0   r   r}   r  )r    r'  r   r   _BGP_HEADER_SIZEr   r"   )r   r   message_types      r.   r  r    s    
 .C {DN33 w<<+++ 222 wr{++Lq  ~..{++Jr-   c                   D    e Zd ZdZdZdZdZdZdZe	d
d            Z
d	 ZdS )BGPz5
    Every BGP message inherits from this class.
    r[   r1   r2   r}   r   Nc                      t          |          S r  r  r  s       r.   r  zBGP.dispatch_hook  r  r-   c                 d    d }t          |          dk    r|d d         t          k    rt          }|S )Nr   r0   )r   r   r  )r=   r"  r   s      r.   r(  zBGP.guess_payload_class  s3    q66B;;1SbS6%777C
r-   rT   )r'   r(   r)   r*   	OPEN_TYPEUPDATE_TYPENOTIFICATION_TYPEKEEPALIVE_TYPEROUTEREFRESH_TYPEr*  r  r(  r,   r-   r.   r/  r/    sh          IKN% % % [%    r-   r/  c                       e Zd ZdZdZdS )r  z
    KEEPALIVE message.
    r   Nr'   r(   r)   r*   r   r,   r-   r.   r  r    s          DDDr-   zAuthentication (deprecated)Capabilitiesr   r[   r1   "Multiprotocol Extensions for BGP-4z"Route Refresh Capability for BGP-4#Outbound Route Filtering Capabilityz+Multiple routes to a destination capabilityzExtended Next Hop EncodingzBGP-Extended MessageGraceful Restart Capability(Support for 4-octet AS number capabilityzDeprecated (2003-03-06)z4Support for Dynamic Capability (capability specific)zMultisession BGP CapabilityzADD-PATH Capabilityz!Enhanced Route Refresh Capabilityz-Long-Lived Graceful Restart (LLGR) CapabilityI   zFQDN Capabilityr   z*Route Refresh Capability for BGP-4 (Cisco)   z+Outbound Route Filtering Capability (Cisco)BGPCapMultiprotocolBGPCapGeneric	BGPCapORFBGPCapGracefulRestartBGPCapFourBytesASN)r[   r1   r2   r   r   r  r@  c                     || |j         <   |S rT   )r'   )registryr   s     r.   _register_clsrH  T  s     HS\Jr-   c                     t           d         }| t           d         }nWt          |           }|t          k    r=t          | d                   }t	          t
                              |d                    }|S )z=
    Returns the right class for a given BGP capability.
    rB  Nr   )_capabilities_registryr   _BGP_CAPABILITY_MIN_SIZEr"   r   _capabilities_objectsr   )r   r   rr   codes       r.   _bgp_capability_dispatcherrN  \  sl    
 !
1C $_5 W---wqz??D044T?KKLLCJr-   c                        e Zd Z fdZ xZS )_BGPCap_metaclassc                     t          t          |                               | |||          }t          t          |           |S rT   )r   rP  __new__rH  rJ  )r   clsnamebasesattrsnewclassr   s        r.   rR  z_BGPCap_metaclass.__new__q  sB    *C0088%( (,h777r-   )r'   r(   r)   rR  r   r   s   @r.   rP  rP  p  s8                r-   rP  c                       e Zd ZdS )_BGPCapability_metaclassN)r'   r(   r)   r,   r-   r.   rX  rX  x  s        Dr-   rX  c                   6    e Zd ZdZedd            Zd Zd ZdS )BGPCapabilityz!
    Generic BGP capability.
    Nc                      t          |          S r  )rN  r  s       r.   r  zBGPCapability.dispatch_hook  s     *$///r-   c                     t          |          }|t          k     rDd                    |          dz   }|d                    t                    z  }t          |          |S )zK
        Check that the payload is long enough (at least 2 bytes).
        z ({}z is < _BGP_CAPABILITY_MIN_SIZE z({})).)r   rK  formatr   )r=   ri   rr   errs       r.   pre_dissectzBGPCapability.pre_dissect  s\     Q,,,--''*KKC8??#;<<<C*3///r-   c                     d}| j         7t          |          dz
  }|d d         t          |          z   |dd          z   }||z   S Nr   r1   r[   )rr   r   r#   r!  s       r.   r$  zBGPCapability.post_build  sN    ; VVaZF"1"F#ae+A3wr-   rT   )r'   r(   r)   r*   r*  r  r_  r$  r,   r-   r.   rZ  rZ  |  s\          0 0 0 [0	 	 	    r-   rZ  )	metaclassc                   p    e Zd ZdZdZdZ edde           edddd	
           e	d	dd d          gZ
dS )rB  zH
    This class provides an implementation of a generic capability.
    zBGP CapabilityTrM  r   rr   NBcap_data)fmt	length_of c                     | j         S rT   rr   r"  s    r.   r   zBGPCapGeneric.<lambda>  s    !( r-   r   )r   
max_length)r'   r(   r)   r*   r   match_subclassr   _capabilitiesr   r   r   r,   r-   r.   rB  rB    su          DNfa//h#DDDJ 2 2s	D 	D 	DKKKr-   c            	           e Zd ZdZdZdZ edde           edd           e	dd	e
           ed
d	           edd	e          gZdS )rA  zm
    This class provides an implementation of the Multiprotocol
    capability.
    References: RFC 4760
    r;  TrM  r[   rr   r}   afir   reservedsafiN)r'   r(   r)   r*   r   rm  r   rn  r   r   address_family_identifierssubsequent_afisr   r,   r-   r.   rA  rA    s}          0DNfa//	(Aua!;<<	*a  fa11KKKr-   Address Prefix ORFCP-ORF)r   r   r   receivesendzreceive + send)r[   r1   r2   c            
           e Zd ZdZ G d de          ZdZ edde           e	dd           e
dde           ed	d
dd           edg ed           gZd Zd
S )BGPCapORFBlockzo
    The "ORFBlock" is made of <AFI, rsvd, SAFI, Number of ORFs, and
    <ORF Type, Send/Receive> entries.
    c                   J    e Zd ZdZdZ edde           edde          gZdS )BGPCapORFBlock.ORFTuplezC
        Packet handling <ORF Types, Send/Receive> tuples.
        zORF Typeorf_typer   send_receiveN)	r'   r(   r)   r*   r   r   
_orf_typessend_receive_valuesr   r,   r-   r.   ORFTupler|    sI        	 	
 M*a44M.!-@AA
r-   r  zORF Capability Entryrp  r   rq  rr  
orf_numberNentries!B)count_ofrf  c                     | j         S rT   )r  rk  s    r.   r   zBGPCapORFBlock.<lambda>       r-   )
count_fromc                     d }| j         ?t          | j                  }|d d         t          j        d|          z   |dd          z   }||z   S )Nr}   r  r   )r  r   r  rc   rd   )r=   r"  r#  counts       r.   r$  zBGPCapORFBlock.post_build  sR    ?"%%E"1"D%0001QRR58A3wr-   )r'   r(   r)   r*   r   r  r   r   rs  r   r   rt  r   r   r   r$  r,   r-   r.   rz  rz    s         


 

 

 

 

6 

 

 

 "Dua!;<<	*a  fa11		
 	
 	
 	--		
 	
 	
K$    r-   rz  c                       e Zd ZdZd ZdS )BGPCapORFBlockPacketListFieldz+
    Handles lists of BGPCapORFBlocks.
    c                 ,   g }d }| j         |                      |          }|}|
|d |         }|rat          |d                   }|dz  }|d d|z            }|d|z   d          }|                     ||          }	|                    |	           |a||fS )Nr}   r1   r   r   r"   rp   append)
r=   rH   ri   lstrr   r   r  entries_lengthcurrentpackets
             r.   rs   z&BGPCapORFBlockPacketListField.getfield  s    '%%c**FwwZF 	 VAYJ'!^N0a.001GA.//0FXXc7++FJJv  	 s{r-   Nr'   r(   r)   r*   rs   r,   r-   r.   r  r    s-             r-   r  c                   j    e Zd ZdZdZdZ edde           edd           e	dg e
d	 
          gZdS )rC  zx
    This class provides an implementation of the Outbound Route Filtering
    capability.
    References: RFC 5291
    r<  TrM  r2   rr   Norfc                     | j         S rT   rj  rk  s    r.   r   zBGPCapORF.<lambda>.  s    !( r-   r   )r'   r(   r)   r*   r   rm  r   rn  r   r  rz  r   r,   r-   r.   rC  rC    so          1DNfa//	(D!!%%**		
 	
 	
	KKKr-   z,Forwarding state preserved (0x80: F bit set)c            	           e Zd ZdZ G d de          ZdZdZ edde	           e
dd	           ed
dd           eddd           edg e          gZd	S )rD  zp
    This class provides an implementation of the Graceful Restart
    capability.
    References: RFC 4724
    c                   b    e Zd ZdZdZ edde           edde           edde	          gZ
dS )BGPCapGracefulRestart.GRTuplez+Tuple <AFI, SAFI, Flags for address family>z%<AFI, SAFI, Flags for address family>rp  r   rr  r   N)r'   r(   r)   r*   r   r   rs  r   rt  gr_address_family_flagsr   r,   r-   r.   GRTupler  C  sV        996%~eQ0JKK$}VQ@@$}Wa1HIIKr-   r  r=  TrM  r   rr   Nrestart_flagsr   r}   restart_timer   r  )r'   r(   r)   r*   r   r  r   rm  r   rn  r   r   r   r   r,   r-   r.   rD  rD  <  s         K K K K K& K K K )DN =];;9Xt,,8OQ228NAr22"?9b'::	<KKKr-   c                   b    e Zd ZdZdZdZ edde           edd           e	dd	          gZ
d
S )rE  zq
    This class provides an implementation of the 4-octet AS number
    capability.
    References: RFC 4893
    r>  TrM  r   rr   r}   asnr   N)r'   r(   r)   r*   r   rm  r   rn  r   r   r   r,   r-   r.   rE  rE  X  sZ          6DN =];;9Xq))8E1%%'KKKr-   c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPAuthenticationInformationz
    Provides an implementation of the Authentication Information optional
    parameter, which is now obsolete.
    References: RFC 1771, RFC 1654, RFC 4271
    zBGP Authentication Dataauthentication_coder   authentication_dataN)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r  r  j  sF          %D92A6681488:KKKr-   r  c                       e Zd ZdZd ZdS )BGPOptParamPacketListFieldzJ
    PacketListField handling the optional parameters (OPEN message).
    c                 <   g }d}| j         |                      |          }|}||d |         ||d          }}|r\t          |d                   }|d d|z            }|d|z   d          }|                     ||          }	|                    |	           |\||z   |fS )Nr   r[   r1   r  )
r=   rH   ri   r  rr   r   ret	param_lenr  r  s
             r.   rs   z#BGPOptParamPacketListField.getfield  s    '%%c**FGVG*ajCF 	F1II^a)m^,GA	MNN+FXXc7++FJJv  	 |S  r-   Nr  r,   r-   r.   r  r  |  s-         ! ! ! ! !r-   r  c            
           e Zd ZdZdZ edde           edd           e e	dde
          d            e e	d	de          d
           gZd ZdS )BGPOptParamzc
    Provides an implementation the OPEN message optional parameters.
    References: RFC 4271
    zOptional parameter
param_typer1   param_lengthNparam_valuec                     | j         dk    S Nr1   r  rk  s    r.   r   zBGPOptParam.<lambda>      ala' r-   r  c                     | j         dk    S rZ   r  rk  s    r.   r   zBGPOptParam.<lambda>  r  r-   c                     d }|}| j         n| j        
| j        d}nt          |          dz
  }|d d         t	          |          z   }| j        dk    r| j        | j        dk    r| j        ||dd          z   }||z   S ra  )r  r  r  r   r#   r  )r=   r"  r#  rr   r  s        r.   r$  zBGPOptParam.post_build  s    $'D,D,LQrrUS[[(F1$$)9)E_))d.F.R!ABB%|r-   )r'   r(   r)   r*   r   r   optional_parameter_codesr   r   r   rZ  r  r   r$  r,   r-   r.   r  r    s         
  DlA'?@@	.$''K 
 ('	
 	
 	K%, 
 ('	
 	
K.    r-   r  c                       e Zd ZdZdZ edd           edd           edd           edd	           ed
ddd           e	dg e
d           gZd ZdS )r  zb
    OPEN messages are exchanged in order to open a new BGP session.
    References: RFC 4271
    r   versionr}   my_asr   	hold_timebgp_id0.0.0.0opt_param_lenN
opt_paramsr  rg  rf  c                     | j         S rT   )r  rk  s    r.   r   zBGPOpen.<lambda>      !/ r-   r  c                     | j         =t          |          dz
  }|d d         t          j        d|          z   |dd          z   }||z   S )Nr   r   r  )r  r   rc   rd   r!  s       r.   r$  zBGPOpen.post_build  sN    %VVb[F"1"D&111AbccF:A3wr-   )r'   r(   r)   r*   r   r   r   r   r   r  r  r   r$  r,   r-   r.   r  r    s         
 D	)Q
7A
;"")$$"		
 	
 	
 	#"11		
 	
 	
K&    r-   ORIGINAS_PATHNEXT_HOPMULTI_EXIT_DISC
LOCAL_PREFATOMIC_AGGREGATE
AGGREGATOR	COMMUNITYORIGINATOR_IDCLUSTER_LISTzDPA (deprecated)z#ADVERTISER  (Historic) (deprecated)z.RCID_PATH / CLUSTER_ID (Historic) (deprecated)MP_REACH_NLRIMP_UNREACH_NLRIzEXTENDED COMMUNITIESAS4_PATHAS4_AGGREGATORz*SAFI Specific Attribute (SSA) (deprecated)z Connector Attribute (deprecated)zAS_PATHLIMIT (deprecated)PMSI_TUNNELzTunnel Encapsulation AttributezTraffic Engineering(IPv6 Address Specific Extended CommunityAIGPzPE Distinguisher Labelsz3BGP Entropy Label Capability Attribute (deprecated)zBGP-LS Attributer   LARGE_COMMUNITY(   zBGP Prefix-SIDATTR_SETr   zReserved for development   )r   r/   r   r   r   r   r   r   r   r   r   r   r   r  r   c                       e Zd ZdZd ZdS )BGPPathAttrPacketListFieldzH
    PacketListField handling the path attributes (UPDATE message).
    c                    g }d}| j         |                      |          }d}|}||d |         ||d          }}|rt          |d                   }d}t          |          r>t          j        d|dd                   d         }|d d|z            }	|d|z   d          }n/t          |d                   }|d d|z            }	|d|z   d          }|                     ||	          }
|                    |
           |||z   |fS )Nr   rh  r   r1   r}   r2   )r   r"   r   rc   unpackrp   r  )r=   rH   ri   r  rr   r  r   r   attr_lenr  r  s              r.   rs   z#BGPPathAttrPacketListField.getfieldF  s6   '%%c**FGVG*ajCF 	 q	NNEH"5)) /!=vac{;;A> !h,/H.vay>> !h,/H.XXc7++FJJv!  	$ |S  r-   Nr  r,   r-   r.   r  r  A  s-         ! ! ! ! !r-   r  c                   :    e Zd ZdZdZ edddddd          gZd	S )
BGPPAOriginzN
    Packet handling the ORIGIN attribute value.
    References: RFC 4271
    r  originr   IGPEGP
INCOMPLETEr:  N)r'   r(   r)   r*   r   r   r   r,   r-   r.   r  r  j  sB         
 Dhu<#H#HIIKKKKr-   r  AS_SETAS_SEQUENCEAS_CONFED_SEQUENCEAS_CONFED_SET)r[   r1   r2   r}   c                       e Zd ZdZd ZdS )ASPathSegmentPacketListFieldz4
    PacketListField handling AS_PATH segments.
    c                 4   g }|}|rt          |d                   }t          j        r!|d d|dz  z            }|d|dz  z   d          }n |d d|dz  z            }|d|dz  z   d          }|                     ||          }|                    |           |||fS )Nr[   r1   r}   )r"   bgp_module_confr+   rp   r  )r=   rH   ri   r  r   segment_lengthr  r  s           r.   rs   z%ASPathSegmentPacketListField.getfield  s     	 !^^N. 9 !8!nq&8"8!89NQ$6 6 7 78 !8!nq&8"8!89NQ$6 6 7 78XXc7++FJJv  	 s{r-   Nr  r,   r-   r.   r  r    s-             r-   r  c                   R    e Zd ZdZdZ G d de          ZdZ edg e          gZ	dS )BGPPAASPathz~
    Packet handling the AS_PATH attribute value (2 bytes ASNs, for old
    speakers).
    References: RFC 4271, RFC 5065
    i[  c            
       v    e Zd ZdZ edde           edd           edg  edd                    gZ	d	 Z
dS )
BGPPAASPath.ASPathSegmentzT
        Provides an implementation for AS_PATH segments with 2 bytes ASNs.
        segment_typer1   r  Nsegment_valuer  r   c                     | j         }|9t          | j                  }|d d         t          |          z   |dd          z   }||z   S Nr[   r1   r  r   r  r#   r=   r"  r#  segment_lens       r.   r$  z$BGPPAASPath.ASPathSegment.post_build  P    -K"!$"455bqbEC,,,qu4s7Nr-   )r'   r(   r)   r*   r   as_path_segment_typesr   r   r   r   r$  r,   r-   r.   ASPathSegmentr    su        	 	
 M.!-BCCI&--N?B

5!0D0DEE
	 	 	 	 	r-   r  zAS_PATH (RFC 4271)segmentsN)
r'   r(   r)   r*   AS_TRANSr   r  r   r  r   r,   r-   r.   r  r    sj          H       &  D$$Z]CCEKKKr-   r  c                   N    e Zd ZdZ G d de          ZdZ edg e          gZdS )BGPPAAS4BytesPathz
    Packet handling the AS_PATH attribute value (4 bytes ASNs, for new
    speakers -> ASNs are encoded as IntFields).
    References: RFC 4893
    c            
       v    e Zd ZdZ edde           edd           edg  edd                    gZ	d	 Z
dS )
BGPPAAS4BytesPath.ASPathSegmentzT
        Provides an implementation for AS_PATH segments with 4 bytes ASNs.
        r  r1   r  Nr  r  r   c                     | j         }|9t          | j                  }|d d         t          |          z   |dd          z   }||z   S r  r  r  s       r.   r$  z*BGPPAAS4BytesPath.ASPathSegment.post_build  r  r-   )r'   r(   r)   r*   r   r  r   r   r   r   r$  r,   r-   r.   r  r    sv        	 	 %}^Q8MNN y!1488%~or88E1;M;MNNP	 	 	 	 	r-   r  zAS_PATH (RFC 4893)r  N)	r'   r(   r)   r*   r   r  r   r  r   r,   r-   r.   r  r    sc                "  D$$Z]CCEKKKr-   r  c                   0    e Zd ZdZdZ edd          gZdS )BGPPANextHopzP
    Packet handling the NEXT_HOP attribute value.
    References: RFC 4271
    r  next_hopr  Nr'   r(   r)   r*   r   r   r   r,   r-   r.   r  r    s3         
 D7:y112KKKr-   r  c                   0    e Zd ZdZdZ edd          gZdS )BGPPAMultiExitDisczW
    Packet handling the MULTI_EXIT_DISC attribute value.
    References: RFC 4271
    r  medr   Nr'   r(   r)   r*   r   r   r   r,   r-   r.   r  r    s3         
 D8E1%%&KKKr-   r  c                   0    e Zd ZdZdZ edd          gZdS )BGPPALocalPrefzR
    Packet handling the LOCAL_PREF attribute value.
    References: RFC 4271
    r  
local_prefr   Nr  r,   r-   r.   r
  r
    s3         
 D8L!,,-KKKr-   r
  c                       e Zd ZdZdZdS )BGPPAAtomicAggregatezX
    Packet handling the ATOMIC_AGGREGATE attribute value.
    References: RFC 4271
    r  Nr8  r,   r-   r.   r  r    s         
 DDDr-   r  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAAggregatorzR
    Packet handling the AGGREGATOR attribute value.
    References: RFC 4271
    r  aggregator_asnr   speaker_addressr  N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r  r    sF         
 D:.227,i88:KKKr-   r  	NO_EXPORTNO_ADVERTISENO_EXPORT_SUBCONFEDNOPEERzplanned-shutz
ACCEPT-OWNROUTE_FILTER_TRANSLATED_v4ROUTE_FILTER_v4ROUTE_FILTER_TRANSLATED_v6ROUTE_FILTER_v6
LLGR_STALENO_LLGRzaccept-own-nexthop)l    l    l    l    l      l     l     l     l     l     l     l     l     c                   2    e Zd ZdZdZ edde          gZdS )BGPPACommunityzS
    Packet handling the COMMUNITIES attribute value.
    References: RFC 1997
    COMMUNITIES	communityr   N)r'   r(   r)   r*   r   r   well_known_communitiesr   r,   r-   r.   r  r  :  s6         
 D<Q0FGGHKKKr-   r  c                   0    e Zd ZdZdZ edd          gZdS )BGPPAOriginatorIDzU
    Packet handling the ORIGINATOR_ID attribute value.
    References: RFC 4456
    r  originator_idr  Nr  r,   r-   r.   r"  r"  H  s3         
 D7?I667KKKr-   r"  c                   F    e Zd ZdZdZ edg  edd                    gZdS )BGPPAClusterListzT
    Packet handling the CLUSTER_LIST attribute value.
    References: RFC 4456
    r  cluster_list
cluster_idr   N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r%  r%  V  sD         
 D~r88L!+D+DEEGKKKr-   r%  z3Transitive Two-Octet AS-Specific Extended Communityz3Transitive IPv4-Address-Specific Extended Communityz4Transitive Four-Octet AS-Specific Extended Communityz$Transitive Opaque Extended CommunityzQoS MarkingzCoS CapabilityEVPN
Unassignedz(Flow spec redirect/mirror to IP next-hopz7Non-Transitive Two-Octet AS-Specific Extended Communityz7Non-Transitive IPv4-Address-Specific Extended Communityz8Non-Transitive Four-Octet AS-Specific Extended Communityz(Non-Transitive Opaque Extended Communityz6Generic Transitive Experimental Use Extended Communityr  z=Generic Transitive Experimental Use Extended Community Part 2z=Generic Transitive Experimental Use Extended Community Part 3zMAC Mobilityz	ESI LabelzES-Import Route Targetz$EVPN Router"s MAC Extended CommunityzLayer 2 Extended CommunityzE-TREE Extended CommunityzDF Election Extended CommunityzI-SID Extended Community)r   r[   r1   r2   r}   r   r   r4   zRoute TargetzRoute OriginzOSPF Domain IdentifierzBGP Data Collectionz	Source ASzL2VPN IdentifierzCisco VPN-Distinguisher)r1   r2   r}   r   r5   r   r   r0   z!Link Bandwidth Extended Communityz-Virtual-Network Identifier Extended Community)r}   r   GenericzCisco VPN Identifier)r1   r2   r}   r   r5   r   r0   zOSPF Route IDzVRF Route ImportzFlow-spec Redirect to IPv4z"Inter-Area P2MP Segmented Next-Hop)	r1   r2   r   r4   r   r   r   r0   r   zCost Communityz"Extranet Source Extended Communityz&Extranet Separation Extended CommunityzOSPF Route Typez&Additional PMSI Tunnel Attribute FlagszColor Extended Communityz Encapsulation Extended CommunityzDefault Gatewayz)Point-to-Point-to-Multipoint (PPMP) LabelzRoute-Target RecordzConsistent Hash Sort Order)r[   r2   r}   r   r   r4   r   r   r   r   r/   r   zBGP Origin Validation State)r   r[   zOSPF Route Type (deprecated)zOSPF Router ID (deprecated)z#OSPF Domain Identifier (deprecated)zFlow spec traffic-ratezFlow spec traffic-actionz"Flow spec redirect AS-2byte formatzFlow spec traffic-remarkingzLayer2 Info Extended CommunityzE-Tree Info)	r   r[   r   r   r4   r5   r   r   r   zFlow spec redirect IPv4 formatz"Flow spec redirect AS-4byte formatzTerminal ActionSample)/   .   z$OSPFv3 Route Attributes (DEPRECATED)zFlow-spec Redirect to IPv6zUUID-based Route Target)r1   r2   r}   r   r   r0   r   r   )r   r[   r1   r2   r   r   r   r   r  r   r  r@  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommTwoOctetASSpecificzt
    Packet handling the Two-Octet AS Specific Extended Community attribute
    value.
    References: RFC 4360
    z(Two-Octet AS Specific Extended Communityglobal_administratorr   local_administratorNr'   r(   r)   r*   r   r   r   r   r,   r-   r.   r/  r/    sF          6D
)1--xx8Mq/Q/QSKKKr-   r/  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommFourOctetASSpecificzu
    Packet handling the Four-Octet AS Specific Extended Community
    attribute value.
    References: RFC 5668
    z)Four-Octet AS Specific Extended Communityr0  r   r1  Nr'   r(   r)   r*   r   r   r   r   r,   r-   r.   r4  r4  !  sF          7D'++ZZ8Mq-Q-QSKKKr-   r4  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommIPv4AddressSpecificzt
    Packet handling the IPv4 Address Specific Extended Community attribute
    value.
    References: RFC 4360
    z(IPv4 Address Specific Extended Communityr0  r   r1  Nr5  r,   r-   r.   r7  r7  -  sF          6D'++ZZ8Mq-Q-QSKKKr-   r7  c                   4    e Zd ZdZdZ eddd          gZdS )BGPPAExtCommOpaqueza
    Packet handling the Opaque Extended Community attribute value.
    References: RFC 4360
    zOpaque Extended Communityvaluerh  r   rj  N)r'   r(   r)   r*   r   r   r   r,   r-   r.   r9  r9  9  s9         
 'D##GR:::;KKKr-   r9  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommTrafficRatezd
    Packet handling the (FlowSpec) "traffic-rate" extended community.
    References: RFC 5575
    z(FlowSpec traffic-rate extended communityidr   rateN)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r<  r<  G  sD         
 6D
4vq!!KKKr-   r<  c                   b    e Zd ZdZdZ eddd           eddd           eddd          gZd	S )
BGPPAExtCommTrafficActionzf
    Packet handling the (FlowSpec) "traffic-action" extended community.
    References: RFC 5575
    z*FlowSpec traffic-action extended communityrq  r   r-  sampler[   terminal_actionN)r'   r(   r)   r*   r   r   r   r,   r-   r.   r@  r@  T  sZ         
 8DQ##1a  "Aq))KKKr-   r@  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommRedirectAS2Bytezx
    Packet handling the (FlowSpec) "redirect AS-2byte" extended community
    (RFC 7674).
    References: RFC 7674
    z-FlowSpec redirect AS-2byte extended communityr  r   r:  Nr2  r,   r-   r.   rD  rD  b  sD          ;D
5!!KKKr-   rD  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommRedirectIPv4zu
    Packet handling the (FlowSpec) "redirect IPv4" extended community.
    (RFC 7674).
    References: RFC 7674
    z)FlowSpec redirect IPv4 extended communityip_addrr   r:  Nr5  r,   r-   r.   rF  rF  p  sD          7DA
7AKKKr-   rF  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAExtCommRedirectAS4Bytezy
    Packet handling the (FlowSpec) "redirect AS-4byte" extended community.
    (RFC 7674).
    References: RFC 7674
    z-FlowSpec redirect AS-4byte extended communityr  r   r:  Nr5  r,   r-   r.   rI  rI  ~  sD          ;D
7AKKKr-   rI  c                   4    e Zd ZdZdZ eddde          gZdS )BGPPAExtCommTrafficMarkingzg
    Packet handling the (FlowSpec) "traffic-marking" extended community.
    References: RFC 5575
    z+FlowSpec traffic-marking extended communitydscp0   N)r'   r(   r)   r*   r   r	   _ext_comm_traffic_action_fieldsr   r,   r-   r.   rK  rK    s:         
 9DVR%DEEKKKr-   rK  r   r   )r[   r   )r1   r   )r2   r   )r   r   )r   r4   )r   r5   )r   r   )r  r5   )r@  r5   c                   &    e Zd ZdZdgZddZd ZdS )_ExtCommValuePacketFieldzB
    PacketField handling Extended Communities "value parts".
    	type_fromrO  c                 B    t          j        | |||           || _        d S rT   )r   r   rR  )r=   r   r   r   rR  s        r.   r   z!_ExtCommValuePacketField.__init__  s$    T4#666"r-   c                 n   d }|                      |          \  }}|dk    s|dk    rt          |          }n|dk    s|dk    rt          |          }n|dk    s|dk    rt          |          }n|dk    s|dk    rt	          |          }n|d	k    rX|d
k    rt          |          }n|dk    rt          |          }nx|dk    rt          |          }nb|dk    rt          |          }nL|dk    r|dk    rt          |          }n0|dk    r|dk    rt          |          }nt          j        |          }|S )Nr   r   r[   r   r1   r   r2   r  r   r   r4   r5   r   r  r@  )rR  r/  r7  r4  r9  r<  r@  rD  rK  rF  rI  r    r'  )r=   rH   rz   r  	type_hightype_lows         r.   rp   z_ExtCommValuePacketField.m2i  s}   "nnS11	8	T 1 1033CC$)t"3"31!44CC$)t"3"31!44CC$)t"3"3$Q''CC$4-a00T!!/22T!!1!44T!!033$4.q11$41!44 .##C
r-   N)rO  )r'   r(   r)   r*   r   r   rp   r,   r-   r.   rQ  rQ    sJ          I# # # #, , , , ,r-   rQ  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAIPv6AddressSpecificExtCommz
    Provides an implementation of the IPv6 Address Specific Extended
    Community attribute. This attribute is not defined using the existing
    BGP Extended Community attribute (see the RFC 5701 excerpt below).
    References: RFC 5701
    r  r0  ::r1  r   N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   rX  rX    sG          6D'..

;PRS0T0TVKKKr-   rX  c                 8    t                               | i           S )z
    Returns a ByteEnumField with the right sub-types dict for a given community.  # noqa: E501
    http://www.iana.org/assignments/bgp-extended-communities/bgp-extended-communities.xhtml
    )_ext_comm_subtypes_classesr   )rU  s    r.   _get_ext_comm_subtyper\    s     &)))R888r-   c                   &    e Zd ZdZdgZddZd ZdS )_TypeLowFieldzG
    Field used to retrieve "dynamically" the right sub-type dict.
    	enum_fromNc                 B    t          j        | ||           || _        d S )Nr   r   )r   r   r_  )r=   r   r   r_  s       r.   r   z_TypeLowField.__init__  s%    4dG<<<<"r-   c                 X    |                      |          }|                    ||          S rT   )r_  r   )r=   rH   rQ   enums       r.   rW   z_TypeLowField.i2repr  s%    ~~c""xx1~~r-   rT   )r'   r(   r)   r*   r   r   rW   r,   r-   r.   r^  r^    sJ          I# # # #    r-   r^  c                   r    e Zd ZdZdZ edde           eddd            ed	de	d
           gZ
d ZdS )BGPPAExtCommunityzd
    Provides an implementation of the Extended Communities attribute.
    References: RFC 4360
    EXTENDED_COMMUNITYrU  r   rV  Nc                 *    t          | j                  S rT   )r\  rU  xs    r.   r   zBGPPAExtCommunity.<lambda>  s     5ak B B r-   )r_  r:  c                     | j         | j        fS rT   )rU  rV  rh  s    r.   r   zBGPPAExtCommunity.<lambda>  s    aj 9 r-   )rR  c                     | j         
|d d         }| j        Y| j         Rt                              | j         j        d          \  }}t          |          t          |          z   |dd          z   }||z   S )Nr1   rO  )r:  rV  _ext_high_low_dictr   r   r#   )r=   r"  r#  highlows        r.   r$  zBGPPAExtCommunity.post_build  sp    :"1"A= TZ%;*..tz/C\RRID#D		CHH$qu,A3wr-   )r'   r(   r)   r*   r   r   _ext_comm_typesr^  rQ  r   r   r$  r,   r-   r.   re  re    s         
  Dk1o66BB	
 	
 	

 	! 99		
 	
 	
K    r-   re  c                       e Zd ZdZd ZdS )_ExtCommsPacketListFieldzB
    PacketListField handling a list of extended communities.
    c                     g }t          |          }|d |         }|rA|d d         }|dd          }|                     ||          }|                    |           |A||fS )Nr5   )r   rp   r  )r=   rH   ri   r  rr   r   r  r  s           r.   rs   z!_ExtCommsPacketListField.getfield*  s|    Q7F7 	RaRjGABBZFXXc7++FJJv	  	 s{r-   Nr  r,   r-   r.   rq  rq  %  s-             r-   rq  c                   2    e Zd ZdZdZ edg e          gZdS )BGPPAExtCommsz<
    Packet handling the multiple extended communities.
    EXTENDED_COMMUNITIESextended_communitiesN)r'   r(   r)   r*   r   rq  re  r   r,   r-   r.   rt  rt  8  s?          "D  "	
 	
KKKr-   rt  c                       e Zd ZdZd ZdS )MPReachNLRIPacketListFieldz
    PacketListField handling the AFI specific part (except for the length of
    Next Hop Network Address field, which is not AFI specific) of the
    MP_REACH_NLRI attribute.
    c                 
   g }|}|j         dk    rq|j        dk    rf|rdt          |d                   }|dz   dz  }|d |dz            }||dz   d          }|                     ||          }|                    |           |d||fS )Nr1   r[   r   r4   r5   )rp  rr  r"   rp   r  )	r=   rH   ri   r  r   r>   length_in_bytesr  r   s	            r.   rs   z#MPReachNLRIPacketListField.getfieldN  s     7a<<x1}} 'vay>>D'+axAoO$%9o&9%9:G#Oa$7$8$89F!XXc733FJJv&&&  ' s{r-   Nr  r,   r-   r.   rx  rx  G  s-             r-   rx  c                   D   e Zd ZdZdZ edde           edde           e	dd           e
 edd          d	            e
 ed
d          d            e
 edd          d            e
 edd          d            e	dd           edg e          g	Zd ZdS )BGPPAMPReachNLRIzk
    Packet handling the MP_REACH_NLRI attribute value, for non IPv6
    AFI.
    References: RFC 4760
    r  rp  r   rr  nh_addr_len
nh_v4_addrr  c                 .    | j         dk    o
| j        dk    S )Nr[   r}   rp  r}  rh  s    r.   r   zBGPPAMPReachNLRI.<lambda>n  s    15A:#D!-12D r-   
nh_v6_addrrY  c                 .    | j         dk    o
| j        dk    S )Nr1   r0   r  rh  s    r.   r   zBGPPAMPReachNLRI.<lambda>p      15A:#E!-22E r-   nh_v6_globalc                 .    | j         dk    o
| j        dk    S Nr1   r   r  rh  s    r.   r   zBGPPAMPReachNLRI.<lambda>r  r  r-   nh_v6_link_localc                 .    | j         dk    o
| j        dk    S r  r  rh  s    r.   r   zBGPPAMPReachNLRI.<lambda>t  r  r-   rq  nlric                 .    | j         
|d d         }||z   S Nr2   )r  r=   r"  r#  s      r.   r$  zBGPPAMPReachNLRI.post_buildx  s     9"1"A3wr-   N)r'   r(   r)   r*   r   r   rs  r   rt  r   r   r   r   rx  r   r   r$  r,   r-   r.   r|  r|  a  s'         Dua!;<<fa11	-##y99DD	F 	F,55EE	G 	G.$77EE	G 	G"4d;;EE	G 	G	*a  ""62|<<>K    r-   r|  c                   2    e Zd ZdZdZ edg d          gZdS )BGPPAMPUnreachNLRI_IPv6zL
    Packet handling the MP_UNREACH_NLRI attribute value, for IPv6 AFI.
    zMP_UNREACH_NLRI (IPv6 NLRI)withdrawn_routesr   N)r'   r(   r)   r*   r   r   r   r,   r-   r.   r  r    s7          )D))*<b&IIJKKKr-   r  c                       e Zd ZdZd ZdS )MPUnreachNLRIPacketFieldzZ
    PacketField handling the AFI specific part of the MP_UNREACH_NLRI
    attribute.
    c                 h    d }|j         dk    rt          |          }nt          j        |          }|S r  )rp  r  r    r'  r=   rH   rz   r  s       r.   rp   zMPUnreachNLRIPacketField.m2i  s5    7a<<)!,,CC.##C
r-   Nr'   r(   r)   r*   rp   r,   r-   r.   r  r    s-         
    r-   r  c                   h    e Zd ZdZdZ edde           edde           e	dde
          gZd ZdS )	BGPPAMPUnreachNLRIzm
    Packet handling the MP_UNREACH_NLRI attribute value, for non IPv6
    AFI.
    References: RFC 4760
    r  rp  r   rr  afi_safi_specificNc                 .    | j         
|d d         }||z   S r  )r  r  s      r.   r$  zBGPPAMPUnreachNLRI.post_build  s!    !)"1"A3wr-   )r'   r(   r)   r*   r   r   rs  r   rt  r  r   r   r$  r,   r-   r.   r  r    sr          D!>%,FGG =O<<++,?vNNPK    r-   r  c            
           e Zd ZdZdZ eddddd           edd	           ed
g  edd                    gZ	d Z
d	S )BGPPAAS4Pathze
    Provides an implementation of the AS4_PATH attribute "value part".
    References: RFC 4893
    r  r  r1   r  r  r[   r1   r  Nr  r  r   c                     | j         9t          | j                  }|d d         t          |          z   |dd          z   }||z   S r  r  r  s       r.   r$  zBGPPAAS4Path.post_build  sK    &d011K"1"K(((1QRR50A3wr-   )r'   r(   r)   r*   r   r   r   r   r   r   r$  r,   r-   r.   r  r    s         
 D]++	
 	

 		"D))HHUA,>,>??K    r-   r  c                   X    e Zd ZdZ edd           edd           edd          gZdS )BGPLargeCommunitySegmentze
    Provides an implementation for LARGE_COMMUNITY segments
    which holds 3*4 bytes integers.
    r0  Nlocal_data_part1local_data_part2)r'   r(   r)   r*   r   r   r,   r-   r.   r  r    sQ          	'..#T**#T**KKKr-   r  c                   2    e Zd ZdZdZ edg e          gZdS )BGPPALargeCommunityzi
    Provides an implementation of the LARGE_COMMUNITY attribute.
    References: RFC 8092, RFC 8195
    r  r  N)r'   r(   r)   r*   r   r   r  r   r,   r-   r.   r  r    s6         
 D"?:r3KLLMKKKr-   r  c                   F    e Zd ZdZdZ edd           edd          gZdS )BGPPAAS4Aggregatorzo
    Provides an implementation of the AS4_AGGREGATOR attribute
    "value part".
    References: RFC 4893
    zAS4_AGGREGATOR r  r   r  r  N)r'   r(   r)   r*   r   r   r   r   r,   r-   r.   r  r    sF          D8,a007,i88:KKKr-   r  c                       e Zd ZdZd ZdS )_PathAttrPacketFieldz:
    PacketField handling path attribute value parts.
    c                    d }|j         }|dk    s|dk    rt          j        |          }n|dk    r|dk    s|dk    r|dk    s|dk    r|dk    rt          j        |          }ns|d	k    rt          j        st          |          }nQ|d
k    rt          |          }n; t          t          	                    |t          j                            |          }|S )Nr   r   !   '   )      r     r1   r   )
	type_coder    r'  r  r+   r  r  r   _path_attr_objectsr   )r=   rH   rz   r  r  s        r.   rp   z_PathAttrPacketField.m2i  s    M	 >>Y#--.##CC2oo)r//"__c!1!1c!!i3&6&6.##CC D  )H '**d"")!,,Gh&**9dnEEG GGHJ J 
r-   Nr  r,   r-   r.   r  r    s-             r-   r  c            	           e Zd ZdZd Z edddg d           edde           e e	dd	          d
            e e
dd	          d            edd	e          gZd Zd	S )BGPPathAttrzU
    Provides an implementation of the path attributes.
    References: RFC 4271
    
type_flagsr   r5   )NA0NA1NA2NA3zExtended-LengthPartial
TransitiveOptionalr  r   attr_ext_lenNc                 <    | j         d uot          | j                   S rT   r  r   rh  s    r.   r   zBGPPathAttr.<lambda>?  s"    al$. .-- r-   r  c                 >    | j         d uot          | j                    S rT   r  rh  s    r.   r   zBGPPathAttr.<lambda>D  s$    al$. .--4. r-   	attributec                    d }d }d }d}| j         @| j        t          v r t                              | j                  }nd}t	          |          }nt	          | j                   }||d d         }nt          j        d|          |d         z   }| j        1| j        d}n'|rt          |          dz
  }nt          |          dz
  }||r||dd         z   }n?||d         z   }n3|r|t          j        d	|          z   }n|t          j        d|          z   }|r| j        ||dd          z   }n| j        ||dd          z   }||z   S )
NFr   r1   r  r[   r   r}   r2   r   )
r  r  attributes_flagsr   r   rc   rd   r  r  r   )r=   r"  r#  flags_valuerr   r  extended_lengths          r.   r$  zBGPPathAttr.post_buildJ  s    ?"~!111.224>BB #1+>>OO1$/BBO rrUFF[{33ad:F = ~%" ( VVaZFF VVaZF> '!AaC&!A$ <&+dF";";;&+dF";";;  	(~)!ABB%~)!ABB%|r-   )r'   r(   r)   r*   r   r   r   path_attributesr   r   r   r  r   r   r$  r,   r-   r.   r  r  *  s         
 D
<q 	+
 	+
 	+
 		 		 	k1o66J~t,,. .	
 	

 	Ij$''. .	
 	

 	[$77-K27 7 7 7 7r-   r  c            	           e Zd ZdZdZ edddd           edg dd	 
           edddd           edg ed 
           edg d          gZ	d Z
dS )r  zR
    UPDATE messages allow peers to exchange routes.
    References: RFC 4271
    r   withdrawn_routes_lenNr  r   r  r   c                     | j         S rT   )r  rk  s    r.   r   zBGPUpdate.<lambda>  s	    !"8 r-   r  path_attr_len	path_attrc                     | j         S rT   )r  rk  s    r.   r   zBGPUpdate.<lambda>  r  r-   r  c                    d }d}| j         Nt          t          || j                            }|d d         t	          j        d|          z   |dd          z   }n| j         }| j        St          t          || j                            }|d d|z            t	          j        d|          z   |d|z   d          z   }||z   S )Nc                      t          |           S rT   )r   rk  s    r.   r   z&BGPUpdate.post_build.<locals>.<lambda>  s    s1vv r-   rh  r   r   r1   r}   )r  summapr  rc   rd   r  r  )r=   r"  r#  
subpacklenr  wlrr   s          r.   r$  zBGPUpdate.post_build  s    %%
$,ST%:;;<<BrrUV[r222QqrrU:FF*B%Z8899FwBwZ&+dF";";;aBjHF|r-   )r'   r(   r)   r*   r   r   r   r  r  r   r$  r,   r-   r.   r  r    s         
 D"(		
 	
 	
 	88		
 	
 	
 	!		
 	
 	
 	#"11		
 	
 	
 	vr6223K8    r-   zMessage Header ErrorzOPEN Message ErrorzUPDATE Message ErrorzHold Timer ExpiredzFinite State Machine ErrorCeasezROUTE-REFRESH Message Error)r[   r1   r2   r}   r   r   r4   
UnspecificzConnection Not SynchronizedzBad Message LengthzBad Message Type)r   r[   r1   r2   zUnsupported Version NumberzBad Peer ASzBad BGP IdentifierzUnsupported Optional Parameterz.Authentication Failure - Deprecated (RFC 4271)zUnacceptable Hold TimezUnsupported CapabilityzMalformed Attribute Listz!Unrecognized Well-known AttributezMissing Well-known AttributezAttribute Flags ErrorzAttribute Length ErrorzInvalid ORIGIN Attributez'AS Routing Loop - Deprecated (RFC 4271)zInvalid NEXT_HOP AttributezOptional Attribute ErrorzInvalid Network FieldzMalformed AS_PATH)r   r[   r1   r2   r}   r   r   r4   r5   r   r   r   zUnspecified Errorz,Receive Unexpected Message in OpenSent Statez/Receive Unexpected Message in OpenConfirm Statez/Receive Unexpected Message in Established Statez"Maximum Number of Prefixes ReachedzAdministrative ShutdownzPeer De-configuredzAdministrative ResetzConnection RejectedzOther Configuration ChangezConnection Collision ResolutionzOut of Resources)	r   r[   r1   r2   r}   r   r   r4   r5   zInvalid Message Lengthc                   j    e Zd ZdZdZ edde           edded d           e	d	d
          gZ
d
S )r  zK
    NOTIFICATION messages end a BGP session.
    References: RFC 4271
    r   
error_coder   error_subcodec                     | j         S rT   )r  rk  s    r.   r   zBGPNotification.<lambda>*	  r  r-   rd  )
depends_onrf  dataNra  )r'   r(   r)   r*   r   r   _error_codesr   _error_subcodesr   r   r,   r-   r.   r  r  	  sq         
 DlA|44--	
 	
 	
 	fd+++
KKKr-   	IMMEDIATEDEFERr  ADDREMOVEz
REMOVE-ALLPERMITDENYc                     | a |adS )zM
    Helper function that sets the afi / safi values
    of ORP entries.
    N)_orf_entry_afi_orf_entry_safirp  rr  s     r.   _update_orf_afi_safir  L	  s     NOOOr-   c                        e Zd ZdZddgZdZ eddde           eddd	e           e	d
dd           e
dd          gZ fdZ xZS )BGPORFEntryzN
    Provides an implementation of an ORF entry.
    References: RFC 5291
    rp  rr  z	ORF entryactionr   r1   matchr[   rq  r   r:  rh  c                     |                     dd          | _        |                     dd          | _         t          t          |           j        |i | d S )Nrp  r[   rr  )poprp  rr  r   r  r   )r=   r   r   r   s      r.   r   zBGPORFEntry.__init__g	  sU    ::eQ''JJvq))	)k4  )4:6:::::r-   )r'   r(   r)   r*   r   r   r	   _orf_actions
_orf_matchr   r   r   r   r   r   s   @r.   r  r  Y	  s          IDXq!\22WaJ//Q"""	K; ; ; ; ; ; ; ; ;r-   r  c                       e Zd ZdZd ZdS )_ORFNLRIPacketFieldz,
    PacketField handling the ORF NLRI.
    c                     d }|j         dk    rt          |          }n/|j         dk    rt          |          }nt          j        |          }|S r  )rp  r   r   r    r'  r  s       r.   rp   z_ORFNLRIPacketField.m2ir	  sM    7a<<q//CCW\\q//CC .##C
r-   Nr  r,   r-   r.   r  r  m	  s-             r-   r  c                       e Zd ZdZdZ eddde           eddde           eddd	           e	d
d           e
dd           e
dd           edde          gZdS )BGPORFAddressPrefixzJ
    Provides an implementation of the Address Prefix ORF (RFC 5292).
    ru  r  r   r1   r  r[   rq  r   sequencemin_lenmax_lenr   rh  N)r'   r(   r)   r*   r   r	   r  r  r   r   r   r  r   r   r,   r-   r.   r  r  	  s           DXq!\22WaJ//Q""Q	)Q	)QHb&11KKKr-   r  c                      e Zd ZdZdZ eddde           eddde           eddd	           e	d
d           e
dd           e
dd           edd           edd           e
dd           edde          g
ZdS )BGPORFCoveringPrefixz>
    Provides an implementation of the CP-ORF (RFC 7543).
    rv  r  r   r1   r  r[   rq  r   r  r  r  rt	import_rt
route_type	host_addrN)r'   r(   r)   r*   r   r	   r  r  r   r   r   r   r   r   r   r,   r-   r.   r  r  	  s          DXq!\22WaJ//Q""Q	)Q	)Q	$	+q!!	,""Kv..KKKr-   r  c                       e Zd ZdZd Zd ZdS )BGPORFEntryPacketListFieldz3
    PacketListField handling the ORF entries.
    c                 .   d }t          |j        t                    r|j        j        }|j        j        }nd}d}|j        dk    s|j        dk    rt          |||          }n2|j        dk    rt          |||          }nt          j	        |          }|S )Nr[   r   r   r  r   )

isinstance
underlayerr  rp  rr  r}  r  r  r    r'  )r=   rH   rz   r  rp  rr  s         r.   rp   zBGPORFEntryPacketListField.m2i	  s    cno66 	.$C>&DDCD <2!4!4%aSt<<<CC\R&qc===CC .##C
r-   c                 B   g }d}d}| j         |                      |          }|}|dk    r|g fS ||d |         ||d          }}|r|}|j        dk    s|j        dk    r(t          t          |d                             }d|z   }nR|j        dk    rG|j        dk    rd	}n9|j        d
k    rd}n+|j        dk    r t          |d                   }	|	d
k    rd}nd}|d |         }
||d          }|                     ||
          }|                    |           |||z   |fS )Nr   r-   r   r   r   r5   r   r[   r   r1   r  r   r   r   r   )r   r}  r7   r"   rp  rp   r  )r=   rH   ri   r  rr   r  r   orf_lenr   r  r  r  s               r.   rs   z#BGPORFEntryPacketListField.getfield	  s~   '%%c**FQ;;b5LGVG*ajCF ,	G |r!!S\S%8%8 0q	NN 

 j.## 7a<< %GGW\\ &GGW]] "%VBZJ!Q"( #%XgX&GGHH%FXXc7++FJJvY  ,	\ |S  r-   N)r'   r(   r)   r*   rp   rs   r,   r-   r.   r  r  	  s<           ,:! :! :! :! :!r-   r  c            	           e Zd ZdZdZ edde           edde           edddd	
           e	dg e
d           gZdS )BGPORFz`
    Provides an implementation of ORFs carried in the RR message.
    References: RFC 5291
    ORFwhen_to_refreshr   r}  r   Nr  r   r  c                     | j         S rT   )r   rk  s    r.   r   zBGPORF.<lambda>
  s    !) r-   r  )r'   r(   r)   r*   r   r   _orf_when_to_refreshr  r   r  r   r   r,   r-   r.   r  r  	  s         
 D',@AAj!Z00iEEE""++		
 	
 	
	
KKKr-   r  zRoute-RefreshBoRREoRR)r   r[   r1   r   c            
           e Zd ZdZdZ edde           edde           edde	           e
 edd	e          d
           gZdS )r  ze
    Provides an implementation of the ROUTE-REFRESH message.
    References: RFC 2918, RFC 7313
    r   rp  r[   subtyper   rr  orf_datarh  c                 4    | j         r| j         j        pddk    S )Nr   r   )r  r   rk  s    r.   r   zBGPRouteRefresh.<lambda>)
  s     2!,"28bB> r-   N)r'   r(   r)   r*   r   r   rs  r   rr_message_subtypesrt  r   r   r  r   r,   r-   r.   r  r  
  s         
 Dua!;<<i$788fa11K
B// 	
 	
	
KKKr-      )dport)sportr  z[bgp.py] use_2_bytes_asn: %s)r*   rc   rD   ra   scapyr   scapy.packetr   r   r   scapy.fieldsr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   scapy.layers.inetr   scapy.layers.inet6r   scapy.configr    r!   scapy.compatr"   r#   scapy.errorr$   r&   r  BGP_MAXIMUM_MESSAGE_SIZEr,  r   r   rK  _BGP_PATH_ATTRIBUTE_MIN_SIZEr7   r9   r   r   r   r   r   r   r   r   r   r   r'  r   r)  rs  rt  r&  r  r  r/  r  r  rn  rL  rH  rJ  rN  r  rP  rX  rZ  rB  rA  r  r  rz  r  rC  r  rD  rE  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r   r  r"  r%  ro  _ext_comm_evpn_subtypes/_ext_comm_trans_two_octets_as_specific_subtypes3_ext_comm_non_trans_two_octets_as_specific_subtypes0_ext_comm_trans_four_octets_as_specific_subtypes4_ext_comm_non_trans_four_octets_as_specific_subtypes+_ext_comm_trans_ipv4_addr_specific_subtypes/_ext_comm_non_trans_ipv4_addr_specific_subtypes_ext_comm_trans_opaque_subtypes#_ext_comm_non_trans_opaque_subtypes)_ext_comm_generic_transitive_exp_subtypes/_ext_comm_generic_transitive_exp_part2_subtypes/_ext_comm_generic_transitive_exp_part3_subtypesrN  (_ext_comm_trans_ipv6_addr_specific_types,_ext_comm_non_trans_ipv6_addr_specific_typesr[  r/  r4  r7  r9  r<  r@  rD  rF  rI  rK  rl  rQ  rX  r\  r^  re  rq  rt  rx  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  warningr+   r,   r-   r.   <module>r*     s<     				        > > > > > > > > > >* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " ! ! ! ! ! ' ' ' ' ' ' ( ( ( ( ( ( ( ( ! ! ! ! ! ! ! ! # # # # # #    i    '))      "       ! % % %-, -, -, -, -,5 -, -, -,`(@ (@ (@ (@ (@5 (@ (@ (@VF F F& & &R" " " " "6 " " "" " " " "6 " " "8 8 8 8 8l 8 8 83 3 3 3 3l 3 3 3         _      F

 

 

 

 

y 

 

 

 !% - - - -   .z.. . v	.
 . z. H. w. '. ~. #. . . . .  +!." "#. .$ %.& '.( ).* +., -.. ,/.0 ,1.2 3.4 #5.6 -7.8 )9.: 0;.< ,=.> .?.@ 
(A.B 
&C.D 
&E. .F 2[. . . bzK M z	
 G {  #  |  ,     0!" #$ %& 		#	D	"	9	:		5  @   "Y "Y "Y "Y "Y "Y "Y "YJ  2    &   B    3	   $ $  z+ + ,	
 4 #  % 2 ! > %  +  7!" #$ 	5%& 	6' 0  


!


    
    (       	 	 	 	 	02B 	 	 	    F&>    D    M   &    -   .  
   * * * * *V * * *Z    O   8       4 	7 
< < < < <M < < <8' ' ' ' ' ' ' '$
: 
: 
: 
: 
:6 
: 
: 
:$! ! ! ! ! ! ! !2, , , , ,& , , ,f    c   Z%z%x% y% z	%
 % |% % |% {% % % % -% 8% %  !%" #% %$ 
%%& '%( 4)%, *-%. #/%0 1%2 (3%4 5%6 27%8 9%: !;%< ==%> ?%@ A%B C%F G%H 	#I% %P!t!t! t! t	!
 t! t! t! t! t! ! ! ! ! ! !  !!" #!$ 		A! ! ! H"! "! "! "! "! "! "! "!R	K 	K 	K 	K 	K& 	K 	K 	K$        ?   6E E E E E& E E EBE E E E E E E EB3 3 3 3 36 3 3 3' ' ' ' ' ' ' '. . . . .V . . .    6   : : : : :f : : :" %,!,!$  "I I I I IV I I I8 8 8 8 8 8 8 8G G G G Gv G G G"
?
? 	
@ 	
0	
 	- 	
 	& 	, 	
4 	
C 	
C 	
D 	
4  	-!$ 	
B%& 	
I'( 	
I)2 

"
1
&
%
*
$
 
  


"


%	3 	3 / .
97 7 3 


"


 4 4 0 	)8 4 

"



&
#
.
/ 
/ + 35 / 

.
2

2
$
,

5

&# # " (
' ' # )
'
/
"
$
.
'
*

- 
- ) 	
*3 / 	
.3 / 	# #  2(%%0	, 	, ( 02 , :
5
:
)
!
=
9
>
-
3
9
9  (	S 	S 	S 	S 	SV 	S 	S 	S	S 	S 	S 	S 	Sf 	S 	S 	S	S 	S 	S 	S 	Sf 	S 	S 	S< < < < < < < <
 
 
 
 
f 
 
 
           &       v       &   	 	 	 	 	 	 	 	 #L#\#\\|l 7 7 7 7 7{ 7 7 7t
V 
V 
V 
V 
Vf 
V 
V 
V9 9 9    I           >       &    F          4    v   DK K K K Kf K K K    {   "       .    6   :
 
 
 
 
v 
 
 
N N N N N& N N N	: 	: 	: 	: 	: 	: 	: 	:-- 	. 	
	
 	
 	
  	
 	
 	
 	
 	
 	
 	/ 	. 	
+  	
! (    ;   <W W W W W& W W W|/ / / / / / / /v !

 

&

'  

 (	  '+;##	 	 %.)"#%4'%#   

 9<<	  /$! ',
 
 # OK K\    c   2 
      
 
 
 
; ; ; ; ;& ; ; ;(    +   ,    +        ;   &U! U! U! U! U! U! U! U!p    V   . 		      c   0 CC         CC         Iw , , , Iy61+ . . . I 4 4 4 I|fa[ 1 1 1 I 4 4 4  "O$CE E E E Er-   