Exemple #1
0
def print_ofp_statResPort(port):
    print('StatRes Type: Port(4)')
    print(
        'StatRes port_number: %s rx_packets: %s rx_bytes: %s rx_errors: %s'
        ' rx_crc_err: %s rx_dropped: %s rx_over_err: %s rx_frame_err: %s\n'
        'StatRes port_number: %s tx_packets: %s tx_bytes: %s tx_errors: %s'
        ' tx_dropped: %s collisions: %s pad: %s' %
        (red(port.port_number), port.rx_packets, port.rx_bytes, port.rx_errors,
         port.rx_crc_err, port.rx_dropped, port.rx_over_err, port.rx_frame_err,
         red(port.port_number), port.tx_packets, port.tx_bytes, port.tx_errors,
         port.tx_dropped, port.collisions, print_pad(port.pad)))
Exemple #2
0
def print_vlan(vlan):
    """
        Print VLAN fields
    Args:
        vlan: VLAN class
    """
    print('VLAN: PCP: %s CFI: %s VID: %s Protocol: %s' %
          (vlan.pcp, vlan.cfi, red(vlan.vid), hex(vlan.ethertype)))
Exemple #3
0
def print_layer2(eth):
    """
        Prints the Ethernet frame
    Args:
        eth: Ethernet class
    """
    print('Ethernet: Destination MAC: %s Source MAC: %s Protocol: %s' %
          (eth_addr(eth.dst_mac), eth_addr(
              eth.src_mac), red(tcpiplib.tcpip.get_ethertype(eth.protocol))))
Exemple #4
0
def print_ofp_flow_removed(msg):
    print_ofp_match(msg.match)

    string = ('Body - Cookie: %s Priority: %s Reason: %s Pad: %s\nBody - '
              'Duration Secs/NSecs: %s/%s Idle Timeout: %s Pad2/Pad3: %s/%s'
              ' Packet Count: %s Byte Count: %s')

    print string % (msg.cookie, msg.priority, red(
        msg.reason), print_pad(msg.pad), msg.duration_sec, msg.duration_nsec,
                    msg.idle_timeout, print_pad(msg.pad2), print_pad(
                        msg.pad3), msg.packet_count, msg.byte_count)
Exemple #5
0
def print_switch_features(msg):
    print "OpenFlow Switch Features:"
    print(
        "Datapath_id: %s N_Buffers: %s N_Tbls: %s\nAuxiliary_id: %s "
        "Pad: %s Reserved: %s" %
        (red(tcpiplib.prints.datapath_id(
            msg.datapath_id)), msg.n_buffers, msg.n_tbls, msg.auxiliary_id,
         print_pad(msg.pad), green(msg.reserved)))
    print("Capabilities: "),
    for i in msg.caps:
        print of13.dissector.get_feature_res_capabilities(i),
    print
Exemple #6
0
def print_openflow_header(ofp):
    """
        Print OpenFlow header
    Args:
        ofp: OFMessage class
    """
    version = tcpiplib.tcpip.get_ofp_version(ofp.version)
    name_version = '%s(%s)' % (version, ofp.version)
    if version == '1.0':
        name = of10.dissector.get_ofp_type(ofp.type)
        name_type = '%s(%s)' % (name, ofp.type)
    elif version == '1.3':
        name = of13.dissector.get_ofp_type(ofp.type)
        name_type = '%s(%s)' % (name, ofp.type)
    else:
        name_type = '%s' % ofp.type

    print('OpenFlow Version: %s Type: %s Length: %s  XID: %s' %
          (name_version, yellow(name_type), ofp.length, red(ofp.xid)))
Exemple #7
0
def print_connection_restablished(pkt):
    print_headers(pkt, overwrite_min=0)
    print(red("!!!! Attention: Connection Re-Established!!\n"))
Exemple #8
0
def print_of_error(msg):
    nCode, tCode = of10.dissector.get_ofp_error(msg.type, msg.code)
    print('OpenFlow Error - Type: %s Code: %s' % (red(nCode), red(tCode)))
    hexdump(msg.data)