diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn index db31841b9527a0584d0752918a4fb2f83f6a8257..1061841989dcb95096f51dacc22bd852c83e65f7 100644 --- a/LibOneM2M/OneM2M_Functions.ttcn +++ b/LibOneM2M/OneM2M_Functions.ttcn @@ -2048,6 +2048,7 @@ module OneM2M_Functions { var integer vc_localResourceIndex := -1; var MsgIn v_request; var ResponsePrimitive v_response; + var integer v_localResourceIndex := -1; [] mccPortIn.receive(mw_request(mw_create())) -> value v_request { log(__SCOPE__&": WARNING: Unexpected CREATE message received"); @@ -2066,12 +2067,22 @@ module OneM2M_Functions { [] mccPortIn.receive(mw_request(mw_retrieve(f_getLocalResourceAddress(-, e_hierarchical, e_spRelative)))) -> value v_request { tc_ac.stop; log(__SCOPE__&": WARNING: Unexpected RETRIEVE message received"); - - v_response := valueof(m_responsePrimitive(int2000,v_request.primitive.requestPrimitive.requestIdentifier)); - v_response.from_ := PX_CSE1_ID; - v_response.to_ := v_request.primitive.requestPrimitive.from_; - v_response.primitiveContent := vc_localResourcesList[vc_cSEBaseIndex].resource; - mccPortIn.send(m_response(v_response)); + + v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + if(v_localResourceIndex == -1) + { + log(__SCOPE__&": ERROR: Resource Index not valid"); + v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier)); + v_response.from_ := PX_CSE1_ID; + v_response.to_ := v_request.primitive.requestPrimitive.from_; + mccPortIn.send(m_response(v_response)); + } else { + v_response := valueof(m_responsePrimitive(int2000,v_request.primitive.requestPrimitive.requestIdentifier)); + v_response.from_ := PX_CSE1_ID; + v_response.to_ := v_request.primitive.requestPrimitive.from_; + v_response.primitiveContent := vc_localResourcesList[vc_cSEBaseIndex].resource; + mccPortIn.send(m_response(v_response)); + } tc_ac.start; repeat; } @@ -2079,11 +2090,21 @@ module OneM2M_Functions { tc_ac.stop; log(__SCOPE__&": WARNING: Unexpected UPDATE message received"); - v_response := valueof(m_responsePrimitive(int2004,v_request.primitive.requestPrimitive.requestIdentifier)); - v_response.from_ := PX_CSE1_ID; - v_response.to_ := v_request.primitive.requestPrimitive.from_; - v_response.primitiveContent := vc_localResourcesList[vc_localRemoteCseIndex].resource; - mccPortIn.send(m_response(v_response)); + v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_); + if(v_localResourceIndex == -1) + { + log(__SCOPE__&": ERROR: Resource Index not valid"); + v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier)); + v_response.from_ := PX_CSE1_ID; + v_response.to_ := v_request.primitive.requestPrimitive.from_; + mccPortIn.send(m_response(v_response)); + } else { + v_response := valueof(m_responsePrimitive(int2004,v_request.primitive.requestPrimitive.requestIdentifier)); + v_response.from_ := PX_CSE1_ID; + v_response.to_ := v_request.primitive.requestPrimitive.from_; + v_response.primitiveContent := vc_localResourcesList[vc_localRemoteCseIndex].resource; + mccPortIn.send(m_response(v_response)); + } tc_ac.start; repeat; } @@ -2153,7 +2174,7 @@ module OneM2M_Functions { tc_ac.stop; v_rp := v_request.primitive.requestPrimitive; - v_parentIndex := f_getResourceIndex(v_rp.to_, v_rp.primitiveContent); + v_parentIndex := f_getResourceIndex(v_rp.to_); v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType); v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex); if(v_resourceIndex != -1) { @@ -2204,7 +2225,7 @@ module OneM2M_Functions { tc_ac.stop; v_rp := v_request.primitive.requestPrimitive; - v_parentIndex := f_getResourceIndex(v_rp.to_, v_rp.primitiveContent); + v_parentIndex := f_getResourceIndex(v_rp.to_); v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType); v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex); if(v_resourceIndex != -1) { @@ -2328,7 +2349,7 @@ module OneM2M_Functions { [] mcaPort.receive(mw_request(mw_create)) -> value v_request { v_rp := v_request.primitive.requestPrimitive; - v_parentIndex := f_getResourceIndex(v_rp.to_, v_rp.primitiveContent); + v_parentIndex := f_getResourceIndex(v_rp.to_); v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType); v_resourceIndex := f_setLocalResource(v_modifiedResource, v_rp.resourceType, v_parentIndex); if(v_resourceIndex != -1) { @@ -2766,7 +2787,7 @@ module OneM2M_Functions { if (f_isHierarchical(p_receivedURI)) { - v_resourceName := f_resourceIdCleaner(p_receivedURI); //f_getResourceName(p_contentResource); + v_resourceName := f_resourceIdCleaner(p_receivedURI); for(i:=0; i < lengthof(vc_resourcesList); i := i+1){ if(match(f_getResourceName(vc_localResourcesList[i].resource), v_resourceName)){ @@ -2776,7 +2797,7 @@ module OneM2M_Functions { } } else { - v_resourceID := f_resourceIdCleaner(v_resourceID); + v_resourceID := f_resourceIdCleaner(p_receivedURI); for(i:=0; i < lengthof(vc_resourcesList); i := i+1){ if(match(f_getResourceId(vc_localResourcesList[i].resource), v_resourceID)){