Пример #1
0
QByteArray NLPacket::hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret) {
    QCryptographicHash hash(QCryptographicHash::Md5);
    
    int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
        + NUM_BYTES_RFC4122_UUID + NUM_BYTES_MD5_HASH;
    
    // add the packet payload and the connection UUID
    hash.addData(packet.getData() + offset, packet.getDataSize() - offset);
    hash.addData(connectionSecret.toRfc4122());
    
    // return the hash
    return hash.result();
}
Пример #2
0
QByteArray NLPacket::verificationHashInHeader(const udt::Packet& packet) {
    int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
    return QByteArray(packet.getData() + offset, NUM_BYTES_MD5_HASH);
}
Пример #3
0
PacketVersion NLPacket::versionInHeader(const udt::Packet& packet) {
    auto headerOffset = Packet::totalHeaderSize(packet.isPartOfMessage());
    return *reinterpret_cast<const PacketVersion*>(packet.getData() + headerOffset + sizeof(PacketType));
}
Пример #4
0
QUuid NLPacket::sourceIDInHeader(const udt::Packet& packet) {
    int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
    return QUuid::fromRfc4122(QByteArray::fromRawData(packet.getData() + offset, NUM_BYTES_RFC4122_UUID));
}
Пример #5
0
PacketType NLPacket::typeInHeader(const udt::Packet& packet) {
    auto headerOffset = Packet::totalHeaderSize(packet.isPartOfMessage());
    return *reinterpret_cast<const PacketType*>(packet.getData() + headerOffset);
}