Skip to content

Instantly share code, notes, and snippets.

@mgodave
Created March 15, 2011 16:42
Show Gist options
  • Save mgodave/871002 to your computer and use it in GitHub Desktop.
Save mgodave/871002 to your computer and use it in GitHub Desktop.
Infinite Sequence of packets from capture interface
(ns netflow.packet
(:import jpcap.JpcapCaptor)
(:import jpcap.packet.Packet))
(def captor (JpcapCaptor/openFile "mytrace.pcap"))
(defn packet-seq [captor]
(let [packet (.getPacket captor)]
(when-not (= (Packet/EOF) packet)
(lazy-seq (cons packet (packet-seq captor))))))
(doseq [packet (packet-seq captor)]
(println packet))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment