source: swig/python/check.py @ 67825b2

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 67825b2 was f0b9060, checked in by Daniel Lawson <dlawson@…>, 16 years ago

removed trace_ prefix on functions where it isn't needed

  • Property mode set to 100755
File size: 993 bytes
RevLine 
[4e194bc]1#!/usr/bin/python
2import sys
[47de0aa]3sys.path.append('/usr/local/lib/python2.4/site-packages/libtrace')
4import libtrace
[4e194bc]5
6trace = libtrace.Trace(sys.argv[1])
7
[f0b9060]8if trace.is_err():
[47de0aa]9        print "Trace failed: %s" % trace.trace_get_err()
10        sys.exit()
[4e194bc]11print "trace=",trace
12
13
[77ba31d]14packet = libtrace.Packet()
[4e194bc]15
[47de0aa]16print "packet=",packet
[6f34090]17count = 0
[f2794ea]18
[d5e7d91]19filter = libtrace.Filter("tcp")
[47de0aa]20print "filter=",filter
21
[f0b9060]22ret=trace.start()
[47de0aa]23
24if ret < 0:
25        print "Trace failed to start with error %s " % ret
26        sys.exit()
[f2794ea]27
[4e194bc]28while 1:
[f0b9060]29        trace.read_packet(packet)
[4e194bc]30        if not packet:
31                break
[f2794ea]32
[f0b9060]33        ippacket = packet.get_ip()
[6f34090]34        if not ippacket:
35                continue
[2980487]36
[d5e7d91]37        count += 1
38        if count % 10000 == 0:
39                print count
[f2794ea]40
[f0b9060]41        tcppacket = packet.get_tcp()
[47de0aa]42        if not tcppacket:
43                continue
[f2794ea]44
[f0b9060]45        if not packet.apply_filter(filter):
[47de0aa]46                continue
47       
[f0b9060]48        src = packet.get_source_port()
49        dst = packet.get_destination_port()
50        if packet.get_server_port(4,src,dst) == 0:
[47de0aa]51                print ippacket.ip_src,':',src,'->',ippacket.ip_dst,':',dst
52        else:   
53                print ippacket.ip_dst,':',dst,'<-',ippacket.ip_src,':',src
[4e194bc]54
Note: See TracBrowser for help on using the repository browser.