Ejemplo n.º 1
0
CmResult COFP13TableFeatureProp::DecodeMPTFP(ACE_InputCDR &is, COFP13TableFeatureProp * &prop)
{
    ACE_UINT16 type;
    bool bGood = is.pre_read(&type, sizeof(type));
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    ACE_CDR::swap_2(reinterpret_cast<const char *>(&type), reinterpret_cast<char *>(&type));

    COFP13TableFeatureProp *propData = nullptr;
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("COFP13TableFeatureProp::DecodeMPTFP, type=%u\n"), type));

    switch (type)
    {
        case OFPTFPT_INSTRUCTIONS:
        case OFPTFPT_INSTRUCTIONS_MISS:
        {
            propData = new COFP13TableFeaturePropInstruct(type);
            break;
        }
        case OFPTFPT_EXPERIMENTER:
        case OFPTFPT_EXPERIMENTER_MISS:
        {
            propData = new COFP13TableFeaturePropExperimenter(type);
            break;
        }
        case OFPTFPT_NEXT_TABLES:
        case OFPTFPT_NEXT_TABLES_MISS:
        {
            propData = new COFP13TableFeaturePropNextTables(type);
        }
        case OFPTFPT_WRITE_ACTIONS:
        case OFPTFPT_WRITE_ACTIONS_MISS:
        case OFPTFPT_APPLY_ACTIONS:
        case OFPTFPT_APPLY_ACTIONS_MISS:
        {
            propData = new COFP13TableFeaturePropActions(type);
        }
        case OFPTFPT_MATCH:
        case OFPTFPT_WILDCARDS:
        case OFPTFPT_WRITE_SETFIELD:
        case OFPTFPT_WRITE_SETFIELD_MISS:
        case OFPTFPT_APPLY_SETFIELD:
        case OFPTFPT_APPLY_SETFIELD_MISS:
        {
            propData = new COFP13TableFeaturePropOXM(type);
        }
        default:
        {
            break;
        }
    }
    CM_ASSERT_RETURN(propData != nullptr, CM_ERROR_OUT_OF_MEMORY);

    CmResult rv = propData->StreamFrom(is);
    if (CM_FAILED(rv))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP13TableFeatureProp::DecodeMPTFP error\n")));
        return CM_ERROR_FAILURE;
    }

    prop = propData;

    return CM_OK;
}
Ejemplo n.º 2
0
CmResult COFP10Action::
DecodeAction(ACE_InputCDR& is, COFP10Action * &apAction)
{
    CmResult      lRet  = CM_ERROR_FAILURE;
    ACE_UINT16    wType = 0;
    COFP10Action *pAct  = nullptr;
    
    bool bGood = is.pre_read(&wType, sizeof(wType));
    CM_ASSERT_RETURN(bGood, CM_ERROR_FAILURE);
    
	ACE_CDR::swap_2(reinterpret_cast<const char *>(&wType), reinterpret_cast<char *>(&wType));

    switch (wType)
    {
        case OFPAT_OUTPUT:
        {
            pAct = new COFP10ActOutput();
            break;
        }
        case OFPAT_SET_VLAN_VID:
        {
            pAct = new COFP10ActSetVlanVid();
            break;
        }
        case OFPAT_SET_VLAN_PCP:
        {
            pAct = new COFP10ActSetVlanPcp();
            break;
        }
        case OFPAT_STRIP_VLAN:
        {
            pAct = new COFP10ActStripVlan();
            break;
        }
        case OFPAT_SET_DL_SRC:
        case OFPAT_SET_DL_DST:
        {
            pAct = new COFP10ActSetDlAddr(wType);
            break;
        }
        case OFPAT_SET_NW_SRC:
        case OFPAT_SET_NW_DST:
        {
            pAct = new COFP10ActSetNwAddr(wType);
            break;
        }
        case OFPAT_SET_NW_TOS:
        {
            pAct = new COFP10ActSetNwTos();
            break;
        }
        case OFPAT_SET_TP_SRC:
        case OFPAT_SET_TP_DST:
        {
            pAct = new COFP10ActSetTpPort(wType);
            break;
        }
        case OFPAT_ENQUEUE:
        {
            pAct = new COFP10ActEnqueue();
            break;
        }
        default:
        {
            break;
        }
    }
    
    CM_ASSERT_RETURN(pAct != nullptr, CM_ERROR_OUT_OF_MEMORY);

    lRet = pAct->StreamFrom(is);
    if (CM_FAILED(lRet))
    {
        ACE_ERROR((LM_ERROR, ACE_TEXT("COFP10Action::DecodeAction(): fail in StreamFrom(), lRet=%d\n"), lRet));
        return lRet;
    }

    apAction = pAct;
    
    return CM_OK;
}