Beispiel #1
0
CmResult COFP10PacketOutMsg::StreamTo(ACE_OutputCDR &os)
{
    CmResult lRet = CM_ERROR_FAILURE;
    
    lRet = COFPMessage::StreamTo(os);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10PacketOutMsg::StreamTo, COFPMessage::StreamTo fail\n")));
        return lRet;
    }

    os<<m_tMember.buffer_id;
    os<<m_tMember.in_port;
    os<<m_tMember.actions_len;
    
    bool bGood = os.good_bit();
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    
    std::list<COFP10Action *>::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);
        it++;
    }
    
    if (m_PacketData)
    {
        ACE_DEBUG((LM_DEBUG, 
                   ACE_TEXT("COFP10PacketOutMsg::StreamTo, m_PacketData->total_length() = %u\n"),
                   m_PacketData->total_length()));

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

    return CM_OK;
}
Beispiel #2
0
int
operator<< (ACE_OutputCDR &cdr,
            const ACE_Log_Record &log_record)
{
  // The written message length can't be more than 32 bits (ACE_CDR::ULong)
  // so reduce it here if needed.
  ACE_CDR::ULong u_msglen =
    ACE_Utils::truncate_cast<ACE_CDR::ULong> (log_record.msg_data_len ());

  // Insert each field from <log_record> into the output CDR stream.
  cdr << ACE_CDR::Long (log_record.type ());
  cdr << ACE_CDR::Long (log_record.pid ());
  cdr << ACE_CDR::LongLong (log_record.time_stamp ().sec ());
  cdr << ACE_CDR::Long (log_record.time_stamp ().usec ());
  cdr << u_msglen;
#if defined (ACE_USES_WCHAR)
  cdr.write_wchar_array (log_record.msg_data (), u_msglen);
#else
  cdr.write_char_array (log_record.msg_data (), u_msglen);
#endif /* ACE_USES_WCHAR */
  return cdr.good_bit ();
}
Beispiel #3
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;
}