Example #1
0
def test_fix_external_prefixes_tie_packet():
    packet_common.add_missing_methods_to_thrift()
    tie_protocol_packet = encoding.ttypes.ProtocolPacket(
        header=encoding.ttypes.PacketHeader(
            major_version=packet_common.MAX_U16,
            minor_version=packet_common.MAX_U16,
            sender=packet_common.MAX_U64,
            level=packet_common.MAX_U16
        ),
        content=encoding.ttypes.PacketContent(
            lie=None,
            tide=None,
            tire=None,
            tie=encoding.ttypes.TIEPacket(
                header=max_tie_header(),
                element=encoding.ttypes.TIEElement(
                    node=None,
                    prefixes=None,
                    positive_disaggregation_prefixes=None,
                    negative_disaggregation_prefixes=None,
                    external_prefixes=max_prefix_tie_element(),
                    keyvalues=None
                )
            )
        )
    )
    packet_info = packet_common.encode_protocol_packet(tie_protocol_packet, None)
    packet_info.update_env_header(0)
    packet_info.update_outer_sec_env_header(None, 111, 222, 10)
    message = b''.join(packet_info.message_parts())
    decoded_packet_info = packet_common.decode_message(None, None, message, None, None, None, None)
    assert not decoded_packet_info.error
    assert packet_info.protocol_packet == decoded_packet_info.protocol_packet
Example #2
0
def test_fix_tire_packet():
    packet_common.add_missing_methods_to_thrift()
    tire_protocol_packet = encoding.ttypes.ProtocolPacket(
        header=encoding.ttypes.PacketHeader(
            major_version=packet_common.MAX_U16,
            minor_version=packet_common.MAX_U16,
            sender=packet_common.MAX_U64,
            level=packet_common.MAX_U16
        ),
        content=encoding.ttypes.PacketContent(
            lie=None,
            tide=None,
            tire=encoding.ttypes.TIREPacket(
                headers=set([
                    max_tie_header_lifetime(0),
                    max_tie_header_lifetime(1),
                    max_tie_header_lifetime(2)
                ])
            ),
            tie=None
        )
    )
    packet_info = packet_common.encode_protocol_packet(tire_protocol_packet, None)
    packet_info.update_env_header(0)
    packet_info.update_outer_sec_env_header(None, 111, 222)
    message = b''.join(packet_info.message_parts())
    decoded_packet_info = packet_common.decode_message(None, None, message, None, None, None, None)
    assert not decoded_packet_info.error
    assert packet_info.protocol_packet == decoded_packet_info.protocol_packet
Example #3
0
def test_fix_node_tie_packet():
    packet_common.add_missing_methods_to_thrift()
    tie_protocol_packet = encoding.ttypes.ProtocolPacket(
        header=encoding.ttypes.PacketHeader(
            major_version=packet_common.MAX_U16,
            minor_version=packet_common.MAX_U16,
            sender=packet_common.MAX_U64,
            level=packet_common.MAX_U16
        ),
        content=encoding.ttypes.PacketContent(
            lie=None,
            tide=None,
            tire=None,
            tie=encoding.ttypes.TIEPacket(
                header=max_tie_header(),
                element=encoding.ttypes.TIEElement(
                    node=encoding.ttypes.NodeTIEElement(
                        level=packet_common.MAX_U16,
                        neighbors={
                            max_system_id(0): max_neighbor(),
                            max_system_id(1): max_neighbor(),
                            max_system_id(2): max_neighbor()
                        },
                        capabilities=encoding.ttypes.NodeCapabilities(
                            protocol_minor_version=protocol_minor_version,
                            flood_reduction=True,
                            hierarchy_indications=common.ttypes.HierarchyIndications.leaf_only
                        ),
                        flags=encoding.ttypes.NodeFlags(
                            overload=True
                        ),
                        name="name"
                    ),
                    prefixes=None,
                    positive_disaggregation_prefixes=None,
                    negative_disaggregation_prefixes=None,
                    external_prefixes=None,
                    keyvalues=None
                )
            )
        )
    )
    packet_info = packet_common.encode_protocol_packet(tie_protocol_packet, None)
    packet_info.update_env_header(0)
    packet_info.update_outer_sec_env_header(None, 111, 222, 10)
    message = b''.join(packet_info.message_parts())
    decoded_packet_info = packet_common.decode_message(None, None, message, None, None, None, None)
    assert not decoded_packet_info.error
    assert packet_info.protocol_packet == decoded_packet_info.protocol_packet
Example #4
0
def test_fix_lie_packet():
    packet_common.add_missing_methods_to_thrift()
    lie_protocol_packet = encoding.ttypes.ProtocolPacket(
        header=encoding.ttypes.PacketHeader(
            major_version=packet_common.MAX_U16,
            minor_version=packet_common.MAX_U16,
            sender=packet_common.MAX_U64,
            level=packet_common.MAX_U16
        ),
        content=encoding.ttypes.PacketContent(
            lie=encoding.ttypes.LIEPacket(
                name="name",
                local_id=packet_common.MAX_U32,
                flood_port=packet_common.MAX_U16,
                link_mtu_size=packet_common.MAX_U32,
                link_bandwidth=packet_common.MAX_U32,
                neighbor=encoding.ttypes.Neighbor(
                    originator=packet_common.MAX_U64,
                    remote_id=packet_common.MAX_U32
                ),
                pod=packet_common.MAX_U32,
                # nonce=packet_common.MAX_U16,
                # last_neighbor_nonce=packet_common.MAX_U16,
                node_capabilities=encoding.ttypes.NodeCapabilities(
                    protocol_minor_version=protocol_minor_version,
                    flood_reduction=True,
                    hierarchy_indications=common.ttypes.HierarchyIndications.leaf_only
                ),
                link_capabilities=encoding.ttypes.LinkCapabilities(
                    bfd=False,
                ),
                holdtime=packet_common.MAX_U16,
                not_a_ztp_offer=True,
                you_are_flood_repeater=True,
                label=packet_common.MAX_U32
            ),
            tide=None,
            tire=None,
            tie=None
        )
    )
    packet_info = packet_common.encode_protocol_packet(lie_protocol_packet, None)
    packet_info.update_env_header(0)
    packet_info.update_outer_sec_env_header(None, 111, 222)
    message = b''.join(packet_info.message_parts())
    decoded_packet_info = packet_common.decode_message(None, None, message, None, None, None, None)
    assert not decoded_packet_info.error
    assert packet_info.protocol_packet == decoded_packet_info.protocol_packet