Ejemplo n.º 1
0
BufferRef COBSEncode(const BufferRef& buffer) {
    size_t maxEncodedSize = buffer->getSize() + ceil(static_cast<float>(buffer->getSize()) / 254) + 1;
    BufferRef encodeBuffer = Buffer::create(maxEncodedSize);
    size_t encodedSize = COBSEncode(reinterpret_cast<const uint8_t*>(buffer->getData()), buffer->getSize(), reinterpret_cast<uint8_t*>(encodeBuffer->getData()));
    encodeBuffer->resize(encodedSize);
    return encodeBuffer;
}
Ejemplo n.º 2
0
BufferRef SLIPEncode(const BufferRef& buffer) {
    size_t maxEncodedSize = 2 * buffer->getSize() + 2;
    BufferRef encodeBuffer = Buffer::create(maxEncodedSize);
    size_t encodedSize = SLIPEncode(reinterpret_cast<const uint8_t*>(buffer->getData()), buffer->getSize(), reinterpret_cast<uint8_t*>(encodeBuffer->getData()));
    encodeBuffer->resize(encodedSize);
    return encodeBuffer;
}
Ejemplo n.º 3
0
BufferRef COBSDecode(const BufferRef& buffer) {
    size_t maxDecodedSize = buffer->getSize() - 1;
    BufferRef decodeBuffer = Buffer::create(maxDecodedSize);
    size_t decodedSize = COBSDecode(reinterpret_cast<const uint8_t*>(buffer->getData()), buffer->getSize(), reinterpret_cast<uint8_t*>(decodeBuffer->getData()));
    decodeBuffer->resize(decodedSize);
    return decodeBuffer;
}
Ejemplo n.º 4
0
BufferRef SLIPDecode(const BufferRef& buffer) {
    // should not assume double-ENDed variant
    size_t maxDecodedSize = buffer->getSize() - 1;
    BufferRef decodeBuffer = Buffer::create(maxDecodedSize);
    size_t decodedSize = SLIPDecode(reinterpret_cast<const uint8_t*>(buffer->getData()), buffer->getSize(), reinterpret_cast<uint8_t*>(decodeBuffer->getData()));
    decodeBuffer->resize(decodedSize);
    return decodeBuffer;
}