Class ByteBufUtils
java.lang.Object
org.opendaylight.openflowjava.util.ByteBufUtils
Class for common operations on ByteBuf.
- Author:
- michal.polkorab, timotej.kubas
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.google.common.base.Splitter
static final com.google.common.base.Splitter
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
byteBufToHexString
(io.netty.buffer.ByteBuf bb) Converts ByteBuf into String.static String
bytesToHexString
(byte[] array) Converts byte array into String.static String
decodeNullTerminatedString
(io.netty.buffer.ByteBuf rawMessage, int length) Reads and parses null-terminated string from ByteBuf.static int
fillBitMask
(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 int
fillBitMaskFromMap
(Map<Integer, Boolean> booleanMap) Fills the bitmask from boolean map where key is bit position.static io.netty.buffer.ByteBuf
hexStringToByteBuf
(String hexSrc) Creates ByteBuf filled with specified data.static void
hexStringToByteBuf
(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 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address
readIetfIpv4Address
(io.netty.buffer.ByteBuf buf) static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address
readIetfIpv6Address
(io.netty.buffer.ByteBuf buf) static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress
readIetfMacAddress
(io.netty.buffer.ByteBuf buf) static byte[]
serializeList
(List<Short> list) static void
updateOFHeaderLength
(io.netty.buffer.ByteBuf out) Write length standard OF header.static void
updateOFHeaderLength
(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.
-
Field Details
-
DOT_SPLITTER
public static final com.google.common.base.Splitter DOT_SPLITTER -
COLON_SPLITTER
public static final com.google.common.base.Splitter COLON_SPLITTER
-
-
Method Details
-
byteBufToHexString
Converts ByteBuf into String.- Parameters:
bb
- input ByteBuf- Returns:
- String
-
hexStringToBytes
Converts String into byte[].- Parameters:
hexSrc
- input String- Returns:
- byte[] filled with input data
-
hexStringToBytes
Converts String into byte[].- Parameters:
hexSrc
- input StringwithSpaces
- if there are spaces in string- Returns:
- byte[] filled with input data
-
hexStringToByteBuf
Creates ByteBuf filled with specified data.- Parameters:
hexSrc
- input String of bytes in hex format- Returns:
- ByteBuf with specified hexString converted
-
hexStringToByteBuf
Creates ByteBuf filled with specified data.- Parameters:
hexSrc
- input String of bytes in hex formatout
- ByteBuf with specified hexString converted
-
writeOFHeader
public static <E extends OfHeader> void writeOFHeader(byte msgType, E message, io.netty.buffer.ByteBuf out, int length) Create standard OF header.- Parameters:
msgType
- message codemessage
- POJOout
- writing bufferlength
- ofheader length
-
updateOFHeaderLength
public static void updateOFHeaderLength(io.netty.buffer.ByteBuf out) Write length standard OF header.- Parameters:
out
- writing buffer
-
updateOFHeaderLength
public static void updateOFHeaderLength(io.netty.buffer.ByteBuf out, int index) Write length OF header.- Parameters:
out
- writing bufferindex
- writing index
-
fillBitMaskFromMap
Fills the bitmask from boolean map where key is bit position.- Parameters:
booleanMap
- bit to boolean mapping- Returns:
- bit mask
-
fillBitMask
public 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 atvalues
- boolean bit values to fill- Returns:
- Filled-in bitmask
-
fillBitMaskFromList
Fills the bitmask from boolean list where key is bit position.- Parameters:
booleanList
- bit to boolean mapping- Returns:
- bit mask
-
bytesToHexString
Converts byte array into String.- Parameters:
array
- input byte array- Returns:
- String
-
decodeNullTerminatedString
Reads and parses null-terminated string from ByteBuf.- Parameters:
rawMessage
- the message to parselength
- maximal length of String- Returns:
- String with name of port
-
readIetfIpv4Address
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address readIetfIpv4Address(io.netty.buffer.ByteBuf buf) -
readIetfIpv6Address
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address readIetfIpv6Address(io.netty.buffer.ByteBuf buf) -
readIetfMacAddress
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress readIetfMacAddress(io.netty.buffer.ByteBuf buf) -
serializeList
-