Package javaforce.net
Class PacketCapture
java.lang.Object
javaforce.net.PacketCapture
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intstatic intstatic intstatic booleanstatic intstatic byte[]static byte[]static byte[]static byte[]static intstatic intstatic int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns MAC address for IP address.booleanarp_ip_equals(byte[] pkt, byte[] ip) voidbuild_arp(byte[] pkt, byte[] src_mac, byte[] src_ip, byte[] request_ip) Build ARP header.voidbuild_ethernet(byte[] pkt, byte[] dest, byte[] src, int type) Build ethernet header.static Stringbuild_ip(byte[] ip) static Stringbuild_mac(byte[] mac) static voidstatic voidcmd_list()static booleancompare_ip(byte[] ip1, byte[] ip2) static booleanCompile program.static byte[]findInterface(String ip) Find interface that contains IP address.byte[]get_arp_mac(byte[] pkt) intget_arp_opcode(byte[] pkt) intget_ethernet_type(byte[] pkt) static intget_ip_range_length(byte[] ip_start, byte[] ip_end) byte[]static voidincrement_ip(byte[] ip) static booleaninit()Load native libraries.static String[]List local interfaces.static voidstatic booleanstatic voidprint_mac(byte[] mac) static byte[]read(long handle) Read packet.longStart process on local interface.static voidstop(long id) Stop processing.static booleanstatic booleanwrite(long handle, byte[] packet, int offset, int length) Write packet.
-
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
-
init
public static boolean init()Load native libraries. -
listLocalInterfaces
List local interfaces. Return is array of strings, each is comma delimited list. DeviceName,IP/MAC,IP/MAC,... -
findInterface
Find interface that contains IP address. -
start
Start process on local interface. -
stop
public static void stop(long id) Stop processing. -
compile
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. -
print_mac
public static void print_mac(byte[] mac) -
get_mac
-
build_mac
-
valid_ip
-
decode_ip
-
build_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
Returns MAC address for IP address. -
main
-
cmd_list
public static void cmd_list() -
cmd_arp
-