Class ByteBufUtils
- java.lang.Object
- 
- org.opendaylight.openflowjava.util.ByteBufUtils
 
- 
 public abstract class ByteBufUtils extends Object Class for common operations on ByteBuf.- Author:
- michal.polkorab, timotej.kubas
 
- 
- 
Field SummaryFields Modifier and Type Field Description static com.google.common.base.SplitterCOLON_SPLITTERstatic com.google.common.base.SplitterDOT_SPLITTER
 - 
Method SummaryAll Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringbyteBufToHexString(io.netty.buffer.ByteBuf bb)Converts ByteBuf into String.static StringbytesToHexString(byte[] array)Converts byte array into String.static StringdecodeNullTerminatedString(io.netty.buffer.ByteBuf rawMessage, int length)Reads and parses null-terminated string from ByteBuf.static intfillBitMask(int offset, boolean... values)Fills the bitmask from a set of bit values, starting at specified offset.static int[]fillBitMaskFromList(List<Boolean> booleanList)Fills the bitmask from boolean list where key is bit position.static intfillBitMaskFromMap(Map<Integer,Boolean> booleanMap)Fills the bitmask from boolean map where key is bit position.static io.netty.buffer.ByteBufhexStringToByteBuf(String hexSrc)Creates ByteBuf filled with specified data.static voidhexStringToByteBuf(String hexSrc, io.netty.buffer.ByteBuf out)Creates ByteBuf filled with specified data.static byte[]hexStringToBytes(String hexSrc)Converts String into byte[].static byte[]hexStringToBytes(String hexSrc, boolean withSpaces)Converts String into byte[].static byte[]macAddressToBytes(String macAddress)Converts macAddress to byte array.static StringmacAddressToString(byte[] address)Converts a MAC address represented in bytes to String.static voidpadBuffer(int length, io.netty.buffer.ByteBuf out)Deprecated.UseByteBuf.writeZero(int)directly.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressreadIetfIpv4Address(io.netty.buffer.ByteBuf buf)static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressreadIetfIpv6Address(io.netty.buffer.ByteBuf buf)static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddressreadIetfMacAddress(io.netty.buffer.ByteBuf buf)static StringreadIpv4Address(io.netty.buffer.ByteBuf buf)Read an IPv4 address from a buffer and format it into dotted-quad string.static StringreadIpv6Address(io.netty.buffer.ByteBuf buf)Read an IPv6 address from a buffer and format it into a string of eight groups of four hexadecimal digits separated by colons.static byte[]serializeList(List<Short> list)static voidupdateOFHeaderLength(io.netty.buffer.ByteBuf out)Write length standard OF header.static voidupdateOFHeaderLength(io.netty.buffer.ByteBuf out, int index)Write length OF header.static <E extends OfHeader>
 voidwriteOFHeader(byte msgType, E message, io.netty.buffer.ByteBuf out, int length)Create standard OF header.
 
- 
- 
- 
Method Detail- 
byteBufToHexStringpublic static String byteBufToHexString(io.netty.buffer.ByteBuf bb) Converts ByteBuf into String.- Parameters:
- bb- input ByteBuf
- Returns:
- String
 
 - 
hexStringToBytespublic static byte[] hexStringToBytes(String hexSrc) Converts String into byte[].- Parameters:
- hexSrc- input String
- Returns:
- byte[] filled with input data
 
 - 
hexStringToBytespublic static byte[] hexStringToBytes(String hexSrc, boolean withSpaces) Converts String into byte[].- Parameters:
- hexSrc- input String
- withSpaces- if there are spaces in string
- Returns:
- byte[] filled with input data
 
 - 
hexStringToByteBufpublic static io.netty.buffer.ByteBuf hexStringToByteBuf(String hexSrc) Creates ByteBuf filled with specified data.- Parameters:
- hexSrc- input String of bytes in hex format
- Returns:
- ByteBuf with specified hexString converted
 
 - 
hexStringToByteBufpublic static void hexStringToByteBuf(String hexSrc, io.netty.buffer.ByteBuf out) Creates ByteBuf filled with specified data.- Parameters:
- hexSrc- input String of bytes in hex format
- out- ByteBuf with specified hexString converted
 
 - 
padBuffer@Deprecated public static void padBuffer(int length, io.netty.buffer.ByteBuf out) Deprecated.UseByteBuf.writeZero(int)directly.Fills specified ByteBuf with 0 (zeros) of desired length, used for padding.- Parameters:
- length- the desired length
- out- ByteBuf to be padded
 
 - 
writeOFHeaderpublic static <E extends OfHeader> void writeOFHeader(byte msgType, E message, io.netty.buffer.ByteBuf out, int length) Create standard OF header.- Parameters:
- msgType- message code
- message- POJO
- out- writing buffer
- length- ofheader length
 
 - 
updateOFHeaderLengthpublic static void updateOFHeaderLength(io.netty.buffer.ByteBuf out) Write length standard OF header.- Parameters:
- out- writing buffer
 
 - 
updateOFHeaderLengthpublic static void updateOFHeaderLength(io.netty.buffer.ByteBuf out, int index)Write length OF header.- Parameters:
- out- writing buffer
- index- writing index
 
 - 
fillBitMaskFromMappublic static int fillBitMaskFromMap(Map<Integer,Boolean> booleanMap) Fills the bitmask from boolean map where key is bit position.- Parameters:
- booleanMap- bit to boolean mapping
- Returns:
- bit mask
 
 - 
fillBitMaskpublic static int fillBitMask(int offset, boolean... values)Fills the bitmask from a set of bit values, starting at specified offset.- Parameters:
- offset- Bit offset to start at
- values- boolean bit values to fill
- Returns:
- Filled-in bitmask
 
 - 
fillBitMaskFromListpublic static int[] fillBitMaskFromList(List<Boolean> booleanList) Fills the bitmask from boolean list where key is bit position.- Parameters:
- booleanList- bit to boolean mapping
- Returns:
- bit mask
 
 - 
bytesToHexStringpublic static String bytesToHexString(byte[] array) Converts byte array into String.- Parameters:
- array- input byte array
- Returns:
- String
 
 - 
macAddressToBytespublic static byte[] macAddressToBytes(String macAddress) Converts macAddress to byte array. See alsoMacAddress.- Parameters:
- macAddress- the mac address to convert
- Returns:
- byte representation of mac address
 
 - 
macAddressToStringpublic static String macAddressToString(byte[] address) Converts a MAC address represented in bytes to String. See alsoMacAddress.- Parameters:
- address- the MAC address to convert
- Returns:
- String representation of a MAC address
 
 - 
decodeNullTerminatedStringpublic static String decodeNullTerminatedString(io.netty.buffer.ByteBuf rawMessage, int length) Reads and parses null-terminated string from ByteBuf.- Parameters:
- rawMessage- the message to parse
- length- maximal length of String
- Returns:
- String with name of port
 
 - 
readIpv4Addresspublic static String readIpv4Address(io.netty.buffer.ByteBuf buf) Read an IPv4 address from a buffer and format it into dotted-quad string.- Parameters:
- buf- Input buffer
- Returns:
- Dotted-quad string
 
 - 
readIpv6Addresspublic static String readIpv6Address(io.netty.buffer.ByteBuf buf) Read an IPv6 address from a buffer and format it into a string of eight groups of four hexadecimal digits separated by colons.- Parameters:
- buf- Input buffer
- Returns:
- IPv6 address in string format
 
 - 
readIetfIpv4Addresspublic static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address readIetfIpv4Address(io.netty.buffer.ByteBuf buf) 
 - 
readIetfIpv6Addresspublic static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address readIetfIpv6Address(io.netty.buffer.ByteBuf buf) 
 - 
readIetfMacAddresspublic static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress readIetfMacAddress(io.netty.buffer.ByteBuf buf) 
 
- 
 
-