title: Using pynids on multiple pcaps
body: <p>I am trying to parse multiple pcap files using the pynids library, but can get to parse only the 1st file. I saw that there was a function <code>nids_unregister_tcp</code> in libnids, will that help? I can't find that function in pynids though.</p>
  
  <pre><code>import nids
  
  
  def handle_tcp_stream(tcp):
      print "In handle_tcp_stream"
  
  
  def extract(pcap_file):
      nids.param("tcp_workarounds", 1)
      nids.param("pcap_filter", "tcp")         # bpf restrict to TCP only, note
      nids.param("scan_num_hosts", 0)          # disable portscan detection
      nids.chksum_ctl([('0.0.0.0/0', False)])  # disable checksumming
  
      nids.param("filename", pcap_file)
      nids.init()
      nids.register_tcp(handle_tcp_stream)
  
      try:
          nids.run()
      except Exception, e:
          print "Exception ", pcap_file + " ", e
  
  
  def main():
      extract("a.pcap")
      print "Done"
      extract("a.pcap")
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>Here's the output:</p>
  
  <pre><code>In handle_tcp_stream
  In handle_tcp_stream
  In handle_tcp_stream
  In handle_tcp_stream
  Done
  </code></pre>