public class ByteAddrUtils
extends java.lang.Object
Constructor and Description |
---|
ByteAddrUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
asHex4Bytes(byte[] buf)
Converts an array of bytes into a string of hexadecimal 4-byte words.
|
static java.lang.String |
asHex4Bytes(byte[] buf,
int off,
int len)
Converts a portion of an array of bytes into a string of hexadecimal 4-byte words.
|
static java.lang.String |
asHexEthernetPacket(byte[] buf)
Converts an array of bytes representing a data packet into a hex string.
|
static java.lang.String |
asHexEthernetPacket(byte[] buf,
int off,
int len)
Converts a portion of an array of bytes representing a data packet into a hex string.
|
static java.lang.String |
bytesToIpv4addr(byte[] b)
Transforms a four-bytes array into a dotted four-decimals string.
|
static java.lang.String |
bytesToIpv4addr(byte[] b,
int off)
Transforms a four-bytes array into a dotted four-decimals string.
|
static void |
changeFrameMacIpDestinationAddresses(byte[] buf,
int off,
java.lang.String mac_addr,
java.lang.String ip_addr)
Changes MAC and IP destination addresses of the given Ethernet frame.
|
static void |
changeFrameMacIpDestinationAddresses(byte[] data,
java.lang.String mac_addr,
java.lang.String ip_addr)
Changes MAC and IP destination addresses of the given Ethernet frame.
|
static void |
changeVlanFrameMacDestinationAddresses(byte[] buf,
int off,
java.lang.String mac_addr)
Changes MAC destination addresses of a VLAN-tagged Ethernet frame.
|
static void |
changeVlanFrameMacDestinationAddresses(byte[] data,
java.lang.String mac_addr)
Changes MAC destination addresses of a VLAN-tagged Ethernet frame.
|
static void |
changeVlanFrameMacIpDestinationAddresses(byte[] buf,
int off,
java.lang.String mac_addr,
java.lang.String ip_addr)
Changes MAC and IP destination addresses of a VLAN-tagged Ethernet frame.
|
static void |
changeVlanFrameMacIpDestinationAddresses(byte[] data,
java.lang.String mac_addr,
java.lang.String ip_addr)
Changes MAC and IP destination addresses of a VLAN-tagged Ethernet frame.
|
static int |
checksum(byte[] buf,
int off,
int len)
Checksum calculation.
|
static byte[] |
ipv4addrToBytes(java.lang.String addr)
Transforms a dotted four-decimals string (ipv4 address) into a four-bytes array.
|
static void |
ipv4addrToBytes(java.lang.String addr,
byte[] buf,
int off)
Transforms a dotted four-decimals string (ipv4 address) into a four-bytes array.
|
static java.lang.String |
trimHexString(java.lang.String str)
Eliminates all non-hexadecimal characters.
|
static void |
updateIPv4HeaderChecksum(byte[] buf,
int off)
Updates IPv4 header chacksum within the given IPv4 datagram.
|
public static java.lang.String bytesToIpv4addr(byte[] b)
public static java.lang.String bytesToIpv4addr(byte[] b, int off)
public static byte[] ipv4addrToBytes(java.lang.String addr)
public static void ipv4addrToBytes(java.lang.String addr, byte[] buf, int off)
public static java.lang.String asHex4Bytes(byte[] buf)
public static java.lang.String asHex4Bytes(byte[] buf, int off, int len)
public static java.lang.String asHexEthernetPacket(byte[] buf)
public static java.lang.String asHexEthernetPacket(byte[] buf, int off, int len)
public static int checksum(byte[] buf, int off, int len)
public static void updateIPv4HeaderChecksum(byte[] buf, int off)
public static java.lang.String trimHexString(java.lang.String str)
public static void changeFrameMacIpDestinationAddresses(byte[] data, java.lang.String mac_addr, java.lang.String ip_addr)
public static void changeFrameMacIpDestinationAddresses(byte[] buf, int off, java.lang.String mac_addr, java.lang.String ip_addr)
public static void changeVlanFrameMacIpDestinationAddresses(byte[] data, java.lang.String mac_addr, java.lang.String ip_addr)
public static void changeVlanFrameMacIpDestinationAddresses(byte[] buf, int off, java.lang.String mac_addr, java.lang.String ip_addr)
public static void changeVlanFrameMacDestinationAddresses(byte[] data, java.lang.String mac_addr)
public static void changeVlanFrameMacDestinationAddresses(byte[] buf, int off, java.lang.String mac_addr)