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 TypeMethodDescriptionstatic byte[]Returns MAC address for IP address.static booleanarp_ip_equals(byte[] pkt, byte[] ip) static voidbuild_arp(byte[] pkt, byte[] src_mac, byte[] src_ip, byte[] request_ip) Build ARP header.static voidbuild_ethernet(byte[] pkt, byte[] dest, byte[] src, int type) Build ethernet header.static Stringbuild_ip(byte[] ip) static Stringbuild_mac(byte[] mac) static booleancompare_ip(byte[] ip1, byte[] ip2) booleanCompile program.static byte[]static StringfindInterface(String ip) Find interface that contains IP address.static byte[]get_arp_mac(byte[] pkt) static intget_arp_opcode(byte[] pkt) static intget_ethernet_type(byte[] pkt) static intget_ip_range_length(byte[] ip_start, byte[] ip_end) static byte[]static PacketCapturestatic voidincrement_ip(byte[] ip) String[]List local interfaces.static voidprint_mac(byte[] mac) byte[]read(long handle) Read packet.longStart process on local interface with blocking mode enabled.longStart process on local interface.voidstop(long id) Stop processing.static booleanbooleanwrite(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
-
getInstance
-
listLocalInterfaces
List local interfaces. Return is array of strings, each is comma delimited list. DeviceName,IP/MAC,IP/MAC,... -
findInterface
-
start
-
start
-
stop
public void stop(long id) Stop processing. -
compile
Compile program. -
read
public byte[] read(long handle) Read packet. -
write
public 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 static void build_ethernet(byte[] pkt, byte[] dest, byte[] src, int type) Build ethernet header. (14 bytes) -
get_ethernet_type
public static int get_ethernet_type(byte[] pkt) -
build_arp
public static void build_arp(byte[] pkt, byte[] src_mac, byte[] src_ip, byte[] request_ip) Build ARP header. (28 bytes) -
get_arp_opcode
public static int get_arp_opcode(byte[] pkt) -
arp_ip_equals
public static boolean arp_ip_equals(byte[] pkt, byte[] ip) -
get_arp_mac
public static byte[] get_arp_mac(byte[] pkt) -
arp
Returns MAC address for IP address.
-