#! /usr/bin/env python

import flowtools
import sys

set = flowtools.FlowSet( "-" ) 

def printAttr( flow, attr, raw = 0 ):
    try:
        if not raw:
            val1 = eval( "flow." + attr )
            val2 = ""
        else:
            val1 = eval( "flow." + attr )
            val2 = "(0x%lx)"  % eval( "flow." + attr + "_raw" )
            
        print "%15s" % attr, val1, val2
            
    except flowtools.Error:
        pass

try:    
    
    for flow in set:
    
        printAttr( flow, "dFlows" )
        printAttr( flow, "dOctets" )
        printAttr( flow, "dPkts" )
        printAttr( flow, "dst_as" )
        printAttr( flow, "dst_mask" )
        printAttr( flow, "dst_tag" )
        printAttr( flow, "dstaddr", 1 )
        printAttr( flow, "dstport" )
        printAttr( flow, "engine_id" )
        printAttr( flow, "engine_type" )
        printAttr( flow, "exaddr", 1 )
        printAttr( flow, "extra_pkts" )
        printAttr( flow, "first", 1 )
        printAttr( flow, "in_encaps" )
        printAttr( flow, "input" )
        printAttr( flow, "last", 1 )
        printAttr( flow, "marked_tos" )
        printAttr( flow, "nexthop", 1 )
        printAttr( flow, "out_encaps" )
        printAttr( flow, "output" )
        printAttr( flow, "peer_nexthop", 1 )
        printAttr( flow, "prot" )
        printAttr( flow, "router_sc" )
        printAttr( flow, "src_as" )
        printAttr( flow, "src_mask" )
        printAttr( flow, "src_tag" )
        printAttr( flow, "srcaddr", 1 )
        printAttr( flow, "srcport" )
        printAttr( flow, "sysUpTime" )
        printAttr( flow, "tcp_flags" )
        printAttr( flow, "tos" )
        printAttr( flow, "unix_nsecs" )
        printAttr( flow, "unix_secs" )
        print

except KeyboardInterrupt:
    pass

except IOError, e:
    if e.errno != errno.EPIPE:
        print >>sys.stderr,  e 
        
