/** * Create an {@link InetAddress} instance which represents the IP address * specified by the given byte array. * * @param bytes A byte array which represents the IP address. * @return An {@link InetAddress} instance. * @throws IllegalArgumentException * The given byte array does not represent an IP network mask. */ public static final InetAddress getInetAddress(byte[] bytes) { try { return InetAddress.getByAddress(bytes); } catch (Exception e) { throw new IllegalArgumentException( "Invalid raw IP address: " + ByteUtils.toHexString(bytes), e); } }
/** * Return a string representation of this object. * * @return A string representation of this object. */ @Override public final String toString() { StringBuilder builder = new StringBuilder(). append(getClass().getSimpleName()).append('{'); String sep = ""; for (String field: getHeaderFormat().keySet()) { byte[] value = hdrFieldsMap.get(field); builder.append(sep).append(field).append('='). append(ByteUtils.toHexString(value)); sep = ", "; } return builder.append('}').toString(); }
/** * Return a {@link MacAddress} instance which represents this ethernet * address. * * @return A {@link MacAddress} instance. */ public MacAddress getMacAddress() { MacAddress mac = macAddress; if (mac == null) { byte[] bytes = getBytesImpl(); String hex = ByteUtils.toHexString(bytes); mac = new MacAddress(hex); macAddress = mac; } return mac; }
ByteUtils.toHexString(packetBytes));
LOG.trace("Deserializing: {}: {}: {} (offset {} bitsize {})", getClass().getSimpleName(), hdrField, ByteUtils.toHexString(hdrFieldBytes), startOffset, numBits);