net.sourceforge.jpcap.net
Class ARPEncoding

java.lang.Object
  |
  +--net.sourceforge.jpcap.net.ARPEncoding

public class ARPEncoding
extends java.lang.Object

ARP protocol encoding information.

todo: the ARP protocol supports hardware types other than ethernet and protocol types other than IP. this class isn't so generic yet.


Field Summary
static int HEADER_LEN
          Length in bytes of an ARP header.
static int HW_LEN_POS
          Position of the hardware address length.
static int HW_TYPE_POS
          Position of the hardware address type.
static int OP_POS
          Position of the operation type.
static int PR_LEN_POS
          Position of the protocol address length.
static int PR_TYPE_POS
          Position of the protocol address type.
static int S_HW_ADDR_POS
          Position of the sender hardware address.
static int S_PR_ADDR_POS
          Position of the sender protocol address.
static int T_HW_ADDR_POS
          Position of the target hardware address.
static int T_PR_ADDR_POS
          Position of the target protocol address.
 
Constructor Summary
ARPEncoding()
           
 
Method Summary
static ARPPacket create(int lLen, byte[] bytes)
          ARPPacket factory.
static java.lang.String extractHwAddr(boolean sourceFlag, int lLen, byte[] packetBytes)
          Extract a hardware (ARP) address from an ARP packet.
static int extractOperation(int lLen, byte[] packetBytes)
          Extract the operation code from an ARP packet.
static java.lang.String extractProtoAddr(boolean sourceFlag, int lLen, byte[] packetBytes)
          Extract a protocol (IP) address from an ARP packet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HW_TYPE_POS

public static final int HW_TYPE_POS
Position of the hardware address type.

PR_TYPE_POS

public static final int PR_TYPE_POS
Position of the protocol address type.

HW_LEN_POS

public static final int HW_LEN_POS
Position of the hardware address length.

PR_LEN_POS

public static final int PR_LEN_POS
Position of the protocol address length.

OP_POS

public static final int OP_POS
Position of the operation type.

S_HW_ADDR_POS

public static final int S_HW_ADDR_POS
Position of the sender hardware address.

S_PR_ADDR_POS

public static final int S_PR_ADDR_POS
Position of the sender protocol address.

T_HW_ADDR_POS

public static final int T_HW_ADDR_POS
Position of the target hardware address.

T_PR_ADDR_POS

public static final int T_PR_ADDR_POS
Position of the target protocol address.

HEADER_LEN

public static final int HEADER_LEN
Length in bytes of an ARP header.
Constructor Detail

ARPEncoding

public ARPEncoding()
Method Detail

create

public static ARPPacket create(int lLen,
                               byte[] bytes)
ARPPacket factory.

extractOperation

public static int extractOperation(int lLen,
                                   byte[] packetBytes)
Extract the operation code from an ARP packet.

extractHwAddr

public static java.lang.String extractHwAddr(boolean sourceFlag,
                                             int lLen,
                                             byte[] packetBytes)
Extract a hardware (ARP) address from an ARP packet.
Parameters:
offset - the offset of the address data from the start of the packet.
packetBytes - packet bytes, including the link-layer header.

extractProtoAddr

public static java.lang.String extractProtoAddr(boolean sourceFlag,
                                                int lLen,
                                                byte[] packetBytes)
Extract a protocol (IP) address from an ARP packet.
Parameters:
offset - the offset of the address data from the start of the packet.
packetBytes - packet bytes, including the link-layer header.