From a0fc12cb372aca37b6c9b9328a38a92e2c4680ff Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 10:57:30 +0700 Subject: [PATCH 01/16] Rename method name --- jxnet-context/src/test/java/com/ardikars/jxnet/App.java | 2 +- jxnet-core/src/main/java/com/ardikars/jxnet/Core.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jxnet-context/src/test/java/com/ardikars/jxnet/App.java b/jxnet-context/src/test/java/com/ardikars/jxnet/App.java index 80799089..6fa69b93 100644 --- a/jxnet-context/src/test/java/com/ardikars/jxnet/App.java +++ b/jxnet-context/src/test/java/com/ardikars/jxnet/App.java @@ -42,6 +42,6 @@ public void nextPacket(String user, PcapPktHdr h, ByteBuffer byteBuffer) { System.out.println(user); } }, "***********************"); - context.pcapClose();; + context.pcapClose(); } } diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java index 8cbe569a..18f98a56 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java @@ -49,7 +49,7 @@ protected Core() { * @throws NativeException native exception. * @throws DeviceNotFoundException device with network connection not found. */ - public static PcapIf LookupNetworkInterface() throws NativeException, DeviceNotFoundException { + public static PcapIf lookupNetworkInterface() throws NativeException, DeviceNotFoundException { final StringBuilder errbuf = new StringBuilder(256); final List pcapIfs = new ArrayList<>(); if (Jxnet.PcapFindAllDevs(pcapIfs, errbuf) != Jxnet.OK) { @@ -92,7 +92,7 @@ public static PcapIf LookupNetworkInterface() throws NativeException, DeviceNotF * @throws NativeException native exception. * @throws IOException IO exception. */ - public static PcapIf SelectNetowrkInterface() throws NativeException, IOException { + public static PcapIf selectNetowrkInterface() throws NativeException { final StringBuilder errbuf = new StringBuilder(); final List pcapIfs = new ArrayList(); if (Jxnet.PcapFindAllDevs(pcapIfs, errbuf) != Jxnet.OK) { From c36faf0e55319fa26dfbedbcd844962bcc7bd2a2 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 11:21:02 +0700 Subject: [PATCH 02/16] Remove Core class --- checkstyle.xml | 253 ++++++++++++++ .../main/java/com/ardikars/jxnet/Core.java | 140 -------- .../main/java/com/ardikars/jxnet/Jxnet.java | 2 +- .../java/com/ardikars/jxnet/CoreTest.java | 327 ------------------ .../java/com/ardikars/jxnet/SuiteTest.java | 1 - suppression.xml | 13 + 6 files changed, 267 insertions(+), 469 deletions(-) create mode 100644 checkstyle.xml delete mode 100644 jxnet-core/src/main/java/com/ardikars/jxnet/Core.java delete mode 100644 jxnet-core/src/test/java/com/ardikars/jxnet/CoreTest.java create mode 100644 suppression.xml diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 00000000..d13b93a7 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java deleted file mode 100644 index 18f98a56..00000000 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Core.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright (C) 2017-2018 Ardika Rommy Sanjaya - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -import com.ardikars.common.net.Inet4Address; -import com.ardikars.jxnet.exception.DeviceNotFoundException; -import com.ardikars.jxnet.exception.NativeException; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -/** - * Utility methods for Jxnet API. - * @author Ardika Rommy Sanjaya - * @since 1.1.4 - */ -class Core { - - private static final Logger LOGGER = Logger.getLogger(Core.class.getSimpleName()); - - protected Core() { - - } - - /** - * Return the first connected device to the network. - * @return returns PcapIf instance. - * @since 1.1.5 - * @throws NativeException native exception. - * @throws DeviceNotFoundException device with network connection not found. - */ - public static PcapIf lookupNetworkInterface() throws NativeException, DeviceNotFoundException { - final StringBuilder errbuf = new StringBuilder(256); - final List pcapIfs = new ArrayList<>(); - if (Jxnet.PcapFindAllDevs(pcapIfs, errbuf) != Jxnet.OK) { - throw new NativeException(errbuf.toString()); - } - PcapIf result = null; - for (final PcapIf pcapIf : pcapIfs) { - for (final PcapAddr pcapAddr : pcapIf.getAddresses()) { - if (pcapAddr.getAddr().getSaFamily() == SockAddr.Family.AF_INET) { - Inet4Address address = Inet4Address.valueOf(0); - Inet4Address netmask = Inet4Address.valueOf(0); - Inet4Address bcastaddr = Inet4Address.valueOf(0); - try { - address = Inet4Address.valueOf(pcapAddr.getAddr().getData()); - netmask = Inet4Address.valueOf(pcapAddr.getNetmask().getData()); - bcastaddr = Inet4Address.valueOf(pcapAddr.getBroadAddr().getData()); - //Inet4Address dstaddr = Inet4Address.valueOf(pcapAddr.getDstAddr().getData());; - } catch (Exception e) { - errbuf.append(e.getMessage() + '\n'); - } - if (!address.equals(Inet4Address.ZERO) && !address.equals(Inet4Address.LOCALHOST) - && !netmask.equals(Inet4Address.ZERO) && !bcastaddr.equals(Inet4Address.ZERO)) { - result = pcapIf; - break; - } - } - } - } - if (result != null) { - return result; - } - errbuf.append("Device with network connention not found.\n"); - throw new DeviceNotFoundException(errbuf.toString()); - } - - /** - * Select network interface. - * @return returns selected PcapIf. - * @since 1.1.5 - * @throws NativeException native exception. - * @throws IOException IO exception. - */ - public static PcapIf selectNetowrkInterface() throws NativeException { - final StringBuilder errbuf = new StringBuilder(); - final List pcapIfs = new ArrayList(); - if (Jxnet.PcapFindAllDevs(pcapIfs, errbuf) != Jxnet.OK) { - throw new NativeException(errbuf.toString()); - } - int index = 0; - final StringBuilder sb = new StringBuilder(1000); - for (final PcapIf pcapIf : pcapIfs) { - sb.append("NO[").append(++index).append("]\t=> "); - sb.append("NAME: ").append(pcapIf.getName()).append(" (").append(pcapIf.getDescription()).append(" )\n"); - for (final PcapAddr pcapAddr : pcapIf.getAddresses()) { - sb.append("\t\tADDRESS: ").append(pcapAddr.getAddr().toString()).append('\n'); - } - } - LOGGER.info(sb.toString() + "\n"); - final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, Charset.forName("UTF-8"))); - PcapIf pcapIf = null; - index = 0; - while (index == 0) { - LOGGER.info("Select a device number, or enter 'q' to quit -> "); - try { - final String input = reader.readLine(); - index = Integer.parseInt(input); - if (index > pcapIfs.size() || index <= 0) { - index = 0; - } else { - pcapIf = pcapIfs.get(index - 1); - reader.close(); - } - } catch (NumberFormatException e) { - index = 0; - } catch (IOException e) { - index = -1; - errbuf.append(e.getMessage()); - try { - reader.close(); - } catch (IOException e1) { - errbuf.append(e1.getMessage()); - } - } - } - return pcapIf; - } - -} diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java index e2b1d3ab..9d52d277 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java @@ -1 +1 @@ -/** * Copyright (C) 2017-2018 Ardika Rommy Sanjaya * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.ardikars.jxnet; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.NativeException; import com.ardikars.jxnet.exception.PcapCloseException; import com.ardikars.jxnet.exception.PcapDumperCloseException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; /** * This class is a function mapping for libpcap api. * @author Ardika Rommy Sanjaya * @since 1.0.0 */ public final class Jxnet extends Core { private static final Logger LOGGER = Logger.getLogger(Jxnet.class.getName()); public static final int OK = 0; public static final int PCAP_ERRBUF_SIZE = 255; private Jxnet() { super(); } /** * PcapFindAllDevs() Constructs a list of network devices that can be * opened with PcapCreate() and PcapActivate() or with PcapOpenLive(). * (Note that there may be network devices that cannot be opened by the * process calling PcapFindAllDevs()). * @param alldevsp list of PcapIf. * @param errbuf error buffer. * @return PcapFindAllDevs() returns 0 on success and -1 on failure; as indicated, * finding no devices is considered success, rather than failure, * so 0 will be returned in that case. If -1 is returned, errbuf is * filled in with an appropriate error message. * @since 1.1.4 */ public static native int PcapFindAllDevs(List alldevsp, StringBuilder errbuf); /** * Open a live capture handle. * On Linux systems with 2.2 or later kernels, a device (source) * argument of "any" or NULL can be used to capture packets from all interfaces. * @param source interface name. * @param snaplen specifies the snapshot length to be set on the handle (16 bit). * @param promisc specifies if the interface is to be put into promiscuous mode. * @param toMs specifies the packet buffer timeout in milliseconds. * @param errbuf error buffer. * @return PcapOpenLive() returns null on error. If null is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenLive(String source, int snaplen, int promisc, int toMs, StringBuilder errbuf); /** * Collect a group of packets. * Callback argument already asyncronous. * @param pcap pcap instance. * @param cnt maximum iteration, -1 is infinite iteration. * @param callback callback funtion. * @param user args * @param args type. * @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a * @throws PcapCloseException pcap close exception. * savefile, no more packets are available. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. It does not return when live packet * buffer timeouts occur; instead, it attempts to read more packets. * @since 1.1.4 */ public static native int PcapLoop(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Collect a group of packets. * @param pcap pcap instance. * @param cnt maximum iteration, -1 to infinite. * @param callback callback function. * @param user arg. * @param args type. * @return PcapDispatch() returns the number of packets processed on success; * @throws PcapCloseException pcap close exception. * this can be 0 if no packets were read from a live capture (if, for * example, they were discarded because they didn't pass the packet filter, * or if, on platforms that support a packet buffer timeout that * starts before any packets arrive, the timeout expires before any packets * arrive, or if the file descriptor for the capture device is in non-blocking * mode and no packets were available to be read) or if no more * packets are available in a savefile. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. If your application uses * PcapBreakLoop(), make sure that you explicitly check for -1 and -2, * rather than just checking for a return value less then 0. * @since 1.1.4 */ public static native int PcapDispatch(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Open a file to write packets. * @param pcap pcap instance. * @param fname fname specifies the name of the file to open. The file will have the same format * as those used by tcpdump(1) and tcpslice(1). The name "-" is a synonym for stdout. * @return null on error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native PcapDumper PcapDumpOpen(Pcap pcap, String fname) throws PcapCloseException; /** * Save a packet to disk. * @param pcapDumper pcap dumper object. * @param h pcap packet header. * @param sp packet buffer. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDump(PcapDumper pcapDumper, PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException; /** * Open a savefile in the tcpdump/libpcap format to read packets. * @param fname file name. * @param errbuf error buffer. * @return null on error. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenOffline(String fname, StringBuilder errbuf); /** * Compile a packet filter, converting an high level filtering expression * (see Filtering expression syntax) in a program that can be interpreted * by the kernel-level filtering engine. * Note: Before libpcap-1.8.1 this function is not thread-safe @link https://github.com/the-tcpdump-group/libpcap/issues/75. * @param pcap pcap instance. * @param fp compiled bfp. * @param str filter expression. * @param optimize optimize (0/1). * @param netmask netmask. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapCompile(Pcap pcap, BpfProgram fp, String str, int optimize, int netmask) throws PcapCloseException; /** * Associate a filter to a capture. * @param pcap pcap instance. * @param fp compiled bpf. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetFilter(Pcap pcap, BpfProgram fp) throws PcapCloseException; /** * Send a raw packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size size of packet buffer. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSendPacket(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException; /** * Return the next available packet. * @param pcap pcap instance. * @param h packet header. * @return PcapNext() returns next available packet. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native ByteBuffer PcapNext(Pcap pcap, PcapPktHdr h) throws PcapCloseException; /** * Read a packet from an interface or from an offline capture. * @param pcap pcap instance. * @param pktHeader packet header. * @param pktData packet buffer. * @return PcapNextEx() returns 1 if the packet was read without problems, 0 if * packets are being read from a live capture and the packet buffer time- * out expired, -1 if an error occurred while reading the packet, and -2 * if packets are being read from a savefile and there are no more * packets to read from the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapNextEx(Pcap pcap, PcapPktHdr pktHeader, ByteBuffer pktData) throws PcapCloseException; /** * Close the files associated with pcap and deallocates resources. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapClose(Pcap pcap) throws PcapCloseException; /** * Flushes the output buffer to the savefile, so that any packets written * with PcapDump() but not yet written to the savefile will be written. -1 * is returned on error, 0 on success. * @param pcapDumper pcap dumper object. * @return -1 on error, 0 otherwise. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native int PcapDumpFlush(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Closes a savefile. * @param pcapDumper pcap dumper object. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDumpClose(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Return the link layer of an adapter on success. * @param pcap pcap instance. * @return link layer type of an adapter on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapDataLink(Pcap pcap) throws PcapCloseException; /** * Set the current data link type of the pcap descriptor to the type * specified by dlt. -1 is returned on failure. * @param pcap pcap instance. * @param dtl data link type. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapSetDataLink(Pcap pcap, int dtl) throws PcapCloseException, NativeException; /** * Set a flag that will force PcapDispatch() or PcapLoop() to return rather than looping. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapBreakLoop(Pcap pcap) throws PcapCloseException; /** * Return the first valid device in the system. * @param errbuf error buffer. * @return first valid device in the system. PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device") * @since 1.1.4 * @deprecated use 'pcap_findalldevs' and use the first device. */ @Deprecated public static native String PcapLookupDev(StringBuilder errbuf); /** * Return the error text pertaining to the last pcap library error. * @param pcap pcap instance. * @return error text pertaining to the last pcap library error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native String PcapGetErr(Pcap pcap) throws PcapCloseException; /** * Returns a string giving information about the version of the libpcap library being used; * note that it contains more information than just a version number. * @return libpcap version. * @since 1.1.4 */ public static native String PcapLibVersion(); /** * Returns true (1) if the current savefile uses a different byte order than the current system. * @param pcap pcap instance. * @return PcapIsSwapped() returns true (1) or false (0) on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapIsSwapped(Pcap pcap) throws PcapCloseException; /** * Return the dimension of the packet portion (in bytes) that is delivered to the application. * @param pcap pcap instance * @return PcapSnapshot() returns the snapshot length on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException; /** * Provided in case StrError() isn't available. It returns an error message string corresponding to error. * @param error error code. * @return error message. * @since 1.1.4 */ public static native String PcapStrError(int error); /** * Return the major version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return major version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMajorVersion(Pcap pcap) throws PcapCloseException; /** * Return the minor version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return minor version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMinorVersion(Pcap pcap) throws PcapCloseException; /** * Translates a data link type value to the corresponding data link type name. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToName(int dtl); /** * Translates a data link type value to a short description of that data link type. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToDescription(int dtl); /** * Translates a data link type name, which is a DLT_ name with the DLT_ removed, * to the corresponding data link type value. The translation is case-insensitive. * -1 is returned on failure. * @param name link type name. * @return PcapDataLinkNameToVal() returns the type value on success and -1 if the name is not a known type name. * @since 1.1.4 */ public static native int PcapDataLinkNameToVal(String name); /** * Switch between blocking and nonblocking mode. * @param pcap pcap instance. * @param nonblock 1 to set non block. * @param errbuf error buffer. * @return returns the current non-blocking state of the capture descriptor; * it always returns 0 on savefiles. If there is an error, -1 is returned and * errbuf is filled in with an appropriate error message. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetNonBlock(Pcap pcap, int nonblock, StringBuilder errbuf) throws PcapCloseException; /** * Get the "non-blocking" state of an interface. * @param pcap pcap instance. * @param errbuf error buffer. * @return PcapGetNonBlock() returns the current non-blocking state of the * capture descriptor; it always returns 0 on savefiles. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapGetNonBlock(Pcap pcap, StringBuilder errbuf) throws PcapCloseException; /** * Create a pcap instance without starting a capture. * @param linktype link type. * @param snaplen snapshot length. * @return null on error. * @since 1.1.4 */ public static native Pcap PcapOpenDead(int linktype, int snaplen); /** * Return the file position for a savefile. * @param pcapDumper pcap dumper object. * @return file position for a savefile. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native long PcapDumpFTell(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Free a filter. * @param bpfProgram compiled bpf. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native void PcapFreeCode(BpfProgram bpfProgram) throws BpfProgramCloseException; /** * Return statistics on current capture. * @param pcap pcap instance. * @param pcapStat pcap stat object. * @return PcapStats() returns 0 on success and returns -1 if there is an error * or if pcap handle doesn't support packet statistics. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapStats(Pcap pcap, PcapStat pcapStat) throws PcapCloseException; /** * Compile a packet filter without the need of opening an adapter. * This function converts an high level filtering expression (see Filtering expression syntax) * in a program that can be interpreted by the kernel-level filtering engine. * @param snaplenArg snapshot length. * @param linktypeArg link type. * @param program bpf. * @param buf str. * @param optimize optiomize (0/1). * @param mask netmask. * @return -1 on error. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native int PcapCompileNoPcap(int snaplenArg, int linktypeArg, BpfProgram program, String buf, int optimize, int mask) throws BpfProgramCloseException; /** * Print the text of the last pcap library error on stderr, prefixed by prefix. * @param pcap pcap instance. * @param prefix prefix. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapPError(Pcap pcap, String prefix) throws PcapCloseException; /** * Is used to create a packet capture handle to look at packets on the network. * Source is a string that specifies the network device to open; * on Linux systems with 2.2 or later kernels, a source argument of "any" or NULL * can be used to capture packets from all interfaces. * *

The returned handle must be activated with PcapActivate() before packets can be captured with it; * options for the capture, such as promiscuous mode, can be set on the handle before activating it.

* @param source network device. * @param errbuf errof buffer. * @return returns a pcap instance on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapCreate(String source, StringBuilder errbuf); /** * Sets the snapshot length to be used on a capture handle when the handle is activated to snaplen. * @param pcap pcap instance. * @param snaplen snaplen. * @return returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetSnaplen(Pcap pcap, int snaplen) throws PcapCloseException; /** * sets whether promiscuous mode should be set on a capture handle when the handle is activated. * If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param promisc promisc. * @return pcapSetPromisc() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetPromisc(Pcap pcap, int promisc) throws PcapCloseException; /** * Sets the packet buffer timeout that will be used on a capture handle when the handle is activated to to_ms, * which is in units of milliseconds. * @param pcap pcap instance. * @param timeout timeout. * @return PcapSetTimeout() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetTimeout(Pcap pcap, int timeout) throws PcapCloseException; /** * Sets the buffer size that will be used on a capture handle when the handle is activated to buffer_size, which is in units of bytes. * @param pcap pcap instance. * @param bufferSize buffer size. * @return PcapSetBufferSize() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetBufferSize(Pcap pcap, int bufferSize) throws PcapCloseException; /** * Checks whether monitor mode could be set on a capture handle when the handle is activated. * @param pcap pcap instance. * @return PcapCanSetRfMon() returns 0 if monitor mode could not be set, 1 if * monitor mode could be set, and a negative value on error. A negative * return value indicates what error condition occurred. The possible * error values are: * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported. * PCAP_ERROR_ACTIVATED(-4): The capture handle has already been activated. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException; /** * Sets whether monitor mode should be set on a capture handle when the handle is activated. * If rfmon is non-zero, monitor mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param rfmon 1 (true) or 0 (false). * @return PcapSetRfMon() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called * on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException; /** * Sets whether immediate mode should be set on a capture handle when the handle is activated. If immediate_mode is non-zero, * immediate mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param immediateMode immediate_mode. * @return PcapSetImmediateMode() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) * if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetImmediateMode(Pcap pcap, int immediateMode) throws PcapCloseException, PlatformNotSupportedException; /** * Is used to activate a packet capture handle to look at packets on the network, * with the options that were set on the handle being in effect. * @param pcap pcap instance. * @return 0 on success without warnings, a non-zero positive value on success with warnings, and a negative value on error. * A non-zero return value indicates what warning or error condition occurred. * The possible warning values are: * PCAP_WARNING_PROMISC_NOTSUP(2): Promiscuous mode was requested, but the capture source doesn't support promiscuous mode. * PCAP_WARNING_TSTAMP_TYPE_NOTSUP(3): The time stamp type specified in a previous PcapSetTStampType() call isn't supported * by the capture source (the time stamp type is left as the default). * PCAP_WARNING(1): Generic waring. * The possible error values are: * PCAP_ERROR_ACTIVATED(-4): The handle has already been activated. * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn't exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to open the capture source. * PCAP_ERROR_PROMISC_PERM_DENIED(-11): The process has permission to open the capture source but doesn't have * spermission to put it into promiscuous mode. * PCAP_ERROR_RFMON_NOTSUP(-6): Monitor mode was specified but the capture source doesn't support monitor mode. * PCAP_ERROR_IFACE_NOT_UP(-9): The capture source device is not up. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapActivate(Pcap pcap) throws PcapCloseException; /** * used to specify a direction that packets will be * captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or * PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the * device, PCAP_D_OUT will only capture packets sent by the device and * PCAP_D_INOUT will capture packets received by or sent by the device. * PCAP_D_INOUT is the default setting if this function is not called. * *

PcapSetdirection() isn't necessarily fully supported on all platforms; * some platforms might return an error for all values, and some other * platforms might not support PCAP_D_OUT.

* *

This operation is not supported if a savefile is being read.

* @param pcap pcap instance. * @param direction direction. * @return returns 0 on success and -1 on failure (not supported by operating system). * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp precision returned in captures. * @param pcap pcap. * @param tstampPrecision time stamp precision. * @return 0 on success if specified time stamp precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampPrecision(Pcap pcap, int tstampPrecision) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp type returned in captures. * @param pcap pcap. * @param type time stamp type. * @return 0 on success if specified time type precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampType(Pcap pcap, int type) throws PcapCloseException, PlatformNotSupportedException; /** * Get the time stamp precision returned in captures. * @param pcap pcap instance. * @return the precision of the time stamp returned in packet captures on the pcap descriptor. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapGetTStampPrecision(Pcap pcap) throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. * @param pcap pcap instance. * @param dtlBuffer datalinks. * @return list of datalinks. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListDataLinks(Pcap pcap, List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; /** * Get link of time stamp types. * @param pcap pcap instance. * @param tstampTypesp time stamp types. * @return time stamp types. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListTStampTypes(Pcap pcap, List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Translates a time stamp type name to the corresponding time stamp type value. The translation is case-insensitive. * @param name time stamp name. * @return returns time stamp type value on success and PCAP_ERROR on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapTStampTypeNameToVal(String name) throws PlatformNotSupportedException; /** * Translates a time stamp type value to the corresponding time stamp type name. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToName(int tstampType) throws PlatformNotSupportedException; /** * Translates a time stamp type value to a short description of that time stamp type. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToDescription(int tstampType) throws PlatformNotSupportedException; /** * Converts a status code value returned by a libpcap routine to an error string. * @param errnum statuc code number. * @return status string. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapStatusToStr(int errnum) throws PlatformNotSupportedException; /** * Used for creating a Pcap instance to use when calling the other functions. * It is typically used when just using for compiling BPF code; * it can also be used if using pcap_dump_open(), pcap_dump(), * and PcapDumpClose() to write a savefile if there is no Pcap that * supplies the packets to be written. * @param linktype specifies the link-layer type * @param snaplen specifies the snapshot length. * @param precision specifies the time stamp precision. * @return null on fail. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenDeadWithTStampPrecision(int linktype, int snaplen, int precision) throws PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw * data for the packet, check whether the packet passes the filter. * Returns the return value of the filter program, which will be zero if * the packet doesn't pass and non-zero if the packet does pass. * @param fp bpfProgram * @param h pktHdr * @param pkt buffer. * @return 0 on success. */ public static native int PcapOfflineFilter(BpfProgram fp, PcapPktHdr h, ByteBuffer pkt); /** * Called to open a savefile for reading pcap file. * @param fname specifies the file name. * @param tstampPrecision specifies the time stamp precision. * @param errbuf specifies errror buffer. * @return pcap instance. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenOfflineWithTStampPrecision(String fname, int tstampPrecision, StringBuilder errbuf) throws PlatformNotSupportedException; /** * Sends a raw packet through the network interface; buf points to the data of the packet, * including the link-layer header, and size is the number of bytes in the packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size packet size. * @return PcapInject returns the number of bytes written on success and -1 on failure. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapInject(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException, PlatformNotSupportedException; /** * Check if pcap handle is alredy activated or no. * @param pcap pcap instance. * @return returns 0 if pcap handle not active yet. */ public static native int PcapCheckActivated(Pcap pcap); /* static { if (!Application.getInstance().isLoaded()) { Application.run("", "", Initializer.class); } } static final class Initializer implements ApplicationInitializer { @Override public void initialize(Application.Context context) { context.addLibrary(new DynamicLibrary()); context.addLibrary(new StaticLibrary()); } } */ public static void main(String[] args) { LOGGER.info(Arrays.toString(args)); } } \ No newline at end of file +/** * Copyright (C) 2017-2018 Ardika Rommy Sanjaya * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.ardikars.jxnet; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.NativeException; import com.ardikars.jxnet.exception.PcapCloseException; import com.ardikars.jxnet.exception.PcapDumperCloseException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; /** * This class is a function mapping for libpcap api. * @author Ardika Rommy Sanjaya * @since 1.0.0 */ public final class Jxnet { private static final Logger LOGGER = Logger.getLogger(Jxnet.class.getName()); public static final int OK = 0; public static final int PCAP_ERRBUF_SIZE = 255; private Jxnet() { super(); } /** * PcapFindAllDevs() Constructs a list of network devices that can be * opened with PcapCreate() and PcapActivate() or with PcapOpenLive(). * (Note that there may be network devices that cannot be opened by the * process calling PcapFindAllDevs()). * @param alldevsp list of PcapIf. * @param errbuf error buffer. * @return PcapFindAllDevs() returns 0 on success and -1 on failure; as indicated, * finding no devices is considered success, rather than failure, * so 0 will be returned in that case. If -1 is returned, errbuf is * filled in with an appropriate error message. * @since 1.1.4 */ public static native int PcapFindAllDevs(List alldevsp, StringBuilder errbuf); /** * Open a live capture handle. * On Linux systems with 2.2 or later kernels, a device (source) * argument of "any" or NULL can be used to capture packets from all interfaces. * @param source interface name. * @param snaplen specifies the snapshot length to be set on the handle (16 bit). * @param promisc specifies if the interface is to be put into promiscuous mode. * @param toMs specifies the packet buffer timeout in milliseconds. * @param errbuf error buffer. * @return PcapOpenLive() returns null on error. If null is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenLive(String source, int snaplen, int promisc, int toMs, StringBuilder errbuf); /** * Collect a group of packets. * Callback argument already asyncronous. * @param pcap pcap instance. * @param cnt maximum iteration, -1 is infinite iteration. * @param callback callback funtion. * @param user args * @param args type. * @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a * @throws PcapCloseException pcap close exception. * savefile, no more packets are available. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. It does not return when live packet * buffer timeouts occur; instead, it attempts to read more packets. * @since 1.1.4 */ public static native int PcapLoop(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Collect a group of packets. * @param pcap pcap instance. * @param cnt maximum iteration, -1 to infinite. * @param callback callback function. * @param user arg. * @param args type. * @return PcapDispatch() returns the number of packets processed on success; * @throws PcapCloseException pcap close exception. * this can be 0 if no packets were read from a live capture (if, for * example, they were discarded because they didn't pass the packet filter, * or if, on platforms that support a packet buffer timeout that * starts before any packets arrive, the timeout expires before any packets * arrive, or if the file descriptor for the capture device is in non-blocking * mode and no packets were available to be read) or if no more * packets are available in a savefile. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. If your application uses * PcapBreakLoop(), make sure that you explicitly check for -1 and -2, * rather than just checking for a return value less then 0. * @since 1.1.4 */ public static native int PcapDispatch(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Open a file to write packets. * @param pcap pcap instance. * @param fname fname specifies the name of the file to open. The file will have the same format * as those used by tcpdump(1) and tcpslice(1). The name "-" is a synonym for stdout. * @return null on error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native PcapDumper PcapDumpOpen(Pcap pcap, String fname) throws PcapCloseException; /** * Save a packet to disk. * @param pcapDumper pcap dumper object. * @param h pcap packet header. * @param sp packet buffer. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDump(PcapDumper pcapDumper, PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException; /** * Open a savefile in the tcpdump/libpcap format to read packets. * @param fname file name. * @param errbuf error buffer. * @return null on error. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenOffline(String fname, StringBuilder errbuf); /** * Compile a packet filter, converting an high level filtering expression * (see Filtering expression syntax) in a program that can be interpreted * by the kernel-level filtering engine. * Note: Before libpcap-1.8.1 this function is not thread-safe @link https://github.com/the-tcpdump-group/libpcap/issues/75. * @param pcap pcap instance. * @param fp compiled bfp. * @param str filter expression. * @param optimize optimize (0/1). * @param netmask netmask. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapCompile(Pcap pcap, BpfProgram fp, String str, int optimize, int netmask) throws PcapCloseException; /** * Associate a filter to a capture. * @param pcap pcap instance. * @param fp compiled bpf. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetFilter(Pcap pcap, BpfProgram fp) throws PcapCloseException; /** * Send a raw packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size size of packet buffer. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSendPacket(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException; /** * Return the next available packet. * @param pcap pcap instance. * @param h packet header. * @return PcapNext() returns next available packet. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native ByteBuffer PcapNext(Pcap pcap, PcapPktHdr h) throws PcapCloseException; /** * Read a packet from an interface or from an offline capture. * @param pcap pcap instance. * @param pktHeader packet header. * @param pktData packet buffer. * @return PcapNextEx() returns 1 if the packet was read without problems, 0 if * packets are being read from a live capture and the packet buffer time- * out expired, -1 if an error occurred while reading the packet, and -2 * if packets are being read from a savefile and there are no more * packets to read from the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapNextEx(Pcap pcap, PcapPktHdr pktHeader, ByteBuffer pktData) throws PcapCloseException; /** * Close the files associated with pcap and deallocates resources. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapClose(Pcap pcap) throws PcapCloseException; /** * Flushes the output buffer to the savefile, so that any packets written * with PcapDump() but not yet written to the savefile will be written. -1 * is returned on error, 0 on success. * @param pcapDumper pcap dumper object. * @return -1 on error, 0 otherwise. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native int PcapDumpFlush(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Closes a savefile. * @param pcapDumper pcap dumper object. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDumpClose(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Return the link layer of an adapter on success. * @param pcap pcap instance. * @return link layer type of an adapter on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapDataLink(Pcap pcap) throws PcapCloseException; /** * Set the current data link type of the pcap descriptor to the type * specified by dlt. -1 is returned on failure. * @param pcap pcap instance. * @param dtl data link type. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapSetDataLink(Pcap pcap, int dtl) throws PcapCloseException, NativeException; /** * Set a flag that will force PcapDispatch() or PcapLoop() to return rather than looping. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapBreakLoop(Pcap pcap) throws PcapCloseException; /** * Return the first valid device in the system. * @param errbuf error buffer. * @return first valid device in the system. PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device") * @since 1.1.4 * @deprecated use 'pcap_findalldevs' and use the first device. */ @Deprecated public static native String PcapLookupDev(StringBuilder errbuf); /** * Return the error text pertaining to the last pcap library error. * @param pcap pcap instance. * @return error text pertaining to the last pcap library error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native String PcapGetErr(Pcap pcap) throws PcapCloseException; /** * Returns a string giving information about the version of the libpcap library being used; * note that it contains more information than just a version number. * @return libpcap version. * @since 1.1.4 */ public static native String PcapLibVersion(); /** * Returns true (1) if the current savefile uses a different byte order than the current system. * @param pcap pcap instance. * @return PcapIsSwapped() returns true (1) or false (0) on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapIsSwapped(Pcap pcap) throws PcapCloseException; /** * Return the dimension of the packet portion (in bytes) that is delivered to the application. * @param pcap pcap instance * @return PcapSnapshot() returns the snapshot length on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException; /** * Provided in case StrError() isn't available. It returns an error message string corresponding to error. * @param error error code. * @return error message. * @since 1.1.4 */ public static native String PcapStrError(int error); /** * Return the major version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return major version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMajorVersion(Pcap pcap) throws PcapCloseException; /** * Return the minor version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return minor version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMinorVersion(Pcap pcap) throws PcapCloseException; /** * Translates a data link type value to the corresponding data link type name. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToName(int dtl); /** * Translates a data link type value to a short description of that data link type. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToDescription(int dtl); /** * Translates a data link type name, which is a DLT_ name with the DLT_ removed, * to the corresponding data link type value. The translation is case-insensitive. * -1 is returned on failure. * @param name link type name. * @return PcapDataLinkNameToVal() returns the type value on success and -1 if the name is not a known type name. * @since 1.1.4 */ public static native int PcapDataLinkNameToVal(String name); /** * Switch between blocking and nonblocking mode. * @param pcap pcap instance. * @param nonblock 1 to set non block. * @param errbuf error buffer. * @return returns the current non-blocking state of the capture descriptor; * it always returns 0 on savefiles. If there is an error, -1 is returned and * errbuf is filled in with an appropriate error message. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetNonBlock(Pcap pcap, int nonblock, StringBuilder errbuf) throws PcapCloseException; /** * Get the "non-blocking" state of an interface. * @param pcap pcap instance. * @param errbuf error buffer. * @return PcapGetNonBlock() returns the current non-blocking state of the * capture descriptor; it always returns 0 on savefiles. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapGetNonBlock(Pcap pcap, StringBuilder errbuf) throws PcapCloseException; /** * Create a pcap instance without starting a capture. * @param linktype link type. * @param snaplen snapshot length. * @return null on error. * @since 1.1.4 */ public static native Pcap PcapOpenDead(int linktype, int snaplen); /** * Return the file position for a savefile. * @param pcapDumper pcap dumper object. * @return file position for a savefile. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native long PcapDumpFTell(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Free a filter. * @param bpfProgram compiled bpf. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native void PcapFreeCode(BpfProgram bpfProgram) throws BpfProgramCloseException; /** * Return statistics on current capture. * @param pcap pcap instance. * @param pcapStat pcap stat object. * @return PcapStats() returns 0 on success and returns -1 if there is an error * or if pcap handle doesn't support packet statistics. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapStats(Pcap pcap, PcapStat pcapStat) throws PcapCloseException; /** * Compile a packet filter without the need of opening an adapter. * This function converts an high level filtering expression (see Filtering expression syntax) * in a program that can be interpreted by the kernel-level filtering engine. * @param snaplenArg snapshot length. * @param linktypeArg link type. * @param program bpf. * @param buf str. * @param optimize optiomize (0/1). * @param mask netmask. * @return -1 on error. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native int PcapCompileNoPcap(int snaplenArg, int linktypeArg, BpfProgram program, String buf, int optimize, int mask) throws BpfProgramCloseException; /** * Print the text of the last pcap library error on stderr, prefixed by prefix. * @param pcap pcap instance. * @param prefix prefix. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapPError(Pcap pcap, String prefix) throws PcapCloseException; /** * Is used to create a packet capture handle to look at packets on the network. * Source is a string that specifies the network device to open; * on Linux systems with 2.2 or later kernels, a source argument of "any" or NULL * can be used to capture packets from all interfaces. * *

The returned handle must be activated with PcapActivate() before packets can be captured with it; * options for the capture, such as promiscuous mode, can be set on the handle before activating it.

* @param source network device. * @param errbuf errof buffer. * @return returns a pcap instance on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapCreate(String source, StringBuilder errbuf); /** * Sets the snapshot length to be used on a capture handle when the handle is activated to snaplen. * @param pcap pcap instance. * @param snaplen snaplen. * @return returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetSnaplen(Pcap pcap, int snaplen) throws PcapCloseException; /** * sets whether promiscuous mode should be set on a capture handle when the handle is activated. * If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param promisc promisc. * @return pcapSetPromisc() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetPromisc(Pcap pcap, int promisc) throws PcapCloseException; /** * Sets the packet buffer timeout that will be used on a capture handle when the handle is activated to to_ms, * which is in units of milliseconds. * @param pcap pcap instance. * @param timeout timeout. * @return PcapSetTimeout() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetTimeout(Pcap pcap, int timeout) throws PcapCloseException; /** * Sets the buffer size that will be used on a capture handle when the handle is activated to buffer_size, which is in units of bytes. * @param pcap pcap instance. * @param bufferSize buffer size. * @return PcapSetBufferSize() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetBufferSize(Pcap pcap, int bufferSize) throws PcapCloseException; /** * Checks whether monitor mode could be set on a capture handle when the handle is activated. * @param pcap pcap instance. * @return PcapCanSetRfMon() returns 0 if monitor mode could not be set, 1 if * monitor mode could be set, and a negative value on error. A negative * return value indicates what error condition occurred. The possible * error values are: * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported. * PCAP_ERROR_ACTIVATED(-4): The capture handle has already been activated. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException; /** * Sets whether monitor mode should be set on a capture handle when the handle is activated. * If rfmon is non-zero, monitor mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param rfmon 1 (true) or 0 (false). * @return PcapSetRfMon() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called * on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException; /** * Sets whether immediate mode should be set on a capture handle when the handle is activated. If immediate_mode is non-zero, * immediate mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param immediateMode immediate_mode. * @return PcapSetImmediateMode() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) * if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetImmediateMode(Pcap pcap, int immediateMode) throws PcapCloseException, PlatformNotSupportedException; /** * Is used to activate a packet capture handle to look at packets on the network, * with the options that were set on the handle being in effect. * @param pcap pcap instance. * @return 0 on success without warnings, a non-zero positive value on success with warnings, and a negative value on error. * A non-zero return value indicates what warning or error condition occurred. * The possible warning values are: * PCAP_WARNING_PROMISC_NOTSUP(2): Promiscuous mode was requested, but the capture source doesn't support promiscuous mode. * PCAP_WARNING_TSTAMP_TYPE_NOTSUP(3): The time stamp type specified in a previous PcapSetTStampType() call isn't supported * by the capture source (the time stamp type is left as the default). * PCAP_WARNING(1): Generic waring. * The possible error values are: * PCAP_ERROR_ACTIVATED(-4): The handle has already been activated. * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn't exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to open the capture source. * PCAP_ERROR_PROMISC_PERM_DENIED(-11): The process has permission to open the capture source but doesn't have * spermission to put it into promiscuous mode. * PCAP_ERROR_RFMON_NOTSUP(-6): Monitor mode was specified but the capture source doesn't support monitor mode. * PCAP_ERROR_IFACE_NOT_UP(-9): The capture source device is not up. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapActivate(Pcap pcap) throws PcapCloseException; /** * used to specify a direction that packets will be * captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or * PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the * device, PCAP_D_OUT will only capture packets sent by the device and * PCAP_D_INOUT will capture packets received by or sent by the device. * PCAP_D_INOUT is the default setting if this function is not called. * *

PcapSetdirection() isn't necessarily fully supported on all platforms; * some platforms might return an error for all values, and some other * platforms might not support PCAP_D_OUT.

* *

This operation is not supported if a savefile is being read.

* @param pcap pcap instance. * @param direction direction. * @return returns 0 on success and -1 on failure (not supported by operating system). * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp precision returned in captures. * @param pcap pcap. * @param tstampPrecision time stamp precision. * @return 0 on success if specified time stamp precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampPrecision(Pcap pcap, int tstampPrecision) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp type returned in captures. * @param pcap pcap. * @param type time stamp type. * @return 0 on success if specified time type precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampType(Pcap pcap, int type) throws PcapCloseException, PlatformNotSupportedException; /** * Get the time stamp precision returned in captures. * @param pcap pcap instance. * @return the precision of the time stamp returned in packet captures on the pcap descriptor. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapGetTStampPrecision(Pcap pcap) throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. * @param pcap pcap instance. * @param dtlBuffer datalinks. * @return list of datalinks. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListDataLinks(Pcap pcap, List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; /** * Get link of time stamp types. * @param pcap pcap instance. * @param tstampTypesp time stamp types. * @return time stamp types. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListTStampTypes(Pcap pcap, List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Translates a time stamp type name to the corresponding time stamp type value. The translation is case-insensitive. * @param name time stamp name. * @return returns time stamp type value on success and PCAP_ERROR on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapTStampTypeNameToVal(String name) throws PlatformNotSupportedException; /** * Translates a time stamp type value to the corresponding time stamp type name. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToName(int tstampType) throws PlatformNotSupportedException; /** * Translates a time stamp type value to a short description of that time stamp type. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToDescription(int tstampType) throws PlatformNotSupportedException; /** * Converts a status code value returned by a libpcap routine to an error string. * @param errnum statuc code number. * @return status string. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapStatusToStr(int errnum) throws PlatformNotSupportedException; /** * Used for creating a Pcap instance to use when calling the other functions. * It is typically used when just using for compiling BPF code; * it can also be used if using pcap_dump_open(), pcap_dump(), * and PcapDumpClose() to write a savefile if there is no Pcap that * supplies the packets to be written. * @param linktype specifies the link-layer type * @param snaplen specifies the snapshot length. * @param precision specifies the time stamp precision. * @return null on fail. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenDeadWithTStampPrecision(int linktype, int snaplen, int precision) throws PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw * data for the packet, check whether the packet passes the filter. * Returns the return value of the filter program, which will be zero if * the packet doesn't pass and non-zero if the packet does pass. * @param fp bpfProgram * @param h pktHdr * @param pkt buffer. * @return 0 on success. */ public static native int PcapOfflineFilter(BpfProgram fp, PcapPktHdr h, ByteBuffer pkt); /** * Called to open a savefile for reading pcap file. * @param fname specifies the file name. * @param tstampPrecision specifies the time stamp precision. * @param errbuf specifies errror buffer. * @return pcap instance. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenOfflineWithTStampPrecision(String fname, int tstampPrecision, StringBuilder errbuf) throws PlatformNotSupportedException; /** * Sends a raw packet through the network interface; buf points to the data of the packet, * including the link-layer header, and size is the number of bytes in the packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size packet size. * @return PcapInject returns the number of bytes written on success and -1 on failure. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapInject(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException, PlatformNotSupportedException; /** * Check if pcap handle is alredy activated or no. * @param pcap pcap instance. * @return returns 0 if pcap handle not active yet. */ public static native int PcapCheckActivated(Pcap pcap); /* static { if (!Application.getInstance().isLoaded()) { Application.run("", "", Initializer.class); } } static final class Initializer implements ApplicationInitializer { @Override public void initialize(Application.Context context) { context.addLibrary(new DynamicLibrary()); context.addLibrary(new StaticLibrary()); } } */ public static void main(String[] args) { LOGGER.info(Arrays.toString(args)); } } \ No newline at end of file diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/CoreTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/CoreTest.java deleted file mode 100644 index 909e36af..00000000 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/CoreTest.java +++ /dev/null @@ -1,327 +0,0 @@ -/** - * Copyright (C) 2017-2018 Ardika Rommy Sanjaya - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -import static com.ardikars.jxnet.Core.LookupNetworkInterface; -import static com.ardikars.jxnet.Jxnet.OK; -import static com.ardikars.jxnet.Jxnet.PcapActivate; -import static com.ardikars.jxnet.Jxnet.PcapCheckActivated; -import static com.ardikars.jxnet.Jxnet.PcapClose; -import static com.ardikars.jxnet.Jxnet.PcapCompile; -import static com.ardikars.jxnet.Jxnet.PcapCompileNoPcap; -import static com.ardikars.jxnet.Jxnet.PcapCreate; -import static com.ardikars.jxnet.Jxnet.PcapDataLink; -import static com.ardikars.jxnet.Jxnet.PcapDumpClose; -import static com.ardikars.jxnet.Jxnet.PcapDumpOpen; -import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs; -import static com.ardikars.jxnet.Jxnet.PcapFreeCode; -import static com.ardikars.jxnet.Jxnet.PcapGetTStampPrecision; -import static com.ardikars.jxnet.Jxnet.PcapLoop; -import static com.ardikars.jxnet.Jxnet.PcapOpenDead; -import static com.ardikars.jxnet.Jxnet.PcapOpenLive; -import static com.ardikars.jxnet.Jxnet.PcapSetDataLink; -import static com.ardikars.jxnet.Jxnet.PcapSetFilter; -import static com.ardikars.jxnet.Jxnet.PcapSetImmediateMode; -import static com.ardikars.jxnet.Jxnet.PcapSetPromisc; -import static com.ardikars.jxnet.Jxnet.PcapSetSnaplen; -import static com.ardikars.jxnet.Jxnet.PcapSetTStampType; -import static com.ardikars.jxnet.Jxnet.PcapSetTimeout; -import static com.ardikars.jxnet.Jxnet.PcapStrError; - -import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.util.Platforms; -import com.ardikars.jxnet.exception.DeviceNotFoundException; -import com.ardikars.jxnet.exception.NativeException; - -import java.io.File; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.junit.runners.MethodSorters; - -@RunWith(JUnit4.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class CoreTest { - - private final Logger logger = Logger.getLogger(JxnetTest.class.getName()); - - private int resultCode; - - private final String resourceDumpFile = "/tmp/dump.pcap"; - - private StringBuilder errbuf = new StringBuilder(); - private Pcap pcap; - private PcapDumper dumper; - private BpfProgram bpfProgram; - private ByteBuffer pkt; - private PcapPktHdr pktHdr = new PcapPktHdr(); - - private PcapIf source; - private final int snaplen = 65335; - private final PromiscuousMode promisc = PromiscuousMode.PRIMISCUOUS; - private final int timeout = 2000; - private final ImmediateMode immediate = ImmediateMode.IMMEDIATE; - private final RadioFrequencyMonitorMode rfMon = RadioFrequencyMonitorMode.RFMON; - private final BpfProgram.BpfCompileMode optimize = BpfProgram.BpfCompileMode.OPTIMIZE; - private final int bufferSize = 1500; - private final String filter = "tcp"; - - private final PcapDirection direction = PcapDirection.PCAP_D_IN; - - private final int maxPkt = 5; - private static int cntPkt = 0; - - private List alldevsp = new ArrayList(); - - private Inet4Address netp = Inet4Address.valueOf(0); - private Inet4Address maskp = Inet4Address.valueOf("255.255.255.0"); - - private final PcapHandler callback = new PcapHandler() { - @Override - public void nextPacket(String user, PcapPktHdr h, ByteBuffer bytes) { - System.out.println("Argument : " + user); - System.out.println("PacketHeader: " + h); - System.out.println("PacketBuffer: " + bytes); - } - }; - - /** - * Initialize - * @throws Exception Exception. - */ - @Before - public void create() throws Exception { - StringBuilder errbuf = new StringBuilder(); - Pcap.Builder pcapBuilder = Pcap.builder() - .source(LoaderTest.getDevice()) - .immediateMode(ImmediateMode.IMMEDIATE) - .errbuf(errbuf); - BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() - .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) - .filter("tcp") - .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); - Application.run("CoreTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, bpfProgramBuilder, ""); - if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { - logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); - } - if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { - logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); - } - for (PcapIf dev : alldevsp) { - for (PcapAddr addr : dev.getAddresses()) { - if (addr.getAddr().getSaFamily() == SockAddr.Family.AF_INET) { - if (addr.getAddr().getData() != null) { - Inet4Address d = Inet4Address.valueOf(addr.getAddr().getData()); - if (!d.equals(Inet4Address.LOCALHOST) && !d.equals(Inet4Address.ZERO)) { - source = dev; - } - } - } - } - } - if (source == null) { - throw new Exception("Failed to lookup device"); - } else { - System.out.println("Source: " + source); - } - pcap = PcapCreate(source.getName(), errbuf); - if (pcap == null) { - logger.warning("create:PcapCreate(): " + errbuf.toString()); - return; - } - if ((resultCode = PcapSetSnaplen(pcap, snaplen)) != OK) { - logger.warning("create:PcapSetSnaplen(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - if ((resultCode = PcapSetPromisc(pcap, promisc.getValue())) != OK) { - logger.warning("create:PcapSetPromisc(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - if ((resultCode = PcapSetTimeout(pcap, timeout)) != OK) { - logger.warning("create:PcapSetTimeout(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - if (!Platforms.isWindows()) { - if ((resultCode = PcapSetImmediateMode(pcap, immediate.getValue())) != OK) { - logger.warning("create:PcapSetImmediateMode(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - } - if ((resultCode = PcapCheckActivated(pcap)) == 0) { - if ((resultCode = PcapActivate(pcap)) != OK) { - logger.warning("create:PcapActivate(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - } - - bpfProgram = new BpfProgram(); - - File file = File.createTempFile("dump", ".pcap"); - if (!file.delete()) { - logger.warning("create:File.delete()"); - return; - } - dumper = PcapDumpOpen(pcap, file.getAbsolutePath()); - if (dumper == null) { - logger.warning("create:PcapDumpOpen() "); - return; - } - } - - @Test - public void Test01_PcapOpenLiveAndPcapClose() { - Pcap pcap = PcapOpenLive(source.getName(), snaplen, promisc.getValue(), timeout, errbuf); - if (pcap == null) { - logger.warning("PcapOpenLiveAndPcapClose:PcapOpenLive(): " + errbuf.toString()); - } else { - PcapClose(pcap); - } - } - - @Test - public void Test02_PcapCompileAndPcapSetFilter() { - if ((resultCode = PcapCompile(pcap, bpfProgram, filter, optimize.getValue(), maskp.toInt())) != OK) { - logger.warning("PcapCompilePcapSetFilterAndPcapLoop:PcapCompile(): " + PcapStrError(resultCode)); - return; - } - if ((resultCode = PcapSetFilter(pcap, bpfProgram)) != OK) { - logger.warning("PcapCompilePcapSetFilterAndPcapLoop:PcapSetFilter(): " + PcapStrError(resultCode)); - return; - } - if ((resultCode = PcapLoop(pcap, maxPkt, callback, "This Is User Argument")) != OK) { - logger.warning("PcapCompilePcapSetFilterAndPcapLoop:PcapLoop(): " + PcapStrError(resultCode)); - return; - } - } - - @Test - public void Test03_PcapCompileNoPcapSetFilterAndPcapLoop() { - if ((resultCode = PcapCompileNoPcap(snaplen, DataLinkType.EN10MB.getValue(), - bpfProgram, filter, optimize.getValue(), maskp.toInt())) != OK) { - logger.warning("PcapCompileNoPcapSetFilterAndPcapLoop:PcapCompileNoPcap(): " + errbuf.toString()); - return; - } - if ((resultCode = PcapSetFilter(pcap, bpfProgram)) != OK) { - logger.warning("PcapCompileNoPcapSetFilterAndPcapLoop:PcapSetFilter(): " + PcapStrError(resultCode)); - return; - } - if ((resultCode = PcapLoop(pcap, maxPkt, callback, "This Is User Argument")) != OK) { - logger.warning("PcapCompileNoPcapSetFilterAndPcapLoop:PcapLoop(): " + PcapStrError(resultCode)); - return; - } - } - - @Test - public void Test04_PcapSetDataLinkPcapDataLinkPcapOpenDeadAndPcapClose() { - Pcap pcap = PcapOpenDead(DataLinkType.EN10MB.getValue(), snaplen); - if (pcap == null) { - logger.warning("PcapSetDataLinkPcapDataLinkPcapOpenDeadAndPcapClose:PcapOpenDead()"); - return; - } - DataLinkType dataLinkType = DataLinkType.valueOf((short) PcapDataLink(pcap)); - System.out.println("Data Link Type (Before): " + dataLinkType); - try { - if ((resultCode = PcapSetDataLink(pcap, DataLinkType.LINUX_SLL.getValue())) != OK) { - logger.warning("PcapSetDataLinkPcapDataLinkPcapOpenDeadAndPcapClose:PcapSetDataLink(): " + PcapStrError(resultCode)); - PcapClose(pcap); - return; - } - } catch (NativeException e) { - logger.warning(e.getMessage()); - } - dataLinkType = DataLinkType.valueOf((short) PcapDataLink(pcap)); - System.out.println("Data Link Type (After): " + dataLinkType); - PcapClose(pcap); - } - - @Test - public void Test05_LookupNetworkInterface() { - try { - PcapIf networkInterface = LookupNetworkInterface(); - System.out.println(networkInterface); - } catch (NativeException e) { - logger.warning(e.getLocalizedMessage()); - } catch (DeviceNotFoundException e) { - logger.warning(e.getMessage()); - } - } - - @Test - public void Test06_PcapGetTStampPrecisionAndPcapSetTStampPrecision() { - TimeStampPrecision timestamp = TimeStampPrecision.valueOf(PcapGetTStampPrecision(pcap)); - System.out.println("Time stamp precision (before): " + timestamp); - if ((resultCode = PcapSetTStampType(pcap, (timestamp == TimeStampPrecision.TIMESTAMP_MICRO) - ? 1 : 0)) != OK) { - logger.warning("Timestamp precision not supported by operation system."); - } - timestamp = TimeStampPrecision.valueOf(PcapGetTStampPrecision(pcap)); - System.out.println("Time stamp precision (after) : " + timestamp); - } - - @Test - public void Test07_PcapListDatalinks() { -// List datalinks = new ArrayList(); -// if ((resultCode = PcapListDataLinks0(pcap, datalinks)) < 0) { -// logger.warning("PcapListDataLinks:PcapListDataLinks(): " + PcapStrError(resultCode)); -// return; -// } -// System.out.print("DataLinks:"); -// for (DataLinkType datalink : datalinks) { -// System.out.print(" " + datalink); -// } -// PcapFreeDataLinks0(datalinks); - } - - @Test - public void Test08_PcapListTStampTypes() { -// List tsTypes = new ArrayList(); -// if ((resultCode = PcapListTStampTypes0(pcap, tsTypes)) < 0) { -// logger.warning("PcapListTStampTypes:PcapListTStampTypes(): " + PcapStrError(resultCode)); -// return; -// } -// System.out.print("Time Stamp Types:"); -// for (TimeStampType tsType : tsTypes) { -// System.out.print(" " + tsType); -// } -// PcapFreeTStampTypes0(tsTypes); - } - - /** - * Destroy method. - */ - @After - public void destroy() { - PcapClose(pcap); - PcapFreeCode(bpfProgram); - PcapDumpClose(dumper); - } - -} diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/SuiteTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/SuiteTest.java index 72279107..44a8c3e2 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/SuiteTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/SuiteTest.java @@ -24,7 +24,6 @@ @RunWith(Suite.class) @Suite.SuiteClasses({ JxnetTest.class, - CoreTest.class, FreakTest.class }) public class SuiteTest { diff --git a/suppression.xml b/suppression.xml new file mode 100644 index 00000000..76614b97 --- /dev/null +++ b/suppression.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file From 21d8e00d6920d06e6d1aa5aa5a78ea02d609504c Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 11:32:12 +0700 Subject: [PATCH 03/16] Replace throwing NPE with IAE --- checkstyle.xml | 253 ------------------ .../main/java/com/ardikars/jxnet/Pcap.java | 15 +- suppression.xml | 13 - 3 files changed, 6 insertions(+), 275 deletions(-) delete mode 100644 checkstyle.xml delete mode 100644 suppression.xml diff --git a/checkstyle.xml b/checkstyle.xml deleted file mode 100644 index d13b93a7..00000000 --- a/checkstyle.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index 82e01584..e8db64fd 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -18,7 +18,6 @@ package com.ardikars.jxnet; import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.util.Builder; import com.ardikars.common.util.Platforms; import com.ardikars.common.util.Validate; import com.ardikars.jxnet.exception.NativeException; @@ -237,11 +236,11 @@ public Builder pcapType(PcapType pcapType) { * @return pcap handle. */ private Pcap buildLive() { - Validate.nullPointer(source, new NullPointerException("Device name should be not null.")); + Validate.notIllegalArgument(source != null, new IllegalArgumentException("Device name should be not null.")); Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536, new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536.")); Validate.notIllegalArgument(timeout > 0, new IllegalArgumentException("Timeout should be greater then 0.")); - Validate.nullPointer(errbuf, new NullPointerException("Error buffer should be not null.")); + Validate.notIllegalArgument(errbuf != null, new IllegalArgumentException("Error buffer should be not null.")); Pcap pcap = Jxnet.PcapCreate(source, errbuf); if (Jxnet.PcapSetSnaplen(pcap, snaplen) != Jxnet.OK) { @@ -299,7 +298,7 @@ private Pcap buildLive() { * @return pcap handle. */ private Pcap buildDead() { - Validate.nullPointer(dataLinkType, new NullPointerException("Datalink type should be not null.")); + Validate.notIllegalArgument(dataLinkType != null, new IllegalArgumentException("Datalink type should be not null.")); Pcap pcap; if (Platforms.isWindows()) { pcap = Jxnet.PcapOpenDead(dataLinkType.getValue(), snaplen); @@ -317,8 +316,8 @@ private Pcap buildDead() { * @return pcap handle. */ private Pcap buildOffline() { - Validate.nullPointer(fileName, new NullPointerException("File name should be not null.")); - Validate.nullPointer(errbuf, new NullPointerException("Error buffer should be not null.")); + Validate.notIllegalArgument(fileName != null && !fileName.equals(""), new IllegalArgumentException("File name should be not null or empty.")); + Validate.notIllegalArgument(errbuf != null, new IllegalArgumentException("Error buffer should be not null.")); Pcap pcap; if (Platforms.isWindows()) { pcap = Jxnet.PcapOpenOffline(fileName, errbuf); @@ -333,9 +332,7 @@ private Pcap buildOffline() { @Override public Pcap build() { - if (pcapType == null) { - throw new IllegalStateException("Pcap type must be not null."); - } + Validate.notIllegalArgument(pcapType != null, new IllegalArgumentException("Pcap type should be not null.")); switch (pcapType) { case OFFLINE: return buildOffline(); diff --git a/suppression.xml b/suppression.xml deleted file mode 100644 index 76614b97..00000000 --- a/suppression.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file From e2f450023870436fe8cc25f14837ddcac6d2d5e8 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 11:42:56 +0700 Subject: [PATCH 04/16] Simplify code --- .../main/java/com/ardikars/jxnet/Pcap.java | 97 +++++++++++-------- 1 file changed, 58 insertions(+), 39 deletions(-) diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index e8db64fd..b2e381d7 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -236,11 +236,14 @@ public Builder pcapType(PcapType pcapType) { * @return pcap handle. */ private Pcap buildLive() { - Validate.notIllegalArgument(source != null, new IllegalArgumentException("Device name should be not null.")); + Validate.notIllegalArgument(source != null, + new IllegalArgumentException("Device name should be not null.")); Validate.notIllegalArgument(snaplen > 0 && snaplen < 65536, new IllegalArgumentException("Snaplen should be greater then 0 and less then 65536.")); - Validate.notIllegalArgument(timeout > 0, new IllegalArgumentException("Timeout should be greater then 0.")); - Validate.notIllegalArgument(errbuf != null, new IllegalArgumentException("Error buffer should be not null.")); + Validate.notIllegalArgument(timeout > 0, + new IllegalArgumentException("Timeout should be greater then 0.")); + Validate.notIllegalArgument(errbuf != null, + new IllegalArgumentException("Error buffer should be not null.")); Pcap pcap = Jxnet.PcapCreate(source, errbuf); if (Jxnet.PcapSetSnaplen(pcap, snaplen) != Jxnet.OK) { @@ -252,44 +255,15 @@ private Pcap buildLive() { if (Jxnet.PcapSetTimeout(pcap, timeout) != Jxnet.OK) { throw new NativeException(); } - if (!Platforms.isWindows()) { - if (Jxnet.PcapSetImmediateMode(pcap, immediateMode.getValue()) != Jxnet.OK) { - throw new NativeException(); - } - if (Jxnet.PcapSetTStampType(pcap, timeStampType.getValue()) != Jxnet.OK) { - throw new NativeException(); - } - if (Jxnet.PcapSetTStampPrecision(pcap, timeStampPrecision.getValue()) != Jxnet.OK) { - throw new NativeException(); - } - } - if (enableRfMon) { - if (Jxnet.PcapCanSetRfMon(pcap) == 1) { - int mode = RadioFrequencyMonitorMode.RFMON.getValue(); - if (Jxnet.PcapSetRfMon(pcap, mode) != Jxnet.OK) { - throw new NativeException(); - } - } - } else { - if (Jxnet.PcapSetRfMon(pcap, RadioFrequencyMonitorMode.NON_RFMON.getValue()) != Jxnet.OK) { - throw new NativeException(); - } - } + setImmediateModeAndTimeStamp(pcap); + setEnableRfMon(pcap); if (Jxnet.PcapActivate(pcap) != Jxnet.OK) { throw new NativeException(); } if (Jxnet.PcapSetDirection(pcap, direction) != Jxnet.OK) { throw new PlatformNotSupportedException(); } - if (enableNonBlock) { - if (Jxnet.PcapSetNonBlock(pcap, 1, errbuf) != Jxnet.OK) { - throw new NativeException(); - } - } else { - if (Jxnet.PcapSetNonBlock(pcap, 0, errbuf) != Jxnet.OK) { - throw new NativeException(); - } - } + setImmediateModeAndTimeStamp(pcap); return pcap; } @@ -298,7 +272,8 @@ private Pcap buildLive() { * @return pcap handle. */ private Pcap buildDead() { - Validate.notIllegalArgument(dataLinkType != null, new IllegalArgumentException("Datalink type should be not null.")); + Validate.notIllegalArgument(dataLinkType != null, + new IllegalArgumentException("Datalink type should be not null.")); Pcap pcap; if (Platforms.isWindows()) { pcap = Jxnet.PcapOpenDead(dataLinkType.getValue(), snaplen); @@ -316,8 +291,10 @@ private Pcap buildDead() { * @return pcap handle. */ private Pcap buildOffline() { - Validate.notIllegalArgument(fileName != null && !fileName.equals(""), new IllegalArgumentException("File name should be not null or empty.")); - Validate.notIllegalArgument(errbuf != null, new IllegalArgumentException("Error buffer should be not null.")); + Validate.notIllegalArgument(fileName != null && !fileName.equals(""), + new IllegalArgumentException("File name should be not null or empty.")); + Validate.notIllegalArgument(errbuf != null, + new IllegalArgumentException("Error buffer should be not null.")); Pcap pcap; if (Platforms.isWindows()) { pcap = Jxnet.PcapOpenOffline(fileName, errbuf); @@ -332,7 +309,8 @@ private Pcap buildOffline() { @Override public Pcap build() { - Validate.notIllegalArgument(pcapType != null, new IllegalArgumentException("Pcap type should be not null.")); + Validate.notIllegalArgument(pcapType != null, + new IllegalArgumentException("Pcap type should be not null.")); switch (pcapType) { case OFFLINE: return buildOffline(); @@ -348,6 +326,47 @@ public Pcap build(Void value) { throw new UnsupportedOperationException(); } + private void setImmediateModeAndTimeStamp(Pcap pcap) throws NativeException { + if (!Platforms.isWindows()) { + if (Jxnet.PcapSetImmediateMode(pcap, immediateMode.getValue()) != Jxnet.OK) { + throw new NativeException(); + } + if (Jxnet.PcapSetTStampType(pcap, timeStampType.getValue()) != Jxnet.OK) { + throw new NativeException(); + } + if (Jxnet.PcapSetTStampPrecision(pcap, timeStampPrecision.getValue()) != Jxnet.OK) { + throw new NativeException(); + } + } + } + + private void setEnableRfMon(Pcap pcap) throws NativeException { + if (enableRfMon) { + if (Jxnet.PcapCanSetRfMon(pcap) == 1) { + int mode = RadioFrequencyMonitorMode.RFMON.getValue(); + if (Jxnet.PcapSetRfMon(pcap, mode) != Jxnet.OK) { + throw new NativeException(); + } + } + } else { + if (Jxnet.PcapSetRfMon(pcap, RadioFrequencyMonitorMode.NON_RFMON.getValue()) != Jxnet.OK) { + throw new NativeException(); + } + } + } + + private void setEnableNonBlock(Pcap pcap) throws NativeException { + if (enableNonBlock) { + if (Jxnet.PcapSetNonBlock(pcap, 1, errbuf) != Jxnet.OK) { + throw new NativeException(); + } + } else { + if (Jxnet.PcapSetNonBlock(pcap, 0, errbuf) != Jxnet.OK) { + throw new NativeException(); + } + } + } + } } From 96e7e39bb2bacb44ae67e5bb5f9e49abcc27ab72 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 11:51:39 +0700 Subject: [PATCH 05/16] Add static method --- .../src/main/java/com/ardikars/jxnet/PcapAddr.java | 11 +++++++++++ .../src/main/java/com/ardikars/jxnet/PcapIf.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java index d6f4af09..17506783 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java @@ -17,6 +17,8 @@ package com.ardikars.jxnet; +import com.ardikars.jxnet.exception.OperationNotSupportedException; + /** * Representation of an interface address, used by Jxnet.PcapFindAllDevs(). * @author Ardika Rommy Sanjaya @@ -36,6 +38,15 @@ private PcapAddr() { // } + /** + * This method will throws {@code OperationNotSupportedException}. + * @see {@code Jxnet.PcapFinaAllDevs}. + * @return nothing. + */ + public static PcapAddr newInstance() { + throw new OperationNotSupportedException("Cannot instantiated directly, please use Jxnet.PcapFindAllDev()."); + } + /** * Getting interface address. * @return returns interface address. diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java index ae35e7d4..4db9b086 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java @@ -17,6 +17,8 @@ package com.ardikars.jxnet; +import com.ardikars.jxnet.exception.OperationNotSupportedException; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -55,6 +57,15 @@ private PcapIf() { // } + /** + * This method will throws {@code OperationNotSupportedException}. + * @see {@code Jxnet.PcapFinaAllDevs}. + * @return nothing. + */ + public static PcapIf newInstance() { + throw new OperationNotSupportedException("Cannot instantiated directly, please use Jxnet.PcapFindAllDev()."); + } + /** * Getting interface name. * @return returns interface name. From ca973ecba80297badd69b6d1e7e5f3811ec3ad1c Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 12:06:34 +0700 Subject: [PATCH 06/16] Fix javadoc and add builder to PcapDumper --- .../java/com/ardikars/jxnet/PcapAddr.java | 2 +- .../java/com/ardikars/jxnet/PcapDumper.java | 43 +++++++++++++++++++ .../main/java/com/ardikars/jxnet/PcapIf.java | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java index 17506783..2f7777cc 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java @@ -40,7 +40,7 @@ private PcapAddr() { /** * This method will throws {@code OperationNotSupportedException}. - * @see {@code Jxnet.PcapFinaAllDevs}. + * See {@code Jxnet.PcapFinaAllDevs}. * @return nothing. */ public static PcapAddr newInstance() { diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapDumper.java b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapDumper.java index d0cb1486..71b7d56b 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapDumper.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapDumper.java @@ -17,6 +17,8 @@ package com.ardikars.jxnet; +import com.ardikars.common.util.Validate; + /** * Savefile descriptor. * @author Ardika Rommy Sanjaya @@ -80,4 +82,45 @@ public String toString() { .toString(); } + public static final class Builder implements com.ardikars.common.util.Builder { + + private Pcap pcap; + private String fileName; + + /** + * Pcap handle. + * @param pcap pcap handle. + * @return resturns PcapDumper builder. + */ + public Builder pcap(Pcap pcap) { + this.pcap = pcap; + return this; + } + + /** + * File name. + * @param fileName file name. + * @return resturns PcapDumper builder. + */ + public Builder fileName(String fileName) { + this.fileName = fileName; + return this; + } + + @Override + public PcapDumper build() { + Validate.notIllegalArgument(pcap != null, + new IllegalArgumentException("Pcap should be not null.")); + Validate.notIllegalArgument(fileName != null && fileName.equals(""), + new IllegalArgumentException("File name should be not null or empty.")); + return Jxnet.PcapDumpOpen(pcap, fileName); + } + + @Override + public PcapDumper build(Void value) { + throw new UnsupportedOperationException(); + } + + } + } diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java index 4db9b086..909452a7 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/PcapIf.java @@ -59,7 +59,7 @@ private PcapIf() { /** * This method will throws {@code OperationNotSupportedException}. - * @see {@code Jxnet.PcapFinaAllDevs}. + * See {@code Jxnet.PcapFinaAllDevs}. * @return nothing. */ public static PcapIf newInstance() { From 1e2a7a98dd8d61de3de1b8239b35befad5731604 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 15:06:40 +0700 Subject: [PATCH 07/16] Jacoco test --- .circleci/config.yml | 11 ++-- build.gradle | 36 ++++++------- gradle/configure.gradle | 1 + gradle/resources/pcap/icmp.pcap | Bin 0 -> 744 bytes .../src/test/java/com/ardikars/jxnet/App.java | 47 ---------------- .../com/ardikars/jxnet/ApplicationTest.java | 51 ++++++++++++++++++ .../main/java/com/ardikars/jxnet/Pcap.java | 2 +- .../java/com/ardikars/jxnet/JxnetTest.java | 2 +- .../test/java/com/ardikars/jxnet/Tests.java | 16 +----- jxnet-core/src/test/resources/dump.pcap | Bin 608 -> 0 bytes 10 files changed, 80 insertions(+), 86 deletions(-) create mode 100644 gradle/resources/pcap/icmp.pcap delete mode 100644 jxnet-context/src/test/java/com/ardikars/jxnet/App.java create mode 100644 jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java delete mode 100644 jxnet-core/src/test/resources/dump.pcap diff --git a/.circleci/config.yml b/.circleci/config.yml index 76dd54c4..2018670a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,9 +17,12 @@ jobs: - gradle - checkout - run: 'export TERM=xterm-color' - - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev -y' - #- run: 'ping -c 10000 google.com &' - - run: 'sudo ./gradlew clean build -x test --info --no-daemon' + - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev wget jq -y' + - run: 'wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)' + - run: 'sudo ./gradlew clean build jacocoTestReport --info --no-daemon' + - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r ./jxnet-context/build/reports/jacoco/test/jacocoTestReport.xml --partial' + - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r jxnet-core/build/reports/jacoco/test/jacocoTestReport.xml --partial' + - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar final' deploy: working_directory: ~/tmp/Jxnet @@ -54,4 +57,4 @@ workflows: filters: branches: only: - - v1 \ No newline at end of file + - v1 diff --git a/build.gradle b/build.gradle index 12b27cfe..81f041e1 100644 --- a/build.gradle +++ b/build.gradle @@ -128,10 +128,28 @@ subprojects { toolVersion "${PMD_VERION}" } + jacoco { + toolVersion = "${JACOCO_VERSION}" + } + + jacocoTestReport { + reports { + xml.enabled true + csv.enabled false + html.destination file("${buildDir}/jacocoHtml") + } + } + + test { testLogging { showStandardStreams = true } + jacoco { + append = false + destinationFile = file("$buildDir/jacoco/jacocoTest.exec") + classDumpDir = file("$buildDir/jacoco/classpathdumps") + } } task javadocJar(type: Jar) { @@ -218,24 +236,6 @@ subprojects { } -task codeCoverageReport(type: JacocoReport) { - executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec") - subprojects.each { subproject -> - if (!(subproject.name.equals("${rootProject.name}")) && !((subproject.name).equals("jxnet-native"))) { - sourceSets subproject.sourceSets.main - } - } - reports { - xml.enabled false - html.enabled true - csv.enabled false - } -} - -codeCoverageReport.dependsOn { - subprojects*.test -} - task ndkBuild(type: Exec) { commandLine "${NDK_HOME}/ndk-build", '-C', "${TOOLS_DIR}", "NDK_LIBS_OUT=${TOOLS_OUT}", "NDK_OUT=${TOOLS_OBJ}" diff --git a/gradle/configure.gradle b/gradle/configure.gradle index 7901fa64..ba34693f 100644 --- a/gradle/configure.gradle +++ b/gradle/configure.gradle @@ -28,6 +28,7 @@ ext { CHECKSTYLE_VERSION = '8.10.1' SPOTBUGS_VERSION = '3.1.5' PMD_VERION = '6.5.0' + JACOCO_VERSION = '0.8.2' pom_project = { diff --git a/gradle/resources/pcap/icmp.pcap b/gradle/resources/pcap/icmp.pcap new file mode 100644 index 0000000000000000000000000000000000000000..39181baaa6e38e4ae6fb244ce934c01427868da8 GIT binary patch literal 744 zcmca|c+)~A1{MYw`2U}Qff2|#l7BGp#~B_5FCZI)83Mu{hyT=;mWUH!oR( z*UeABZoY(YvmwzYU$~0b&7NR4=OWy!0W?{epqq~a-Mqz@5fOu!;rs#Y=3@vq8xU=> o{tdit_5-^)1L0 { - - - @Override - public Loader initialize(String arguments) { - return new DefaultLibraryLoader(); - } - } - - public static void main(String[] args) { - StringBuilder errbuf = new StringBuilder(); - Application.run("Test", "0.1", Initializer.class, - new Pcap.Builder().pcapType(Pcap.PcapType.LIVE) - .source("en0") - .immediateMode(ImmediateMode.IMMEDIATE) - .errbuf(errbuf), - new BpfProgram.Builder().bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) - .filter("tcp") - .netmask(Inet4Address.valueOf("255.255.255.0").toInt()), - "Yoo" - ); - Context context = Application.getApplicationContext(); - context.pcapLoop(-1, new PcapHandler() { - @Override - public void nextPacket(String user, PcapPktHdr h, ByteBuffer byteBuffer) { - byte[] buffer = new byte[byteBuffer.capacity()]; - byteBuffer.get(buffer, 0, buffer.length); - System.out.println("Header: " + h); - System.out.println("Buffer: \n" + Hexs.toPrettyHexDump(buffer)); - System.out.println(user); - } - }, "***********************"); - context.pcapClose(); - } -} diff --git a/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java b/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java new file mode 100644 index 00000000..6232a7fc --- /dev/null +++ b/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java @@ -0,0 +1,51 @@ +package com.ardikars.jxnet; + +import com.ardikars.common.net.Inet4Address; +import com.ardikars.common.util.Hexs; +import com.ardikars.common.util.Loader; +import com.ardikars.jxnet.util.DefaultLibraryLoader; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.nio.ByteBuffer; + +@RunWith(JUnit4.class) +public class ApplicationTest { + + static class Initializer implements ApplicationInitializer { + @Override + public Loader initialize(String arguments) { + return new DefaultLibraryLoader(); + } + } + + @Test + public void test() { + assert true; +// StringBuilder errbuf = new StringBuilder(); +// Application.run("Test", "0.1", Initializer.class, +// new Pcap.Builder().pcapType(Pcap.PcapType.LIVE) +// .source("en0") +// .immediateMode(ImmediateMode.IMMEDIATE) +// .errbuf(errbuf), +// new BpfProgram.Builder().bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) +// .filter("tcp") +// .netmask(Inet4Address.valueOf("255.255.255.0").toInt()), +// "Yoo" +// ); +// Context context = Application.getApplicationContext(); +// context.pcapLoop(5, new PcapHandler() { +// @Override +// public void nextPacket(String user, PcapPktHdr h, ByteBuffer byteBuffer) { +// byte[] buffer = new byte[byteBuffer.capacity()]; +// byteBuffer.get(buffer, 0, buffer.length); +// System.out.println("Header: " + h); +// System.out.println("Buffer: \n" + Hexs.toPrettyHexDump(buffer)); +// System.out.println(user); +// } +// }, "***********************"); +// context.pcapClose(); + } + +} diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index b2e381d7..cf30b18e 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -263,7 +263,7 @@ private Pcap buildLive() { if (Jxnet.PcapSetDirection(pcap, direction) != Jxnet.OK) { throw new PlatformNotSupportedException(); } - setImmediateModeAndTimeStamp(pcap); + setEnableNonBlock(pcap); return pcap; } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index bd16ae51..2827b1b2 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -104,7 +104,7 @@ public class JxnetTest { private int resultCode; - private final String resourceDumpFile = "/tmp/dump.pcap"; + private final String resourceDumpFile = "../gradle/resources/pcap/icmp.pcap"; private StringBuilder errbuf = new StringBuilder(); private Pcap pcap; diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java index 0da364f7..500b27ca 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java @@ -34,21 +34,7 @@ public class Tests { @Test public void ex() throws SocketException { - StringBuilder errbuf = new StringBuilder(); - Pcap.Builder pcapBuilder = Pcap.builder() - .source(LoaderTest.getDevice()) - .immediateMode(ImmediateMode.IMMEDIATE) - .pcapType(Pcap.PcapType.LIVE) - .errbuf(errbuf); - Application.run("JxnetTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, ""); - Context context = Application.getApplicationContext(); - context.pcapLoop(10, new PcapHandler() { - @Override - public void nextPacket(String user, PcapPktHdr h, ByteBuffer bytes) { - System.out.println(h); - } - }, null); - context.pcapClose(); + } } diff --git a/jxnet-core/src/test/resources/dump.pcap b/jxnet-core/src/test/resources/dump.pcap deleted file mode 100644 index 33e0adacc8ca0e00150deff04fee98343a188082..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 608 zcmca|c+)~A1{MYwF#pfMzzF0du8WMiCBVwy24sWqx%pMq*Zn4(-8Q3cA_s#j1B1nX zW(Nib!IX#tE40~xn6Y6BgDHc``TiqTK>Z*ifPgJMKR-Pul{q;-7bM0AGIfVED?=Di z4um1*LCgl5>hZoAWNPsVkcl9Z8BBrZnjCv^#Hz6YWCAu*5AZ-`xEWa1+?3`6*>XjW zl_3eJ7=$t09ujZ~XbYp61IPxD4i1JHr>!g@?gQDd45%9f1O$bIMMTBKB_yS!Wn|^# z6%>_}RaDi~H8i!fb#(Rg4GfKpO-#+qK{oCWVP(()>H%RCf3Yzzaxk#5Ffc*f0rD9{ z9%MU6XYMXGh6_MlAk4@RSO5PPQaB%ycXnW46s)rYseb?e|F7F~*>f1y)%N@92D>^2 zIeRE*DR_j01n3*;8S-*@_y>nrDHs`B>KU1uLa~9Bp{0QVFPE>QpOu1AadAq4RZ3=Y za(-EAkrGfe!b$^H q4bpXVcl85ma?U8q&&@2&)i*QNGte^zS#4pW;FFnGTEWZ3%LM>!tF4~^ From 974404590552b56cc9db4a67795b66fc2fd3ebb7 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 19:57:49 +0700 Subject: [PATCH 08/16] Close pcap handle --- jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java | 2 ++ jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java | 1 + jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java | 4 +++- jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java index fded12c7..9451d471 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java @@ -60,12 +60,14 @@ public void create() { Pcap.Builder pcapBuilder = Pcap.builder() .source(LoaderTest.getDevice()) .immediateMode(ImmediateMode.IMMEDIATE) + .pcapType(Pcap.PcapType.LIVE) .errbuf(errbuf); BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) .filter("tcp") .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); Application.run("FreadTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, bpfProgramBuilder, ""); + Application.getApplicationContext().pcapClose(); pcap = PcapOpenDead(linkType.getValue(), snaplen); if (pcap == null) { logger.warning("create:PcapOpenDead(): "); diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index 2827b1b2..92bd7856 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -156,6 +156,7 @@ public void create() throws Exception { .filter("tcp") .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); Application.run("JxnetTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, bpfProgramBuilder, ""); + Application.getApplicationContext().pcapClose(); if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java index 2684b720..d98e0dda 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java @@ -30,12 +30,14 @@ public void test01LoadLibrary() throws SocketException { Pcap.Builder pcapBuilder = Pcap.builder() .source(getDevice()) .immediateMode(ImmediateMode.IMMEDIATE) - .errbuf(errbuf); + .errbuf(errbuf) + .pcapType(Pcap.PcapType.LIVE); BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) .filter("tcp") .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); Application.run("TestApp", "0.0.1", Initializer.class, pcapBuilder, bpfProgramBuilder, ""); + Application.getApplicationContext().pcapClose(); assert true; } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java index 500b27ca..00b04cd3 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java @@ -34,7 +34,7 @@ public class Tests { @Test public void ex() throws SocketException { - + assert true; } } From 5ceed6e692c3fd6fc08c769956076107bcc597ad Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 20:12:19 +0700 Subject: [PATCH 09/16] Ensures the handle is not null and address not zero --- .../main/java/com/ardikars/jxnet/ApplicationContext.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java index 8f90f3d1..bbd6fbde 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java @@ -216,7 +216,9 @@ public PcapCode pcapNextEx(PcapPktHdr pktHeader, ByteBuffer pktData) throws Pcap @Override public void pcapClose() throws PcapCloseException { - Jxnet.PcapClose(pcap); + if (pcap != null && !pcap.isClosed()) { + Jxnet.PcapClose(pcap); + } } @Override @@ -307,7 +309,9 @@ public long pcapDumpFTell() throws PcapDumperCloseException { @Override public void pcapFreeCode() throws BpfProgramCloseException { - Jxnet.PcapFreeCode(bpfProgram); + if (bpfProgram != null && !bpfProgram.isClosed()) { + Jxnet.PcapFreeCode(bpfProgram); + } } @Override From 1114f7ef82e63660e01067329736f9f9ec9a9043 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Sun, 26 Aug 2018 20:32:33 +0700 Subject: [PATCH 10/16] Pcap activate handle return code --- .appveyor/config.yml | 2 +- .circleci/config.yml | 10 ++--- build.gradle | 4 +- .../main/java/com/ardikars/jxnet/Pcap.java | 4 +- .../jxnet/util/DefaultLibraryLoader.java | 2 +- .../java/com/ardikars/jxnet/JxnetTest.java | 38 +++++++++++++++++-- .../java/com/ardikars/jxnet/LoaderTest.java | 16 +++++++- 7 files changed, 60 insertions(+), 16 deletions(-) diff --git a/.appveyor/config.yml b/.appveyor/config.yml index fc13a31d..822af113 100644 --- a/.appveyor/config.yml +++ b/.appveyor/config.yml @@ -41,7 +41,7 @@ install: build_script: - cmd: set PATH=C:\tools\mingw64\bin;C:\Program Files (x86)\NSIS\;%PATH% - - cmd: gradlew.bat clean build -x test --info --no-daemon + - cmd: gradlew.bat clean test --info --no-daemon #---------------------------------# # notifications # diff --git a/.circleci/config.yml b/.circleci/config.yml index 2018670a..c5c0b635 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,11 +18,11 @@ jobs: - checkout - run: 'export TERM=xterm-color' - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev wget jq -y' - - run: 'wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)' - - run: 'sudo ./gradlew clean build jacocoTestReport --info --no-daemon' - - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r ./jxnet-context/build/reports/jacoco/test/jacocoTestReport.xml --partial' - - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r jxnet-core/build/reports/jacoco/test/jacocoTestReport.xml --partial' - - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar final' +# - run: 'wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)' + - run: 'sudo ./gradlew clean build -x test --info --no-daemon' +# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r ./jxnet-context/build/reports/jacoco/test/jacocoTestReport.xml --partial' +# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r jxnet-core/build/reports/jacoco/test/jacocoTestReport.xml --partial' +# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar final' deploy: working_directory: ~/tmp/Jxnet diff --git a/build.gradle b/build.gradle index 81f041e1..dcc85e11 100644 --- a/build.gradle +++ b/build.gradle @@ -46,8 +46,8 @@ subprojects { } dependencies { - compile('com.ardikars.common:common-net:1.2.0.RC1') - compile 'com.ardikars.common:common-util:1.2.0.RC1' + compile('com.ardikars.common:common-net:1.2.0.RC2') + compile 'com.ardikars.common:common-util:1.2.0.RC2' } configurations.archives.artifacts.with { archives -> diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index cf30b18e..74467c4f 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -257,8 +257,8 @@ private Pcap buildLive() { } setImmediateModeAndTimeStamp(pcap); setEnableRfMon(pcap); - if (Jxnet.PcapActivate(pcap) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapActivate(pcap) < 0) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } if (Jxnet.PcapSetDirection(pcap, direction) != Jxnet.OK) { throw new PlatformNotSupportedException(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java b/jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java index 2963b1cb..6eea80ac 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java @@ -80,7 +80,7 @@ public void load(final Callback callback) { nativeLibrary.load(new Callback() { @Override public void onSuccess(Void value) { - callback.onSuccess(value); + callback.onSuccess(null); } @Override diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index 92bd7856..ed61035c 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -83,6 +83,9 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; @@ -384,7 +387,9 @@ public void Test11_PcapNextEx() { if (pktHdr != null && pkt != null) { System.out.println("PacketHeader: " + pktHdr); System.out.println("PacketBuffer: " + pkt); + pkt.clear(); } + } } @@ -700,9 +705,36 @@ public void Test35_PcapInject() { */ @After public void destroy() { - PcapClose(pcap); - PcapFreeCode(bpfProgram); - PcapDumpClose(dumper); + if (pcap != null && !pcap.isClosed()) { + PcapClose(pcap); + } + if (bpfProgram != null && !bpfProgram.isClosed()) { + PcapFreeCode(bpfProgram); + } + if (dumper != null && !dumper.isClosed()) { + PcapDumpClose(dumper); + } + } + + public static void destroyBuffer(Buffer buffer) { + if(buffer.isDirect()) { + try { + if(!buffer.getClass().getName().equals("java.nio.DirectByteBuffer")) { + Field attField = buffer.getClass().getDeclaredField("att"); + attField.setAccessible(true); + buffer = (Buffer) attField.get(buffer); + } + + Method cleanerMethod = buffer.getClass().getMethod("cleaner"); + cleanerMethod.setAccessible(true); + Object cleaner = cleanerMethod.invoke(buffer); + Method cleanMethod = cleaner.getClass().getMethod("clean"); + cleanMethod.setAccessible(true); + cleanMethod.invoke(cleaner); + } catch(Exception e) { + throw new IllegalStateException("Could not destroy direct buffer " + buffer, e); + } + } } } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java index d98e0dda..f1e76216 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java @@ -1,6 +1,8 @@ package com.ardikars.jxnet; import com.ardikars.common.net.Inet4Address; +import com.ardikars.common.net.InetAddress; +import com.ardikars.common.net.MacAddress; import com.ardikars.common.net.NetworkInterface; import com.ardikars.common.util.Loader; import com.ardikars.jxnet.util.DefaultLibraryLoader; @@ -49,8 +51,18 @@ public static String getDevice() { return null; } for (NetworkInterface networkInterface : networkInterfaces) { - if (networkInterface.getMtu() == 1500 && networkInterface.getHardwareAddress() != null && networkInterface.getAddresses().size() > 0) { - return networkInterface.getName(); + if (networkInterface.getHardwareAddress() != null && networkInterface.getHardwareAddress() instanceof MacAddress) { + MacAddress macAddress = (MacAddress) networkInterface.getHardwareAddress(); + if (!macAddress.equals(MacAddress.ZERO)) { + for (NetworkInterface.Address inetAddress : networkInterface.getAddresses()) { + if (inetAddress.getInetAddress() instanceof Inet4Address) { + Inet4Address inet4Address = (Inet4Address) inetAddress.getInetAddress(); + if (!inet4Address.equals(Inet4Address.LOCALHOST) && !inet4Address.equals(Inet4Address.ZERO)) { + return networkInterface.getName(); + } + } + } + } } } return null; From 282f4aea85cb16d34c87e60c409565e4908ea9b1 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Tue, 28 Aug 2018 19:30:51 +0700 Subject: [PATCH 11/16] Update application properties --- .../java/com/ardikars/jxnet/Application.java | 28 +++++++--- .../ardikars/jxnet/ApplicationContext.java | 56 +++++++++---------- .../java/com/ardikars/jxnet/FreakTest.java | 6 +- .../java/com/ardikars/jxnet/JxnetTest.java | 6 +- .../java/com/ardikars/jxnet/LoaderTest.java | 27 +++++---- .../test/java/com/ardikars/jxnet/Tests.java | 6 -- 6 files changed, 62 insertions(+), 67 deletions(-) diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java index f99dd0df..6010de1b 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java @@ -54,24 +54,32 @@ private Application() { /** * Used for bootstraping Jxnet. - * @param applicationName application name. - * @param applicationVersion application version. + * @param initializerClass initializer class. + * @param argements additional information. + * @throws UnsatisfiedLinkError UnsatisfiedLinkError. + */ + @SuppressWarnings("PMD.AvoidUsingNativeCode") + public static void run(Class initializerClass, + final Object argements) { + run(initializerClass, null, null, argements); + } + + /** + * Used for bootstraping Jxnet. * @param initializerClass initializer class. * @param pcapBuilder pcap builder. * @param argements additional information. * @throws UnsatisfiedLinkError UnsatisfiedLinkError. */ @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(final String applicationName, final String applicationVersion, Class initializerClass, + public static void run(Class initializerClass, final Pcap.Builder pcapBuilder, final Object argements) { - run(applicationName, applicationVersion, initializerClass, pcapBuilder, null, argements); + run(initializerClass, pcapBuilder, null, argements); } /** * Used for bootstraping Jxnet. - * @param applicationName application name. - * @param applicationVersion application version. * @param initializerClass initializer class. * @param pcapBuilder pcap builder. * @param bpfBuilder bpf builder. @@ -79,7 +87,7 @@ public static void run(final String applicationName, final String applicationVer * @throws UnsatisfiedLinkError UnsatisfiedLinkError. */ @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(final String applicationName, final String applicationVersion, Class initializerClass, + public static void run(Class initializerClass, final Pcap.Builder pcapBuilder, final BpfProgram.Builder bpfBuilder, final Object argements) { @@ -106,6 +114,7 @@ public static void run(final String applicationName, final String applicationVer } else { if (!instance.loaded && libraryLoaders != null) { libraryLoaders.load(new Callback() { + @Override public void onSuccess(Object value) { instance.loaded = true; @@ -113,10 +122,10 @@ public void onSuccess(Object value) { if (bpfBuilder != null) { BpfProgram bpfProgram = bpfBuilder.pcap(pcap).build(); instance.context = ApplicationContext - .newApplicationContext(applicationName, applicationVersion, argements, pcap, bpfProgram); + .newApplicationContext(pcap, bpfProgram, argements); } else { instance.context = ApplicationContext - .newApplicationContext(applicationName, applicationVersion, argements, pcap, null); + .newApplicationContext(pcap, null, argements); } } @@ -124,6 +133,7 @@ public void onSuccess(Object value) { public void onFailure(Throwable throwable) { LOGGER.warning(throwable.getMessage()); } + }); } } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java index bbd6fbde..40bf7fac 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java @@ -24,8 +24,11 @@ import com.ardikars.jxnet.exception.PcapDumperCloseException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; +import java.io.IOException; +import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; +import java.util.Properties; import java.util.logging.Logger; /** @@ -65,6 +68,18 @@ public void run() { LOGGER.info("Application closed gracefully."); } }); + final Properties properties = new Properties(); + try (InputStream stream = ClassLoader.class.getResourceAsStream("application.properties")) { + if (stream != null) { + properties.load(stream); + } + applicationName = properties.getProperty("jxnet.application.name", ""); + applicationVersion = properties.getProperty("jxnet.application.version", ""); + } catch (IOException e) { + applicationName = ""; + applicationVersion = ""; + LOGGER.warning(e.getMessage()); + } } @Override @@ -85,56 +100,35 @@ public Object getAdditionalInformation() { /** * Create application context. * @param pcap pcap. - * @param bpfProgram bpf program. * @return application context. */ - public static ApplicationContext newApplicationContext(Pcap pcap, BpfProgram bpfProgram) { - return newApplicationContext(null, null, pcap, bpfProgram); + public static ApplicationContext newApplicationContext(Pcap pcap) { + return newApplicationContext(pcap, null, null); } /** * Create application context. - * @param applicationName application name. - * @param applicationVersion application version. * @param pcap pcap. + * @param additionalInformation additional information. * @return application context. */ - public static ApplicationContext newApplicationContext(String applicationName, String applicationVersion, Pcap pcap) { - Validate.nullPointer(pcap); - return newApplicationContext(applicationName, applicationVersion, pcap, null); + public static ApplicationContext newApplicationContext(Pcap pcap, Object additionalInformation) { + return newApplicationContext(pcap, null, additionalInformation); } /** * Create application context. - * @param applicationName application name. - * @param applicationVersion application version. * @param pcap pcap. * @param bpfProgram bpf program. - * @return application context. - */ - public static ApplicationContext newApplicationContext(String applicationName, String applicationVersion, Pcap pcap, BpfProgram bpfProgram) { - Validate.nullPointer(pcap); - return newApplicationContext(applicationName, applicationVersion, null, pcap, bpfProgram); - } - - /** - * Create application context. - * @param applicationName application name. - * @param applicationVersion application version. * @param additionalInformation additional information. - * @param pcap pcap. - * @param bpfProgram bpf program. * @return application context. */ - public static ApplicationContext newApplicationContext(String applicationName, String applicationVersion, Object additionalInformation, - Pcap pcap, BpfProgram bpfProgram) { - Validate.nullPointer(pcap); + public static ApplicationContext newApplicationContext(Pcap pcap, BpfProgram bpfProgram, Object additionalInformation) { + Validate.notIllegalArgument(pcap != null); ApplicationContext applicationContext = new ApplicationContext(); - applicationContext.applicationName = applicationName; - applicationContext.applicationVersion = applicationVersion; - applicationContext.additionalInformation = additionalInformation; applicationContext.pcap = pcap; applicationContext.bpfProgram = bpfProgram; + applicationContext.additionalInformation = additionalInformation; return applicationContext; } @@ -247,7 +241,7 @@ public DataLinkType pcapDataLink() throws PcapCloseException { @Override public PcapCode pcapSetDataLink(DataLinkType dataLinkType) throws PcapCloseException { - Validate.nullPointer(dataLinkType); + Validate.notIllegalArgument(dataLinkType != null); int result = Jxnet.PcapSetDataLink(pcap, dataLinkType.getValue()); if (result == 0) { return PcapCode.PCAP_OK; @@ -353,7 +347,7 @@ public PcapCode pcapCanSetRfMon() throws PcapCloseException { @Override public PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException { - Validate.nullPointer(direction); + Validate.notIllegalArgument(direction != null); int result = Jxnet.PcapSetDirection(pcap, direction); if (result == 0) { return PcapCode.PCAP_OK; diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java index 9451d471..02e1057a 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java @@ -62,11 +62,7 @@ public void create() { .immediateMode(ImmediateMode.IMMEDIATE) .pcapType(Pcap.PcapType.LIVE) .errbuf(errbuf); - BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() - .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) - .filter("tcp") - .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); - Application.run("FreadTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, bpfProgramBuilder, ""); + Application.run(LoaderTest.Initializer.class, pcapBuilder, ""); Application.getApplicationContext().pcapClose(); pcap = PcapOpenDead(linkType.getValue(), snaplen); if (pcap == null) { diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index ed61035c..ecaea2fc 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -154,11 +154,7 @@ public void create() throws Exception { .immediateMode(ImmediateMode.IMMEDIATE) .pcapType(Pcap.PcapType.LIVE) .errbuf(errbuf); - BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() - .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) - .filter("tcp") - .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); - Application.run("JxnetTest", "0.0.1", LoaderTest.Initializer.class, pcapBuilder, bpfProgramBuilder, ""); + Application.run(LoaderTest.Initializer.class, pcapBuilder, ""); Application.getApplicationContext().pcapClose(); if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java index f1e76216..5baa28c7 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java @@ -1,7 +1,6 @@ package com.ardikars.jxnet; import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.net.InetAddress; import com.ardikars.common.net.MacAddress; import com.ardikars.common.net.NetworkInterface; import com.ardikars.common.util.Loader; @@ -12,34 +11,40 @@ import java.net.SocketException; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; @RunWith(JUnit4.class) public class LoaderTest { - public static class Initializer implements ApplicationInitializer { + public static final String KEY = "jxnet"; + public static final String VALUE = "ROCK!!!..."; + + public static class Initializer implements ApplicationInitializer> { @Override - public Loader initialize(String additionalInformation) { + public Loader initialize(Map additionalInformation) { + additionalInformation.put(KEY, VALUE); return new DefaultLibraryLoader(); } } @Test - public void test01LoadLibrary() throws SocketException { - + public void test01LoadLibrary() { + Map parameter = new HashMap<>(); StringBuilder errbuf = new StringBuilder(); Pcap.Builder pcapBuilder = Pcap.builder() .source(getDevice()) .immediateMode(ImmediateMode.IMMEDIATE) .errbuf(errbuf) .pcapType(Pcap.PcapType.LIVE); - BpfProgram.Builder bpfProgramBuilder = BpfProgram.builder() - .bpfCompileMode(BpfProgram.BpfCompileMode.OPTIMIZE) - .filter("tcp") - .netmask(Inet4Address.valueOf("255.255.255.0").toInt()); - Application.run("TestApp", "0.0.1", Initializer.class, pcapBuilder, bpfProgramBuilder, ""); - Application.getApplicationContext().pcapClose(); + Application.run(Initializer.class, pcapBuilder, parameter); + Context context = Application.getApplicationContext(); + if (context.getAdditionalInformation() instanceof Map) { + Map additionalInformation = (Map) context.getAdditionalInformation(); + assert additionalInformation.get(KEY).equals(VALUE); + } assert true; } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java index 00b04cd3..81c2b20b 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java @@ -17,17 +17,11 @@ package com.ardikars.jxnet; -import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.net.NetworkInterface; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.net.SocketException; -import java.nio.ByteBuffer; - -import static com.ardikars.jxnet.Jxnet.OK; -import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs; @RunWith(JUnit4.class) public class Tests { From 417c9c0469f9def9d2fe70d5fbe342fb1753a18b Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Wed, 29 Aug 2018 09:35:56 +0700 Subject: [PATCH 12/16] Remove additional information on application context --- .appveyor/config.yml | 4 +- .circleci/config.yml | 1 + .../java/com/ardikars/jxnet/Application.java | 55 +++----- .../ardikars/jxnet/ApplicationContext.java | 118 ++++++++++-------- .../main/java/com/ardikars/jxnet/Context.java | 24 ++-- .../java/com/ardikars/jxnet/BpfProgram.java | 9 +- .../java/com/ardikars/jxnet/FreakTest.java | 3 +- .../java/com/ardikars/jxnet/JxnetTest.java | 7 +- .../java/com/ardikars/jxnet/LoaderTest.java | 9 +- .../test/java/com/ardikars/jxnet/Tests.java | 4 + 10 files changed, 116 insertions(+), 118 deletions(-) diff --git a/.appveyor/config.yml b/.appveyor/config.yml index 822af113..3190e96d 100644 --- a/.appveyor/config.yml +++ b/.appveyor/config.yml @@ -41,8 +41,8 @@ install: build_script: - cmd: set PATH=C:\tools\mingw64\bin;C:\Program Files (x86)\NSIS\;%PATH% - - cmd: gradlew.bat clean test --info --no-daemon - +# - cmd: gradlew.bat clean build -x test --info --no-daemon + - cmd: gradlew.bat clean build jacocoTestReport --info --no-daemon #---------------------------------# # notifications # #---------------------------------# diff --git a/.circleci/config.yml b/.circleci/config.yml index c5c0b635..2a1253a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,7 @@ jobs: - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev wget jq -y' # - run: 'wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)' - run: 'sudo ./gradlew clean build -x test --info --no-daemon' +# - run: 'sudo ./gradlew clean build jacocoTestReport --info --no-daemon' # - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r ./jxnet-context/build/reports/jacoco/test/jacocoTestReport.xml --partial' # - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r jxnet-core/build/reports/jacoco/test/jacocoTestReport.xml --partial' # - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar final' diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java index 6010de1b..25e2d933 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java @@ -36,6 +36,7 @@ public final class Application { private static final Application instance = new Application(); private Context context; + private Object additionalInformation; public boolean isLoaded() { return this.loaded; @@ -52,50 +53,22 @@ private Application() { } - /** - * Used for bootstraping Jxnet. - * @param initializerClass initializer class. - * @param argements additional information. - * @throws UnsatisfiedLinkError UnsatisfiedLinkError. - */ - @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(Class initializerClass, - final Object argements) { - run(initializerClass, null, null, argements); - } - - /** - * Used for bootstraping Jxnet. - * @param initializerClass initializer class. - * @param pcapBuilder pcap builder. - * @param argements additional information. - * @throws UnsatisfiedLinkError UnsatisfiedLinkError. - */ - @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(Class initializerClass, - final Pcap.Builder pcapBuilder, - final Object argements) { - run(initializerClass, pcapBuilder, null, argements); - } - /** * Used for bootstraping Jxnet. * @param initializerClass initializer class. * @param pcapBuilder pcap builder. - * @param bpfBuilder bpf builder. * @param argements additional information. * @throws UnsatisfiedLinkError UnsatisfiedLinkError. */ @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(Class initializerClass, - final Pcap.Builder pcapBuilder, final BpfProgram.Builder bpfBuilder, - final Object argements) { + public static void run(Class initializerClass, final Pcap.Builder pcapBuilder, final Object argements) { ApplicationInitializer initializer; Loader libraryLoaders; try { initializer = (ApplicationInitializer) initializerClass.newInstance(); - libraryLoaders = initializer.initialize(argements); + instance.additionalInformation = argements; + libraryLoaders = initializer.initialize(instance.additionalInformation); } catch (InstantiationException e) { LOGGER.warning(e.getMessage()); return; @@ -118,16 +91,8 @@ public static void run(Class initializerClass, @Override public void onSuccess(Object value) { instance.loaded = true; - Pcap pcap = pcapBuilder.build(); - if (bpfBuilder != null) { - BpfProgram bpfProgram = bpfBuilder.pcap(pcap).build(); - instance.context = ApplicationContext - .newApplicationContext(pcap, bpfProgram, argements); - } else { - instance.context = ApplicationContext - .newApplicationContext(pcap, null, argements); - } - } + instance.context = new ApplicationContext(pcapBuilder); + } @Override public void onFailure(Throwable throwable) { @@ -147,4 +112,12 @@ public static Context getApplicationContext() { return instance.context; } + /** + * Get additional information. + * @return additional information. + */ + public static Object getAdditionalInformation() { + return instance.additionalInformation; + } + } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java index 40bf7fac..46fd5a50 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java @@ -18,6 +18,7 @@ package com.ardikars.jxnet; import com.ardikars.common.net.Inet4Address; +import com.ardikars.common.util.Builder; import com.ardikars.common.util.Validate; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.PcapCloseException; @@ -27,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.List; import java.util.Properties; import java.util.logging.Logger; @@ -43,15 +45,13 @@ public final class ApplicationContext implements Context { private String applicationVersion; - private Object additionalInformation; - - private Pcap pcap; + private final Pcap pcap; private BpfProgram bpfProgram; private PcapDumper pcapDumper; - private ApplicationContext() { + protected ApplicationContext(Builder builder) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { @@ -73,13 +73,15 @@ public void run() { if (stream != null) { properties.load(stream); } - applicationName = properties.getProperty("jxnet.application.name", ""); - applicationVersion = properties.getProperty("jxnet.application.version", ""); + this.applicationName = properties.getProperty("jxnet.application.name", ""); + this.applicationVersion = properties.getProperty("jxnet.application.version", ""); } catch (IOException e) { - applicationName = ""; - applicationVersion = ""; + this.applicationName = ""; + this.applicationVersion = ""; LOGGER.warning(e.getMessage()); } + Validate.notIllegalArgument(builder != null, new IllegalArgumentException("Pcap builder should be not null.")); + this.pcap = builder.build(); } @Override @@ -93,43 +95,8 @@ public String getApplicationVersion() { } @Override - public Object getAdditionalInformation() { - return additionalInformation; - } - - /** - * Create application context. - * @param pcap pcap. - * @return application context. - */ - public static ApplicationContext newApplicationContext(Pcap pcap) { - return newApplicationContext(pcap, null, null); - } - - /** - * Create application context. - * @param pcap pcap. - * @param additionalInformation additional information. - * @return application context. - */ - public static ApplicationContext newApplicationContext(Pcap pcap, Object additionalInformation) { - return newApplicationContext(pcap, null, additionalInformation); - } - - /** - * Create application context. - * @param pcap pcap. - * @param bpfProgram bpf program. - * @param additionalInformation additional information. - * @return application context. - */ - public static ApplicationContext newApplicationContext(Pcap pcap, BpfProgram bpfProgram, Object additionalInformation) { - Validate.notIllegalArgument(pcap != null); - ApplicationContext applicationContext = new ApplicationContext(); - applicationContext.pcap = pcap; - applicationContext.bpfProgram = bpfProgram; - applicationContext.additionalInformation = additionalInformation; - return applicationContext; + public Context newInstance(Builder builder) { + return new ApplicationContext(builder); } @Override @@ -168,8 +135,11 @@ public void pcapDump(PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseExceptio } @Override - public PcapCode pcapCompile(String str, int optimize, int netmask) throws PcapCloseException { - int result = Jxnet.PcapCompile(pcap, bpfProgram, str, optimize, netmask); + public PcapCode pcapCompile(String str, boolean optimize, int netmask) throws PcapCloseException, BpfProgramCloseException { + if (bpfProgram == null) { + bpfProgram = new BpfProgram(); + } + int result = Jxnet.PcapCompile(pcap, bpfProgram, str, optimize ? 1 : 0, netmask); if (result == 0) { return PcapCode.PCAP_OK; } @@ -177,7 +147,10 @@ public PcapCode pcapCompile(String str, int optimize, int netmask) throws PcapCl } @Override - public PcapCode pcapSetFilter() throws PcapCloseException { + public PcapCode pcapSetFilter() throws PcapCloseException, BpfProgramCloseException { + if (bpfProgram == null) { + bpfProgram = new BpfProgram(); + } int result = Jxnet.PcapSetFilter(pcap, bpfProgram); if (result == 0) { return PcapCode.PCAP_OK; @@ -320,6 +293,9 @@ public PcapCode pcapStats(PcapStat pcapStat) throws PcapCloseException { @Override public PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter, boolean optimize, Inet4Address mask) throws BpfProgramCloseException { + if (bpfProgram == null) { + bpfProgram = new BpfProgram(); + } int result = Jxnet.PcapCompileNoPcap(snaplen, dataLinkType.getValue(), bpfProgram, filter, optimize ? 1 : 0, mask.toInt()); if (result == 0) { return PcapCode.PCAP_OK; @@ -356,23 +332,54 @@ public PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseExcept } @Override - public int pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException { - return Jxnet.PcapGetTStampPrecision(pcap); + public PcapTimeStampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException { + if (Jxnet.PcapGetTStampPrecision(pcap) == 0) { + return PcapTimeStampPrecision.MICRO; + } + return PcapTimeStampPrecision.NANO; } @Override - public PcapCode pcapListDataLinks(List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException { - int result = Jxnet.PcapListDataLinks(pcap, dtlBuffer); + public PcapCode pcapListDataLinks(List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException { + List buffers = new ArrayList<>(); + int result = Jxnet.PcapListDataLinks(pcap, buffers); if (result == 0) { + dtlBuffer.clear(); // clear buffer. + for (Integer datalink : buffers) { + dtlBuffer.add(DataLinkType.valueOf(datalink.shortValue())); + } return PcapCode.PCAP_OK; } return PcapCode.PCAP_ERROR; } @Override - public PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException { - int result = Jxnet.PcapListTStampTypes(pcap, tstampTypesp); + public PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException { + List buffers = new ArrayList<>(); + int result = Jxnet.PcapListTStampTypes(pcap, buffers); if (result == 0) { + tstampTypesp.clear(); // clear buffer. + for (Integer tstampType : buffers) { + switch (tstampType) { + case 0: + tstampTypesp.add(PcapTimeStampType.HOST); + break; + case 1: + tstampTypesp.add(PcapTimeStampType.HOST_LOWPREC); + break; + case 2: + tstampTypesp.add(PcapTimeStampType.HOST_HIPREC); + break; + case 3: + tstampTypesp.add(PcapTimeStampType.ADAPTER); + break; + case 4: + tstampTypesp.add(PcapTimeStampType.ADAPTER_UNSYNCED); + break; + default: + // do nothing + } + } return PcapCode.PCAP_OK; } return PcapCode.PCAP_ERROR; @@ -380,7 +387,8 @@ public PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapClose @Override public PcapCode pcapOfflineFilter(BpfProgram fp, PcapPktHdr h, ByteBuffer pkt) { - int result = Jxnet.PcapOfflineFilter(bpfProgram, h, pkt); + Validate.notIllegalArgument(fp != null && !fp.isClosed(), new IllegalArgumentException("Bpf should be not null or closed.")); + int result = Jxnet.PcapOfflineFilter(fp, h, pkt); if (result == 0) { return PcapCode.PCAP_OK; } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java index d62712bd..b35b3723 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java @@ -18,6 +18,8 @@ package com.ardikars.jxnet; import com.ardikars.common.net.Inet4Address; +import com.ardikars.common.util.Builder; +import com.ardikars.common.util.Factory; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.PcapCloseException; import com.ardikars.jxnet.exception.PcapDumperCloseException; @@ -26,14 +28,12 @@ import java.nio.ByteBuffer; import java.util.List; -public interface Context { +public interface Context extends Factory> { String getApplicationName(); String getApplicationVersion(); - Object getAdditionalInformation(); - /** * Native function mapping */ @@ -106,17 +106,19 @@ public interface Context { * @param netmask netmask. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. + * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ - PcapCode pcapCompile(String str, int optimize, int netmask) throws PcapCloseException; + PcapCode pcapCompile(String str, boolean optimize, int netmask) throws PcapCloseException, BpfProgramCloseException; /** * Associate a filter to a capture. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. + * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ - PcapCode pcapSetFilter() throws PcapCloseException; + PcapCode pcapSetFilter() throws PcapCloseException, BpfProgramCloseException; /** * Send a raw packet. @@ -354,12 +356,12 @@ PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; /** - * Get the time stamp precision returned in captures. - * @return the precision of the time stamp returned in packet captures on the pcap descriptor. + * Get the timestamp precision returned in captures. + * @return the precision of the timestamp returned in packet captures on the pcap descriptor. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ - int pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException; + PcapTimeStampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. @@ -368,16 +370,16 @@ PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ - PcapCode pcapListDataLinks(List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; + PcapCode pcapListDataLinks(List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; /** * Get link of time stamp types. - * @param tstampTypesp time stamp types. + * @param tstampTypesp timestamp types. * @return time stamp types. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ - PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; + PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java b/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java index 68c106be..78f0d9f1 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java @@ -182,9 +182,12 @@ public Builder bpfCompileMode(final BpfCompileMode bpfCompileMode) { * @return returns BpfProgram. */ private BpfProgram buildBpf() { - Validate.nullPointer(pcap); - Validate.notIllegalArgument(!pcap.isClosed(), new IllegalArgumentException("Pcap handle is closed.")); - Validate.notIllegalArgument(filter != null && !filter.equals("")); + Validate.notIllegalArgument(pcap != null, + new IllegalArgumentException("Pcap handle should be not null.")); + Validate.notIllegalArgument(!pcap.isClosed(), + new IllegalArgumentException("Pcap handle is closed.")); + Validate.notIllegalArgument(filter != null && !filter.equals(""), + new IllegalArgumentException("Filter expression should be not null or empty.")); BpfProgram bpfProgram = new BpfProgram(); if (Jxnet.PcapCompile(pcap, bpfProgram, filter, bpfCompileMode.getValue(), netmask) != Jxnet.OK) { diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java index 02e1057a..59ee259f 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java @@ -32,6 +32,7 @@ import com.ardikars.jxnet.exception.NativeException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; +import java.util.HashMap; import java.util.logging.Logger; import org.junit.After; @@ -62,7 +63,7 @@ public void create() { .immediateMode(ImmediateMode.IMMEDIATE) .pcapType(Pcap.PcapType.LIVE) .errbuf(errbuf); - Application.run(LoaderTest.Initializer.class, pcapBuilder, ""); + Application.run(LoaderTest.Initializer.class, pcapBuilder, new HashMap<>()); Application.getApplicationContext().pcapClose(); pcap = PcapOpenDead(linkType.getValue(), snaplen); if (pcap == null) { diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index ecaea2fc..cfd2745d 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -88,6 +88,7 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.logging.Logger; @@ -123,7 +124,7 @@ public class JxnetTest { private final int immediate = 1; private final int optimize = 1; private final int bufferSize = 1500; - private final String filter = "tcp"; + private final String filter = ""; private final int precision = 0; private final int maxPkt = 5; @@ -154,7 +155,7 @@ public void create() throws Exception { .immediateMode(ImmediateMode.IMMEDIATE) .pcapType(Pcap.PcapType.LIVE) .errbuf(errbuf); - Application.run(LoaderTest.Initializer.class, pcapBuilder, ""); + Application.run(LoaderTest.Initializer.class, pcapBuilder, new HashMap<>()); Application.getApplicationContext().pcapClose(); if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); @@ -374,7 +375,7 @@ public void Test10_PcapNext() { } } - @Test + //@Test public void Test11_PcapNextEx() { pkt = ByteBuffer.allocateDirect(bufferSize); for (int i = 0; i < maxPkt; i++) { diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java index 5baa28c7..be52f7e9 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java @@ -41,13 +41,18 @@ public void test01LoadLibrary() { .pcapType(Pcap.PcapType.LIVE); Application.run(Initializer.class, pcapBuilder, parameter); Context context = Application.getApplicationContext(); - if (context.getAdditionalInformation() instanceof Map) { - Map additionalInformation = (Map) context.getAdditionalInformation(); + if (Application.getAdditionalInformation() instanceof Map) { + Map additionalInformation = (Map) Application.getAdditionalInformation(); assert additionalInformation.get(KEY).equals(VALUE); } assert true; } + @Test + public void getDeviceTest() { + System.out.println("DEVICE" + getDevice()); + } + public static String getDevice() { Collection networkInterfaces = null; try { diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java index 81c2b20b..6ace2af9 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java @@ -28,6 +28,10 @@ public class Tests { @Test public void ex() throws SocketException { + Context context = null; + Pcap.Builder pcapBuilder = null; + BpfProgram.Builder builder = null; + context.newInstance(pcapBuilder); assert true; } From fa2ad19719821b5fd7d85a80906fafde51982ee6 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Wed, 29 Aug 2018 12:40:36 +0700 Subject: [PATCH 13/16] Add coveralls and update README.md --- .appveyor/config.yml | 4 +- .circleci/config.yml | 9 +-- .scripts/InstallCodacyDeployer.ps1 | 17 ++++ README.md | 2 +- build.gradle | 16 ++++ .../ardikars/jxnet/ApplicationContext.java | 11 ++- .../main/java/com/ardikars/jxnet/Context.java | 4 +- jxnet-core/build.gradle | 2 +- .../java/com/ardikars/jxnet/BpfProgram.java | 8 +- .../main/java/com/ardikars/jxnet/Jxnet.java | 2 +- .../main/java/com/ardikars/jxnet/Pcap.java | 44 +++++----- .../exception/BpfProgramCloseException.java | 2 +- .../exception/DeviceNotFoundException.java | 2 +- .../jxnet/exception/FileCloseException.java | 2 +- .../jxnet/exception/NativeException.java | 2 +- .../jxnet/exception/PcapCloseException.java | 2 +- .../exception/PcapDumperCloseException.java | 2 +- .../java/com/ardikars/jxnet/FreakTest.java | 8 -- .../java/com/ardikars/jxnet/JxnetTest.java | 11 +-- .../java/com/ardikars/jxnet/LoaderTest.java | 81 ------------------- .../test/java/com/ardikars/jxnet/Tests.java | 38 --------- 21 files changed, 84 insertions(+), 185 deletions(-) create mode 100644 .scripts/InstallCodacyDeployer.ps1 delete mode 100644 jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java delete mode 100644 jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java diff --git a/.appveyor/config.yml b/.appveyor/config.yml index 3190e96d..edda1845 100644 --- a/.appveyor/config.yml +++ b/.appveyor/config.yml @@ -41,8 +41,8 @@ install: build_script: - cmd: set PATH=C:\tools\mingw64\bin;C:\Program Files (x86)\NSIS\;%PATH% -# - cmd: gradlew.bat clean build -x test --info --no-daemon - - cmd: gradlew.bat clean build jacocoTestReport --info --no-daemon + - cmd: gradlew.bat clean build jacocoTestReport coveralls --info --no-daemon + #---------------------------------# # notifications # #---------------------------------# diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a1253a0..6cad4bbd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,13 +17,8 @@ jobs: - gradle - checkout - run: 'export TERM=xterm-color' - - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev wget jq -y' -# - run: 'wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)' - - run: 'sudo ./gradlew clean build -x test --info --no-daemon' -# - run: 'sudo ./gradlew clean build jacocoTestReport --info --no-daemon' -# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r ./jxnet-context/build/reports/jacoco/test/jacocoTestReport.xml --partial' -# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r jxnet-core/build/reports/jacoco/test/jacocoTestReport.xml --partial' -# - run: 'java -jar ~/codacy-coverage-reporter-assembly-latest.jar final' + - run: 'sudo apt-get update && sudo apt-get install gcc libpcap-dev -y' + - run: './gradlew clean build -x test --info --no-daemon' deploy: working_directory: ~/tmp/Jxnet diff --git a/.scripts/InstallCodacyDeployer.ps1 b/.scripts/InstallCodacyDeployer.ps1 new file mode 100644 index 00000000..86ffe8dc --- /dev/null +++ b/.scripts/InstallCodacyDeployer.ps1 @@ -0,0 +1,17 @@ + +#---------------------------------# +# general configuration # +#---------------------------------# + +if (Test-Path "C:\tools\codacy.jar") { + echo "Codacy is already installed" +} else { + $urlPath = "https://github.com/codacy/codacy-coverage-reporter/releases/download/4.0.2/codacy-coverage-reporter-4.0.2-assembly.jar" + + # Download the file + echo "Downloading... ($urlPath)" + wget $urlPath -UseBasicParsing -OutFile "C:\tools\codacy.jar" + + echo "Installing Codacy..." + echo "Codacy has been installed." +} diff --git a/README.md b/README.md index cce5786d..c4c007b8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Jxnet is a Java library for capturing and sending custom network packet buffers Jxnet wraps a native packet capture library (libpcap/npcap) via JNI (Java Native Interface). [![Codacy Badge](https://api.codacy.com/project/badge/Grade/4d6ca7f3d9214098b1436990ac76a6cd)](https://www.codacy.com/project/jxnet/Jxnet/dashboard?utm_source=github.com&utm_medium=referral&utm_content=jxnet/Jxnet&utm_campaign=Badge_Grade_Dashboard) -[![CircleCI](https://circleci.com/gh/jxnet/Jxnet/tree/master.svg?style=svg)](https://circleci.com/gh/jxnet/Jxnet/tree/master) +[![Coverage Status](https://coveralls.io/repos/github/jxnet/Jxnet/badge.svg?branch=)](https://coveralls.io/github/jxnet/Jxnet?branch=) [![Build status](https://ci.appveyor.com/api/projects/status/ev4t6t1ssacwj18j?svg=true)](https://ci.appveyor.com/project/jxnet/jxnet) [ ![Download](https://api.bintray.com/packages/ardikars/maven/com.ardikars.jxnet/images/download.svg?version=1.3.0.Final) ](https://bintray.com/ardikars/maven/com.ardikars.jxnet/1.3.0.Final/link) diff --git a/build.gradle b/build.gradle index dcc85e11..2d18338d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ buildscript { dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.2' + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' } } @@ -32,6 +33,7 @@ subprojects { apply plugin: 'checkstyle' apply plugin: 'pmd' apply plugin: 'com.github.spotbugs' + apply plugin: 'com.github.kt3k.coveralls' group = "${GROUP}" version = "${VERSION}" @@ -62,6 +64,13 @@ subprojects { evaluationDependsOn(project.path) + jar { + manifest { + attributes 'Implementation-Title': 'Jxnet', + 'Implementation-Version': version + } + } + javadoc { def currentYear = Calendar.getInstance().get Calendar.YEAR options.with { @@ -230,6 +239,13 @@ subprojects { file("${rootDir}/${project.name}/out").deleteDir() } + /** + * Upload converage report + */ + tasks.coveralls { + dependsOn 'check' + } + } else { apply plugin: 'c' } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java index 46fd5a50..74969483 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java @@ -135,11 +135,12 @@ public void pcapDump(PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseExceptio } @Override - public PcapCode pcapCompile(String str, boolean optimize, int netmask) throws PcapCloseException, BpfProgramCloseException { + public PcapCode pcapCompile(String str, BpfProgram.BpfCompileMode optimize, int netmask) throws PcapCloseException, BpfProgramCloseException { if (bpfProgram == null) { bpfProgram = new BpfProgram(); } - int result = Jxnet.PcapCompile(pcap, bpfProgram, str, optimize ? 1 : 0, netmask); + Validate.notIllegalArgument(optimize != null, new IllegalArgumentException("Bpf compile mode should be not null.")); + int result = Jxnet.PcapCompile(pcap, bpfProgram, str, optimize.getValue(), netmask); if (result == 0) { return PcapCode.PCAP_OK; } @@ -291,12 +292,14 @@ public PcapCode pcapStats(PcapStat pcapStat) throws PcapCloseException { } @Override - public PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter, boolean optimize, Inet4Address mask) + public PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter, + BpfProgram.BpfCompileMode optimize, Inet4Address mask) throws BpfProgramCloseException { if (bpfProgram == null) { bpfProgram = new BpfProgram(); } - int result = Jxnet.PcapCompileNoPcap(snaplen, dataLinkType.getValue(), bpfProgram, filter, optimize ? 1 : 0, mask.toInt()); + Validate.notIllegalArgument(optimize != null, new IllegalArgumentException("Bpf compile mode should be not null.")); + int result = Jxnet.PcapCompileNoPcap(snaplen, dataLinkType.getValue(), bpfProgram, filter, optimize.getValue(), mask.toInt()); if (result == 0) { return PcapCode.PCAP_OK; } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java index b35b3723..201a277f 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java @@ -109,7 +109,7 @@ public interface Context extends Factory> { * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ - PcapCode pcapCompile(String str, boolean optimize, int netmask) throws PcapCloseException, BpfProgramCloseException; + PcapCode pcapCompile(String str, BpfProgram.BpfCompileMode optimize, int netmask) throws PcapCloseException, BpfProgramCloseException; /** * Associate a filter to a capture. @@ -308,7 +308,7 @@ public interface Context extends Factory> { * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ - PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter, boolean optimize, Inet4Address mask) + PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter, BpfProgram.BpfCompileMode optimize, Inet4Address mask) throws BpfProgramCloseException; /** diff --git a/jxnet-core/build.gradle b/jxnet-core/build.gradle index ec9b5f30..a39413ce 100644 --- a/jxnet-core/build.gradle +++ b/jxnet-core/build.gradle @@ -13,7 +13,7 @@ sourceSets { } dependencies { - testCompile project(":jxnet-context") +// testCompile project(":jxnet-context") testCompile "junit:junit:${JUNIT_VERSION}" testCompile "org.mockito:mockito-core:${MOCKITO_VERSION}" } diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java b/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java index 78f0d9f1..6fe65203 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/BpfProgram.java @@ -190,11 +190,11 @@ private BpfProgram buildBpf() { new IllegalArgumentException("Filter expression should be not null or empty.")); BpfProgram bpfProgram = new BpfProgram(); - if (Jxnet.PcapCompile(pcap, bpfProgram, filter, bpfCompileMode.getValue(), netmask) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapCompile(pcap, bpfProgram, filter, bpfCompileMode.getValue(), netmask) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetFilter(pcap, bpfProgram) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetFilter(pcap, bpfProgram) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } return bpfProgram; } diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java index 9d52d277..98957eee 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Jxnet.java @@ -1 +1 @@ -/** * Copyright (C) 2017-2018 Ardika Rommy Sanjaya * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.ardikars.jxnet; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.NativeException; import com.ardikars.jxnet.exception.PcapCloseException; import com.ardikars.jxnet.exception.PcapDumperCloseException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; import java.nio.ByteBuffer; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; /** * This class is a function mapping for libpcap api. * @author Ardika Rommy Sanjaya * @since 1.0.0 */ public final class Jxnet { private static final Logger LOGGER = Logger.getLogger(Jxnet.class.getName()); public static final int OK = 0; public static final int PCAP_ERRBUF_SIZE = 255; private Jxnet() { super(); } /** * PcapFindAllDevs() Constructs a list of network devices that can be * opened with PcapCreate() and PcapActivate() or with PcapOpenLive(). * (Note that there may be network devices that cannot be opened by the * process calling PcapFindAllDevs()). * @param alldevsp list of PcapIf. * @param errbuf error buffer. * @return PcapFindAllDevs() returns 0 on success and -1 on failure; as indicated, * finding no devices is considered success, rather than failure, * so 0 will be returned in that case. If -1 is returned, errbuf is * filled in with an appropriate error message. * @since 1.1.4 */ public static native int PcapFindAllDevs(List alldevsp, StringBuilder errbuf); /** * Open a live capture handle. * On Linux systems with 2.2 or later kernels, a device (source) * argument of "any" or NULL can be used to capture packets from all interfaces. * @param source interface name. * @param snaplen specifies the snapshot length to be set on the handle (16 bit). * @param promisc specifies if the interface is to be put into promiscuous mode. * @param toMs specifies the packet buffer timeout in milliseconds. * @param errbuf error buffer. * @return PcapOpenLive() returns null on error. If null is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenLive(String source, int snaplen, int promisc, int toMs, StringBuilder errbuf); /** * Collect a group of packets. * Callback argument already asyncronous. * @param pcap pcap instance. * @param cnt maximum iteration, -1 is infinite iteration. * @param callback callback funtion. * @param user args * @param args type. * @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a * @throws PcapCloseException pcap close exception. * savefile, no more packets are available. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. It does not return when live packet * buffer timeouts occur; instead, it attempts to read more packets. * @since 1.1.4 */ public static native int PcapLoop(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Collect a group of packets. * @param pcap pcap instance. * @param cnt maximum iteration, -1 to infinite. * @param callback callback function. * @param user arg. * @param args type. * @return PcapDispatch() returns the number of packets processed on success; * @throws PcapCloseException pcap close exception. * this can be 0 if no packets were read from a live capture (if, for * example, they were discarded because they didn't pass the packet filter, * or if, on platforms that support a packet buffer timeout that * starts before any packets arrive, the timeout expires before any packets * arrive, or if the file descriptor for the capture device is in non-blocking * mode and no packets were available to be read) or if no more * packets are available in a savefile. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. If your application uses * PcapBreakLoop(), make sure that you explicitly check for -1 and -2, * rather than just checking for a return value less then 0. * @since 1.1.4 */ public static native int PcapDispatch(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Open a file to write packets. * @param pcap pcap instance. * @param fname fname specifies the name of the file to open. The file will have the same format * as those used by tcpdump(1) and tcpslice(1). The name "-" is a synonym for stdout. * @return null on error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native PcapDumper PcapDumpOpen(Pcap pcap, String fname) throws PcapCloseException; /** * Save a packet to disk. * @param pcapDumper pcap dumper object. * @param h pcap packet header. * @param sp packet buffer. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDump(PcapDumper pcapDumper, PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException; /** * Open a savefile in the tcpdump/libpcap format to read packets. * @param fname file name. * @param errbuf error buffer. * @return null on error. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenOffline(String fname, StringBuilder errbuf); /** * Compile a packet filter, converting an high level filtering expression * (see Filtering expression syntax) in a program that can be interpreted * by the kernel-level filtering engine. * Note: Before libpcap-1.8.1 this function is not thread-safe @link https://github.com/the-tcpdump-group/libpcap/issues/75. * @param pcap pcap instance. * @param fp compiled bfp. * @param str filter expression. * @param optimize optimize (0/1). * @param netmask netmask. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapCompile(Pcap pcap, BpfProgram fp, String str, int optimize, int netmask) throws PcapCloseException; /** * Associate a filter to a capture. * @param pcap pcap instance. * @param fp compiled bpf. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetFilter(Pcap pcap, BpfProgram fp) throws PcapCloseException; /** * Send a raw packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size size of packet buffer. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSendPacket(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException; /** * Return the next available packet. * @param pcap pcap instance. * @param h packet header. * @return PcapNext() returns next available packet. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native ByteBuffer PcapNext(Pcap pcap, PcapPktHdr h) throws PcapCloseException; /** * Read a packet from an interface or from an offline capture. * @param pcap pcap instance. * @param pktHeader packet header. * @param pktData packet buffer. * @return PcapNextEx() returns 1 if the packet was read without problems, 0 if * packets are being read from a live capture and the packet buffer time- * out expired, -1 if an error occurred while reading the packet, and -2 * if packets are being read from a savefile and there are no more * packets to read from the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapNextEx(Pcap pcap, PcapPktHdr pktHeader, ByteBuffer pktData) throws PcapCloseException; /** * Close the files associated with pcap and deallocates resources. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapClose(Pcap pcap) throws PcapCloseException; /** * Flushes the output buffer to the savefile, so that any packets written * with PcapDump() but not yet written to the savefile will be written. -1 * is returned on error, 0 on success. * @param pcapDumper pcap dumper object. * @return -1 on error, 0 otherwise. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native int PcapDumpFlush(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Closes a savefile. * @param pcapDumper pcap dumper object. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDumpClose(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Return the link layer of an adapter on success. * @param pcap pcap instance. * @return link layer type of an adapter on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapDataLink(Pcap pcap) throws PcapCloseException; /** * Set the current data link type of the pcap descriptor to the type * specified by dlt. -1 is returned on failure. * @param pcap pcap instance. * @param dtl data link type. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapSetDataLink(Pcap pcap, int dtl) throws PcapCloseException, NativeException; /** * Set a flag that will force PcapDispatch() or PcapLoop() to return rather than looping. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapBreakLoop(Pcap pcap) throws PcapCloseException; /** * Return the first valid device in the system. * @param errbuf error buffer. * @return first valid device in the system. PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device") * @since 1.1.4 * @deprecated use 'pcap_findalldevs' and use the first device. */ @Deprecated public static native String PcapLookupDev(StringBuilder errbuf); /** * Return the error text pertaining to the last pcap library error. * @param pcap pcap instance. * @return error text pertaining to the last pcap library error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native String PcapGetErr(Pcap pcap) throws PcapCloseException; /** * Returns a string giving information about the version of the libpcap library being used; * note that it contains more information than just a version number. * @return libpcap version. * @since 1.1.4 */ public static native String PcapLibVersion(); /** * Returns true (1) if the current savefile uses a different byte order than the current system. * @param pcap pcap instance. * @return PcapIsSwapped() returns true (1) or false (0) on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapIsSwapped(Pcap pcap) throws PcapCloseException; /** * Return the dimension of the packet portion (in bytes) that is delivered to the application. * @param pcap pcap instance * @return PcapSnapshot() returns the snapshot length on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException; /** * Provided in case StrError() isn't available. It returns an error message string corresponding to error. * @param error error code. * @return error message. * @since 1.1.4 */ public static native String PcapStrError(int error); /** * Return the major version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return major version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMajorVersion(Pcap pcap) throws PcapCloseException; /** * Return the minor version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return minor version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMinorVersion(Pcap pcap) throws PcapCloseException; /** * Translates a data link type value to the corresponding data link type name. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToName(int dtl); /** * Translates a data link type value to a short description of that data link type. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToDescription(int dtl); /** * Translates a data link type name, which is a DLT_ name with the DLT_ removed, * to the corresponding data link type value. The translation is case-insensitive. * -1 is returned on failure. * @param name link type name. * @return PcapDataLinkNameToVal() returns the type value on success and -1 if the name is not a known type name. * @since 1.1.4 */ public static native int PcapDataLinkNameToVal(String name); /** * Switch between blocking and nonblocking mode. * @param pcap pcap instance. * @param nonblock 1 to set non block. * @param errbuf error buffer. * @return returns the current non-blocking state of the capture descriptor; * it always returns 0 on savefiles. If there is an error, -1 is returned and * errbuf is filled in with an appropriate error message. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetNonBlock(Pcap pcap, int nonblock, StringBuilder errbuf) throws PcapCloseException; /** * Get the "non-blocking" state of an interface. * @param pcap pcap instance. * @param errbuf error buffer. * @return PcapGetNonBlock() returns the current non-blocking state of the * capture descriptor; it always returns 0 on savefiles. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapGetNonBlock(Pcap pcap, StringBuilder errbuf) throws PcapCloseException; /** * Create a pcap instance without starting a capture. * @param linktype link type. * @param snaplen snapshot length. * @return null on error. * @since 1.1.4 */ public static native Pcap PcapOpenDead(int linktype, int snaplen); /** * Return the file position for a savefile. * @param pcapDumper pcap dumper object. * @return file position for a savefile. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native long PcapDumpFTell(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Free a filter. * @param bpfProgram compiled bpf. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native void PcapFreeCode(BpfProgram bpfProgram) throws BpfProgramCloseException; /** * Return statistics on current capture. * @param pcap pcap instance. * @param pcapStat pcap stat object. * @return PcapStats() returns 0 on success and returns -1 if there is an error * or if pcap handle doesn't support packet statistics. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapStats(Pcap pcap, PcapStat pcapStat) throws PcapCloseException; /** * Compile a packet filter without the need of opening an adapter. * This function converts an high level filtering expression (see Filtering expression syntax) * in a program that can be interpreted by the kernel-level filtering engine. * @param snaplenArg snapshot length. * @param linktypeArg link type. * @param program bpf. * @param buf str. * @param optimize optiomize (0/1). * @param mask netmask. * @return -1 on error. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native int PcapCompileNoPcap(int snaplenArg, int linktypeArg, BpfProgram program, String buf, int optimize, int mask) throws BpfProgramCloseException; /** * Print the text of the last pcap library error on stderr, prefixed by prefix. * @param pcap pcap instance. * @param prefix prefix. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapPError(Pcap pcap, String prefix) throws PcapCloseException; /** * Is used to create a packet capture handle to look at packets on the network. * Source is a string that specifies the network device to open; * on Linux systems with 2.2 or later kernels, a source argument of "any" or NULL * can be used to capture packets from all interfaces. * *

The returned handle must be activated with PcapActivate() before packets can be captured with it; * options for the capture, such as promiscuous mode, can be set on the handle before activating it.

* @param source network device. * @param errbuf errof buffer. * @return returns a pcap instance on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapCreate(String source, StringBuilder errbuf); /** * Sets the snapshot length to be used on a capture handle when the handle is activated to snaplen. * @param pcap pcap instance. * @param snaplen snaplen. * @return returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetSnaplen(Pcap pcap, int snaplen) throws PcapCloseException; /** * sets whether promiscuous mode should be set on a capture handle when the handle is activated. * If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param promisc promisc. * @return pcapSetPromisc() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetPromisc(Pcap pcap, int promisc) throws PcapCloseException; /** * Sets the packet buffer timeout that will be used on a capture handle when the handle is activated to to_ms, * which is in units of milliseconds. * @param pcap pcap instance. * @param timeout timeout. * @return PcapSetTimeout() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetTimeout(Pcap pcap, int timeout) throws PcapCloseException; /** * Sets the buffer size that will be used on a capture handle when the handle is activated to buffer_size, which is in units of bytes. * @param pcap pcap instance. * @param bufferSize buffer size. * @return PcapSetBufferSize() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetBufferSize(Pcap pcap, int bufferSize) throws PcapCloseException; /** * Checks whether monitor mode could be set on a capture handle when the handle is activated. * @param pcap pcap instance. * @return PcapCanSetRfMon() returns 0 if monitor mode could not be set, 1 if * monitor mode could be set, and a negative value on error. A negative * return value indicates what error condition occurred. The possible * error values are: * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported. * PCAP_ERROR_ACTIVATED(-4): The capture handle has already been activated. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException; /** * Sets whether monitor mode should be set on a capture handle when the handle is activated. * If rfmon is non-zero, monitor mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param rfmon 1 (true) or 0 (false). * @return PcapSetRfMon() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called * on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException; /** * Sets whether immediate mode should be set on a capture handle when the handle is activated. If immediate_mode is non-zero, * immediate mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param immediateMode immediate_mode. * @return PcapSetImmediateMode() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) * if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetImmediateMode(Pcap pcap, int immediateMode) throws PcapCloseException, PlatformNotSupportedException; /** * Is used to activate a packet capture handle to look at packets on the network, * with the options that were set on the handle being in effect. * @param pcap pcap instance. * @return 0 on success without warnings, a non-zero positive value on success with warnings, and a negative value on error. * A non-zero return value indicates what warning or error condition occurred. * The possible warning values are: * PCAP_WARNING_PROMISC_NOTSUP(2): Promiscuous mode was requested, but the capture source doesn't support promiscuous mode. * PCAP_WARNING_TSTAMP_TYPE_NOTSUP(3): The time stamp type specified in a previous PcapSetTStampType() call isn't supported * by the capture source (the time stamp type is left as the default). * PCAP_WARNING(1): Generic waring. * The possible error values are: * PCAP_ERROR_ACTIVATED(-4): The handle has already been activated. * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn't exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to open the capture source. * PCAP_ERROR_PROMISC_PERM_DENIED(-11): The process has permission to open the capture source but doesn't have * spermission to put it into promiscuous mode. * PCAP_ERROR_RFMON_NOTSUP(-6): Monitor mode was specified but the capture source doesn't support monitor mode. * PCAP_ERROR_IFACE_NOT_UP(-9): The capture source device is not up. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapActivate(Pcap pcap) throws PcapCloseException; /** * used to specify a direction that packets will be * captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or * PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the * device, PCAP_D_OUT will only capture packets sent by the device and * PCAP_D_INOUT will capture packets received by or sent by the device. * PCAP_D_INOUT is the default setting if this function is not called. * *

PcapSetdirection() isn't necessarily fully supported on all platforms; * some platforms might return an error for all values, and some other * platforms might not support PCAP_D_OUT.

* *

This operation is not supported if a savefile is being read.

* @param pcap pcap instance. * @param direction direction. * @return returns 0 on success and -1 on failure (not supported by operating system). * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp precision returned in captures. * @param pcap pcap. * @param tstampPrecision time stamp precision. * @return 0 on success if specified time stamp precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampPrecision(Pcap pcap, int tstampPrecision) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp type returned in captures. * @param pcap pcap. * @param type time stamp type. * @return 0 on success if specified time type precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampType(Pcap pcap, int type) throws PcapCloseException, PlatformNotSupportedException; /** * Get the time stamp precision returned in captures. * @param pcap pcap instance. * @return the precision of the time stamp returned in packet captures on the pcap descriptor. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapGetTStampPrecision(Pcap pcap) throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. * @param pcap pcap instance. * @param dtlBuffer datalinks. * @return list of datalinks. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListDataLinks(Pcap pcap, List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; /** * Get link of time stamp types. * @param pcap pcap instance. * @param tstampTypesp time stamp types. * @return time stamp types. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListTStampTypes(Pcap pcap, List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Translates a time stamp type name to the corresponding time stamp type value. The translation is case-insensitive. * @param name time stamp name. * @return returns time stamp type value on success and PCAP_ERROR on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapTStampTypeNameToVal(String name) throws PlatformNotSupportedException; /** * Translates a time stamp type value to the corresponding time stamp type name. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToName(int tstampType) throws PlatformNotSupportedException; /** * Translates a time stamp type value to a short description of that time stamp type. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToDescription(int tstampType) throws PlatformNotSupportedException; /** * Converts a status code value returned by a libpcap routine to an error string. * @param errnum statuc code number. * @return status string. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapStatusToStr(int errnum) throws PlatformNotSupportedException; /** * Used for creating a Pcap instance to use when calling the other functions. * It is typically used when just using for compiling BPF code; * it can also be used if using pcap_dump_open(), pcap_dump(), * and PcapDumpClose() to write a savefile if there is no Pcap that * supplies the packets to be written. * @param linktype specifies the link-layer type * @param snaplen specifies the snapshot length. * @param precision specifies the time stamp precision. * @return null on fail. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenDeadWithTStampPrecision(int linktype, int snaplen, int precision) throws PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw * data for the packet, check whether the packet passes the filter. * Returns the return value of the filter program, which will be zero if * the packet doesn't pass and non-zero if the packet does pass. * @param fp bpfProgram * @param h pktHdr * @param pkt buffer. * @return 0 on success. */ public static native int PcapOfflineFilter(BpfProgram fp, PcapPktHdr h, ByteBuffer pkt); /** * Called to open a savefile for reading pcap file. * @param fname specifies the file name. * @param tstampPrecision specifies the time stamp precision. * @param errbuf specifies errror buffer. * @return pcap instance. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenOfflineWithTStampPrecision(String fname, int tstampPrecision, StringBuilder errbuf) throws PlatformNotSupportedException; /** * Sends a raw packet through the network interface; buf points to the data of the packet, * including the link-layer header, and size is the number of bytes in the packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size packet size. * @return PcapInject returns the number of bytes written on success and -1 on failure. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapInject(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException, PlatformNotSupportedException; /** * Check if pcap handle is alredy activated or no. * @param pcap pcap instance. * @return returns 0 if pcap handle not active yet. */ public static native int PcapCheckActivated(Pcap pcap); /* static { if (!Application.getInstance().isLoaded()) { Application.run("", "", Initializer.class); } } static final class Initializer implements ApplicationInitializer { @Override public void initialize(Application.Context context) { context.addLibrary(new DynamicLibrary()); context.addLibrary(new StaticLibrary()); } } */ public static void main(String[] args) { LOGGER.info(Arrays.toString(args)); } } \ No newline at end of file +/** * Copyright (C) 2017-2018 Ardika Rommy Sanjaya * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.ardikars.jxnet; import com.ardikars.common.util.Callback; import com.ardikars.jxnet.exception.BpfProgramCloseException; import com.ardikars.jxnet.exception.NativeException; import com.ardikars.jxnet.exception.PcapCloseException; import com.ardikars.jxnet.exception.PcapDumperCloseException; import com.ardikars.jxnet.exception.PlatformNotSupportedException; import com.ardikars.jxnet.util.DefaultLibraryLoader; import java.nio.ByteBuffer; import java.util.List; import java.util.logging.Logger; /** * This class is a function mapping for libpcap api. * @author Ardika Rommy Sanjaya * @since 1.0.0 */ public final class Jxnet { private static final Logger LOGGER = Logger.getLogger(Jxnet.class.getName()); public static final int OK = 0; public static final int PCAP_ERRBUF_SIZE = 255; private static boolean loaded; private Jxnet() { super(); } /** * PcapFindAllDevs() Constructs a list of network devices that can be * opened with PcapCreate() and PcapActivate() or with PcapOpenLive(). * (Note that there may be network devices that cannot be opened by the * process calling PcapFindAllDevs()). * @param alldevsp list of PcapIf. * @param errbuf error buffer. * @return PcapFindAllDevs() returns 0 on success and -1 on failure; as indicated, * finding no devices is considered success, rather than failure, * so 0 will be returned in that case. If -1 is returned, errbuf is * filled in with an appropriate error message. * @since 1.1.4 */ public static native int PcapFindAllDevs(List alldevsp, StringBuilder errbuf); /** * Open a live capture handle. * On Linux systems with 2.2 or later kernels, a device (source) * argument of "any" or NULL can be used to capture packets from all interfaces. * @param source interface name. * @param snaplen specifies the snapshot length to be set on the handle (16 bit). * @param promisc specifies if the interface is to be put into promiscuous mode. * @param toMs specifies the packet buffer timeout in milliseconds. * @param errbuf error buffer. * @return PcapOpenLive() returns null on error. If null is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenLive(String source, int snaplen, int promisc, int toMs, StringBuilder errbuf); /** * Collect a group of packets. * Callback argument already asyncronous. * @param pcap pcap instance. * @param cnt maximum iteration, -1 is infinite iteration. * @param callback callback funtion. * @param user args * @param args type. * @return PcapLoop() returns 0 if cnt is exhausted or if, when reading from a * @throws PcapCloseException pcap close exception. * savefile, no more packets are available. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. It does not return when live packet * buffer timeouts occur; instead, it attempts to read more packets. * @since 1.1.4 */ public static native int PcapLoop(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Collect a group of packets. * @param pcap pcap instance. * @param cnt maximum iteration, -1 to infinite. * @param callback callback function. * @param user arg. * @param args type. * @return PcapDispatch() returns the number of packets processed on success; * @throws PcapCloseException pcap close exception. * this can be 0 if no packets were read from a live capture (if, for * example, they were discarded because they didn't pass the packet filter, * or if, on platforms that support a packet buffer timeout that * starts before any packets arrive, the timeout expires before any packets * arrive, or if the file descriptor for the capture device is in non-blocking * mode and no packets were available to be read) or if no more * packets are available in a savefile. It returns -1 if an error * occurs or -2 if the loop terminated due to a call to PcapBreakLoop() * before any packets were processed. If your application uses * PcapBreakLoop(), make sure that you explicitly check for -1 and -2, * rather than just checking for a return value less then 0. * @since 1.1.4 */ public static native int PcapDispatch(Pcap pcap, int cnt, PcapHandler callback, T user) throws PcapCloseException; /** * Open a file to write packets. * @param pcap pcap instance. * @param fname fname specifies the name of the file to open. The file will have the same format * as those used by tcpdump(1) and tcpslice(1). The name "-" is a synonym for stdout. * @return null on error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native PcapDumper PcapDumpOpen(Pcap pcap, String fname) throws PcapCloseException; /** * Save a packet to disk. * @param pcapDumper pcap dumper object. * @param h pcap packet header. * @param sp packet buffer. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDump(PcapDumper pcapDumper, PcapPktHdr h, ByteBuffer sp) throws PcapDumperCloseException; /** * Open a savefile in the tcpdump/libpcap format to read packets. * @param fname file name. * @param errbuf error buffer. * @return null on error. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapOpenOffline(String fname, StringBuilder errbuf); /** * Compile a packet filter, converting an high level filtering expression * (see Filtering expression syntax) in a program that can be interpreted * by the kernel-level filtering engine. * Note: Before libpcap-1.8.1 this function is not thread-safe @link https://github.com/the-tcpdump-group/libpcap/issues/75. * @param pcap pcap instance. * @param fp compiled bfp. * @param str filter expression. * @param optimize optimize (0/1). * @param netmask netmask. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapCompile(Pcap pcap, BpfProgram fp, String str, int optimize, int netmask) throws PcapCloseException; /** * Associate a filter to a capture. * @param pcap pcap instance. * @param fp compiled bpf. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetFilter(Pcap pcap, BpfProgram fp) throws PcapCloseException; /** * Send a raw packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size size of packet buffer. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSendPacket(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException; /** * Return the next available packet. * @param pcap pcap instance. * @param h packet header. * @return PcapNext() returns next available packet. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native ByteBuffer PcapNext(Pcap pcap, PcapPktHdr h) throws PcapCloseException; /** * Read a packet from an interface or from an offline capture. * @param pcap pcap instance. * @param pktHeader packet header. * @param pktData packet buffer. * @return PcapNextEx() returns 1 if the packet was read without problems, 0 if * packets are being read from a live capture and the packet buffer time- * out expired, -1 if an error occurred while reading the packet, and -2 * if packets are being read from a savefile and there are no more * packets to read from the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapNextEx(Pcap pcap, PcapPktHdr pktHeader, ByteBuffer pktData) throws PcapCloseException; /** * Close the files associated with pcap and deallocates resources. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapClose(Pcap pcap) throws PcapCloseException; /** * Flushes the output buffer to the savefile, so that any packets written * with PcapDump() but not yet written to the savefile will be written. -1 * is returned on error, 0 on success. * @param pcapDumper pcap dumper object. * @return -1 on error, 0 otherwise. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native int PcapDumpFlush(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Closes a savefile. * @param pcapDumper pcap dumper object. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native void PcapDumpClose(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Return the link layer of an adapter on success. * @param pcap pcap instance. * @return link layer type of an adapter on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapDataLink(Pcap pcap) throws PcapCloseException; /** * Set the current data link type of the pcap descriptor to the type * specified by dlt. -1 is returned on failure. * @param pcap pcap instance. * @param dtl data link type. * @return -1 on error, 0 otherwise. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapSetDataLink(Pcap pcap, int dtl) throws PcapCloseException, NativeException; /** * Set a flag that will force PcapDispatch() or PcapLoop() to return rather than looping. * @param pcap pcap instance. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapBreakLoop(Pcap pcap) throws PcapCloseException; /** * Return the first valid device in the system. * @param errbuf error buffer. * @return first valid device in the system. PCAP_DEPRECATED(pcap_lookupdev, "use 'pcap_findalldevs' and use the first device") * @since 1.1.4 * @deprecated use 'pcap_findalldevs' and use the first device. */ @Deprecated public static native String PcapLookupDev(StringBuilder errbuf); /** * Return the error text pertaining to the last pcap library error. * @param pcap pcap instance. * @return error text pertaining to the last pcap library error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native String PcapGetErr(Pcap pcap) throws PcapCloseException; /** * Returns a string giving information about the version of the libpcap library being used; * note that it contains more information than just a version number. * @return libpcap version. * @since 1.1.4 */ public static native String PcapLibVersion(); /** * Returns true (1) if the current savefile uses a different byte order than the current system. * @param pcap pcap instance. * @return PcapIsSwapped() returns true (1) or false (0) on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been * created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapIsSwapped(Pcap pcap) throws PcapCloseException; /** * Return the dimension of the packet portion (in bytes) that is delivered to the application. * @param pcap pcap instance * @return PcapSnapshot() returns the snapshot length on success and * PCAP_ERROR_NOT_ACTIVATED(-3) if called on a capture handle that has been created but not activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSnapshot(Pcap pcap) throws PcapCloseException; /** * Provided in case StrError() isn't available. It returns an error message string corresponding to error. * @param error error code. * @return error message. * @since 1.1.4 */ public static native String PcapStrError(int error); /** * Return the major version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return major version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMajorVersion(Pcap pcap) throws PcapCloseException; /** * Return the minor version number of the pcap library used to write the savefile. * @param pcap pcap instance. * @return minor version number of the pcap library used to write the savefile. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapMinorVersion(Pcap pcap) throws PcapCloseException; /** * Translates a data link type value to the corresponding data link type name. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToName(int dtl); /** * Translates a data link type value to a short description of that data link type. * NULL is returned on failure. * @param dtl link type. * @return null is returned if the type value does not correspond to a known datalink value. * @since 1.1.4 */ public static native String PcapDataLinkValToDescription(int dtl); /** * Translates a data link type name, which is a DLT_ name with the DLT_ removed, * to the corresponding data link type value. The translation is case-insensitive. * -1 is returned on failure. * @param name link type name. * @return PcapDataLinkNameToVal() returns the type value on success and -1 if the name is not a known type name. * @since 1.1.4 */ public static native int PcapDataLinkNameToVal(String name); /** * Switch between blocking and nonblocking mode. * @param pcap pcap instance. * @param nonblock 1 to set non block. * @param errbuf error buffer. * @return returns the current non-blocking state of the capture descriptor; * it always returns 0 on savefiles. If there is an error, -1 is returned and * errbuf is filled in with an appropriate error message. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetNonBlock(Pcap pcap, int nonblock, StringBuilder errbuf) throws PcapCloseException; /** * Get the "non-blocking" state of an interface. * @param pcap pcap instance. * @param errbuf error buffer. * @return PcapGetNonBlock() returns the current non-blocking state of the * capture descriptor; it always returns 0 on savefiles. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapGetNonBlock(Pcap pcap, StringBuilder errbuf) throws PcapCloseException; /** * Create a pcap instance without starting a capture. * @param linktype link type. * @param snaplen snapshot length. * @return null on error. * @since 1.1.4 */ public static native Pcap PcapOpenDead(int linktype, int snaplen); /** * Return the file position for a savefile. * @param pcapDumper pcap dumper object. * @return file position for a savefile. * @throws PcapDumperCloseException pcap dumper close exception. * @since 1.1.4 */ public static native long PcapDumpFTell(PcapDumper pcapDumper) throws PcapDumperCloseException; /** * Free a filter. * @param bpfProgram compiled bpf. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native void PcapFreeCode(BpfProgram bpfProgram) throws BpfProgramCloseException; /** * Return statistics on current capture. * @param pcap pcap instance. * @param pcapStat pcap stat object. * @return PcapStats() returns 0 on success and returns -1 if there is an error * or if pcap handle doesn't support packet statistics. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapStats(Pcap pcap, PcapStat pcapStat) throws PcapCloseException; /** * Compile a packet filter without the need of opening an adapter. * This function converts an high level filtering expression (see Filtering expression syntax) * in a program that can be interpreted by the kernel-level filtering engine. * @param snaplenArg snapshot length. * @param linktypeArg link type. * @param program bpf. * @param buf str. * @param optimize optiomize (0/1). * @param mask netmask. * @return -1 on error. * @throws BpfProgramCloseException bpf program close exception. * @since 1.1.4 */ public static native int PcapCompileNoPcap(int snaplenArg, int linktypeArg, BpfProgram program, String buf, int optimize, int mask) throws BpfProgramCloseException; /** * Print the text of the last pcap library error on stderr, prefixed by prefix. * @param pcap pcap instance. * @param prefix prefix. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native void PcapPError(Pcap pcap, String prefix) throws PcapCloseException; /** * Is used to create a packet capture handle to look at packets on the network. * Source is a string that specifies the network device to open; * on Linux systems with 2.2 or later kernels, a source argument of "any" or NULL * can be used to capture packets from all interfaces. * *

The returned handle must be activated with PcapActivate() before packets can be captured with it; * options for the capture, such as promiscuous mode, can be set on the handle before activating it.

* @param source network device. * @param errbuf errof buffer. * @return returns a pcap instance on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. * @since 1.1.4 */ public static native Pcap PcapCreate(String source, StringBuilder errbuf); /** * Sets the snapshot length to be used on a capture handle when the handle is activated to snaplen. * @param pcap pcap instance. * @param snaplen snaplen. * @return returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetSnaplen(Pcap pcap, int snaplen) throws PcapCloseException; /** * sets whether promiscuous mode should be set on a capture handle when the handle is activated. * If promisc is non-zero, promiscuous mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param promisc promisc. * @return pcapSetPromisc() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetPromisc(Pcap pcap, int promisc) throws PcapCloseException; /** * Sets the packet buffer timeout that will be used on a capture handle when the handle is activated to to_ms, * which is in units of milliseconds. * @param pcap pcap instance. * @param timeout timeout. * @return PcapSetTimeout() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetTimeout(Pcap pcap, int timeout) throws PcapCloseException; /** * Sets the buffer size that will be used on a capture handle when the handle is activated to buffer_size, which is in units of bytes. * @param pcap pcap instance. * @param bufferSize buffer size. * @return PcapSetBufferSize() returns 0 on success or PCAP_ERROR_ACTIVATED(-3) if * called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetBufferSize(Pcap pcap, int bufferSize) throws PcapCloseException; /** * Checks whether monitor mode could be set on a capture handle when the handle is activated. * @param pcap pcap instance. * @return PcapCanSetRfMon() returns 0 if monitor mode could not be set, 1 if * monitor mode could be set, and a negative value on error. A negative * return value indicates what error condition occurred. The possible * error values are: * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn' exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to check whether monitor mode could be supported. * PCAP_ERROR_ACTIVATED(-4): The capture handle has already been activated. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @throws NativeException native exception (pcap handle is dead). * @since 1.1.4 */ public static native int PcapCanSetRfMon(Pcap pcap) throws PcapCloseException, NativeException; /** * Sets whether monitor mode should be set on a capture handle when the handle is activated. * If rfmon is non-zero, monitor mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param rfmon 1 (true) or 0 (false). * @return PcapSetRfMon() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) if called * on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapSetRfMon(Pcap pcap, int rfmon) throws PcapCloseException; /** * Sets whether immediate mode should be set on a capture handle when the handle is activated. If immediate_mode is non-zero, * immediate mode will be set, otherwise it will not be set. * @param pcap pcap instance. * @param immediateMode immediate_mode. * @return PcapSetImmediateMode() returns 0 on success or PCAP_ERROR_ACTIVATED(-4) * if called on a capture handle that has been activated. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetImmediateMode(Pcap pcap, int immediateMode) throws PcapCloseException, PlatformNotSupportedException; /** * Is used to activate a packet capture handle to look at packets on the network, * with the options that were set on the handle being in effect. * @param pcap pcap instance. * @return 0 on success without warnings, a non-zero positive value on success with warnings, and a negative value on error. * A non-zero return value indicates what warning or error condition occurred. * The possible warning values are: * PCAP_WARNING_PROMISC_NOTSUP(2): Promiscuous mode was requested, but the capture source doesn't support promiscuous mode. * PCAP_WARNING_TSTAMP_TYPE_NOTSUP(3): The time stamp type specified in a previous PcapSetTStampType() call isn't supported * by the capture source (the time stamp type is left as the default). * PCAP_WARNING(1): Generic waring. * The possible error values are: * PCAP_ERROR_ACTIVATED(-4): The handle has already been activated. * PCAP_ERROR_NO_SUCH_DEVICE(-5): The capture source specified when the handle was created doesn't exist. * PCAP_ERROR_PERM_DENIED(-8): The process doesn't have permission to open the capture source. * PCAP_ERROR_PROMISC_PERM_DENIED(-11): The process has permission to open the capture source but doesn't have * spermission to put it into promiscuous mode. * PCAP_ERROR_RFMON_NOTSUP(-6): Monitor mode was specified but the capture source doesn't support monitor mode. * PCAP_ERROR_IFACE_NOT_UP(-9): The capture source device is not up. * PCAP_ERROR(-1): Generic error. * @throws PcapCloseException pcap close exception. * @since 1.1.4 */ public static native int PcapActivate(Pcap pcap) throws PcapCloseException; /** * used to specify a direction that packets will be * captured. Direction is one of the constants PCAP_D_IN, PCAP_D_OUT or * PCAP_D_INOUT. PCAP_D_IN will only capture packets received by the * device, PCAP_D_OUT will only capture packets sent by the device and * PCAP_D_INOUT will capture packets received by or sent by the device. * PCAP_D_INOUT is the default setting if this function is not called. * *

PcapSetdirection() isn't necessarily fully supported on all platforms; * some platforms might return an error for all values, and some other * platforms might not support PCAP_D_OUT.

* *

This operation is not supported if a savefile is being read.

* @param pcap pcap instance. * @param direction direction. * @return returns 0 on success and -1 on failure (not supported by operating system). * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. * @since 1.1.4 */ public static native int PcapSetDirection(Pcap pcap, PcapDirection direction) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp precision returned in captures. * @param pcap pcap. * @param tstampPrecision time stamp precision. * @return 0 on success if specified time stamp precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampPrecision(Pcap pcap, int tstampPrecision) throws PcapCloseException, PlatformNotSupportedException; /** * Set the time stamp type returned in captures. * @param pcap pcap. * @param type time stamp type. * @return 0 on success if specified time type precision is expected to be supported by operating system. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapSetTStampType(Pcap pcap, int type) throws PcapCloseException, PlatformNotSupportedException; /** * Get the time stamp precision returned in captures. * @param pcap pcap instance. * @return the precision of the time stamp returned in packet captures on the pcap descriptor. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapGetTStampPrecision(Pcap pcap) throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. * @param pcap pcap instance. * @param dtlBuffer datalinks. * @return list of datalinks. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListDataLinks(Pcap pcap, List dtlBuffer) throws PcapCloseException, PlatformNotSupportedException; /** * Get link of time stamp types. * @param pcap pcap instance. * @param tstampTypesp time stamp types. * @return time stamp types. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapListTStampTypes(Pcap pcap, List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Translates a time stamp type name to the corresponding time stamp type value. The translation is case-insensitive. * @param name time stamp name. * @return returns time stamp type value on success and PCAP_ERROR on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapTStampTypeNameToVal(String name) throws PlatformNotSupportedException; /** * Translates a time stamp type value to the corresponding time stamp type name. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToName(int tstampType) throws PlatformNotSupportedException; /** * Translates a time stamp type value to a short description of that time stamp type. * @param tstampType time stamp type. * @return NULL is returned on failure. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapTStampTypeValToDescription(int tstampType) throws PlatformNotSupportedException; /** * Converts a status code value returned by a libpcap routine to an error string. * @param errnum statuc code number. * @return status string. * @throws PlatformNotSupportedException platform not supported exception. */ public static native String PcapStatusToStr(int errnum) throws PlatformNotSupportedException; /** * Used for creating a Pcap instance to use when calling the other functions. * It is typically used when just using for compiling BPF code; * it can also be used if using pcap_dump_open(), pcap_dump(), * and PcapDumpClose() to write a savefile if there is no Pcap that * supplies the packets to be written. * @param linktype specifies the link-layer type * @param snaplen specifies the snapshot length. * @param precision specifies the time stamp precision. * @return null on fail. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenDeadWithTStampPrecision(int linktype, int snaplen, int precision) throws PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw * data for the packet, check whether the packet passes the filter. * Returns the return value of the filter program, which will be zero if * the packet doesn't pass and non-zero if the packet does pass. * @param fp bpfProgram * @param h pktHdr * @param pkt buffer. * @return 0 on success. */ public static native int PcapOfflineFilter(BpfProgram fp, PcapPktHdr h, ByteBuffer pkt); /** * Called to open a savefile for reading pcap file. * @param fname specifies the file name. * @param tstampPrecision specifies the time stamp precision. * @param errbuf specifies errror buffer. * @return pcap instance. * @throws PlatformNotSupportedException platform not supported exception. */ public static native Pcap PcapOpenOfflineWithTStampPrecision(String fname, int tstampPrecision, StringBuilder errbuf) throws PlatformNotSupportedException; /** * Sends a raw packet through the network interface; buf points to the data of the packet, * including the link-layer header, and size is the number of bytes in the packet. * @param pcap pcap instance. * @param buf packet buffer. * @param size packet size. * @return PcapInject returns the number of bytes written on success and -1 on failure. * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ public static native int PcapInject(Pcap pcap, ByteBuffer buf, int size) throws PcapCloseException, PlatformNotSupportedException; /** * Check if pcap handle is alredy activated or no. * @param pcap pcap instance. * @return returns 0 if pcap handle not active yet. */ public static native int PcapCheckActivated(Pcap pcap); static { if (!loaded) { new DefaultLibraryLoader().load(new Callback() { @Override public void onSuccess(Void value) { loaded = true; } @Override public void onFailure(Throwable throwable) { LOGGER.warning(throwable.getMessage()); } }); } } } \ No newline at end of file diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index 74467c4f..2e74db5a 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -246,21 +246,21 @@ private Pcap buildLive() { new IllegalArgumentException("Error buffer should be not null.")); Pcap pcap = Jxnet.PcapCreate(source, errbuf); - if (Jxnet.PcapSetSnaplen(pcap, snaplen) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetSnaplen(pcap, snaplen) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetPromisc(pcap, promiscuousMode.getValue()) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetPromisc(pcap, promiscuousMode.getValue()) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetTimeout(pcap, timeout) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetTimeout(pcap, timeout) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } setImmediateModeAndTimeStamp(pcap); setEnableRfMon(pcap); - if (Jxnet.PcapActivate(pcap) < 0) { + if (Jxnet.PcapActivate(pcap) < Jxnet.OK) { throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetDirection(pcap, direction) != Jxnet.OK) { + if (Jxnet.PcapSetDirection(pcap, direction) < Jxnet.OK) { throw new PlatformNotSupportedException(); } setEnableNonBlock(pcap); @@ -328,14 +328,14 @@ public Pcap build(Void value) { private void setImmediateModeAndTimeStamp(Pcap pcap) throws NativeException { if (!Platforms.isWindows()) { - if (Jxnet.PcapSetImmediateMode(pcap, immediateMode.getValue()) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetImmediateMode(pcap, immediateMode.getValue()) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetTStampType(pcap, timeStampType.getValue()) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetTStampType(pcap, timeStampType.getValue()) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } - if (Jxnet.PcapSetTStampPrecision(pcap, timeStampPrecision.getValue()) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetTStampPrecision(pcap, timeStampPrecision.getValue()) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } } } @@ -344,25 +344,25 @@ private void setEnableRfMon(Pcap pcap) throws NativeException { if (enableRfMon) { if (Jxnet.PcapCanSetRfMon(pcap) == 1) { int mode = RadioFrequencyMonitorMode.RFMON.getValue(); - if (Jxnet.PcapSetRfMon(pcap, mode) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetRfMon(pcap, mode) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } } } else { - if (Jxnet.PcapSetRfMon(pcap, RadioFrequencyMonitorMode.NON_RFMON.getValue()) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetRfMon(pcap, RadioFrequencyMonitorMode.NON_RFMON.getValue()) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } } } private void setEnableNonBlock(Pcap pcap) throws NativeException { if (enableNonBlock) { - if (Jxnet.PcapSetNonBlock(pcap, 1, errbuf) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetNonBlock(pcap, 1, errbuf) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } } else { - if (Jxnet.PcapSetNonBlock(pcap, 0, errbuf) != Jxnet.OK) { - throw new NativeException(); + if (Jxnet.PcapSetNonBlock(pcap, 0, errbuf) < Jxnet.OK) { + throw new NativeException(Jxnet.PcapGetErr(pcap)); } } } diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java index 422c1cc4..82265886 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/BpfProgramCloseException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.0.0 */ -public final class BpfProgramCloseException extends RuntimeException { +public class BpfProgramCloseException extends RuntimeException { public BpfProgramCloseException() { super(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/DeviceNotFoundException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/DeviceNotFoundException.java index c31aa031..ac5619a3 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/DeviceNotFoundException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/DeviceNotFoundException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.1.5 */ -public final class DeviceNotFoundException extends RuntimeException { +public class DeviceNotFoundException extends RuntimeException { public DeviceNotFoundException() { super(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/FileCloseException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/FileCloseException.java index c9a1f35f..39c8b9bc 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/FileCloseException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/FileCloseException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.0.0 */ -public final class FileCloseException extends RuntimeException { +public class FileCloseException extends RuntimeException { public FileCloseException() { super(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java index 29dfc6a1..43edfa30 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/NativeException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.1.5 */ -public final class NativeException extends RuntimeException { +public class NativeException extends RuntimeException { public NativeException() { super(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java index 4b7b642a..6c5a521b 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapCloseException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.0.0 */ -public final class PcapCloseException extends RuntimeException { +public class PcapCloseException extends RuntimeException { public PcapCloseException() { super(); diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java index e8b9a483..45eab486 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/exception/PcapDumperCloseException.java @@ -23,7 +23,7 @@ * @author Ardika Rommy Sanjaya * @since 1.0.0 */ -public final class PcapDumperCloseException extends RuntimeException { +public class PcapDumperCloseException extends RuntimeException { public PcapDumperCloseException() { super(); diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java index 59ee259f..f818784d 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/FreakTest.java @@ -57,14 +57,6 @@ public class FreakTest { */ @Before public void create() { - StringBuilder errbuf = new StringBuilder(); - Pcap.Builder pcapBuilder = Pcap.builder() - .source(LoaderTest.getDevice()) - .immediateMode(ImmediateMode.IMMEDIATE) - .pcapType(Pcap.PcapType.LIVE) - .errbuf(errbuf); - Application.run(LoaderTest.Initializer.class, pcapBuilder, new HashMap<>()); - Application.getApplicationContext().pcapClose(); pcap = PcapOpenDead(linkType.getValue(), snaplen); if (pcap == null) { logger.warning("create:PcapOpenDead(): "); diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index cfd2745d..9c6114d5 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -150,13 +150,6 @@ public void nextPacket(String user, PcapPktHdr h, ByteBuffer bytes) { */ @Before public void create() throws Exception { - Pcap.Builder pcapBuilder = Pcap.builder() - .source(LoaderTest.getDevice()) - .immediateMode(ImmediateMode.IMMEDIATE) - .pcapType(Pcap.PcapType.LIVE) - .errbuf(errbuf); - Application.run(LoaderTest.Initializer.class, pcapBuilder, new HashMap<>()); - Application.getApplicationContext().pcapClose(); if ((resultCode = PcapFindAllDevs(alldevsp, errbuf)) != OK) { logger.warning("create:PcapFindAllDevs(): " + errbuf.toString()); } @@ -625,7 +618,9 @@ public void Test31_PcapTStampTypeNameToValPcapTStampTypeValToNameAndPcapTStampTy } System.out.println("Time stamp name : " + tsName); try { - System.out.println("Time stamp value : " + PcapTStampTypeNameToVal(tsName)); + if (tsName != null) { + System.out.println("Time stamp value : " + PcapTStampTypeNameToVal(tsName)); + } } catch (PlatformNotSupportedException e) { logger.warning(e.getMessage()); } diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java deleted file mode 100644 index be52f7e9..00000000 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/LoaderTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.ardikars.jxnet; - -import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.net.MacAddress; -import com.ardikars.common.net.NetworkInterface; -import com.ardikars.common.util.Loader; -import com.ardikars.jxnet.util.DefaultLibraryLoader; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.net.SocketException; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -@RunWith(JUnit4.class) -public class LoaderTest { - - public static final String KEY = "jxnet"; - public static final String VALUE = "ROCK!!!..."; - - public static class Initializer implements ApplicationInitializer> { - - @Override - public Loader initialize(Map additionalInformation) { - additionalInformation.put(KEY, VALUE); - return new DefaultLibraryLoader(); - } - - } - - @Test - public void test01LoadLibrary() { - Map parameter = new HashMap<>(); - StringBuilder errbuf = new StringBuilder(); - Pcap.Builder pcapBuilder = Pcap.builder() - .source(getDevice()) - .immediateMode(ImmediateMode.IMMEDIATE) - .errbuf(errbuf) - .pcapType(Pcap.PcapType.LIVE); - Application.run(Initializer.class, pcapBuilder, parameter); - Context context = Application.getApplicationContext(); - if (Application.getAdditionalInformation() instanceof Map) { - Map additionalInformation = (Map) Application.getAdditionalInformation(); - assert additionalInformation.get(KEY).equals(VALUE); - } - assert true; - } - - @Test - public void getDeviceTest() { - System.out.println("DEVICE" + getDevice()); - } - - public static String getDevice() { - Collection networkInterfaces = null; - try { - networkInterfaces = NetworkInterface.getNetworkInterfaces(); - } catch (SocketException e) { - return null; - } - for (NetworkInterface networkInterface : networkInterfaces) { - if (networkInterface.getHardwareAddress() != null && networkInterface.getHardwareAddress() instanceof MacAddress) { - MacAddress macAddress = (MacAddress) networkInterface.getHardwareAddress(); - if (!macAddress.equals(MacAddress.ZERO)) { - for (NetworkInterface.Address inetAddress : networkInterface.getAddresses()) { - if (inetAddress.getInetAddress() instanceof Inet4Address) { - Inet4Address inet4Address = (Inet4Address) inetAddress.getInetAddress(); - if (!inet4Address.equals(Inet4Address.LOCALHOST) && !inet4Address.equals(Inet4Address.ZERO)) { - return networkInterface.getName(); - } - } - } - } - } - } - return null; - } - -} diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java b/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java deleted file mode 100644 index 6ace2af9..00000000 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/Tests.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (C) 2017-2018 Ardika Rommy Sanjaya - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.net.SocketException; - -@RunWith(JUnit4.class) -public class Tests { - - @Test - public void ex() throws SocketException { - Context context = null; - Pcap.Builder pcapBuilder = null; - BpfProgram.Builder builder = null; - context.newInstance(pcapBuilder); - assert true; - } - -} From bdf57dcedf49d4b4a61f29cb2ffec924b3b89722 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Thu, 30 Aug 2018 20:30:24 +0700 Subject: [PATCH 14/16] Add spring boot integration --- .../resources/findbugs/findbugs-exclude.xml | 9 + .../java/com/ardikars/jxnet/Application.java | 84 +-- .../ardikars/jxnet/ApplicationContext.java | 18 +- .../jxnet/ApplicationInitializer.java | 30 - .../main/java/com/ardikars/jxnet/Context.java | 4 +- .../com/ardikars/jxnet/ApplicationTest.java | 13 +- .../main/java/com/ardikars/jxnet/Pcap.java | 48 +- ...ision.java => PcapTimestampPrecision.java} | 4 +- ...eStampType.java => PcapTimestampType.java} | 4 +- .../ardikars/jxnet/TimeStampPrecision.java | 56 -- .../com/ardikars/jxnet/TimeStampType.java | 64 -- .../java/com/ardikars/jxnet/JxnetTest.java | 3 +- jxnet-spring-boot-autoconfigure/build.gradle | 12 + .../spring-configuration-metadata.json | 72 ++ .../JxnetAutoConfiguration$1.class | Bin 0 -> 852 bytes .../JxnetAutoConfiguration.class | Bin 0 -> 6920 bytes .../JxnetConfigurationProperties.class | Bin 0 -> 5594 bytes .../build/docs/javadoc/allclasses-frame.html | 21 + .../docs/javadoc/allclasses-noframe.html | 21 + .../autoconfigure/JxnetAutoConfiguration.html | 331 ++++++++++ .../JxnetConfigurationProperties.html | 614 ++++++++++++++++++ .../boot/autoconfigure/package-frame.html | 22 + .../boot/autoconfigure/package-summary.html | 146 +++++ .../boot/autoconfigure/package-tree.html | 134 ++++ .../build/docs/javadoc/constant-values.html | 124 ++++ .../build/docs/javadoc/deprecated-list.html | 124 ++++ .../build/docs/javadoc/help-doc.html | 221 +++++++ .../build/docs/javadoc/index-all.html | 239 +++++++ .../build/docs/javadoc/index.html | 73 +++ .../build/docs/javadoc/overview-tree.html | 138 ++++ .../build/docs/javadoc/package-list | 1 + .../build/docs/javadoc/script.js | 30 + .../build/docs/javadoc/stylesheet.css | 574 ++++++++++++++++ .../build/poms/pom-default.xml | 78 +++ .../build/reports/checkstyle/main.html | 109 ++++ .../build/reports/checkstyle/main.xml | 7 + .../build/reports/findbugs/main.html | 146 +++++ .../build/reports/pmd/main.html | 10 + .../build/reports/pmd/main.xml | 7 + .../resources/main/META-INF/spring.factories | 2 + .../build/tmp/jar/MANIFEST.MF | 4 + .../build/tmp/javadoc/javadoc.options | 16 + .../build/tmp/javadocJar/MANIFEST.MF | 2 + .../build/tmp/sourcesJar/MANIFEST.MF | 2 + .../autoconfigure/JxnetAutoConfiguration.java | 140 ++++ .../JxnetConfigurationProperties.java | 207 ++++++ .../main/resources/META-INF/spring.factories | 2 + jxnet-spring-boot-starter/build.gradle | 10 + .../build/poms/pom-default.xml | 54 ++ .../build/tmp/jar/MANIFEST.MF | 4 + .../build/tmp/javadocJar/MANIFEST.MF | 2 + .../build/tmp/sourcesJar/MANIFEST.MF | 2 + settings.gradle | 3 + 53 files changed, 3770 insertions(+), 271 deletions(-) delete mode 100644 jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationInitializer.java rename jxnet-core/src/main/java/com/ardikars/jxnet/{PcapTimeStampPrecision.java => PcapTimestampPrecision.java} (92%) rename jxnet-core/src/main/java/com/ardikars/jxnet/{PcapTimeStampType.java => PcapTimestampType.java} (93%) delete mode 100644 jxnet-core/src/main/java/com/ardikars/jxnet/TimeStampPrecision.java delete mode 100644 jxnet-core/src/main/java/com/ardikars/jxnet/TimeStampType.java create mode 100644 jxnet-spring-boot-autoconfigure/build.gradle create mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json create mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class create mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.class create mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-frame.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js create mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css create mode 100644 jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml create mode 100644 jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html create mode 100644 jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml create mode 100644 jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html create mode 100644 jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html create mode 100644 jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml create mode 100644 jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories create mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF create mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options create mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF create mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF create mode 100644 jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java create mode 100644 jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java create mode 100644 jxnet-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories create mode 100644 jxnet-spring-boot-starter/build.gradle create mode 100644 jxnet-spring-boot-starter/build/poms/pom-default.xml create mode 100644 jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF create mode 100644 jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF create mode 100644 jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF diff --git a/gradle/resources/findbugs/findbugs-exclude.xml b/gradle/resources/findbugs/findbugs-exclude.xml index 7b92f052..96ace355 100644 --- a/gradle/resources/findbugs/findbugs-exclude.xml +++ b/gradle/resources/findbugs/findbugs-exclude.xml @@ -3,4 +3,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java index 25e2d933..d5e73786 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java @@ -17,10 +17,8 @@ package com.ardikars.jxnet; -import com.ardikars.common.util.Callback; -import com.ardikars.common.util.Loader; - -import java.util.logging.Logger; +import com.ardikars.common.util.Builder; +import com.ardikars.common.util.Validate; /** * @author Ardika Rommy Sanjaya @@ -28,80 +26,22 @@ */ public final class Application { - private static final Logger LOGGER = Logger.getLogger(Application.class.getName()); - - private boolean loaded; - private boolean developmentMode; - private static final Application instance = new Application(); private Context context; - private Object additionalInformation; - - public boolean isLoaded() { - return this.loaded; - } - - /** - * Enable development mode will be force to use default installed library on the system. - */ - public void enableDevelopmentMode() { - this.developmentMode = true; - } private Application() { } /** - * Used for bootstraping Jxnet. - * @param initializerClass initializer class. - * @param pcapBuilder pcap builder. - * @param argements additional information. - * @throws UnsatisfiedLinkError UnsatisfiedLinkError. + * Bootstraping application. + * @param builder pcap builder. */ - @SuppressWarnings("PMD.AvoidUsingNativeCode") - public static void run(Class initializerClass, final Pcap.Builder pcapBuilder, final Object argements) { - - ApplicationInitializer initializer; - Loader libraryLoaders; - try { - initializer = (ApplicationInitializer) initializerClass.newInstance(); - instance.additionalInformation = argements; - libraryLoaders = initializer.initialize(instance.additionalInformation); - } catch (InstantiationException e) { - LOGGER.warning(e.getMessage()); - return; - } catch (IllegalAccessException e) { - LOGGER.warning(e.getMessage()); - return; - } - - if (instance.developmentMode && !instance.loaded) { - try { - System.loadLibrary("jxnet"); - instance.loaded = true; - } catch (Exception e) { - instance.loaded = false; - } - } else { - if (!instance.loaded && libraryLoaders != null) { - libraryLoaders.load(new Callback() { - - @Override - public void onSuccess(Object value) { - instance.loaded = true; - instance.context = new ApplicationContext(pcapBuilder); - } - - @Override - public void onFailure(Throwable throwable) { - LOGGER.warning(throwable.getMessage()); - } - - }); - } - } + public static void run(Builder builder) { + Validate.notIllegalArgument(builder != null, + new IllegalArgumentException("Pcap builder should be not null.")); + instance.context = new ApplicationContext(builder); } /** @@ -112,12 +52,4 @@ public static Context getApplicationContext() { return instance.context; } - /** - * Get additional information. - * @return additional information. - */ - public static Object getAdditionalInformation() { - return instance.additionalInformation; - } - } diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java index 74969483..b22efbeb 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationContext.java @@ -335,11 +335,11 @@ public PcapCode pcapSetDirection(PcapDirection direction) throws PcapCloseExcept } @Override - public PcapTimeStampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException { + public PcapTimestampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException { if (Jxnet.PcapGetTStampPrecision(pcap) == 0) { - return PcapTimeStampPrecision.MICRO; + return PcapTimestampPrecision.MICRO; } - return PcapTimeStampPrecision.NANO; + return PcapTimestampPrecision.NANO; } @Override @@ -357,7 +357,7 @@ public PcapCode pcapListDataLinks(List dtlBuffer) throws PcapClose } @Override - public PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException { + public PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException { List buffers = new ArrayList<>(); int result = Jxnet.PcapListTStampTypes(pcap, buffers); if (result == 0) { @@ -365,19 +365,19 @@ public PcapCode pcapListTStampTypes(List tstampTypesp) throws for (Integer tstampType : buffers) { switch (tstampType) { case 0: - tstampTypesp.add(PcapTimeStampType.HOST); + tstampTypesp.add(PcapTimestampType.HOST); break; case 1: - tstampTypesp.add(PcapTimeStampType.HOST_LOWPREC); + tstampTypesp.add(PcapTimestampType.HOST_LOWPREC); break; case 2: - tstampTypesp.add(PcapTimeStampType.HOST_HIPREC); + tstampTypesp.add(PcapTimestampType.HOST_HIPREC); break; case 3: - tstampTypesp.add(PcapTimeStampType.ADAPTER); + tstampTypesp.add(PcapTimestampType.ADAPTER); break; case 4: - tstampTypesp.add(PcapTimeStampType.ADAPTER_UNSYNCED); + tstampTypesp.add(PcapTimestampType.ADAPTER_UNSYNCED); break; default: // do nothing diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationInitializer.java b/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationInitializer.java deleted file mode 100644 index 2c3db1d7..00000000 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/ApplicationInitializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2017-2018 Ardika Rommy Sanjaya - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -import com.ardikars.common.util.Loader; - -/** - * @author Ardika Rommy Sanjaya - * @since 1.1.5 - */ -public interface ApplicationInitializer { - - Loader initialize(T additionalInformation); - -} diff --git a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java index 201a277f..06292fa0 100644 --- a/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java +++ b/jxnet-context/src/main/java/com/ardikars/jxnet/Context.java @@ -361,7 +361,7 @@ PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ - PcapTimeStampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException; + PcapTimestampPrecision pcapGetTStampPrecision() throws PcapCloseException, PlatformNotSupportedException; /** * Get list of datalinks. @@ -379,7 +379,7 @@ PcapCode pcapCompileNoPcap(int snaplen, DataLinkType dataLinkType, String filter * @throws PcapCloseException pcap close exception. * @throws PlatformNotSupportedException platform not supported exception. */ - PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; + PcapCode pcapListTStampTypes(List tstampTypesp) throws PcapCloseException, PlatformNotSupportedException; /** * Given a BPF program, a PcapPktHdr structure for a packet, and the raw diff --git a/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java b/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java index 6232a7fc..d1c8925e 100644 --- a/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java +++ b/jxnet-context/src/test/java/com/ardikars/jxnet/ApplicationTest.java @@ -1,24 +1,13 @@ package com.ardikars.jxnet; -import com.ardikars.common.net.Inet4Address; -import com.ardikars.common.util.Hexs; -import com.ardikars.common.util.Loader; -import com.ardikars.jxnet.util.DefaultLibraryLoader; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.nio.ByteBuffer; - @RunWith(JUnit4.class) public class ApplicationTest { - static class Initializer implements ApplicationInitializer { - @Override - public Loader initialize(String arguments) { - return new DefaultLibraryLoader(); - } - } + @Test public void test() { diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java index 2e74db5a..d78ad84f 100644 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java +++ b/jxnet-core/src/main/java/com/ardikars/jxnet/Pcap.java @@ -144,17 +144,13 @@ public static final class Builder implements com.ardikars.common.util.Builder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -/** - * @author Ardika Rommy Sanjaya - * @since 1.1.4 - */ -public enum TimeStampPrecision { - - TIMESTAMP_MICRO(0), TIMESTAMP_NANO(1); - - private final int value; - - TimeStampPrecision(final int value) { - this.value = value; - } - - /** - * Get timestamp precision value; - * @return returns timestamp precision value; - */ - public int getValue() { - return this.value; - } - - /** - * Get timestamp precision. - * @param value value. - * @return returns timestamp precision. - */ - public static TimeStampPrecision valueOf(final int value) { - for (final TimeStampPrecision timeStampPrecision : values()) { - if (timeStampPrecision.getValue() == value) { - return timeStampPrecision; - } - } - return null; - } - -} diff --git a/jxnet-core/src/main/java/com/ardikars/jxnet/TimeStampType.java b/jxnet-core/src/main/java/com/ardikars/jxnet/TimeStampType.java deleted file mode 100644 index 9e128544..00000000 --- a/jxnet-core/src/main/java/com/ardikars/jxnet/TimeStampType.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2017-2018 Ardika Rommy Sanjaya - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.ardikars.jxnet; - -/** - * @author Ardika Rommy Sanjaya - * @since 1.1.5 - */ -public enum TimeStampType { - - PCAP_TSTAMP_HOST(0), - /* host-provided, unknown characteristics */ - PCAP_TSTAMP_HOST_LOWPREC(1), - /* host-provided, high precision */ - PCAP_TSTAMP_HOST_HIPREC(2), - /* device-provided, synced with the system clock */ - PCAP_TSTAMP_ADAPTER(3), - /* device-provided, not synced with the system clock */ - PCAP_TSTAMP_ADAPTER_UNSYNCED(4); - - private final int type; - - TimeStampType(final int type) { - this.type = type; - } - - /** - * Returns a time stamp type. - * @return returns time stamp type. - */ - public int getType() { - return this.type; - } - - /** - * Get time stamp type from value. - * @param type time stamp value. - * @return returns time stamp type. - */ - public static TimeStampType valueOf(final int type) { - for (final TimeStampType timeStampType : values()) { - if (timeStampType.getType() == type) { - return timeStampType; - } - } - return null; - } - -} diff --git a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java index 9c6114d5..eff4196f 100644 --- a/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java +++ b/jxnet-core/src/test/java/com/ardikars/jxnet/JxnetTest.java @@ -88,7 +88,6 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.logging.Logger; @@ -609,7 +608,7 @@ public void Test30_PcapListTStampTypes() { @Test public void Test31_PcapTStampTypeNameToValPcapTStampTypeValToNameAndPcapTStampTypeValToDescription() { - int tsVal = TimeStampType.PCAP_TSTAMP_HOST.getType(); + int tsVal = PcapTimestampType.HOST.getValue(); String tsName = null; try { tsName = PcapTStampTypeValToName(tsVal); diff --git a/jxnet-spring-boot-autoconfigure/build.gradle b/jxnet-spring-boot-autoconfigure/build.gradle new file mode 100644 index 00000000..d48b3f0a --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build.gradle @@ -0,0 +1,12 @@ + +/** + * Copyright (C) 2017-2018 Ardika Rommy Sanjaya + */ + +dependencies { + compile project(":jxnet-core") + compile project(":jxnet-context") + compile('org.slf4j:slf4j-api:1.7.25') + compile('org.springframework.boot:spring-boot-configuration-processor:2.0.4.RELEASE') + compile('org.springframework.boot:spring-boot-autoconfigure:2.0.4.RELEASE') +} diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json b/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json new file mode 100644 index 00000000..4d33c172 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json @@ -0,0 +1,72 @@ +{ + "hints": [], + "groups": [ + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet", + "type": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties" + } + ], + "properties": [ + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.blocking", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.direction", + "type": "com.ardikars.jxnet.PcapDirection" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.file", + "type": "java.lang.String" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.immediate", + "type": "com.ardikars.jxnet.ImmediateMode" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.pcap-type", + "type": "com.ardikars.jxnet.Pcap$PcapType" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.promiscuous", + "type": "com.ardikars.jxnet.PromiscuousMode" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.rfmon", + "type": "com.ardikars.jxnet.RadioFrequencyMonitorMode" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.snapshot", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.source", + "type": "java.lang.String" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.timeout", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.timestamp-precision", + "type": "com.ardikars.jxnet.PcapTimestampPrecision" + }, + { + "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", + "name": "jxnet.timestamp-type", + "type": "com.ardikars.jxnet.PcapTimestampType" + } + ] +} \ No newline at end of file diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class b/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class new file mode 100644 index 0000000000000000000000000000000000000000..1437adb187e3666932f5297ab8095d1dff906f2c GIT binary patch literal 852 zcmb_bZEF)j5PmkfWRrNcF}@^i)yDQ}6DuC#M@1}Y0@1t(DfL4?Z8m3e>Gd}3-BtZX zepW$5q(8tPCC(m|f>iW_aI-tl?94nf%-r`MUrzx%!u=9%pjre+tw`F6fvX&A2HfPh z#j(z?`E=~lIv_l!F$PcG|FP^ChN1bEChJ!5|MU-sZ#kP$GnhdKZ z#0^9^bq8vc$XUntf=OFzrET29Hba|Qc7L_(rY*bCLQ{5ktW@j@szRPs;kg$V<~(Gu zyJ6_*Rv@Ctix|r1#KZC2lQBc7IoT9!}*=^oHx@L{LZ>kirs)ju$m>$Hsp+D=xknQ0k~@Fm!EFAPDeHEYwGY`lwI`g}Oh}9pL;cYSB$<-!}o$%hVKV)KOQK@gZP0^KMdkW z_;ERZej?OELj6?4Jfz`gWq3G>YuAQ56e?S7rzez*buZo(YPEZMOlO5cFyYt<(@9yvx}h~<_k|26YV{gU zGPG-N+)Ra%3CD`}gt}}y6*AH(J7UMXt)8@FhStmbHQAw&vh4V#eqj_{y3&eUsZ|PX zwXdPvIa?J1YwW10Fs9Xtn{Da7F4Ng!bj3JB6C*}!tKnEO&Q1nWJ1rU){vVWRpuKqp z(yXeEbUbDCnOm)-#Z4OGaXaN2&pnoTE_OZE?HGOL9^2^+b(uyy8R|A7Dcji>GWr*U zMEoAhF{2c#(XT0UZ%U!V*Ik<;Mxv#AMe8nOw-JgNj7Von0@IkbVo`>2j-PqdU1Uly z67G71DSmue;bb!%rz_n}D~H{POi4TKL|k_lY9oepc^Z+*>ZUM#xJ_$v>MM-uOc{~h zjYh%^8HI%2-JCXJR=4FQm*3tw2QRH1*2BJ`><^KOD$L6FCr#|L;~~k`7XB=5h(;YV znWPs221$jf`TSmDi$vihTXEFftx#sf2&LW0gu+-)xpc~kg<7qoAZTKKZtY9t@~f_Z zcja)K5x%QdX!xCm$60v7dn0B-iU#v$O6{Csy+OTJMq=4gQd}$fAMA7i*lbD8PjSo8 zkW5`5&{SADQrIw6+_L7TGR+P9F7&B_1XI)!J3>)W78mQu-a9nC%o;i7Cd9qK9cU`DsGp^Cmj!im#kCPgnP&n6z zS#XofTODt}lN$b@-|?)Df8Z${|CG6Z;W-_r@Vt(H z<3BoHz>7Lw!pk~d!D$_5cz7wLigZ=10-7q(RjJZ+Ri?^y6;u_v($y$kjmAk`jlq*T zE>~l9HBMFP>MS)uQxkPHNp|0eHcd^|Rh7~drnM)`IO}9}f@)VsO(R;p(}+i7rc+&C zebt+Eb+($Kt8>&;T}@Nx>Z)3(>1wK`X6S0Bs?pVXYL>2MFQ#&T2~E7>Z(z#(NzA`= z+i3IZVmsOBmN?$h&A$E{e&tB~D2dq^vm?DcqY4wV(Y9k=H#;aXvy(h3*^J2Rf#lrI zTr=I{zs-)jLIuFvN2*4Xkz(%}?^T%T?;~O0ovT-X$k6H0L1Tp`U+?6t8HpxRXuZy^ zteXv>n$YvPP|H1U?>TWbfaLUqd$Qa@bt{cBggeIs$Y*52IQ+R_&0Eu^(&D<9K*T+)z8 z#H@(h0`MB*q?w@S72t@gUHw7lEkG*JpyfRJy!-PsfAD7C)7Ek>^llJ5VZ^Rx zD;{l##n=b&aGIa>@4($>*sF=0hGi)`*GOnqGTfI)?UOUJzi*gGZHD#})I!^7B-`8z ze<1EY^81Qx9GPWergx!}Z#0#8^0Id`$r<5c!|rcKhEI$OxM+Gq^A!Zf7FH)eY!>i~uV|kX5<;nV&W=W|%iAW4kiz>f z*SQ}7+W9?WZtaf70?-b#N&wQ@zNVpdU3(`rEaiz{#OU}5gYzzzWvsY??ct90g4Z4* zyd-3gM6iw-=&anEA^XL`oNx9%5PA6YKF~?4Gz5J-@Cui%z;u4HT+iEL5zdzT52;GI z$?;jj8{}qm@J%O2&3qQ|8Jv3*MRVufiQ?NhD#8~2jz%$mmmz@VC`UbB$I(QO8(VP+ zM_lJhRd_w=QcB*&r^0sZ;9AO8C;2Sl+^KmP1lmrZWZO}c)@7j0y#vJ=lx0w!;pXn3 zA_Lu{M!D0Yy}_6a#(LDa3@Sb9tPI9`)PxKsdeo#0Cf@`ta0mfPuJR_&&R~j1os+@T z`58>B4;;a{-c)r4(-$13cF6ilbO)yJPkgfK2xc6|Oof9OL$b1_DsUX<6{Ct0W@Rw@ zl0%p*bgf70LeCMpDsT*Qk73@e6jJQEvI~<*hv|xDjACfUV;w`(f_dC{89z2RqLu$P z(yeX0LAN8#P+iS1UB^Hjpd;^~^Y7u?2kGdC>EuV~;Ky+(p1|dJ8U}CFU2b?5d(Q3; z&nfa;<{EX1oLA7S5IjVmZFTdGA#@Pu4ETPW`2Kw2XQAu;`S&5nI9_lN2kMUVzYkC!khmaWQ42p;1uCDqo38Crj literal 0 HcmV?d00001 diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class b/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class new file mode 100644 index 0000000000000000000000000000000000000000..101069e5786816c81646e517ba40c8006e532bbc GIT binary patch literal 5594 zcmbW4{dXK?7017mrrnp!rg>{nA7ZUgpek`-+6Zi>!Dzl#@@d7T& z?C0|Mg*ZGfCSQ!(rcf}Q{&}NR zGI>OG&F@@Mq4^DWTjW2aVO@961YPv=+%#+)vIX`JSoZ5y<6#{7igShB8e zHoCJG9i31`sZ^AUm7cV1H*J(%J7*WBt(mf8rtguv(qCN~5(?g%qUpGnSt3zVfGoc9 zBXpY@bB)|wmhbChbd8n^a=a5fR&w+e3byN+AjWp@+AgGxU^6{pm&8-ab;>zcqCaE0 zW7RC^=>CW1W;yObb-fTtuFEme$A zns=)mdRI1*=q*+5kamyK@mghZzA5ZH$bJpC-vB`%&P%l^j1m06;&FYJK>DBn#R)X( z7oPoUh7T=0#HeZ?PG^I_YW^GhwutZOc~>0(e) z)AdX3hN5FmTMO)WUjNo{H$J1|lQ^j3WqItxt{8r!9|v5|DfX%F6(#`e`FI0ePztrj;mu46&<%>cMMl_yoKF5y0J?~4|-!* z((xzs>im+rBZjwi{26!XNMnBt@920J`*j?^$6|O-K>niR6S!5!E%JC3S2bi51@r&w zKrBkD+{2Tn*{oyuE4z!rL(NgLc@AbKj%sLK)vwlhrnXgZCye}WHmgk zp|d*^ZbU1sfmu_>qm=4U$!k15JT|VO=X%mXt>JNJGyS8(8n!8P!imDqgQG(S_Ggc1 z*rDnyVOb`X)UWDG);3rFOM((feqcH)G7Q8Rzfu$op{6FSg6TRkn#pFy`cDp@q>Ab& zYI+MBeI}bdI*{ob=Xt2a<>W%8Mjz?#8#y&_Dl;^ElCj*YV5(a^>1=3t=+x-3?C?;{ z;a3ZyobUtT6J9BlQWwXRtv(Xhn-nf&D(SD9DpX#CzKl-VNL@kmRcyS17Eep(FRi{@TLrCLwfolFJ?p97*4TeM z!FK-C;R|l6po6PUe|1xZb{DbPUv*WmnX4_!XzE?JgpX9Ph0CqW1kx(lDnVEW3BokG z`0PWBFW!s+Y{OAjyU#IZ$637YVHi$uH_PV`zJw8&xEJ#n!#RxONlf4w+=mOepa0Z7 zfM4T_cnuHYGEQL$U&d8TVi`HSPp!lB;s^O!HOK?pX+d*yOFWh8O0^_XsZ?_lz554q zjH5=5<9ybh;UaFn#2*_xeE$q*L*~~9XP6Uy#G@e3DnY)$+)><-cogJ0f?TKrA~jP$9%QDj1xZFh zo>zjLV&W=5l2MQs2y(Fwh!kxBF<1cBf^3e0yr=}pVM+zEISTR;L0+x{B3(m3OxC%z zAX}m!uP8xgFslOD5(RmkAaB$Gk+vlu7EUWbI-?+$lpu4gyo#ggjDjo@q*4b&`lf*7 zQK;Iw(_4d$g3aj)KDvZ$QJkd^PE$}{ZFLgsQJi;(^KKm+Y2SiVR2KTJQIM-4kkvx} zkh;)&UCwV4exd(6LH + + + + + +All Classes (Jxnet 1.4.0.RC1) + + + + + +

All Classes

+ + + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html new file mode 100644 index 00000000..43ff8be1 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html @@ -0,0 +1,21 @@ + + + + + + +All Classes (Jxnet 1.4.0.RC1) + + + + + +

All Classes

+ + + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html new file mode 100644 index 00000000..c988170b --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html @@ -0,0 +1,331 @@ + + + + + + +JxnetAutoConfiguration (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + + +
+
com.ardikars.jxnet.spring.boot.autoconfigure
+

Class JxnetAutoConfiguration

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
    • +
    +
  • +
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      com.ardikars.jxnet.Contextcontext(com.ardikars.jxnet.PcapIf pcapIf, + java.lang.StringBuilder errbuf) +
      Jxnet application context.
      +
      java.lang.StringBuildererrbuf() 
      com.ardikars.jxnet.PcapIfpcapIf(java.lang.StringBuilder errbuf) +
      Pcap if (source).
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        context

        +
        @Bean(value="com.ardikars.jxnet.contex")
        +public com.ardikars.jxnet.Context context(com.ardikars.jxnet.PcapIf pcapIf,
        +                                                                                   @Qualifier(value="com.ardikars.jxnet.errbuf")
        +                                                                                   java.lang.StringBuilder errbuf)
        +
        Jxnet application context.
        +
        +
        Parameters:
        +
        pcapIf - pcap if.
        +
        errbuf - error buffer.
        +
        Returns:
        +
        returns application context.
        +
        +
      • +
      + + + +
        +
      • +

        pcapIf

        +
        @Bean
        +public com.ardikars.jxnet.PcapIf pcapIf(@Qualifier(value="com.ardikars.jxnet.errbuf")
        +                                              java.lang.StringBuilder errbuf)
        +                                       throws com.ardikars.jxnet.exception.DeviceNotFoundException
        +
        Pcap if (source).
        +
        +
        Parameters:
        +
        errbuf - error buffer.
        +
        Returns:
        +
        pcap_if.
        +
        Throws:
        +
        com.ardikars.jxnet.exception.DeviceNotFoundException - device not found exception.
        +
        +
      • +
      + + + +
        +
      • +

        errbuf

        +
        @Bean(value="com.ardikars.jxnet.errbuf")
        +public java.lang.StringBuilder errbuf()
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html new file mode 100644 index 00000000..360eb48c --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html @@ -0,0 +1,614 @@ + + + + + + +JxnetConfigurationProperties (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + + +
+
com.ardikars.jxnet.spring.boot.autoconfigure
+

Class JxnetConfigurationProperties

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
    • +
    +
  • +
+
+
    +
  • +
    +
    +
    @ConfigurationProperties(prefix="jxnet")
    +public class JxnetConfigurationProperties
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.lang.BooleangetBlocking() 
      com.ardikars.jxnet.DataLinkTypegetDatalink() 
      com.ardikars.jxnet.PcapDirectiongetDirection() 
      java.lang.StringgetFile() 
      com.ardikars.jxnet.ImmediateModegetImmediate() 
      com.ardikars.jxnet.Pcap.PcapTypegetPcapType() 
      com.ardikars.jxnet.PromiscuousModegetPromiscuous() 
      com.ardikars.jxnet.RadioFrequencyMonitorModegetRfmon() 
      java.lang.IntegergetSnapshot() 
      java.lang.StringgetSource() 
      java.lang.IntegergetTimeout() 
      com.ardikars.jxnet.PcapTimestampPrecisiongetTimestampPrecision() 
      com.ardikars.jxnet.PcapTimestampTypegetTimestampType() 
      voidinitialize() +
      Initialze field.
      +
      voidsetBlocking(java.lang.Boolean blocking) 
      voidsetDatalink(java.lang.Integer datalink) 
      voidsetDirection(com.ardikars.jxnet.PcapDirection direction) 
      voidsetFile(java.lang.String file) 
      voidsetImmediate(com.ardikars.jxnet.ImmediateMode immediate) 
      voidsetPcapType(com.ardikars.jxnet.Pcap.PcapType pcapType) 
      voidsetPromiscuous(com.ardikars.jxnet.PromiscuousMode promiscuous) 
      voidsetRfmon(com.ardikars.jxnet.RadioFrequencyMonitorMode rfmon) 
      voidsetSnapshot(java.lang.Integer snapshot) 
      voidsetSource(java.lang.String source) 
      voidsetTimeout(java.lang.Integer timeout) 
      voidsetTimestampPrecision(com.ardikars.jxnet.PcapTimestampPrecision timestampPrecision) 
      voidsetTimestampType(com.ardikars.jxnet.PcapTimestampType timestampType) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        JxnetConfigurationProperties

        +
        public JxnetConfigurationProperties()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        initialize

        +
        @PostConstruct
        +public void initialize()
        +
        Initialze field.
        +
      • +
      + + + +
        +
      • +

        getSource

        +
        public java.lang.String getSource()
        +
      • +
      + + + +
        +
      • +

        setSource

        +
        public void setSource(java.lang.String source)
        +
      • +
      + + + +
        +
      • +

        getSnapshot

        +
        public java.lang.Integer getSnapshot()
        +
      • +
      + + + +
        +
      • +

        setSnapshot

        +
        public void setSnapshot(java.lang.Integer snapshot)
        +
      • +
      + + + +
        +
      • +

        getPromiscuous

        +
        public com.ardikars.jxnet.PromiscuousMode getPromiscuous()
        +
      • +
      + + + +
        +
      • +

        setPromiscuous

        +
        public void setPromiscuous(com.ardikars.jxnet.PromiscuousMode promiscuous)
        +
      • +
      + + + +
        +
      • +

        getTimeout

        +
        public java.lang.Integer getTimeout()
        +
      • +
      + + + +
        +
      • +

        setTimeout

        +
        public void setTimeout(java.lang.Integer timeout)
        +
      • +
      + + + +
        +
      • +

        getImmediate

        +
        public com.ardikars.jxnet.ImmediateMode getImmediate()
        +
      • +
      + + + +
        +
      • +

        setImmediate

        +
        public void setImmediate(com.ardikars.jxnet.ImmediateMode immediate)
        +
      • +
      + + + +
        +
      • +

        getTimestampType

        +
        public com.ardikars.jxnet.PcapTimestampType getTimestampType()
        +
      • +
      + + + +
        +
      • +

        setTimestampType

        +
        public void setTimestampType(com.ardikars.jxnet.PcapTimestampType timestampType)
        +
      • +
      + + + +
        +
      • +

        getTimestampPrecision

        +
        public com.ardikars.jxnet.PcapTimestampPrecision getTimestampPrecision()
        +
      • +
      + + + +
        +
      • +

        setTimestampPrecision

        +
        public void setTimestampPrecision(com.ardikars.jxnet.PcapTimestampPrecision timestampPrecision)
        +
      • +
      + + + +
        +
      • +

        getRfmon

        +
        public com.ardikars.jxnet.RadioFrequencyMonitorMode getRfmon()
        +
      • +
      + + + +
        +
      • +

        setRfmon

        +
        public void setRfmon(com.ardikars.jxnet.RadioFrequencyMonitorMode rfmon)
        +
      • +
      + + + +
        +
      • +

        getBlocking

        +
        public java.lang.Boolean getBlocking()
        +
      • +
      + + + +
        +
      • +

        setBlocking

        +
        public void setBlocking(java.lang.Boolean blocking)
        +
      • +
      + + + +
        +
      • +

        getDirection

        +
        public com.ardikars.jxnet.PcapDirection getDirection()
        +
      • +
      + + + +
        +
      • +

        setDirection

        +
        public void setDirection(com.ardikars.jxnet.PcapDirection direction)
        +
      • +
      + + + +
        +
      • +

        getDatalink

        +
        public com.ardikars.jxnet.DataLinkType getDatalink()
        +
      • +
      + + + +
        +
      • +

        setDatalink

        +
        public void setDatalink(java.lang.Integer datalink)
        +
      • +
      + + + +
        +
      • +

        getFile

        +
        public java.lang.String getFile()
        +
      • +
      + + + +
        +
      • +

        setFile

        +
        public void setFile(java.lang.String file)
        +
      • +
      + + + +
        +
      • +

        getPcapType

        +
        public com.ardikars.jxnet.Pcap.PcapType getPcapType()
        +
      • +
      + + + +
        +
      • +

        setPcapType

        +
        public void setPcapType(com.ardikars.jxnet.Pcap.PcapType pcapType)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html new file mode 100644 index 00000000..5f3a1156 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html @@ -0,0 +1,22 @@ + + + + + + +com.ardikars.jxnet.spring.boot.autoconfigure (Jxnet 1.4.0.RC1) + + + + + +

com.ardikars.jxnet.spring.boot.autoconfigure

+ + + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html new file mode 100644 index 00000000..c01800c7 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html @@ -0,0 +1,146 @@ + + + + + + +com.ardikars.jxnet.spring.boot.autoconfigure (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

Package com.ardikars.jxnet.spring.boot.autoconfigure

+
+
+ +
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html new file mode 100644 index 00000000..78f988ed --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html @@ -0,0 +1,134 @@ + + + + + + +com.ardikars.jxnet.spring.boot.autoconfigure Class Hierarchy (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

Hierarchy For Package com.ardikars.jxnet.spring.boot.autoconfigure

+
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html new file mode 100644 index 00000000..524aa081 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html @@ -0,0 +1,124 @@ + + + + + + +Constant Field Values (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

Constant Field Values

+

Contents

+
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html new file mode 100644 index 00000000..aaef550b --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html @@ -0,0 +1,124 @@ + + + + + + +Deprecated List (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html new file mode 100644 index 00000000..46935344 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html @@ -0,0 +1,221 @@ + + + + + + +API Help (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html new file mode 100644 index 00000000..a544e677 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html @@ -0,0 +1,239 @@ + + + + + + +Index (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
C E G I J P S  + + +

C

+
+
com.ardikars.jxnet.spring.boot.autoconfigure - package com.ardikars.jxnet.spring.boot.autoconfigure
+
 
+
context(PcapIf, StringBuilder) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
+
+
Jxnet application context.
+
+
+ + + +

E

+
+
errbuf() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
+
 
+
+ + + +

G

+
+
getBlocking() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getDatalink() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getDirection() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getFile() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getImmediate() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getPcapType() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getPromiscuous() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getRfmon() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getSnapshot() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getSource() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getTimeout() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getTimestampPrecision() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
getTimestampType() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
+ + + +

I

+
+
initialize() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
+
Initialze field.
+
+
+ + + +

J

+
+
JxnetAutoConfiguration - Class in com.ardikars.jxnet.spring.boot.autoconfigure
+
 
+
JxnetAutoConfiguration(JxnetConfigurationProperties) - Constructor for class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
+
 
+
JxnetConfigurationProperties - Class in com.ardikars.jxnet.spring.boot.autoconfigure
+
 
+
JxnetConfigurationProperties() - Constructor for class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
+ + + +

P

+
+
pcapIf(StringBuilder) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
+
+
Pcap if (source).
+
+
+ + + +

S

+
+
setBlocking(Boolean) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setDatalink(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setDirection(PcapDirection) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setFile(String) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setImmediate(ImmediateMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setPcapType(Pcap.PcapType) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setPromiscuous(PromiscuousMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setRfmon(RadioFrequencyMonitorMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setSnapshot(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setSource(String) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setTimeout(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setTimestampPrecision(PcapTimestampPrecision) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
setTimestampType(PcapTimestampType) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
+
 
+
+C E G I J P S 
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html new file mode 100644 index 00000000..e8ee7eec --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html @@ -0,0 +1,73 @@ + + + + + + +Jxnet 1.4.0.RC1 + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html">Non-frame version</a>.</p> + + + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html new file mode 100644 index 00000000..66341ce9 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html @@ -0,0 +1,138 @@ + + + + + + +Class Hierarchy (Jxnet 1.4.0.RC1) + + + + + + + + +
+ + + + + + + +
Jxnet 1.4.0.RC1
+
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + + + +
https://github.com/jxnet/Jxnet
+
+ + +

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list new file mode 100644 index 00000000..be0d934a --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list @@ -0,0 +1 @@ +com.ardikars.jxnet.spring.boot.autoconfigure diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js new file mode 100644 index 00000000..b3463569 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css new file mode 100644 index 00000000..98055b22 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml b/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml new file mode 100644 index 00000000..c1d78bec --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + com.ardikars.jxnet + jxnet-spring-boot-autoconfigure + 1.4.0.RC1 + Jxnet + Jxnet is a java library for capturing and sending network paket. + https://github.com/jxnet/Jxnet + + ardikars + http://ardikars.com + + + + GNU Lesser General Public License, Version 3.0 + http://www.gnu.org/licenses + repo + + + + + ardikars + Ardika Rommy Sanjaya + contact@ardikars.com + + + + scm:git:https://github.com/jxnet/Jxnet.git + scm:git:git@github.com/jxnet/Jxnet.git + https://github.com/jxnet/Jxnet.git + + + + com.ardikars.common + common-net + 1.2.0.RC2 + compile + + + com.ardikars.common + common-util + 1.2.0.RC2 + compile + + + com.ardikars.jxnet + jxnet-core + 1.4.0.RC1 + compile + + + com.ardikars.jxnet + jxnet-context + 1.4.0.RC1 + compile + + + org.slf4j + slf4j-api + 1.7.25 + compile + + + org.springframework.boot + spring-boot-configuration-processor + 2.0.4.RELEASE + compile + + + org.springframework.boot + spring-boot-autoconfigure + 2.0.4.RELEASE + compile + + + diff --git a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html new file mode 100644 index 00000000..4933873f --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + +
+

CheckStyle Audit

+
Designed for use with CheckStyle and Ant.
+
+

Summary

+ + + + + + + +
FilesErrors
20
+
+

Files

+ + + + + + + + + + +
NameErrors
/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java0
/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java0
+
+ +

File /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java

+ + + + +
Error DescriptionLine
+Back to top +

File /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java

+ + + + +
Error DescriptionLine
+Back to top +
+ + diff --git a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml new file mode 100644 index 00000000..4c4ac6a7 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html b/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html new file mode 100644 index 00000000..2a382343 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html @@ -0,0 +1,146 @@ + + + +SpotBugs Report + + + + +

+SpotBugs Report

+

Project Information

+

Project: +

+

SpotBugs version: 3.1.5

+

Code analyzed:

+
    +
  • /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/classes/java/main
  • +
+

+
+
+

+

Metrics

+

166 lines of code analyzed, + in 3 classes, + in 1 packages.

+ + + + + + + + + + + + + + + + + + + +
MetricTotalDensity*
High Priority Warnings +0.00
Medium Priority Warnings +0.00
+Total Warnings + +0 + +0.00 +
+

+(* Defects per Thousand lines of non-commenting source statements) +

+

+
+
+

+

Contents

+ +

Summary

+ + + + + + + + + +
Warning TypeNumber
+Total + +0 +
+

Warnings

+

Click on a warning row to see full context information.

+

+Details +

+ + diff --git a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html new file mode 100644 index 00000000..faeb4ba5 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html @@ -0,0 +1,10 @@ +PMD +

PMD report

Problems found

+ +
#FileLineProblem

Configuration errors

+ + + + + +
RuleProblem
LoosePackageCouplingNo packages or classes specified
diff --git a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml new file mode 100644 index 00000000..bce089df --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml @@ -0,0 +1,7 @@ + + + + diff --git a/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories b/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories new file mode 100644 index 00000000..6822fc13 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration \ No newline at end of file diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF new file mode 100644 index 00000000..73d59646 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Implementation-Title: Jxnet +Implementation-Version: 1.4.0.RC1 + diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options b/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options new file mode 100644 index 00000000..672806bf --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options @@ -0,0 +1,16 @@ +-locale 'en_US' +-Xdoclint:all,-reference '-quiet' +-author +-bottom 'Copyright © 2015 - 2018 ardikars.com. All rights reserved.' +-charset 'UTF-8' +-classpath '/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/classes/java/main:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/resources/main:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-context/build/libs/jxnet-context-1.4.0.RC1.jar:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-core/build/libs/jxnet-core-1.4.0.RC1.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-net/1.2.0.RC2/13aac17732209ff9399218a7f064e66fdbaadd50/common-net-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-util/1.2.0.RC2/6095fa2d4d3363d6095c309d21ba2b36727024fb/common-util-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-configuration-processor/2.0.4.RELEASE/dcaf863e151e728debbf37cf024e7b698ea92281/spring-boot-configuration-processor-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.0.4.RELEASE/65cd1244d606acc02ab7bfc47a203a3fe2400dda/spring-boot-autoconfigure-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-annotation/1.2.0.RC2/14b8d39ee970692ccf9410d7356fdef0e166f758/common-annotation-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.0.4.RELEASE/c8619c5b06d4dcdb4cac1e5e9c839e6e8b1c8574/spring-boot-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.0.8.RELEASE/3a067d8990761111c9b6d1d895640be26cc1fb38/spring-context-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.0.8.RELEASE/f5086c1a3185c481104511837427b39a07a57aa2/spring-aop-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.0.8.RELEASE/5fc965d3e7f5515099244857a8ae9e2a208c169b/spring-beans-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.0.8.RELEASE/f23158f22c917df2cddf2ecebc398a9e95f95fae/spring-expression-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.8.RELEASE/dc39c49e3246cdf73d3786ac41119140aed3fa08/spring-core-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.0.8.RELEASE/a1fa8fb560fb252321776e16bc9ac8201af4ef5e/spring-jcl-5.0.8.RELEASE.jar' +-d '/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/docs/javadoc' +-doctitle 'Jxnet 1.4.0.RC1 API Documentation' +-encoding 'UTF-8' +-footer 'https://github.com/jxnet/Jxnet' +-header 'Jxnet 1.4.0.RC1' +-protected +-quiet +-windowtitle 'Jxnet 1.4.0.RC1' +'/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java' +'/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java' diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF new file mode 100644 index 00000000..58630c02 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF new file mode 100644 index 00000000..58630c02 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java new file mode 100644 index 00000000..847798cc --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java @@ -0,0 +1,140 @@ +/** + * Copyright (C) 2017-2018 Ardika Rommy Sanjaya + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.ardikars.jxnet.spring.boot.autoconfigure; + +import static com.ardikars.jxnet.Jxnet.OK; +import static com.ardikars.jxnet.Jxnet.PCAP_ERRBUF_SIZE; +import static com.ardikars.jxnet.Jxnet.PcapFindAllDevs; + +import com.ardikars.common.net.Inet4Address; +import com.ardikars.jxnet.Application; +import com.ardikars.jxnet.Context; +import com.ardikars.jxnet.Pcap; +import com.ardikars.jxnet.PcapAddr; +import com.ardikars.jxnet.PcapIf; +import com.ardikars.jxnet.SockAddr; +import com.ardikars.jxnet.exception.DeviceNotFoundException; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfigureOrder; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; + +@Configuration +@ConditionalOnClass(JxnetConfigurationProperties.class) +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@EnableConfigurationProperties(JxnetConfigurationProperties.class) +public class JxnetAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory.getLogger(JxnetAutoConfiguration.class.getName()); + + private final JxnetConfigurationProperties properties; + + @Autowired + public JxnetAutoConfiguration(JxnetConfigurationProperties properties) { + this.properties = properties; + } + + /** + * Jxnet application context. + * @param pcapIf pcap if. + * @param errbuf error buffer. + * @return returns application context. + */ + @Bean("com.ardikars.jxnet.contex") + public Context context(PcapIf pcapIf, + @Qualifier("com.ardikars.jxnet.errbuf") StringBuilder errbuf) { + String source = pcapIf.getName(); + Pcap.Builder builder = new Pcap.Builder() + .source(source) + .snaplen(properties.getSnapshot()) + .promiscuousMode(properties.getPromiscuous()) + .timeout(properties.getTimeout()) + .immediateMode(properties.getImmediate()) + .timestampType(properties.getTimestampType()) + .timestampPrecision(properties.getTimestampPrecision()) + .rfmon(properties.getRfmon()) + .enableNonBlock(!properties.getBlocking()) + .dataLinkType(properties.getDatalink()) + .fileName(properties.getFile()) + .errbuf(errbuf); + switch (properties.getPcapType()) { + case DEAD: + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Opening pcap dead handler : {}", builder); + } + builder.pcapType(Pcap.PcapType.DEAD); + break; + case OFFLINE: + builder.pcapType(Pcap.PcapType.OFFLINE); + break; + default: + builder.pcapType(Pcap.PcapType.LIVE); + break; + } + Application.run(builder); + return Application.getApplicationContext(); + } + + /** + * Pcap if (source). + * @param errbuf error buffer. + * @return pcap_if. + * @throws DeviceNotFoundException device not found exception. + */ + @Bean + public PcapIf pcapIf(@Qualifier("com.ardikars.jxnet.errbuf") StringBuilder errbuf) throws DeviceNotFoundException { + String source = properties.getSource(); + List alldevsp = new ArrayList<>(); + if (PcapFindAllDevs(alldevsp, errbuf) != OK && LOGGER.isDebugEnabled()) { + LOGGER.debug("Error: {}", errbuf.toString()); + } + if (source == null || source.isEmpty()) { + for (PcapIf dev : alldevsp) { + for (PcapAddr addr : dev.getAddresses()) { + if (addr.getAddr().getSaFamily() == SockAddr.Family.AF_INET && addr.getAddr().getData() != null) { + Inet4Address d = Inet4Address.valueOf(addr.getAddr().getData()); + if (!d.equals(Inet4Address.LOCALHOST) && !d.equals(Inet4Address.ZERO)) { + return dev; + } + } + } + } + } else { + for (PcapIf dev : alldevsp) { + if (dev.getName().equals(source)) { + return dev; + } + } + } + throw new DeviceNotFoundException(""); + } + + @Bean("com.ardikars.jxnet.errbuf") + public StringBuilder errbuf() { + return new StringBuilder(PCAP_ERRBUF_SIZE); + } + +} diff --git a/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java new file mode 100644 index 00000000..af4fc32f --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java @@ -0,0 +1,207 @@ +/** + * Copyright (C) 2017-2018 Ardika Rommy Sanjaya + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.ardikars.jxnet.spring.boot.autoconfigure; + +import com.ardikars.jxnet.DataLinkType; +import com.ardikars.jxnet.ImmediateMode; +import com.ardikars.jxnet.Pcap; +import com.ardikars.jxnet.PcapDirection; +import com.ardikars.jxnet.PcapTimestampPrecision; +import com.ardikars.jxnet.PcapTimestampType; +import com.ardikars.jxnet.PromiscuousMode; +import com.ardikars.jxnet.RadioFrequencyMonitorMode; +import javax.annotation.PostConstruct; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "jxnet") +public class JxnetConfigurationProperties { + + private String source; + + private Integer snapshot; + + private PromiscuousMode promiscuous; + + private Integer timeout; + + private ImmediateMode immediate; + + private PcapTimestampType timestampType; + + private PcapTimestampPrecision timestampPrecision; + + private RadioFrequencyMonitorMode rfmon; + + private Boolean blocking; + + private PcapDirection direction; + + private Integer datalink; + + private String file; + + private Pcap.PcapType pcapType; + + /** + * Initialze field. + */ + @PostConstruct + public void initialize() { + if (pcapType == null) { + pcapType = Pcap.PcapType.LIVE; + } + if (snapshot == null || snapshot <= 0) { + snapshot = 65535; + } + if (timestampType == null) { + timestampType = PcapTimestampType.HOST; + } + if (timestampPrecision == null) { + timestampPrecision = PcapTimestampPrecision.MICRO; + } + if (datalink == null) { + datalink = (int) DataLinkType.EN10MB.getValue(); + } + if (promiscuous == null) { + promiscuous = PromiscuousMode.PRIMISCUOUS; + } + if (timeout == null || timeout <= 0) { + timeout = 2000; + } + if (immediate == null) { + immediate = ImmediateMode.IMMEDIATE; + } + if (direction == null) { + direction = PcapDirection.PCAP_D_INOUT; + } + if (rfmon == null) { + rfmon = RadioFrequencyMonitorMode.NON_RFMON; + } + if (blocking == null) { + blocking = false; + } + if (file == null) { + file = null; + } + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public Integer getSnapshot() { + return snapshot; + } + + public void setSnapshot(Integer snapshot) { + this.snapshot = snapshot; + } + + public PromiscuousMode getPromiscuous() { + return promiscuous; + } + + public void setPromiscuous(PromiscuousMode promiscuous) { + this.promiscuous = promiscuous; + } + + public Integer getTimeout() { + return timeout; + } + + public void setTimeout(Integer timeout) { + this.timeout = timeout; + } + + public ImmediateMode getImmediate() { + return immediate; + } + + public void setImmediate(ImmediateMode immediate) { + this.immediate = immediate; + } + + public PcapTimestampType getTimestampType() { + return timestampType; + } + + public void setTimestampType(PcapTimestampType timestampType) { + this.timestampType = timestampType; + } + + public PcapTimestampPrecision getTimestampPrecision() { + return timestampPrecision; + } + + public void setTimestampPrecision(PcapTimestampPrecision timestampPrecision) { + this.timestampPrecision = timestampPrecision; + } + + public RadioFrequencyMonitorMode getRfmon() { + return rfmon; + } + + public void setRfmon(RadioFrequencyMonitorMode rfmon) { + this.rfmon = rfmon; + } + + public Boolean getBlocking() { + return blocking; + } + + public void setBlocking(Boolean blocking) { + this.blocking = blocking; + } + + public PcapDirection getDirection() { + return direction; + } + + public void setDirection(PcapDirection direction) { + this.direction = direction; + } + + public DataLinkType getDatalink() { + return DataLinkType.valueOf(datalink.shortValue()); + } + + public void setDatalink(Integer datalink) { + this.datalink = datalink; + } + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public Pcap.PcapType getPcapType() { + return pcapType; + } + + public void setPcapType(Pcap.PcapType pcapType) { + this.pcapType = pcapType; + } + +} diff --git a/jxnet-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/jxnet-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000..6822fc13 --- /dev/null +++ b/jxnet-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration \ No newline at end of file diff --git a/jxnet-spring-boot-starter/build.gradle b/jxnet-spring-boot-starter/build.gradle new file mode 100644 index 00000000..7d3e9739 --- /dev/null +++ b/jxnet-spring-boot-starter/build.gradle @@ -0,0 +1,10 @@ + +/** + * Copyright (C) 2017-2018 Ardika Rommy Sanjaya + */ + +description = "Jxnet spring boot starter" + +dependencies { + compile project(":jxnet-spring-boot-autoconfigure") +} diff --git a/jxnet-spring-boot-starter/build/poms/pom-default.xml b/jxnet-spring-boot-starter/build/poms/pom-default.xml new file mode 100644 index 00000000..1a0600a6 --- /dev/null +++ b/jxnet-spring-boot-starter/build/poms/pom-default.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + com.ardikars.jxnet + jxnet-spring-boot-starter + 1.4.0.RC1 + Jxnet + Jxnet is a java library for capturing and sending network paket. + https://github.com/jxnet/Jxnet + + ardikars + http://ardikars.com + + + + GNU Lesser General Public License, Version 3.0 + http://www.gnu.org/licenses + repo + + + + + ardikars + Ardika Rommy Sanjaya + contact@ardikars.com + + + + scm:git:https://github.com/jxnet/Jxnet.git + scm:git:git@github.com/jxnet/Jxnet.git + https://github.com/jxnet/Jxnet.git + + + + com.ardikars.common + common-net + 1.2.0.RC2 + compile + + + com.ardikars.common + common-util + 1.2.0.RC2 + compile + + + com.ardikars.jxnet + jxnet-spring-boot-autoconfigure + 1.4.0.RC1 + compile + + + diff --git a/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF new file mode 100644 index 00000000..73d59646 --- /dev/null +++ b/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Implementation-Title: Jxnet +Implementation-Version: 1.4.0.RC1 + diff --git a/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF new file mode 100644 index 00000000..58630c02 --- /dev/null +++ b/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF new file mode 100644 index 00000000..58630c02 --- /dev/null +++ b/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/settings.gradle b/settings.gradle index a32362d2..a4864c83 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,3 +3,6 @@ rootProject.name = 'jxnet' include 'jxnet-native' include 'jxnet-context' include 'jxnet-core' +include 'jxnet-spring-boot-autoconfigure' +include 'jxnet-spring-boot-starter' + From 06fa7917b5960caa4cf779fb75d904e65995b28c Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Thu, 30 Aug 2018 20:33:00 +0700 Subject: [PATCH 15/16] Update .gitignore --- .gitignore | 16 +- .../spring-configuration-metadata.json | 72 -- .../JxnetAutoConfiguration$1.class | Bin 852 -> 0 bytes .../JxnetAutoConfiguration.class | Bin 6920 -> 0 bytes .../JxnetConfigurationProperties.class | Bin 5594 -> 0 bytes .../build/docs/javadoc/allclasses-frame.html | 21 - .../docs/javadoc/allclasses-noframe.html | 21 - .../autoconfigure/JxnetAutoConfiguration.html | 331 ---------- .../JxnetConfigurationProperties.html | 614 ------------------ .../boot/autoconfigure/package-frame.html | 22 - .../boot/autoconfigure/package-summary.html | 146 ----- .../boot/autoconfigure/package-tree.html | 134 ---- .../build/docs/javadoc/constant-values.html | 124 ---- .../build/docs/javadoc/deprecated-list.html | 124 ---- .../build/docs/javadoc/help-doc.html | 221 ------- .../build/docs/javadoc/index-all.html | 239 ------- .../build/docs/javadoc/index.html | 73 --- .../build/docs/javadoc/overview-tree.html | 138 ---- .../build/docs/javadoc/package-list | 1 - .../build/docs/javadoc/script.js | 30 - .../build/docs/javadoc/stylesheet.css | 574 ---------------- .../build/poms/pom-default.xml | 78 --- .../build/reports/checkstyle/main.html | 109 ---- .../build/reports/checkstyle/main.xml | 7 - .../build/reports/findbugs/main.html | 146 ----- .../build/reports/pmd/main.html | 10 - .../build/reports/pmd/main.xml | 7 - .../resources/main/META-INF/spring.factories | 2 - .../build/tmp/jar/MANIFEST.MF | 4 - .../build/tmp/javadoc/javadoc.options | 16 - .../build/tmp/javadocJar/MANIFEST.MF | 2 - .../build/tmp/sourcesJar/MANIFEST.MF | 2 - .../build/poms/pom-default.xml | 54 -- .../build/tmp/jar/MANIFEST.MF | 4 - .../build/tmp/javadocJar/MANIFEST.MF | 2 - .../build/tmp/sourcesJar/MANIFEST.MF | 2 - 36 files changed, 8 insertions(+), 3338 deletions(-) delete mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json delete mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class delete mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.class delete mode 100644 jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-frame.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js delete mode 100644 jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css delete mode 100644 jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml delete mode 100644 jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml delete mode 100644 jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html delete mode 100644 jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml delete mode 100644 jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories delete mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF delete mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options delete mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF delete mode 100644 jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF delete mode 100644 jxnet-spring-boot-starter/build/poms/pom-default.xml delete mode 100644 jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF delete mode 100644 jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF delete mode 100644 jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF diff --git a/.gitignore b/.gitignore index a9a46ad2..4159c1fd 100644 --- a/.gitignore +++ b/.gitignore @@ -44,14 +44,14 @@ a.out /jxnet-core/build /jxnet-core/target /jxnet-core/out -/jxnet-static/.gradle -/jxnet-static/build -/jxnet-static/target -/jxnet-static/out -/jxnet-dynamic/.gradle -/jxnet-dynamic/build -/jxnet-dynamic/target -/jxnet-dynamic/out +/jxnet-spring-boot-autoconfigure/.gradle +/jxnet-spring-boot-autoconfigure/build/ +/jxnet-spring-boot-autoconfigure/target +/jxnet-spring-boot-autoconfigure/out +/jxnet-spring-boot-starter/.gradle +/jxnet-spring-boot-starter/build/ +/jxnet-spring-boot-starter/target +/jxnet-spring-boot-starter/out /jxnet-android/.gradle /jxnet-android/build/ /jxnet-android/target diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json b/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json deleted file mode 100644 index 4d33c172..00000000 --- a/jxnet-spring-boot-autoconfigure/build/classes/java/main/META-INF/spring-configuration-metadata.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "hints": [], - "groups": [ - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet", - "type": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties" - } - ], - "properties": [ - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.blocking", - "type": "java.lang.Boolean" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.direction", - "type": "com.ardikars.jxnet.PcapDirection" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.file", - "type": "java.lang.String" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.immediate", - "type": "com.ardikars.jxnet.ImmediateMode" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.pcap-type", - "type": "com.ardikars.jxnet.Pcap$PcapType" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.promiscuous", - "type": "com.ardikars.jxnet.PromiscuousMode" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.rfmon", - "type": "com.ardikars.jxnet.RadioFrequencyMonitorMode" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.snapshot", - "type": "java.lang.Integer" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.source", - "type": "java.lang.String" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.timeout", - "type": "java.lang.Integer" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.timestamp-precision", - "type": "com.ardikars.jxnet.PcapTimestampPrecision" - }, - { - "sourceType": "com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties", - "name": "jxnet.timestamp-type", - "type": "com.ardikars.jxnet.PcapTimestampType" - } - ] -} \ No newline at end of file diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class b/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration$1.class deleted file mode 100644 index 1437adb187e3666932f5297ab8095d1dff906f2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 852 zcmb_bZEF)j5PmkfWRrNcF}@^i)yDQ}6DuC#M@1}Y0@1t(DfL4?Z8m3e>Gd}3-BtZX zepW$5q(8tPCC(m|f>iW_aI-tl?94nf%-r`MUrzx%!u=9%pjre+tw`F6fvX&A2HfPh z#j(z?`E=~lIv_l!F$PcG|FP^ChN1bEChJ!5|MU-sZ#kP$GnhdKZ z#0^9^bq8vc$XUntf=OFzrET29Hba|Qc7L_(rY*bCLQ{5ktW@j@szRPs;kg$V<~(Gu zyJ6_*Rv@Ctix|r1#KZC2lQBc7IoT9!}*=^oHx@L{LZ>kirs)ju$m>$Hsp+D=xknQ0k~@Fm!EFAPDeHEYwGY`lwI`g}Oh}9pL;cYSB$<-!}o$%hVKV)KOQK@gZP0^KMdkW z_;ERZej?OELj6?4Jfz`gWq3G>YuAQ56e?S7rzez*buZo(YPEZMOlO5cFyYt<(@9yvx}h~<_k|26YV{gU zGPG-N+)Ra%3CD`}gt}}y6*AH(J7UMXt)8@FhStmbHQAw&vh4V#eqj_{y3&eUsZ|PX zwXdPvIa?J1YwW10Fs9Xtn{Da7F4Ng!bj3JB6C*}!tKnEO&Q1nWJ1rU){vVWRpuKqp z(yXeEbUbDCnOm)-#Z4OGaXaN2&pnoTE_OZE?HGOL9^2^+b(uyy8R|A7Dcji>GWr*U zMEoAhF{2c#(XT0UZ%U!V*Ik<;Mxv#AMe8nOw-JgNj7Von0@IkbVo`>2j-PqdU1Uly z67G71DSmue;bb!%rz_n}D~H{POi4TKL|k_lY9oepc^Z+*>ZUM#xJ_$v>MM-uOc{~h zjYh%^8HI%2-JCXJR=4FQm*3tw2QRH1*2BJ`><^KOD$L6FCr#|L;~~k`7XB=5h(;YV znWPs221$jf`TSmDi$vihTXEFftx#sf2&LW0gu+-)xpc~kg<7qoAZTKKZtY9t@~f_Z zcja)K5x%QdX!xCm$60v7dn0B-iU#v$O6{Csy+OTJMq=4gQd}$fAMA7i*lbD8PjSo8 zkW5`5&{SADQrIw6+_L7TGR+P9F7&B_1XI)!J3>)W78mQu-a9nC%o;i7Cd9qK9cU`DsGp^Cmj!im#kCPgnP&n6z zS#XofTODt}lN$b@-|?)Df8Z${|CG6Z;W-_r@Vt(H z<3BoHz>7Lw!pk~d!D$_5cz7wLigZ=10-7q(RjJZ+Ri?^y6;u_v($y$kjmAk`jlq*T zE>~l9HBMFP>MS)uQxkPHNp|0eHcd^|Rh7~drnM)`IO}9}f@)VsO(R;p(}+i7rc+&C zebt+Eb+($Kt8>&;T}@Nx>Z)3(>1wK`X6S0Bs?pVXYL>2MFQ#&T2~E7>Z(z#(NzA`= z+i3IZVmsOBmN?$h&A$E{e&tB~D2dq^vm?DcqY4wV(Y9k=H#;aXvy(h3*^J2Rf#lrI zTr=I{zs-)jLIuFvN2*4Xkz(%}?^T%T?;~O0ovT-X$k6H0L1Tp`U+?6t8HpxRXuZy^ zteXv>n$YvPP|H1U?>TWbfaLUqd$Qa@bt{cBggeIs$Y*52IQ+R_&0Eu^(&D<9K*T+)z8 z#H@(h0`MB*q?w@S72t@gUHw7lEkG*JpyfRJy!-PsfAD7C)7Ek>^llJ5VZ^Rx zD;{l##n=b&aGIa>@4($>*sF=0hGi)`*GOnqGTfI)?UOUJzi*gGZHD#})I!^7B-`8z ze<1EY^81Qx9GPWergx!}Z#0#8^0Id`$r<5c!|rcKhEI$OxM+Gq^A!Zf7FH)eY!>i~uV|kX5<;nV&W=W|%iAW4kiz>f z*SQ}7+W9?WZtaf70?-b#N&wQ@zNVpdU3(`rEaiz{#OU}5gYzzzWvsY??ct90g4Z4* zyd-3gM6iw-=&anEA^XL`oNx9%5PA6YKF~?4Gz5J-@Cui%z;u4HT+iEL5zdzT52;GI z$?;jj8{}qm@J%O2&3qQ|8Jv3*MRVufiQ?NhD#8~2jz%$mmmz@VC`UbB$I(QO8(VP+ zM_lJhRd_w=QcB*&r^0sZ;9AO8C;2Sl+^KmP1lmrZWZO}c)@7j0y#vJ=lx0w!;pXn3 zA_Lu{M!D0Yy}_6a#(LDa3@Sb9tPI9`)PxKsdeo#0Cf@`ta0mfPuJR_&&R~j1os+@T z`58>B4;;a{-c)r4(-$13cF6ilbO)yJPkgfK2xc6|Oof9OL$b1_DsUX<6{Ct0W@Rw@ zl0%p*bgf70LeCMpDsT*Qk73@e6jJQEvI~<*hv|xDjACfUV;w`(f_dC{89z2RqLu$P z(yeX0LAN8#P+iS1UB^Hjpd;^~^Y7u?2kGdC>EuV~;Ky+(p1|dJ8U}CFU2b?5d(Q3; z&nfa;<{EX1oLA7S5IjVmZFTdGA#@Pu4ETPW`2Kw2XQAu;`S&5nI9_lN2kMUVzYkC!khmaWQ42p;1uCDqo38Crj diff --git a/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class b/jxnet-spring-boot-autoconfigure/build/classes/java/main/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.class deleted file mode 100644 index 101069e5786816c81646e517ba40c8006e532bbc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5594 zcmbW4{dXK?7017mrrnp!rg>{nA7ZUgpek`-+6Zi>!Dzl#@@d7T& z?C0|Mg*ZGfCSQ!(rcf}Q{&}NR zGI>OG&F@@Mq4^DWTjW2aVO@961YPv=+%#+)vIX`JSoZ5y<6#{7igShB8e zHoCJG9i31`sZ^AUm7cV1H*J(%J7*WBt(mf8rtguv(qCN~5(?g%qUpGnSt3zVfGoc9 zBXpY@bB)|wmhbChbd8n^a=a5fR&w+e3byN+AjWp@+AgGxU^6{pm&8-ab;>zcqCaE0 zW7RC^=>CW1W;yObb-fTtuFEme$A zns=)mdRI1*=q*+5kamyK@mghZzA5ZH$bJpC-vB`%&P%l^j1m06;&FYJK>DBn#R)X( z7oPoUh7T=0#HeZ?PG^I_YW^GhwutZOc~>0(e) z)AdX3hN5FmTMO)WUjNo{H$J1|lQ^j3WqItxt{8r!9|v5|DfX%F6(#`e`FI0ePztrj;mu46&<%>cMMl_yoKF5y0J?~4|-!* z((xzs>im+rBZjwi{26!XNMnBt@920J`*j?^$6|O-K>niR6S!5!E%JC3S2bi51@r&w zKrBkD+{2Tn*{oyuE4z!rL(NgLc@AbKj%sLK)vwlhrnXgZCye}WHmgk zp|d*^ZbU1sfmu_>qm=4U$!k15JT|VO=X%mXt>JNJGyS8(8n!8P!imDqgQG(S_Ggc1 z*rDnyVOb`X)UWDG);3rFOM((feqcH)G7Q8Rzfu$op{6FSg6TRkn#pFy`cDp@q>Ab& zYI+MBeI}bdI*{ob=Xt2a<>W%8Mjz?#8#y&_Dl;^ElCj*YV5(a^>1=3t=+x-3?C?;{ z;a3ZyobUtT6J9BlQWwXRtv(Xhn-nf&D(SD9DpX#CzKl-VNL@kmRcyS17Eep(FRi{@TLrCLwfolFJ?p97*4TeM z!FK-C;R|l6po6PUe|1xZb{DbPUv*WmnX4_!XzE?JgpX9Ph0CqW1kx(lDnVEW3BokG z`0PWBFW!s+Y{OAjyU#IZ$637YVHi$uH_PV`zJw8&xEJ#n!#RxONlf4w+=mOepa0Z7 zfM4T_cnuHYGEQL$U&d8TVi`HSPp!lB;s^O!HOK?pX+d*yOFWh8O0^_XsZ?_lz554q zjH5=5<9ybh;UaFn#2*_xeE$q*L*~~9XP6Uy#G@e3DnY)$+)><-cogJ0f?TKrA~jP$9%QDj1xZFh zo>zjLV&W=5l2MQs2y(Fwh!kxBF<1cBf^3e0yr=}pVM+zEISTR;L0+x{B3(m3OxC%z zAX}m!uP8xgFslOD5(RmkAaB$Gk+vlu7EUWbI-?+$lpu4gyo#ggjDjo@q*4b&`lf*7 zQK;Iw(_4d$g3aj)KDvZ$QJkd^PE$}{ZFLgsQJi;(^KKm+Y2SiVR2KTJQIM-4kkvx} zkh;)&UCwV4exd(6LH - - - - - -All Classes (Jxnet 1.4.0.RC1) - - - - - -

All Classes

- - - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html deleted file mode 100644 index 43ff8be1..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/allclasses-noframe.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -All Classes (Jxnet 1.4.0.RC1) - - - - - -

All Classes

- - - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html deleted file mode 100644 index c988170b..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.html +++ /dev/null @@ -1,331 +0,0 @@ - - - - - - -JxnetAutoConfiguration (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - - -
-
com.ardikars.jxnet.spring.boot.autoconfigure
-

Class JxnetAutoConfiguration

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
    • -
    -
  • -
-
- -
-
-
    -
  • - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      com.ardikars.jxnet.Contextcontext(com.ardikars.jxnet.PcapIf pcapIf, - java.lang.StringBuilder errbuf) -
      Jxnet application context.
      -
      java.lang.StringBuildererrbuf() 
      com.ardikars.jxnet.PcapIfpcapIf(java.lang.StringBuilder errbuf) -
      Pcap if (source).
      -
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        context

        -
        @Bean(value="com.ardikars.jxnet.contex")
        -public com.ardikars.jxnet.Context context(com.ardikars.jxnet.PcapIf pcapIf,
        -                                                                                   @Qualifier(value="com.ardikars.jxnet.errbuf")
        -                                                                                   java.lang.StringBuilder errbuf)
        -
        Jxnet application context.
        -
        -
        Parameters:
        -
        pcapIf - pcap if.
        -
        errbuf - error buffer.
        -
        Returns:
        -
        returns application context.
        -
        -
      • -
      - - - -
        -
      • -

        pcapIf

        -
        @Bean
        -public com.ardikars.jxnet.PcapIf pcapIf(@Qualifier(value="com.ardikars.jxnet.errbuf")
        -                                              java.lang.StringBuilder errbuf)
        -                                       throws com.ardikars.jxnet.exception.DeviceNotFoundException
        -
        Pcap if (source).
        -
        -
        Parameters:
        -
        errbuf - error buffer.
        -
        Returns:
        -
        pcap_if.
        -
        Throws:
        -
        com.ardikars.jxnet.exception.DeviceNotFoundException - device not found exception.
        -
        -
      • -
      - - - -
        -
      • -

        errbuf

        -
        @Bean(value="com.ardikars.jxnet.errbuf")
        -public java.lang.StringBuilder errbuf()
        -
      • -
      -
    • -
    -
  • -
-
-
- - -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html deleted file mode 100644 index 360eb48c..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.html +++ /dev/null @@ -1,614 +0,0 @@ - - - - - - -JxnetConfigurationProperties (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - - -
-
com.ardikars.jxnet.spring.boot.autoconfigure
-

Class JxnetConfigurationProperties

-
-
-
    -
  • java.lang.Object
  • -
  • -
      -
    • com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
    • -
    -
  • -
-
-
    -
  • -
    -
    -
    @ConfigurationProperties(prefix="jxnet")
    -public class JxnetConfigurationProperties
    -extends java.lang.Object
    -
  • -
-
-
-
    -
  • - - - -
      -
    • - - -

      Method Summary

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethod and Description
      java.lang.BooleangetBlocking() 
      com.ardikars.jxnet.DataLinkTypegetDatalink() 
      com.ardikars.jxnet.PcapDirectiongetDirection() 
      java.lang.StringgetFile() 
      com.ardikars.jxnet.ImmediateModegetImmediate() 
      com.ardikars.jxnet.Pcap.PcapTypegetPcapType() 
      com.ardikars.jxnet.PromiscuousModegetPromiscuous() 
      com.ardikars.jxnet.RadioFrequencyMonitorModegetRfmon() 
      java.lang.IntegergetSnapshot() 
      java.lang.StringgetSource() 
      java.lang.IntegergetTimeout() 
      com.ardikars.jxnet.PcapTimestampPrecisiongetTimestampPrecision() 
      com.ardikars.jxnet.PcapTimestampTypegetTimestampType() 
      voidinitialize() -
      Initialze field.
      -
      voidsetBlocking(java.lang.Boolean blocking) 
      voidsetDatalink(java.lang.Integer datalink) 
      voidsetDirection(com.ardikars.jxnet.PcapDirection direction) 
      voidsetFile(java.lang.String file) 
      voidsetImmediate(com.ardikars.jxnet.ImmediateMode immediate) 
      voidsetPcapType(com.ardikars.jxnet.Pcap.PcapType pcapType) 
      voidsetPromiscuous(com.ardikars.jxnet.PromiscuousMode promiscuous) 
      voidsetRfmon(com.ardikars.jxnet.RadioFrequencyMonitorMode rfmon) 
      voidsetSnapshot(java.lang.Integer snapshot) 
      voidsetSource(java.lang.String source) 
      voidsetTimeout(java.lang.Integer timeout) 
      voidsetTimestampPrecision(com.ardikars.jxnet.PcapTimestampPrecision timestampPrecision) 
      voidsetTimestampType(com.ardikars.jxnet.PcapTimestampType timestampType) 
      -
        -
      • - - -

        Methods inherited from class java.lang.Object

        -clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • -
      -
    • -
    -
  • -
-
-
-
    -
  • - -
      -
    • - - -

      Constructor Detail

      - - - -
        -
      • -

        JxnetConfigurationProperties

        -
        public JxnetConfigurationProperties()
        -
      • -
      -
    • -
    - -
      -
    • - - -

      Method Detail

      - - - -
        -
      • -

        initialize

        -
        @PostConstruct
        -public void initialize()
        -
        Initialze field.
        -
      • -
      - - - -
        -
      • -

        getSource

        -
        public java.lang.String getSource()
        -
      • -
      - - - -
        -
      • -

        setSource

        -
        public void setSource(java.lang.String source)
        -
      • -
      - - - -
        -
      • -

        getSnapshot

        -
        public java.lang.Integer getSnapshot()
        -
      • -
      - - - -
        -
      • -

        setSnapshot

        -
        public void setSnapshot(java.lang.Integer snapshot)
        -
      • -
      - - - -
        -
      • -

        getPromiscuous

        -
        public com.ardikars.jxnet.PromiscuousMode getPromiscuous()
        -
      • -
      - - - -
        -
      • -

        setPromiscuous

        -
        public void setPromiscuous(com.ardikars.jxnet.PromiscuousMode promiscuous)
        -
      • -
      - - - -
        -
      • -

        getTimeout

        -
        public java.lang.Integer getTimeout()
        -
      • -
      - - - -
        -
      • -

        setTimeout

        -
        public void setTimeout(java.lang.Integer timeout)
        -
      • -
      - - - -
        -
      • -

        getImmediate

        -
        public com.ardikars.jxnet.ImmediateMode getImmediate()
        -
      • -
      - - - -
        -
      • -

        setImmediate

        -
        public void setImmediate(com.ardikars.jxnet.ImmediateMode immediate)
        -
      • -
      - - - -
        -
      • -

        getTimestampType

        -
        public com.ardikars.jxnet.PcapTimestampType getTimestampType()
        -
      • -
      - - - -
        -
      • -

        setTimestampType

        -
        public void setTimestampType(com.ardikars.jxnet.PcapTimestampType timestampType)
        -
      • -
      - - - -
        -
      • -

        getTimestampPrecision

        -
        public com.ardikars.jxnet.PcapTimestampPrecision getTimestampPrecision()
        -
      • -
      - - - -
        -
      • -

        setTimestampPrecision

        -
        public void setTimestampPrecision(com.ardikars.jxnet.PcapTimestampPrecision timestampPrecision)
        -
      • -
      - - - -
        -
      • -

        getRfmon

        -
        public com.ardikars.jxnet.RadioFrequencyMonitorMode getRfmon()
        -
      • -
      - - - -
        -
      • -

        setRfmon

        -
        public void setRfmon(com.ardikars.jxnet.RadioFrequencyMonitorMode rfmon)
        -
      • -
      - - - -
        -
      • -

        getBlocking

        -
        public java.lang.Boolean getBlocking()
        -
      • -
      - - - -
        -
      • -

        setBlocking

        -
        public void setBlocking(java.lang.Boolean blocking)
        -
      • -
      - - - -
        -
      • -

        getDirection

        -
        public com.ardikars.jxnet.PcapDirection getDirection()
        -
      • -
      - - - -
        -
      • -

        setDirection

        -
        public void setDirection(com.ardikars.jxnet.PcapDirection direction)
        -
      • -
      - - - -
        -
      • -

        getDatalink

        -
        public com.ardikars.jxnet.DataLinkType getDatalink()
        -
      • -
      - - - -
        -
      • -

        setDatalink

        -
        public void setDatalink(java.lang.Integer datalink)
        -
      • -
      - - - -
        -
      • -

        getFile

        -
        public java.lang.String getFile()
        -
      • -
      - - - -
        -
      • -

        setFile

        -
        public void setFile(java.lang.String file)
        -
      • -
      - - - -
        -
      • -

        getPcapType

        -
        public com.ardikars.jxnet.Pcap.PcapType getPcapType()
        -
      • -
      - - - -
        -
      • -

        setPcapType

        -
        public void setPcapType(com.ardikars.jxnet.Pcap.PcapType pcapType)
        -
      • -
      -
    • -
    -
  • -
-
-
- - -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html deleted file mode 100644 index 5f3a1156..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-frame.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -com.ardikars.jxnet.spring.boot.autoconfigure (Jxnet 1.4.0.RC1) - - - - - -

com.ardikars.jxnet.spring.boot.autoconfigure

- - - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html deleted file mode 100644 index c01800c7..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - -com.ardikars.jxnet.spring.boot.autoconfigure (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

Package com.ardikars.jxnet.spring.boot.autoconfigure

-
-
- -
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html deleted file mode 100644 index 78f988ed..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/com/ardikars/jxnet/spring/boot/autoconfigure/package-tree.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - -com.ardikars.jxnet.spring.boot.autoconfigure Class Hierarchy (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

Hierarchy For Package com.ardikars.jxnet.spring.boot.autoconfigure

-
-
-

Class Hierarchy

- -
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html deleted file mode 100644 index 524aa081..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/constant-values.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Constant Field Values (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

Constant Field Values

-

Contents

-
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html deleted file mode 100644 index aaef550b..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/deprecated-list.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - -Deprecated List (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

Deprecated API

-

Contents

-
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html deleted file mode 100644 index 46935344..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/help-doc.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - -API Help (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

How This API Document Is Organized

-
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-
-
-
    -
  • -

    Package

    -

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    -
      -
    • Interfaces (italic)
    • -
    • Classes
    • -
    • Enums
    • -
    • Exceptions
    • -
    • Errors
    • -
    • Annotation Types
    • -
    -
  • -
  • -

    Class/Interface

    -

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
      -
    • Class inheritance diagram
    • -
    • Direct Subclasses
    • -
    • All Known Subinterfaces
    • -
    • All Known Implementing Classes
    • -
    • Class/interface declaration
    • -
    • Class/interface description
    • -
    -
      -
    • Nested Class Summary
    • -
    • Field Summary
    • -
    • Constructor Summary
    • -
    • Method Summary
    • -
    -
      -
    • Field Detail
    • -
    • Constructor Detail
    • -
    • Method Detail
    • -
    -

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    -
  • -
  • -

    Annotation Type

    -

    Each annotation type has its own separate page with the following sections:

    -
      -
    • Annotation Type declaration
    • -
    • Annotation Type description
    • -
    • Required Element Summary
    • -
    • Optional Element Summary
    • -
    • Element Detail
    • -
    -
  • -
  • -

    Enum

    -

    Each enum has its own separate page with the following sections:

    -
      -
    • Enum declaration
    • -
    • Enum description
    • -
    • Enum Constant Summary
    • -
    • Enum Constant Detail
    • -
    -
  • -
  • -

    Tree (Class Hierarchy)

    -

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    -
      -
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • -
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • -
    -
  • -
  • -

    Deprecated API

    -

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    -
  • -
  • -

    Index

    -

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    -
  • -
  • -

    Prev/Next

    -

    These links take you to the next or previous class, interface, package, or related page.

    -
  • -
  • -

    Frames/No Frames

    -

    These links show and hide the HTML frames. All pages are available with or without frames.

    -
  • -
  • -

    All Classes

    -

    The All Classes link shows all classes and interfaces except non-static nested types.

    -
  • -
  • -

    Serialized Form

    -

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    -
  • -
  • -

    Constant Field Values

    -

    The Constant Field Values page lists the static final fields and their values.

    -
  • -
-This help file applies to API documentation generated using the standard doclet.
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html deleted file mode 100644 index a544e677..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index-all.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - -Index (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
C E G I J P S  - - -

C

-
-
com.ardikars.jxnet.spring.boot.autoconfigure - package com.ardikars.jxnet.spring.boot.autoconfigure
-
 
-
context(PcapIf, StringBuilder) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
-
-
Jxnet application context.
-
-
- - - -

E

-
-
errbuf() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
-
 
-
- - - -

G

-
-
getBlocking() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getDatalink() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getDirection() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getFile() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getImmediate() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getPcapType() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getPromiscuous() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getRfmon() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getSnapshot() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getSource() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getTimeout() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getTimestampPrecision() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
getTimestampType() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
- - - -

I

-
-
initialize() - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
-
Initialze field.
-
-
- - - -

J

-
-
JxnetAutoConfiguration - Class in com.ardikars.jxnet.spring.boot.autoconfigure
-
 
-
JxnetAutoConfiguration(JxnetConfigurationProperties) - Constructor for class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
-
 
-
JxnetConfigurationProperties - Class in com.ardikars.jxnet.spring.boot.autoconfigure
-
 
-
JxnetConfigurationProperties() - Constructor for class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
- - - -

P

-
-
pcapIf(StringBuilder) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration
-
-
Pcap if (source).
-
-
- - - -

S

-
-
setBlocking(Boolean) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setDatalink(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setDirection(PcapDirection) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setFile(String) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setImmediate(ImmediateMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setPcapType(Pcap.PcapType) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setPromiscuous(PromiscuousMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setRfmon(RadioFrequencyMonitorMode) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setSnapshot(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setSource(String) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setTimeout(Integer) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setTimestampPrecision(PcapTimestampPrecision) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
setTimestampType(PcapTimestampType) - Method in class com.ardikars.jxnet.spring.boot.autoconfigure.JxnetConfigurationProperties
-
 
-
-C E G I J P S 
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html deleted file mode 100644 index e8ee7eec..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/index.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - -Jxnet 1.4.0.RC1 - - - - - - -<noscript> -<div>JavaScript is disabled on your browser.</div> -</noscript> -<h2>Frame Alert</h2> -<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="com/ardikars/jxnet/spring/boot/autoconfigure/package-summary.html">Non-frame version</a>.</p> - - - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html deleted file mode 100644 index 66341ce9..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/overview-tree.html +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - -Class Hierarchy (Jxnet 1.4.0.RC1) - - - - - - - - -
- - - - - - - -
Jxnet 1.4.0.RC1
-
- - -
-

Hierarchy For All Packages

-Package Hierarchies: - -
-
-

Class Hierarchy

- -
- -
- - - - - - - -
https://github.com/jxnet/Jxnet
-
- - -

Copyright © 2015 - 2018 ardikars.com. All rights reserved.

- - diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list deleted file mode 100644 index be0d934a..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/package-list +++ /dev/null @@ -1 +0,0 @@ -com.ardikars.jxnet.spring.boot.autoconfigure diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js deleted file mode 100644 index b3463569..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/script.js +++ /dev/null @@ -1,30 +0,0 @@ -function show(type) -{ - count = 0; - for (var key in methods) { - var row = document.getElementById(key); - if ((methods[key] & type) != 0) { - row.style.display = ''; - row.className = (count++ % 2) ? rowColor : altColor; - } - else - row.style.display = 'none'; - } - updateTabs(type); -} - -function updateTabs(type) -{ - for (var value in tabs) { - var sNode = document.getElementById(tabs[value][0]); - var spanNode = sNode.firstChild; - if (value == type) { - sNode.className = activeTableTab; - spanNode.innerHTML = tabs[value][1]; - } - else { - sNode.className = tableTab; - spanNode.innerHTML = "" + tabs[value][1] + ""; - } - } -} diff --git a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css b/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css deleted file mode 100644 index 98055b22..00000000 --- a/jxnet-spring-boot-autoconfigure/build/docs/javadoc/stylesheet.css +++ /dev/null @@ -1,574 +0,0 @@ -/* Javadoc style sheet */ -/* -Overall document style -*/ - -@import url('resources/fonts/dejavu.css'); - -body { - background-color:#ffffff; - color:#353833; - font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; - font-size:14px; - margin:0; -} -a:link, a:visited { - text-decoration:none; - color:#4A6782; -} -a:hover, a:focus { - text-decoration:none; - color:#bb7a2a; -} -a:active { - text-decoration:none; - color:#4A6782; -} -a[name] { - color:#353833; -} -a[name]:hover { - text-decoration:none; - color:#353833; -} -pre { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; -} -h1 { - font-size:20px; -} -h2 { - font-size:18px; -} -h3 { - font-size:16px; - font-style:italic; -} -h4 { - font-size:13px; -} -h5 { - font-size:12px; -} -h6 { - font-size:11px; -} -ul { - list-style-type:disc; -} -code, tt { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; - margin-top:8px; - line-height:1.4em; -} -dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - padding-top:4px; -} -table tr td dt code { - font-family:'DejaVu Sans Mono', monospace; - font-size:14px; - vertical-align:top; - padding-top:4px; -} -sup { - font-size:8px; -} -/* -Document title and Copyright styles -*/ -.clear { - clear:both; - height:0px; - overflow:hidden; -} -.aboutLanguage { - float:right; - padding:0px 21px; - font-size:11px; - z-index:200; - margin-top:-9px; -} -.legalCopy { - margin-left:.5em; -} -.bar a, .bar a:link, .bar a:visited, .bar a:active { - color:#FFFFFF; - text-decoration:none; -} -.bar a:hover, .bar a:focus { - color:#bb7a2a; -} -.tab { - background-color:#0066FF; - color:#ffffff; - padding:8px; - width:5em; - font-weight:bold; -} -/* -Navigation bar styles -*/ -.bar { - background-color:#4D7A97; - color:#FFFFFF; - padding:.8em .5em .4em .8em; - height:auto;/*height:1.8em;*/ - font-size:11px; - margin:0; -} -.topNav { - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.bottomNav { - margin-top:10px; - background-color:#4D7A97; - color:#FFFFFF; - float:left; - padding:0; - width:100%; - clear:right; - height:2.8em; - padding-top:10px; - overflow:hidden; - font-size:12px; -} -.subNav { - background-color:#dee3e9; - float:left; - width:100%; - overflow:hidden; - font-size:12px; -} -.subNav div { - clear:left; - float:left; - padding:0 0 5px 6px; - text-transform:uppercase; -} -ul.navList, ul.subNavList { - float:left; - margin:0 25px 0 0; - padding:0; -} -ul.navList li{ - list-style:none; - float:left; - padding: 5px 6px; - text-transform:uppercase; -} -ul.subNavList li{ - list-style:none; - float:left; -} -.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { - color:#FFFFFF; - text-decoration:none; - text-transform:uppercase; -} -.topNav a:hover, .bottomNav a:hover { - text-decoration:none; - color:#bb7a2a; - text-transform:uppercase; -} -.navBarCell1Rev { - background-color:#F8981D; - color:#253441; - margin: auto 5px; -} -.skipNav { - position:absolute; - top:auto; - left:-9999px; - overflow:hidden; -} -/* -Page header and footer styles -*/ -.header, .footer { - clear:both; - margin:0 20px; - padding:5px 0 0 0; -} -.indexHeader { - margin:10px; - position:relative; -} -.indexHeader span{ - margin-right:15px; -} -.indexHeader h1 { - font-size:13px; -} -.title { - color:#2c4557; - margin:10px 0; -} -.subTitle { - margin:5px 0 0 0; -} -.header ul { - margin:0 0 15px 0; - padding:0; -} -.footer ul { - margin:20px 0 5px 0; -} -.header ul li, .footer ul li { - list-style:none; - font-size:13px; -} -/* -Heading styles -*/ -div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList ul.blockList li.blockList h3 { - background-color:#dee3e9; - border:1px solid #d0d9e0; - margin:0 0 6px -8px; - padding:7px 5px; -} -ul.blockList ul.blockList li.blockList h3 { - padding:0; - margin:15px 0; -} -ul.blockList li.blockList h2 { - padding:0px 0 20px 0; -} -/* -Page layout container styles -*/ -.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { - clear:both; - padding:10px 20px; - position:relative; -} -.indexContainer { - margin:10px; - position:relative; - font-size:12px; -} -.indexContainer h2 { - font-size:13px; - padding:0 0 3px 0; -} -.indexContainer ul { - margin:0; - padding:0; -} -.indexContainer ul li { - list-style:none; - padding-top:2px; -} -.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { - font-size:12px; - font-weight:bold; - margin:10px 0 0 0; - color:#4E4E4E; -} -.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { - margin:5px 0 10px 0px; - font-size:14px; - font-family:'DejaVu Sans Mono',monospace; -} -.serializedFormContainer dl.nameValue dt { - margin-left:1px; - font-size:1.1em; - display:inline; - font-weight:bold; -} -.serializedFormContainer dl.nameValue dd { - margin:0 0 0 1px; - font-size:1.1em; - display:inline; -} -/* -List styles -*/ -ul.horizontal li { - display:inline; - font-size:0.9em; -} -ul.inheritance { - margin:0; - padding:0; -} -ul.inheritance li { - display:inline; - list-style:none; -} -ul.inheritance li ul.inheritance { - margin-left:15px; - padding-left:15px; - padding-top:1px; -} -ul.blockList, ul.blockListLast { - margin:10px 0 10px 0; - padding:0; -} -ul.blockList li.blockList, ul.blockListLast li.blockList { - list-style:none; - margin-bottom:15px; - line-height:1.4; -} -ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { - padding:0px 20px 5px 10px; - border:1px solid #ededed; - background-color:#f8f8f8; -} -ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { - padding:0 0 5px 8px; - background-color:#ffffff; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { - margin-left:0; - padding-left:0; - padding-bottom:15px; - border:none; -} -ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { - list-style:none; - border-bottom:none; - padding-bottom:0; -} -table tr td dl, table tr td dl dt, table tr td dl dd { - margin-top:0; - margin-bottom:1px; -} -/* -Table styles -*/ -.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { - width:100%; - border-left:1px solid #EEE; - border-right:1px solid #EEE; - border-bottom:1px solid #EEE; -} -.overviewSummary, .memberSummary { - padding:0px; -} -.overviewSummary caption, .memberSummary caption, .typeSummary caption, -.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { - position:relative; - text-align:left; - background-repeat:no-repeat; - color:#253441; - font-weight:bold; - clear:none; - overflow:hidden; - padding:0px; - padding-top:10px; - padding-left:1px; - margin:0px; - white-space:pre; -} -.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, -.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, -.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, -.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, -.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, -.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, -.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, -.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { - color:#FFFFFF; -} -.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, -.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - padding-bottom:7px; - display:inline-block; - float:left; - background-color:#F8981D; - border: none; - height:16px; -} -.memberSummary caption span.activeTableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#F8981D; - height:16px; -} -.memberSummary caption span.tableTab span { - white-space:nowrap; - padding-top:5px; - padding-left:12px; - padding-right:12px; - margin-right:3px; - display:inline-block; - float:left; - background-color:#4D7A97; - height:16px; -} -.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { - padding-top:0px; - padding-left:0px; - padding-right:0px; - background-image:none; - float:none; - display:inline; -} -.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, -.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { - display:none; - width:5px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .activeTableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - float:left; - background-color:#F8981D; -} -.memberSummary .tableTab .tabEnd { - display:none; - width:5px; - margin-right:3px; - position:relative; - background-color:#4D7A97; - float:left; - -} -.overviewSummary td, .memberSummary td, .typeSummary td, -.useSummary td, .constantsSummary td, .deprecatedSummary td { - text-align:left; - padding:0px 0px 12px 10px; -} -th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, -td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ - vertical-align:top; - padding-right:0px; - padding-top:8px; - padding-bottom:3px; -} -th.colFirst, th.colLast, th.colOne, .constantsSummary th { - background:#dee3e9; - text-align:left; - padding:8px 3px 3px 7px; -} -td.colFirst, th.colFirst { - white-space:nowrap; - font-size:13px; -} -td.colLast, th.colLast { - font-size:13px; -} -td.colOne, th.colOne { - font-size:13px; -} -.overviewSummary td.colFirst, .overviewSummary th.colFirst, -.useSummary td.colFirst, .useSummary th.colFirst, -.overviewSummary td.colOne, .overviewSummary th.colOne, -.memberSummary td.colFirst, .memberSummary th.colFirst, -.memberSummary td.colOne, .memberSummary th.colOne, -.typeSummary td.colFirst{ - width:25%; - vertical-align:top; -} -td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { - font-weight:bold; -} -.tableSubHeadingColor { - background-color:#EEEEFF; -} -.altColor { - background-color:#FFFFFF; -} -.rowColor { - background-color:#EEEEEF; -} -/* -Content styles -*/ -.description pre { - margin-top:0; -} -.deprecatedContent { - margin:0; - padding:10px 0; -} -.docSummary { - padding:0; -} - -ul.blockList ul.blockList ul.blockList li.blockList h3 { - font-style:normal; -} - -div.block { - font-size:14px; - font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; -} - -td.colLast div { - padding-top:0px; -} - - -td.colLast a { - padding-bottom:3px; -} -/* -Formatting effect styles -*/ -.sourceLineNo { - color:green; - padding:0 30px 0 0; -} -h1.hidden { - visibility:hidden; - overflow:hidden; - font-size:10px; -} -.block { - display:block; - margin:3px 10px 2px 0px; - color:#474747; -} -.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, -.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, -.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { - font-weight:bold; -} -.deprecationComment, .emphasizedPhrase, .interfaceName { - font-style:italic; -} - -div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, -div.block div.block span.interfaceName { - font-style:normal; -} - -div.contentContainer ul.blockList li.blockList h2{ - padding-bottom:0px; -} diff --git a/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml b/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml deleted file mode 100644 index c1d78bec..00000000 --- a/jxnet-spring-boot-autoconfigure/build/poms/pom-default.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - 4.0.0 - com.ardikars.jxnet - jxnet-spring-boot-autoconfigure - 1.4.0.RC1 - Jxnet - Jxnet is a java library for capturing and sending network paket. - https://github.com/jxnet/Jxnet - - ardikars - http://ardikars.com - - - - GNU Lesser General Public License, Version 3.0 - http://www.gnu.org/licenses - repo - - - - - ardikars - Ardika Rommy Sanjaya - contact@ardikars.com - - - - scm:git:https://github.com/jxnet/Jxnet.git - scm:git:git@github.com/jxnet/Jxnet.git - https://github.com/jxnet/Jxnet.git - - - - com.ardikars.common - common-net - 1.2.0.RC2 - compile - - - com.ardikars.common - common-util - 1.2.0.RC2 - compile - - - com.ardikars.jxnet - jxnet-core - 1.4.0.RC1 - compile - - - com.ardikars.jxnet - jxnet-context - 1.4.0.RC1 - compile - - - org.slf4j - slf4j-api - 1.7.25 - compile - - - org.springframework.boot - spring-boot-configuration-processor - 2.0.4.RELEASE - compile - - - org.springframework.boot - spring-boot-autoconfigure - 2.0.4.RELEASE - compile - - - diff --git a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html deleted file mode 100644 index 4933873f..00000000 --- a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - -
-

CheckStyle Audit

-
Designed for use with CheckStyle and Ant.
-
-

Summary

- - - - - - - -
FilesErrors
20
-
-

Files

- - - - - - - - - - -
NameErrors
/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java0
/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java0
-
- -

File /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java

- - - - -
Error DescriptionLine
-Back to top -

File /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java

- - - - -
Error DescriptionLine
-Back to top -
- - diff --git a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml b/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml deleted file mode 100644 index 4c4ac6a7..00000000 --- a/jxnet-spring-boot-autoconfigure/build/reports/checkstyle/main.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html b/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html deleted file mode 100644 index 2a382343..00000000 --- a/jxnet-spring-boot-autoconfigure/build/reports/findbugs/main.html +++ /dev/null @@ -1,146 +0,0 @@ - - - -SpotBugs Report - - - - -

-SpotBugs Report

-

Project Information

-

Project: -

-

SpotBugs version: 3.1.5

-

Code analyzed:

-
    -
  • /Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/classes/java/main
  • -
-

-
-
-

-

Metrics

-

166 lines of code analyzed, - in 3 classes, - in 1 packages.

- - - - - - - - - - - - - - - - - - - -
MetricTotalDensity*
High Priority Warnings -0.00
Medium Priority Warnings -0.00
-Total Warnings - -0 - -0.00 -
-

-(* Defects per Thousand lines of non-commenting source statements) -

-

-
-
-

-

Contents

- -

Summary

- - - - - - - - - -
Warning TypeNumber
-Total - -0 -
-

Warnings

-

Click on a warning row to see full context information.

-

-Details -

- - diff --git a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html deleted file mode 100644 index faeb4ba5..00000000 --- a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.html +++ /dev/null @@ -1,10 +0,0 @@ -PMD -

PMD report

Problems found

- -
#FileLineProblem

Configuration errors

- - - - - -
RuleProblem
LoosePackageCouplingNo packages or classes specified
diff --git a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml b/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml deleted file mode 100644 index bce089df..00000000 --- a/jxnet-spring-boot-autoconfigure/build/reports/pmd/main.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories b/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories deleted file mode 100644 index 6822fc13..00000000 --- a/jxnet-spring-boot-autoconfigure/build/resources/main/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.ardikars.jxnet.spring.boot.autoconfigure.JxnetAutoConfiguration \ No newline at end of file diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF deleted file mode 100644 index 73d59646..00000000 --- a/jxnet-spring-boot-autoconfigure/build/tmp/jar/MANIFEST.MF +++ /dev/null @@ -1,4 +0,0 @@ -Manifest-Version: 1.0 -Implementation-Title: Jxnet -Implementation-Version: 1.4.0.RC1 - diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options b/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options deleted file mode 100644 index 672806bf..00000000 --- a/jxnet-spring-boot-autoconfigure/build/tmp/javadoc/javadoc.options +++ /dev/null @@ -1,16 +0,0 @@ --locale 'en_US' --Xdoclint:all,-reference '-quiet' --author --bottom 'Copyright © 2015 - 2018 ardikars.com. All rights reserved.' --charset 'UTF-8' --classpath '/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/classes/java/main:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/resources/main:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-context/build/libs/jxnet-context-1.4.0.RC1.jar:/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-core/build/libs/jxnet-core-1.4.0.RC1.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-net/1.2.0.RC2/13aac17732209ff9399218a7f064e66fdbaadd50/common-net-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-util/1.2.0.RC2/6095fa2d4d3363d6095c309d21ba2b36727024fb/common-util-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-configuration-processor/2.0.4.RELEASE/dcaf863e151e728debbf37cf024e7b698ea92281/spring-boot-configuration-processor-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/2.0.4.RELEASE/65cd1244d606acc02ab7bfc47a203a3fe2400dda/spring-boot-autoconfigure-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/com.ardikars.common/common-annotation/1.2.0.RC2/14b8d39ee970692ccf9410d7356fdef0e166f758/common-annotation-1.2.0.RC2.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.0.4.RELEASE/c8619c5b06d4dcdb4cac1e5e9c839e6e8b1c8574/spring-boot-2.0.4.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/5.0.8.RELEASE/3a067d8990761111c9b6d1d895640be26cc1fb38/spring-context-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/5.0.8.RELEASE/f5086c1a3185c481104511837427b39a07a57aa2/spring-aop-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/5.0.8.RELEASE/5fc965d3e7f5515099244857a8ae9e2a208c169b/spring-beans-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/5.0.8.RELEASE/f23158f22c917df2cddf2ecebc398a9e95f95fae/spring-expression-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.8.RELEASE/dc39c49e3246cdf73d3786ac41119140aed3fa08/spring-core-5.0.8.RELEASE.jar:/Users/ardikars/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/5.0.8.RELEASE/a1fa8fb560fb252321776e16bc9ac8201af4ef5e/spring-jcl-5.0.8.RELEASE.jar' --d '/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/build/docs/javadoc' --doctitle 'Jxnet 1.4.0.RC1 API Documentation' --encoding 'UTF-8' --footer 'https://github.com/jxnet/Jxnet' --header 'Jxnet 1.4.0.RC1' --protected --quiet --windowtitle 'Jxnet 1.4.0.RC1' -'/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetConfigurationProperties.java' -'/Users/ardikars/IdeaProjects/CodeLab/Jxnet/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java' diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF deleted file mode 100644 index 58630c02..00000000 --- a/jxnet-spring-boot-autoconfigure/build/tmp/javadocJar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF b/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF deleted file mode 100644 index 58630c02..00000000 --- a/jxnet-spring-boot-autoconfigure/build/tmp/sourcesJar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/jxnet-spring-boot-starter/build/poms/pom-default.xml b/jxnet-spring-boot-starter/build/poms/pom-default.xml deleted file mode 100644 index 1a0600a6..00000000 --- a/jxnet-spring-boot-starter/build/poms/pom-default.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 4.0.0 - com.ardikars.jxnet - jxnet-spring-boot-starter - 1.4.0.RC1 - Jxnet - Jxnet is a java library for capturing and sending network paket. - https://github.com/jxnet/Jxnet - - ardikars - http://ardikars.com - - - - GNU Lesser General Public License, Version 3.0 - http://www.gnu.org/licenses - repo - - - - - ardikars - Ardika Rommy Sanjaya - contact@ardikars.com - - - - scm:git:https://github.com/jxnet/Jxnet.git - scm:git:git@github.com/jxnet/Jxnet.git - https://github.com/jxnet/Jxnet.git - - - - com.ardikars.common - common-net - 1.2.0.RC2 - compile - - - com.ardikars.common - common-util - 1.2.0.RC2 - compile - - - com.ardikars.jxnet - jxnet-spring-boot-autoconfigure - 1.4.0.RC1 - compile - - - diff --git a/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF deleted file mode 100644 index 73d59646..00000000 --- a/jxnet-spring-boot-starter/build/tmp/jar/MANIFEST.MF +++ /dev/null @@ -1,4 +0,0 @@ -Manifest-Version: 1.0 -Implementation-Title: Jxnet -Implementation-Version: 1.4.0.RC1 - diff --git a/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF deleted file mode 100644 index 58630c02..00000000 --- a/jxnet-spring-boot-starter/build/tmp/javadocJar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF b/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF deleted file mode 100644 index 58630c02..00000000 --- a/jxnet-spring-boot-starter/build/tmp/sourcesJar/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - From 3683937fac4053300e6d32114bdaad9fe9efc4d0 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Thu, 30 Aug 2018 20:42:32 +0700 Subject: [PATCH 16/16] 1.4.0.RC2 --- gradle/configure.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/configure.gradle b/gradle/configure.gradle index ba34693f..0205ac43 100644 --- a/gradle/configure.gradle +++ b/gradle/configure.gradle @@ -7,7 +7,7 @@ ext { NAME = 'Jxnet' GROUP = 'com.ardikars.jxnet' - VERSION = '1.4.0.RC1' + VERSION = '1.4.0.RC2' NDK_HOME = "${System.env.NDK_HOME}" TOOLS_DIR = "${rootDir}/tools"