Ejemplo n.º 1
0
void Logger::dump(bool verbose, unsigned char * buf, int length)
{
    if(verbose && !m_verbose)
        return;
    int num_lines = length / 16;
    if(length % 16 != 0)
        num_lines++;

    // Dump the buffer 16 bytes per line
	int MS=GetMessageLength(buf,length);
    for(int line = 0; line < num_lines; line++)
    {
        int row;
        fprintf(m_fp, "%04x: ", line * 16);

        // Print the bytes of the line as hex
        for(row = 0; row < 16; row++)
        {
            if(line * 16 + row < length)
			{
                fprintf(m_fp, "%02x", buf[line * 16 + row]);
				MS--;
				if(MS==0 && (line * 16 + row + 1)<length) 
				{
					fprintf(m_fp,":");
					MS=GetMessageLength(buf+line * 16 + row+1,length-(line * 16 + row));
				}
				else
					fprintf(m_fp," ");
			}
            else
                fprintf(m_fp, "-- ");
        }
        fprintf(m_fp, ": ");

        // Print the bytes as characters (if printable)
        for(row = 0; row < 16; row++)
        {
            if(line * 16 + row < length)
                fputc(isprint(buf[line * 16 + row])
                    ? buf[line * 16 + row] : '.', m_fp);
        }
        fputc('\n', m_fp);
    }
    if(m_flush)
        fflush(m_fp);
}
Ejemplo n.º 2
0
std::string LSBSoundCoder::GetMessage( const Container* _container, const Key* _key )
{
    // Must be a BMP container
    if ( _container->IsWaveContainer() )
    {
        // Get container
        const WAVContainer* container = 
            static_cast<const WAVContainer*>(_container);

        // Setup Wave container
        SetupContainer(container);

        // Get message length first
        unsigned long messageLength = GetMessageLength();

        // Get message text
        return GetMessageText(messageLength);
    }

    // Error, not a Wave container
    return "";
}
 void MIDIParser::ParseStatusByte ( uchar b )
 {
   ENTER ( "MIDIParser::ParseStatusByte" );
   
   char len=GetMessageLength ( b );
   
   if ( len==2 )
   {
     state=FIRST_OF_ONE;
     tmp_msg.SetStatus ( b );
   }
   else if ( len==3 )
   {
     state=FIRST_OF_TWO;
     tmp_msg.SetStatus ( b );
   }
   else
   {
     state=FIND_STATUS;
     tmp_msg.SetStatus ( 0 );
   }
 }
Ejemplo n.º 4
0
CmResult COFP13PacketOutMsg::StreamTo(ACE_OutputCDR &os)
{
    CmResult lRet = CM_ERROR_FAILURE;
    ACE_CDR::Octet pad[6];
    
    lRet = COFPMessage::StreamTo(os);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13PacketOutMsg::StreamTo, COFPMessage::StreamTo fail\n")));
        return lRet;
    }

    ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13PacketOutMsg::StreamTo():\n")));
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("msgLen=%u\n"), GetMessageLength()));
    
    os<<m_buffer_id;
    os<<m_in_port;
    os<<m_actions_len;
    os.write_octet_array(pad, sizeof(pad));
    
    bool bGood = os.good_bit();
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);

    ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_actions_len=%u\n"), m_actions_len));
    
#if 0
    while(!m_action_list.empty())
    {
        CCmComAutoPtr<COpenFlowProtAction> action;
        action = m_action_list.front();
        m_action_list.pop_front();
        action->EncodeAction(os);
    }
#endif

    ACE_UINT16 i = 0;
    std::list<COFP13Action *>::const_iterator it = m_action_list.begin();
    while(it != m_action_list.end())
    {
        lRet = (*it)->StreamTo(os);
        CM_ASSERT_RETURN(CM_SUCCEEDED(lRet), CM_ERROR_FAILURE);
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("action[%u]'s length=%u\n"), i++, (*it)->GetActionLen()));
        bGood = os.good_bit();
        CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
        it++;
    }

    // just for debugging
    ACE_UINT32 length = sizeof(m_buffer_id)+sizeof(m_in_port)+sizeof(m_actions_len)+sizeof(m_pad);
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("length=%u\n"), length));
    ACE_INT32 dataLen = GetStreamLen()-COFPMessage::GetStreamLen()-length-m_actions_len;
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("dataLen=%d\n"), dataLen));

    if (m_PacketData)
    {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_PacketData->total_length() = %u\n"), m_PacketData->total_length()));

        std::string str = m_PacketData->flatten_chained();
        bGood = os.write_char_array(str.c_str(), str.length());
        CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    }

    return CM_OK;
}