java.lang.Object
org.jnetpcap.internal.StandardPcapDispatcher
- All Implemented Interfaces:
AutoCloseable
,PcapDispatcher
,PcapHandler
,PcapHandler.NativeCallback
A proxy PcapHandler, which receives packets from native pcap handle and
forwards all packets to the sink java PcapHandler.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jnetpcap.PcapHandler
PcapHandler.NativeCallback, PcapHandler.OfArray<U>, PcapHandler.OfByteBuffer<U>, PcapHandler.OfMemorySegment<U>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStandardPcapDispatcher
(MemorySegment pcapHandle, PcapHeaderABI abi, Runnable breakDispatch) Instantiates a new standard pcap dispatcher. -
Method Summary
Modifier and TypeMethodDescriptionint
captureLength
(MemorySegment headerAddress) Capture length.void
close()
Close.final int
dispatchNative
(int count, PcapHandler.NativeCallback handler, MemorySegment user) Dispatch native.final int
dispatchRaw
(int count, MemorySegment callbackFunc, MemorySegment userData) Dispatch raw.final String
geterr()
Gets the last pcap error string.protected String
getErrorString
(int error) Dynamic non-pcap utility method to convert libpcap error code to a string, by various fallback methods with an active pcap handle.final RuntimeException
Gets the uncaught exception.int
headerLength
(MemorySegment headerAddress) Header length.final void
Interrupt.final int
loopNative
(int count, PcapHandler.NativeCallback handler, MemorySegment user) Loop native.final int
loopRaw
(int count, MemorySegment callbackFunc, MemorySegment userData) Loop raw.final void
nativeCallback
(MemorySegment user, MemorySegment header, MemorySegment packet) Native callback.next()
Next.nextEx()
Next ex.final void
Called on a native callback exception within the user handler.Pcap header ABI.final void
setUncaughtExceptionHandler
(Thread.UncaughtExceptionHandler exceptionHandler) Sets the uncaught exception handler.
-
Field Details
-
arena
The arena.
-
-
Constructor Details
-
StandardPcapDispatcher
Instantiates a new standard pcap dispatcher.- Parameters:
pcapHandle
- the pcap handleabi
- the abibreakDispatch
- the break dispatch
-
-
Method Details
-
geterr
-
captureLength
Capture length.- Specified by:
captureLength
in interfacePcapDispatcher
- Parameters:
headerAddress
- the header address- Returns:
- the int
- See Also:
-
close
public void close()Close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacePcapDispatcher
- See Also:
-
dispatchNative
Description copied from interface:PcapDispatcher
Dispatch native.- Specified by:
dispatchNative
in interfacePcapDispatcher
- Parameters:
count
- the counthandler
- the handleruser
- the user- Returns:
- the int
- See Also:
-
dispatchRaw
Dispatch raw.- Specified by:
dispatchRaw
in interfacePcapDispatcher
- Parameters:
count
- the countcallbackFunc
- the callback funcuserData
- the user data- Returns:
- the int
-
getUncaughtException
Gets the uncaught exception.- Specified by:
getUncaughtException
in interfacePcapDispatcher
- Returns:
- the uncaughtException
-
headerLength
Header length.- Specified by:
headerLength
in interfacePcapDispatcher
- Parameters:
headerAddress
- the header address- Returns:
- the int
- See Also:
-
interrupt
public final void interrupt()Description copied from interface:PcapDispatcher
Interrupt.- Specified by:
interrupt
in interfacePcapDispatcher
- See Also:
-
loopNative
Description copied from interface:PcapDispatcher
Loop native.- Specified by:
loopNative
in interfacePcapDispatcher
- Parameters:
count
- the counthandler
- the handleruser
- the user- Returns:
- the int
- See Also:
-
loopRaw
Loop raw.- Specified by:
loopRaw
in interfacePcapDispatcher
- Parameters:
count
- the countcallbackFunc
- the callback funcuserData
- the user data- Returns:
- the int
-
nativeCallback
Native callback.- Specified by:
nativeCallback
in interfacePcapHandler.NativeCallback
- Parameters:
user
- the userheader
- the headerpacket
- the packet- See Also:
-
onNativeCallbackException
Called on a native callback exception within the user handler.- Specified by:
onNativeCallbackException
in interfacePcapDispatcher
- Parameters:
e
- the exception
-
setUncaughtExceptionHandler
Description copied from interface:PcapDispatcher
Sets the uncaught exception handler.- Specified by:
setUncaughtExceptionHandler
in interfacePcapDispatcher
- Parameters:
exceptionHandler
- the new uncaught exception handler- See Also:
-
pcapHeaderABI
Pcap header ABI.- Specified by:
pcapHeaderABI
in interfacePcapDispatcher
- Returns:
- the pcap header ABI
- See Also:
-
getErrorString
Dynamic non-pcap utility method to convert libpcap error code to a string, by various fallback methods with an active pcap handle.- Parameters:
error
- the code- Returns:
- the error string
-
nextEx
Next ex.- Specified by:
nextEx
in interfacePcapDispatcher
- Returns:
- the pcap packet ref
- Throws:
PcapException
- the pcap exceptionTimeoutException
- the timeout exception- See Also:
-
next
Next.- Specified by:
next
in interfacePcapDispatcher
- Returns:
- the pcap packet ref
- Throws:
PcapException
- the pcap exception- See Also:
-