//COFP13MPAggregateFlowStatsRequestMsg
CmResult COFP13MPAggregateFlowStatsRequestMsg::
StreamFrom(ACE_InputCDR &is)
{
    if (COFP13MultipartMsg::StreamFrom(is) != CM_OK)
    {
        return CM_ERROR_FAILURE;
    }

    is>>m_stats_request.table_id;
    is.read_octet_array(m_stats_request.pad,sizeof(m_stats_request.pad));

    is>>m_stats_request.out_port;
    is>>m_stats_request.out_group;

    is.read_octet_array(m_stats_request.pad2,sizeof(m_stats_request.pad2));

    
    is>>m_stats_request.cookie;
    is>>m_stats_request.cookie_mask;

    bool bGood = is.good_bit();
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    return m_match.StreamFrom(is);

}
CmResult COFP13MPAggregateFlowStatsReplyMsg::
StreamFrom(ACE_InputCDR &is)
{
    if (COFP13MultipartMsg::StreamFrom(is) != CM_OK)
    {
        return CM_ERROR_FAILURE;
    }

    is>>m_flowstats.packet_count;
    is>>m_flowstats.byte_count;
    is>>m_flowstats.flow_count;

    is.read_octet_array(m_flowstats.pad,sizeof(m_flowstats.pad));

    bool bGood = is.good_bit();
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    return CM_OK;

}
Beispiel #3
0
CmResult COFP13PacketOutMsg::StreamFrom(ACE_InputCDR &is)
{
    ACE_INT32 remainActLen = 0;
    ACE_INT32 packet_length = 0;
    ACE_CDR::Octet pad[6];
    CmResult lRet = CM_ERROR_FAILURE;
    
    lRet = COFPMessage::StreamFrom(is);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13PacketOutMsg::StreamFrom(), COFPMessage::StreamFrom fail\n")));
        return lRet;
    }

    ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13PacketOutMsg::StreamFrom(): \n")));
    
    is>>m_buffer_id;
    is>>m_in_port;
    is>>m_actions_len;
    is.read_octet_array(pad, sizeof(pad));
    
    bool bGood = is.good_bit();
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);

    ACE_DEBUG((LM_DEBUG, ACE_TEXT("m_actions_len=%u\n"), m_actions_len));
    
    if (m_actions_len>0)
    {
        remainActLen = m_actions_len;
        ACE_UINT16 i = 0;
        while (remainActLen > 0)
        {
            COFP13Action *action = nullptr;
            CmResult result = COFP13Action::DecodeAction(is, action);
            if (CM_SUCCEEDED(result))
            {
                m_action_list.push_back(action);
                ACE_DEBUG((LM_DEBUG, ACE_TEXT("action[%u], len=%u\n"), i++, action->GetStreamLen()));
                remainActLen = remainActLen - (action->GetStreamLen());
            }
            else
            {
                ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13Action::DecodeAction failed.\n")));
                return CM_ERROR_FAILURE;
            }
        }
    }

    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));

    packet_length = m_wLength-COFPMessage::GetStreamLen()-length-m_actions_len;
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("packet_length=%d, GetStreamLen=%u\n"), packet_length, GetStreamLen()));
    if (packet_length < 0)
    {
        ACE_ERROR((LM_ERROR, 
                   ACE_TEXT("COFP13PacketOutMsg::StreamFrom, error, length=%u, actionlength=%u\n"), 
                   length, 
                   m_actions_len));
        return CM_ERROR_FAILURE;
    }

    ACE_Message_Block data(packet_length);

    ACE_DEBUG((LM_DEBUG, 
               ACE_TEXT("COFP13PacketOutMsg::StreamFrom, wr_ptr=%p, space=%u\n"),
               data.wr_ptr(),
               data.space()));
    
    bGood = is.read_char_array(data.wr_ptr(), packet_length);
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);

    data.wr_ptr((size_t)packet_length);
    
    if (m_PacketData)
    {
        m_PacketData->append(data.duplicate());
    }
    else
    {
        m_PacketData = data.duplicate();
    }

    return CM_OK;
}
Beispiel #4
0
CmResult COFP13HelloMsg::StreamFrom(ACE_InputCDR &is)
{
    CmResult lRet = CM_ERROR_FAILURE;
    ACE_UINT16 i = 0;
    bool bGood;

    lRet = COFPMessage::StreamFrom(is);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13HelloMsg::StreamFrom(), COFPMessage::StreamFrom fail\n")));
        return lRet;
    }
    
    if (m_wLength < COFPMessage::GetStreamLen())
    {
        ACE_ERROR((LM_ERROR, 
                   ACE_TEXT("COFP13HelloMsg::StreamFrom(): "),
                   ACE_TEXT("m_wLength(%u) is less than COFPMessage::GetStreamLen()(%u).\n"), 
                   m_wLength,
                   COFPMessage::GetStreamLen()));
        return CM_ERROR_FAILURE;
    }

    ACE_UINT16 wElemListLen = m_wLength - COFPMessage::GetStreamLen();
    ACE_UINT16 data_size    = wElemListLen;
    ACE_UINT16 iter_size    = 0;
    ACE_CDR::Octet  *pElem        = m_pElemList;

    while (iter_size < wElemListLen)
    {
        ACE_UINT16 elem_type = 0;
        ACE_UINT16 elem_size = 0;  // length of the element, excluding paddings
        
        is>>elem_type;
        is>>elem_size;
        
        bGood = is.good_bit();
        CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
        
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13HelloMsg::StreamFrom(): parse hello elem %u.\n"), i++));
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("elem_type=%u, elem_size=%u\n"), elem_type, elem_size));

        SetHelloElemType(pElem, elem_type);
        SetHelloElemLen(pElem, elem_size);
        
        if (elem_size < 4)
        {
            ACE_ERROR((LM_ERROR, 
                       ACE_TEXT("COFP13HelloMsg::StreamFrom(): elem_size(%u) error, less than 4.\n"),
                       elem_size));
            return CM_ERROR_FAILURE;
        }

        if (((elem_size + 7)/8*8) > data_size)
        {
            ACE_ERROR((LM_ERROR, 
                       ACE_TEXT("COFP13HelloMsg::StreamFrom(): "),
                       ACE_TEXT("((elem_size + 7)/8*8)=%u, greater than data_size(%u)\n"),
                       ((elem_size + 7)/8*8),
                       data_size));
            return CM_ERROR_FAILURE;
        }
        
        if (elem_type != OFPHET_VERSIONBITMAP)
        {
            ACE_ERROR((LM_ERROR, 
                       ACE_TEXT("COFP13HelloMsg::StreamFrom(): elem_type(%u) isnot OFPHET_VERSIONBITMAP(%u)\n"),
                       elem_type,
                       OFPHET_VERSIONBITMAP));
            return CM_ERROR_FAILURE;
        }

        ACE_UINT16 bitmap_size      = elem_size-4;
        CM_ASSERT_RETURN((bitmap_size/4*4 == bitmap_size), CM_ERROR_INVALID_ARG);
        
        ACE_UINT16 iter_bitmap_size = 0;
        ACE_UINT16 bitmap_index     = 0;

        while (iter_bitmap_size < bitmap_size)//(bitmap_size > 0)
        {
            ACE_UINT32 bitmap = 0;
            is>>bitmap;
            bGood = is.good_bit();
            CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("bitmap[%u]=%u\n"), bitmap_index, bitmap));

            SetVerBMHelloElemBitmap(pElem, bitmap_index++, bitmap);
            //bitmap_size -= sizeof(bitmap);
            iter_bitmap_size += sizeof(bitmap);
        }

        // deal with paddings
        ACE_UINT16 pad_size = (elem_size + 7)/8*8 - elem_size;
        is.read_octet_array(pElem + 4 + bitmap_index * sizeof(ACE_UINT32), pad_size);
        bGood = is.good_bit();
        CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
        
        data_size      -= (elem_size + pad_size);
        iter_size      += (elem_size + pad_size);
        pElem          += (elem_size + pad_size);
        m_wElemListLen += (elem_size + pad_size);
    }

    return CM_OK;
}