Example #1
0
/**
 *
 * Method Name:  FormatSenderReport
 *
 *
 * Inputs:   unsigned long  ulBufferSize     - length allocated for the buffer
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 *
 * Outputs:  unsigned char *puchReportBuffer
 *                                    - Buffer used to store the Sender Report
 *
 * Returns:  unsigned long - number of octets written into the buffer.
 *
 * Description: Constructs a Sender report using the buffer passed in by the
 *              caller.  The Sender Report object shall keep track of the
 *              reporting periods that have passed an which information should
 *              be used to populate the report.
 *
 * Usage Notes: The header of the RTCP Report shall be formatted by delegating
 *              to the base class.
 *
 *
 */
unsigned long CSenderReport::FormatSenderReport(
                  unsigned char *puchReportBuffer, unsigned long ulBufferSize)
{

    unsigned long ulReportLength=0;

    // Let's offset into the Formatting buffer enough to
    //  start depositing payload
    unsigned char *puchPayloadBuffer = puchReportBuffer + GetHeaderLength();

    // Let's load the NTP and RTP timestamps into the Sender Report
    puchPayloadBuffer += LoadTimestamps((unsigned long *)puchPayloadBuffer);

    // Let's load the Sender Statistics
    puchPayloadBuffer += LoadSenderStats((unsigned long *)puchPayloadBuffer);

    // Set the sender report length
    ulReportLength = puchPayloadBuffer - puchReportBuffer;

    // Let's slap a header on this report
    FormatRTCPHeader( puchReportBuffer,  // RTCP Report Buffer
          FALSE,                         // No Padding
          1,                             // Receiver Count set to 1 for now
          ulReportLength + RR_LENGTH);   // Report Length

    return(ulReportLength);

}
Example #2
0
void NetPacket::WriteInitHeaderBytes( const uint16_t& ackID, const Byte& connID ){
	//unsigned short ackID = ackID;
	
	WRITE_BYTES(connID);
	
	WRITE_BYTES(ackID);

	Byte messageCount = 0;
	WRITE_BYTES(messageCount);

	curSize += GetHeaderLength();
}
Example #3
0
bool NetPacket::IsValid() {
	
	//validate myself then validate others
	//BinaryBufferParser bp = BinaryBufferParser(buffer, curSize);
	unsigned short ackID = GetAckID();
	UNUSED(ackID);
	Byte messageCount = GetMessageCount();

// 	if (ackID == 0xffff) {
// 		return true;
// 	}

	int validMessageCount = 0;
	for(int i = 0; i < messageCount; i++){
		BinaryBufferParser bp(readMessagesPtr, curSize);
		unsigned short messageLen = bp.ReadNextUShort();
		Byte messageID = bp.ReadNextUChar();

		if (messageLen < MESSAGE_MTU) {
			if (IsNetMessageIDInRegistry(messageID)) {
				validMessageCount++;
			}
		}

		readMessagesPtr += messageLen;
		//make sure it ends at packetLength
		
		//everything after that in the buffer is messages
		//validate each messageIDsocketNetPacketQueue->DequeueRead();
	}

	//add all message lengths + 3 should be packet length


	//reset read messages
	readMessagesPtr = buffer + GetHeaderLength();

	if (validMessageCount == messageCount) {
		return true;
	}

	

	return false;
}
Example #4
0
/**
 *
 * Method Name:  FormatByeReport
 *
 *
 * Inputs:      unsigned long  ulBufferSize - length allocated for the buffer
 *
 * Outputs:     unsigned char *puchReportBuffer
 *                       - Buffer to receive the contents of the Sender Report
 *
 * Returns:     unsigned long  - number of octets written into the buffer.
 *
 * Description: Constructs a Bye report using the buffer passed in by the
 *              caller.
 *
 * Usage Notes: The header of the RTCP Report shall be formatted by
 *              delegating to the base class.
 *
 *
 */
unsigned long CByeReport::FormatByeReport(unsigned char *puchReportBuffer,
        unsigned long ulBufferSize)
{
    unsigned long  ulReportLength, ulCSRCCount = 0;
    unsigned char *puchPayloadBuffer;
    unsigned long l = GetHeaderLength();

    // Let's offset into the Formatting buffer enough to
    // start depositing payload
    puchPayloadBuffer = puchReportBuffer + l;
    // OsSysLog::add(FAC_MP, PRI_DEBUG, "CByeReport::FormatByeReport: GetHeaderLength() = %ld", l);

    // Let's load the field information based upon the period.
    // Conversion to NBO done in GetCSRC().
    ulCSRCCount = GetCSRC((ssrc_t *)puchPayloadBuffer, TRUE);
    puchPayloadBuffer += (ulCSRCCount * sizeof(ssrc_t));

    // Let's load the field information based upon the period
    unsigned long ulReasonLength = GetReason(puchPayloadBuffer+1);
    bool bPadded = FALSE;
    if(ulReasonLength > 0)
    {
        // Adjust the count and payload pointer
        *puchPayloadBuffer++ = (unsigned char)ulReasonLength;
        puchPayloadBuffer += ulReasonLength;

        // Let's load padding onto the end of the packet to
        // ensure 4 byte alignment
        puchPayloadBuffer += LoadPadding(puchPayloadBuffer, &bPadded);
    }

    // Set the report length
    ulReportLength = puchPayloadBuffer - puchReportBuffer;

    // Let's call the RTCP Header base class's formatter so we can prepend
    // a header to this Bye Payload
    FormatRTCPHeader(puchReportBuffer,      // RTCP Report Buffer
                     bPadded,               // Padding Flag
                     ulCSRCCount+1,         // SSRC/CSRC Count
                     ulReportLength);       // Report Length

    return(ulReportLength);
}
Example #5
0
/**
 *
 * Method Name:  ParseByeReport
 *
 *
 * Inputs:   unsigned char *puchReportBuffer - Buffer containing the Bye Report
 *
 * Outputs:  None
 *
 * Returns:  unsigned long
 *
 * Description: Extracts the contents of an Bye report using the buffer
 *              passed in by the caller.
 *
 * Usage Notes: The header of the RTCP Report shall be parsed by delegating
 *              to the base class.
 *
 *
 */
unsigned long CByeReport::ParseByeReport(unsigned char *puchReportBuffer)
{

    unsigned char    *puchPayloadBuffer = puchReportBuffer;

    // Check whether the RTCP Header has been correctly
    //   formed (Version, etc...).
    if(!ParseRTCPHeader(puchReportBuffer))
        return(GetReportLength());

    // Good header.  Let's bump the payload pointer and continue.
    puchPayloadBuffer += GetHeaderLength();


    // Let's store the CSRCs from the Bye Report
    unsigned long ulCSRCCount = GetReportCount() ? GetReportCount() - 1 : 0;

    SetCSRC((ssrc_t *)puchPayloadBuffer, ulCSRCCount, TRUE);
    puchPayloadBuffer += (sizeof(ssrc_t) * ulCSRCCount);

    // Let's determine whether there is an optional Reason field associated
    // with this Bye Report.  We can surmise this through comparing the
    // packet length to what we've already processed

    if(puchPayloadBuffer - puchReportBuffer < (long)GetReportLength())
    {
        uint32_t ulReasonLength = (uint32_t)*puchPayloadBuffer++;
        SetReason(puchPayloadBuffer, ulReasonLength);
        puchPayloadBuffer += ulReasonLength;

    }

    // Let's process any padding that might be present to align the
    // payload on a 32 bit boundary.
    if(GetPadding())
        puchPayloadBuffer += ExtractPadding(puchPayloadBuffer);

    return(puchPayloadBuffer - puchReportBuffer);

}
Example #6
0
/**
 *
 * Method Name:  ParseSenderReport
 *
 *
 * Inputs:   unsigned char *puchReportBuffer
 *                               - Buffer containing the Sender Report
 *
 * Outputs:  None
 *
 * Returns:  unsigned long
 *
 * Description: Extracts the contents of an Sender report using the buffer
 *              passed in by the caller.  The Sender Report object shall store
 *              the content and length of data fields extracted from the Sender
 *              Report.  The timestamps identifying the time of SR report
 *              reception shall obtained and sent with the SR Send timestamp to
 *              the associated Receiver Report through the SetLastRcvdSRTime()
 *              method of the ISetReceiverStatistics interface.
 *
 * Usage Notes: The header of the RTCP Report shall be parsed by delegating to
 *              the base class.
 *
 *
 */
unsigned long CSenderReport::ParseSenderReport(unsigned char *puchReportBuffer)
{

    unsigned char   *puchPayloadBuffer = puchReportBuffer;

    // Check whether the RTCP Header has been correctly
    //  formed (Version, etc...).
    if(!ParseRTCPHeader(puchReportBuffer))
        return(GetReportLength());

    // Good header.  Let's bump the payload pointer and continue.
    puchPayloadBuffer += GetHeaderLength();

    // Let's extract the NTP and RTP timestamps from the Sender Report
    puchPayloadBuffer += ExtractTimestamps((unsigned long *)puchPayloadBuffer);

    // Let's extract the Sender Statistics
    puchPayloadBuffer += ExtractSenderStats((unsigned long*)puchPayloadBuffer);

    return(puchPayloadBuffer - puchReportBuffer);

}
Example #7
0
otError Frame::SetPayloadLength(uint8_t aLength)
{
    SetPsduLength(GetHeaderLength() + GetFooterLength() + aLength);
    return OT_ERROR_NONE;
}
Example #8
0
uint8_t Frame::GetPayloadLength(void) const
{
    return GetPsduLength() - (GetHeaderLength() + GetFooterLength());
}
Example #9
0
uint8_t Frame::GetMaxPayloadLength(void) const
{
    return kMTU - (GetHeaderLength() + GetFooterLength());
}
unsigned long
TMsgDirGetDirContentsReply::GetBaseSize() const
{
	return (GetHeaderLength() + sizeof(short) + sizeof(short));
}