Changeset 47de0aa for swig/python


Ignore:
Timestamp:
06/29/06 21:07:50 (15 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
2553732
Parents:
66caf4b
Message:
  • Cosmetic changes to trace_help() output
  • inclusion of some m4 handlers to deal with swig and python, lifted from http://autoconf-archive.cryp.to/. These are GPLd, which needs to be taken into account if libtrace licensing changes!
  • updated the swig bindings for python. Mostly api compliant now. Still possibly a memory leak to do with displaying ip addresses - I haven't touched this particular part of the code yet.
Location:
swig/python
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • swig/python/check.py

    rd5e7d91 r47de0aa  
    11#!/usr/bin/python
     2import sys
     3sys.path.append('/usr/local/lib/python2.4/site-packages/libtrace')
    24import libtrace
    3 import sys
    45
    56trace = libtrace.Trace(sys.argv[1])
    67
     8if trace.trace_is_err():
     9        print "Trace failed: %s" % trace.trace_get_err()
     10        sys.exit()
    711print "trace=",trace
    812
     
    1014packet = libtrace.Packet()
    1115
     16print "packet=",packet
    1217count = 0
    1318
    1419filter = libtrace.Filter("tcp")
     20print "filter=",filter
     21
     22ret=trace.trace_start()
     23
     24if ret < 0:
     25        print "Trace failed to start with error %s " % ret
     26        sys.exit()
    1527
    1628while 1:
     
    2739                print count
    2840
    29         #tcppacket = packet.trace_get_tcp()
    30         #if not tcppacket:
    31         #       continue
     41        tcppacket = packet.trace_get_tcp()
     42        if not tcppacket:
     43                continue
    3244
    33         #if not packet.trace_bpf_filter(filter):
    34         #       continue
     45        if not packet.trace_apply_filter(filter):
     46                continue
     47       
     48        src = packet.trace_get_source_port()
     49        dst = packet.trace_get_destination_port()
     50        if packet.trace_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
    3554
    36         #print ippacket.ip_src,':',tcppacket.source,'->',ippacket.ip_dst,':',tcppacket.dest
    37 
Note: See TracChangeset for help on using the changeset viewer.