source: swig/python/check.py @ f0b9060

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

removed trace_ prefix on functions where it isn't needed

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