- return bytes;
- }
-
- private byte[] putEOM(NetconfMessage msg) {
- // create byte buffer from the String XML
- // all Netconf messages are encoded using UTF-8
- final ByteBuffer msgBytes = Charsets.UTF_8.encode(xmlToString(msg.getDocument()));
- final ByteBuffer result = ByteBuffer.allocate(msgBytes.limit() + endOfMessage.length);
- result.put(msgBytes);
- // put end of message
- result.put(endOfMessage);
- return result.array();
- }
-
- private byte[] putChunked(NetconfMessage msg) {
- final ByteBuffer msgBytes = Charsets.UTF_8.encode(xmlToString(msg.getDocument()));
- final NetconfMessageHeader h = new NetconfMessageHeader();
- if (msgBytes.limit() > MAX_CHUNK_SIZE)
- logger.warn("Netconf message too long, should be split.");
- h.setLength(msgBytes.limit());
- final byte[] headerBytes = h.toBytes();
- final ByteBuffer result = ByteBuffer.allocate(headerBytes.length + msgBytes.limit() + endOfChunk.length);
- result.put(headerBytes);
- result.put(msgBytes);
- result.put(endOfChunk);
- return result.array();