Class PacketCapture

java.lang.Object
javaforce.net.PacketCapture

public class PacketCapture extends Object
  • Field Details

    • debug

      public static boolean debug
    • TYPE_IP4

      public static int TYPE_IP4
    • TYPE_ARP

      public static int TYPE_ARP
    • TYPE_IP6

      public static int TYPE_IP6
    • ethernet_size

      public static int ethernet_size
    • mac_broadcast

      public static byte[] mac_broadcast
    • mac_zero

      public static byte[] mac_zero
    • ip_broadcast

      public static byte[] ip_broadcast
    • ip_zero

      public static byte[] ip_zero
    • ARP_REQUEST

      public static int ARP_REQUEST
    • ARP_REPLY

      public static int ARP_REPLY
    • arp_size

      public static int arp_size
  • Constructor Details

    • PacketCapture

      public PacketCapture()
  • Method Details

    • ninit

      public static boolean ninit(String lib1, String lib2)
    • init

      public static boolean init()
      Load native libraries.
    • listLocalInterfaces

      public static String[] listLocalInterfaces()
      List local interfaces. Return is array of strings, each is comma delimited list. DeviceName,IP/MAC,IP/MAC,...
    • findInterface

      public String findInterface(String ip)
      Find interface that contains IP address.
    • start

      public long start(String local_interface, String local_ip, boolean nonblocking)
      Start process on local interface.
    • start

      public long start(String local_interface, String local_ip)
      Start process on local interface with blocking mode enabled.
    • stop

      public static void stop(long id)
      Stop processing.
    • compile

      public static boolean compile(long handle, String program)
      Compile program.
    • read

      public static byte[] read(long handle)
      Read packet.
    • write

      public static boolean write(long handle, byte[] packet, int offset, int length)
      Write packet.
    • get_mac

      public byte[] get_mac(String ip)
    • build_mac

      public static String build_mac(byte[] mac)
    • valid_ip

      public static boolean valid_ip(String ip)
    • decode_ip

      public static byte[] decode_ip(String ip)
    • build_ip

      public static String build_ip(byte[] ip)
    • compare_ip

      public static boolean compare_ip(byte[] ip1, byte[] ip2)
    • increment_ip

      public static void increment_ip(byte[] ip)
    • get_ip_range_length

      public static int get_ip_range_length(byte[] ip_start, byte[] ip_end)
    • build_ethernet

      public void build_ethernet(byte[] pkt, byte[] dest, byte[] src, int type)
      Build ethernet header. (14 bytes)
    • get_ethernet_type

      public int get_ethernet_type(byte[] pkt)
    • build_arp

      public void build_arp(byte[] pkt, byte[] src_mac, byte[] src_ip, byte[] request_ip)
      Build ARP header. (28 bytes)
    • get_arp_opcode

      public int get_arp_opcode(byte[] pkt)
    • arp_ip_equals

      public boolean arp_ip_equals(byte[] pkt, byte[] ip)
    • get_arp_mac

      public byte[] get_arp_mac(byte[] pkt)
    • arp

      public byte[] arp(long handle, String target_ip, int ms)
      Returns MAC address for IP address.
    • main

      public static void main(String[] args)
    • cmd_list

      public static void cmd_list()
    • cmd_arp

      public static void cmd_arp(String ip)