2011/9/7 Greg Bowyer <[email protected]>
> Hi all, I have a rather interesting in house networking tool that uses pcap
> to sniff packets, take them into twisted and replay them against a target.
>
> Internally the tight loop for packet reassembly is currently run via
> twisted and some custom parsing and packet reconstruction code, I have been
> investigating if I can make this code faster _without_ reimplementing the
> capture part in C, as such I think I have two options:
>
> * Pypy (which I would prefer as it means that I hopefully will gain
> performance improvements over time, as well as JIT acceleration throughout
> the code)
> * Cython (which will let me change the main loop to be mostly C without
> having to write a lot of C)
>
> The tool currently uses an old style cPython c extension to bind python to
> pcap, since this will be slow in pypy I found the first semi implemented
> ctype pcap binding from google code here
> (http://code.google.com/p/**pcap/<http://code.google.com/p/pcap/>)
> (I didnt write it so it may be broken)
>
> The following test code works fine on cPython2.7
>
The pcap module has an important issue; pcap_open_live() contains this code:
error=c_char_p()
handle=pcap_c_funcs.pcap_open_live(source,snaplen,promisc,to_ms,error)
Which is wrong: according to the man page, the "error" parameter
"is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars"
which is not the case here, NULL is passed instead and bad things will
happen at runtime.
pcap should be modified, probably with something like "error =
create_string_buffer(256)"
--
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev