Introduction

Pcap provides packet processing library for rapid development on the top of JVM languages.

Hello Pcap!

"Hello pcap!" implementation in different JVM languages.

Java
Kotlin
Scala
Clojure
Groovy
Java
var pcap = Pcaps.live(new PcapLive(Pcaps.lookupInterface()));
pcap.loop(10, (args, header, buffer) -> {
log.info("Args {}", args);
log.info("Header {}", header);
log.info("Packet {}", buffer);
}, "Hello pcap!");
pcap.close();
Kotlin
val pcap = Pcaps.live(PcapLive(Pcaps.lookupInterface()))
pcap.loop(10, { args, header, buffer ->
log.info("Args {}", args)
log.info("Header {}", header)
log.info("Packet {}", buffer)
}, "Hello pcap!")
pcap.close()
Scala
val pcap = Pcaps.live(new PcapLive(Pcaps.lookupInterface()))
pcap.loop(10, (args: String, header: PacketHeader, buffer: PacketBuffer) => {
log.info("Args {}", args)
log.info("Header {}", header)
log.info("Packet {}", buffer)
}, "Hello pcap!")
pcap.close()
Clojure
(def pcap (. Pcaps (live (new PcapLive (. Pcaps (lookupInterface))))))
(def handler (reify PacketHandler (gotPacket [this args header buffer]
(.info log "Args {}" args)
(.info log "Header {}" header)
(.info log "Buffer {}" buffer))))
(.loop pcap 10 handler "Hello pcap!")
(.close pcap)
Groovy
def pcap = Pcaps.live(new PcapLive(Pcaps.lookupInterface()))
pcap.loop(10, { args, header, buffer ->
log.info("Args {}", args)
log.info("Header {}", header)
log.info("Packet {}", buffer)
}, "Hello pcap!");
pcap.close()

Disclimers

  • Every classes, methods, or fields annotated with @Incubating might never make it into a stable release.

  • Every classes, methods, or fields annotated with @Incubating might be changed or removed at any time.

  • Every classes, methods, or fields annotated with @Incubating does not imply that the functionality being tested will be present in any particular stable release.

This project does not yet have a stable release. Every artifact published on "maven central" is only for testing.