Server : LiteSpeed
System : Linux us-phx-web1359.main-hosting.eu 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : u311880514 ( 311880514)
PHP Version : 8.1.31
Disable Function : NONE
Directory :  /lib/frr/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //lib/frr/__pycache__/frr_babeltrace.cpython-36.pyc
3

8je�"�@s�dZddlZddlZddlZddlZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zed'kr�e�dS)(a
Usage: frr_babeltrace.py trace_path

FRR pushes data into lttng tracepoints in the least overhead way possible
i.e. as binary-data/crf_arrays. These traces need to be converted into pretty
strings for easy greping etc. This script is a babeltrace python plugin for
that pretty printing.

Copyright (C) 2021  NVIDIA Corporation
Anuradha Karuppiah

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; see the file COPYING; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
�NcCs�|dtjkr8dd�|dd�D�}ttjdj|���S|dtjkr�djdd	�|dd
�D��}g}x&|r�|j|d
d��|dd
�}qhWdj|�}ttj|��S|ds�dS|S)z&
    pretty print "struct ipaddr"
    rcSsg|]}t|��qS�)�str)�.0Zfvrr�./usr/lib/frr/frr_babeltrace.py�
<listcomp>(sz!print_ip_addr.<locals>.<listcomp>���.�css|]}d|VqdS)z%02xNr)r�fbrrr�	<genexpr>,sz print_ip_addr.<locals>.<genexpr>N�:)	�socketZAF_INETr�	ipaddress�IPv4Address�joinZAF_INET6�appendZIPv6Address)�	field_valZaddrZtmprrr�
print_ip_addr#s
rcCsdjdd�|D��S)z"
    pretty print "u8 mac[6]"
    r
css|]}d|VqdS)z%02xNr)rrrrrr>szprint_mac.<locals>.<genexpr>)r)rrrr�	print_mac:srcCsttj|��S)z/
    pretty print ctf_integer_network ipv4
    )rrr)rrrr�print_net_ipv4_addr@srcCsdjdd�|D��S)z1
    pretty print ethernet segment id, esi_t
    r
css|]}d|VqdS)z%02xNr)rrrrrrJszprint_esi.<locals>.<genexpr>)r)rrrr�	print_esiFsrcCs|jtjj�S)z@
    only fetch fields added via the TP, skip metadata etc.
    )Zfield_list_with_scope�
babeltraceZCTFScopeZEVENT_FIELDS)�eventrrr�get_field_listLsrcCs^t|�}i}x@|D]8}||kr<|j|�}||j|��||<q|j|�||<qWt|j|�dS)zB
    Wild card event parser; doesn't make things any prettier
    N)r�get�print�name)r�
field_parsersZ
field_listZ
field_infoZfieldZfield_parserrrr�parse_eventRs

rcCsttttd�}t||�dS)ad
    bgp evpn mac-ip parser; raw format -
    ctf_array(unsigned char, mac, &pfx->prefix.macip_addr.mac,
            sizeof(struct ethaddr))
    ctf_array(unsigned char, ip, &pfx->prefix.macip_addr.ip,
            sizeof(struct ipaddr))
    ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    )�ip�mac�esi�vtepN)rrrrr)rrrrr�parse_frr_bgp_evpn_mac_ip_zsendbs

r$cCsdti}t||�dS)z�
    bgp evpn bum-vtep parser; raw format -
    ctf_integer_network_hex(unsigned int, vtep,
            pfx->prefix.imet_addr.ip.ipaddr_v4.s_addr)

    r#N)rr)rrrrr�!parse_frr_bgp_evpn_bum_vtep_zsendssr%cCsdti}t||�dS)zu
    bgp evpn nh-rmac parser; raw format -
    ctf_array(unsigned char, rmac, &nh->rmac, sizeof(struct ethaddr))
    ZrmacN)rr)rrrrr�"parse_frr_bgp_evpn_mh_nh_rmac_send~sr&cCsttd�}t||�dS)z�
    bgp evpn local-es parser; raw format -
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
    )r"r#N)rrr)rrrrr�(parse_frr_bgp_evpn_mh_local_es_add_zrecv�sr'cCsdti}t||�dS)zf
    bgp evpn local-es parser; raw format -
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    r"N)rr)rrrrr�(parse_frr_bgp_evpn_mh_local_es_del_zrecv�sr(cCsdti}t||�dS)zj
    bgp evpn local-es-evi parser; raw format -
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    r"N)rr)rrrrr�,parse_frr_bgp_evpn_mh_local_es_evi_add_zrecv�sr)cCsdti}t||�dS)zj
    bgp evpn local-es-evi parser; raw format -
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    r"N)rr)rrrrr�,parse_frr_bgp_evpn_mh_local_es_evi_del_zrecv�sr*cCsttd�}t||�dS)z�
    bgp evpn local-vni parser; raw format -
    ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
    ctf_integer_network_hex(unsigned int, mc_grp, mc_grp.s_addr)
    )r#Zmc_grpN)rr)rrrrr�&parse_frr_bgp_evpn_local_vni_add_zrecv�sr+cCstttd�}t||�dS)a
    bgp evpn local-l3vni parser; raw format -
    ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
    ctf_array(unsigned char, svi_rmac, svi_rmac, sizeof(struct ethaddr))
    ctf_array(unsigned char, vrr_rmac, vrr_rmac, sizeof(struct ethaddr))
    )r#Zsvi_rmacZvrr_rmacN)rrr)rrrrr�(parse_frr_bgp_evpn_local_l3vni_add_zrecv�sr,cCstttd�}t||�dS)z�
    bgp evpn local-mac-ip parser; raw format -
    ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
    ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
    ctf_array(unsigned char, esi, esi, sizeof(esi_t))
    )r r!r"N)rrrr)rrrrr�(parse_frr_bgp_evpn_local_macip_add_zrecv�sr-cCsttd�}t||�dS)z�
    bgp evpn local-mac-ip del parser; raw format -
    ctf_array(unsigned char, ip, ip, sizeof(struct ipaddr))
    ctf_array(unsigned char, mac, mac, sizeof(struct ethaddr))
    )r r!N)rrr)rrrrr�(parse_frr_bgp_evpn_local_macip_del_zrecv�sr.cCsxtttttttttt	t
d�}tjd}t
j�}|j|d�x8|jD].}|j|krf|j|j�}||�qBt|i�qBWdS)z;
    FRR lttng trace output parser; babel trace plugin
    )zfrr_bgp:evpn_mac_ip_zsendzfrr_bgp:evpn_bum_vtep_zsendzfrr_bgp:evpn_mh_nh_rmac_zsendz"frr_bgp:evpn_mh_local_es_add_zrecvz"frr_bgp:evpn_mh_local_es_del_zrecvz&frr_bgp:evpn_mh_local_es_evi_add_zrecvz&frr_bgp:evpn_mh_local_es_evi_del_zrecvz frr_bgp:evpn_local_vni_add_zrecvz"frr_bgp:evpn_local_l3vni_add_zrecvz"frr_bgp:evpn_local_macip_add_zrecvz"frr_bgp:evpn_local_macip_del_zrecv�ZctfN)r$r%r&r'r(r)r*r+r,r-r.�sys�argvrZTraceCollectionZadd_traces_recursiveZeventsrrr)Z
event_parsersZ
trace_pathZtrace_collectionrZevent_parserrrr�main�s&


r2�__main__)�__doc__rrr0rrrrrrrr$r%r&r'r(r)r*r+r,r-r.r2�__name__rrrr�<module>s0				


*

F1le Man4ger