<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Fri, 24 May 2013 18:42:25 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Marcelo Gornstein's Blog: Sniffing in PHP using libpcap: Thank you SWIG!]]></title>
      <guid>http://www.phpdeveloper.org/news/17566</guid>
      <link>http://www.phpdeveloper.org/news/17566</link>
      <description><![CDATA[<p>
<i>Marcelo Gornstein</i> has posted a new article showing how to <a href="http://marcelog.github.com/articles/swig_php_libpcap_module_c++.html">use SWIG and libpcap</a> to sniff packets from the network directly from his PHP application.
</p>
<blockquote>
I've been wanting to try <a href="http://www.swig.org/">SWIG</a> for a long time, but never got the chance, for one thing or the other. So this weekend I've finally decided to give it a try by trying to create a php extension that access a small C++ wrapper for libpcap, so I can sniff packets directly from PHP. Just for fun (and actually because I couldn't find any active pecl extension to use libpcap, so it might as well be something useful). I've named it "<a href="https://github.com/marcelog/SimplePcap">SimplePcap</a>".
</blockquote>
<p>
He includes both the sample code showing the extension's usage and an example of the output from his local "eth0" device. His PHP script uses SWIG to interface with the pcap_t/Packet class structure via <A href="https://github.com/marcelog/SimplePcap/blob/master/SimplePcap.i">this interface file</a> and typemap.
</p>
<blockquote>
SWIG is really great. I just did some C++ code and then worried about how to integrate it to PHP. Althought it seems that you really need lots of experience with it to actually do more advanced things in the right way. [...] So I guess that sometimes it's more productive to just make the PHP extension than using SWIG. But if you want your code to be run in many languages, this is definitely an excellent library to try!
</blockquote>]]></description>
      <pubDate>Tue, 21 Feb 2012 10:13:34 -0600</pubDate>
    </item>
  </channel>
</rss>
