fixed NormCmdCCMsg item parsing and iteration per issue reported by CrunchyJohnHaven

pull/101/head
bebopagogo 2026-05-23 20:48:17 -04:00
parent fcd2554051
commit 0c4b130c7b
4 changed files with 136 additions and 111 deletions

View File

@ -92,6 +92,30 @@ ssize_t NormWrite(NormSocketHandle normSocket, const void* buf, size_t nbyte);
int NormFlush(NormSocketHandle normSocket);
/*
// These calls _will_ be used for file/data object and message-stream delivery. (Sketching the calls out for now)
NormObject NormSendFile(NormSocketHandle normSocket,
const char* filePath,
const char* infoPtr,
ssize_t infoLen);
NormObject NormSendData(NormSocketHandle normSocket,
const char* data, // NormSocket will copy the "data" unlike NORM low-level API
ssize_t nbyte,
const char* infoPtr,
ssize_t infoLen);
// Notification events will indicate receipt of file/data objects. Are additional NormSocket API calls
// needed to manage receipt?
ssize_t NormSendMsg(NormSocketHandle normSocket, const char* data, ssize_t nbyte, bool flush);
ssize_t NormRecvMsg(NormSocketHandle normSocket, const char* data, ssize_t nbyte);
*/
// NormSocket helper functions
void NormSetSocketUserData(NormSocketHandle normSocket, const void* userData);

View File

@ -69,12 +69,12 @@ inline UINT16 NormQuantizeLoss(double lossFraction)
lossFraction = MIN(lossFraction, 65535.0);
return (UINT16)lossFraction;
} // end NormQuantizeLossFraction()
inline double NormUnquantizeLoss(UINT16 lossQuantized)
{
return (((double)lossQuantized) / 65535.0);
} // end NormUnquantizeLossFraction()
// Extended precision Norm loss quantize/unquantize with
// 32-bit precision (needed for low BER, high bandwidth*delay)
inline UINT32 NormQuantizeLoss32(double lossFraction)

@ -1 +1 @@
Subproject commit a28606945f6b507760548b242b6706b51b5b69d3
Subproject commit e5ac157eb61e991c74acfe39e2febe8c09e187dc

View File

@ -118,7 +118,7 @@ bool NormCmdCCMsg::GetCCNode(NormNodeId nodeId,
UINT16 cmdLength = length/4;
UINT16 offset = header_length/4;
nodeId = htonl(nodeId);
while (offset < cmdLength)
while (offset + (CC_ITEM_SIZE/4) <= cmdLength)
{
if (nodeId == buffer[offset])
{
@ -134,7 +134,7 @@ bool NormCmdCCMsg::GetCCNode(NormNodeId nodeId,
} // end NormCmdCCMsg::GetCCNode()
NormCmdCCMsg::Iterator::Iterator(const NormCmdCCMsg& msg)
: cc_cmd(msg), offset(0)
: cc_cmd(msg), offset(msg.GetHeaderLength())
{
}
@ -145,7 +145,7 @@ bool NormCmdCCMsg::Iterator::GetNextNode(NormNodeId& nodeId,
UINT16& rate)
{
if ((offset+CC_ITEM_SIZE) > cc_cmd.GetLength()) return false;
const UINT32* ptr = cc_cmd.buffer + cc_cmd.header_length/4;
const UINT32* ptr = cc_cmd.buffer + offset/4;
nodeId = ntohl(ptr[offset/4]);
flags = ((UINT8*)ptr)[offset+CC_FLAGS_OFFSET];
rtt = ((UINT8*)ptr)[offset+CC_RTT_OFFSET];
@ -154,6 +154,7 @@ bool NormCmdCCMsg::Iterator::GetNextNode(NormNodeId& nodeId,
return true;
} // end NormCmdCCMsg::Iterator::GetNextNode()
NormRepairRequest::NormRepairRequest()
: form(INVALID), flags(0), length(0), buffer(NULL), buffer_len(0)
{