diff options
author | 2018-06-08 12:27:37 +0000 | |
---|---|---|
committer | 2018-06-08 12:27:37 +0000 | |
commit | 3066cc55c95c7ffaa76ceb1599b61f6f42da626e (patch) | |
tree | 7d755718709035a84d9c9a0c46a272db0e84fbc8 /ucs2-interface/ucs-xml/UcsXml.c | |
parent | 8db2dc7986e6c61ffb70bbf2e99ab76a65c5735d (diff) | |
parent | 8cc415c1706f340e2997270f8a040474681e451e (diff) |
Merge "agl-service-unicens: robustess measure for tx msg" into eel
Diffstat (limited to 'ucs2-interface/ucs-xml/UcsXml.c')
-rw-r--r-- | ucs2-interface/ucs-xml/UcsXml.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/ucs2-interface/ucs-xml/UcsXml.c b/ucs2-interface/ucs-xml/UcsXml.c index 2360c7a..7715cd4 100644 --- a/ucs2-interface/ucs-xml/UcsXml.c +++ b/ucs2-interface/ucs-xml/UcsXml.c @@ -42,6 +42,7 @@ #define RETURN_ASSERT(result) { UcsXml_CB_OnError("Assertion in file=%s, line=%d", 2, __FILE__, __LINE__); return result; } #define MISC_HB(value) ((uint8_t)((uint16_t)(value) >> 8)) #define MISC_LB(value) ((uint8_t)((uint16_t)(value) & (uint16_t)0xFF)) +#define ROUTE_AUTO_ID_START (0x8000) struct UcsXmlRoute { @@ -260,6 +261,7 @@ static ParseResult_t ParseScriptPortWrite(xmlNode *act, Ucs_Ns_Script_t *scr, Pr static ParseResult_t ParseScriptPortRead(xmlNode *act, Ucs_Ns_Script_t *scr, PrivateData_t *priv); static ParseResult_t ParseScriptPause(xmlNode *act, Ucs_Ns_Script_t *scr, PrivateData_t *priv); static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv); +static bool IsAutoRouteId(uint16_t id, PrivateData_t *priv); /************************************************************************/ /* Public Functions */ @@ -708,7 +710,7 @@ static ParseResult_t ParseAll(xmlNode *tree, UcsXmlVal_t *ucs, PrivateData_t *pr uint32_t nodeCount; xmlNode *sub; ParseResult_t result; - priv->autoRouteId = 0x8000; + priv->autoRouteId = ROUTE_AUTO_ID_START; if (!GetCount(tree, NODE, &nodeCount, true)) RETURN_ASSERT(Parse_XmlError); @@ -1535,9 +1537,19 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv) sourceRoute = priv->pRtLst; while (NULL != sourceRoute) { - if (!sourceRoute->isSource) /*There can be more sinks than sources, so count them*/ + if (sourceRoute->isSource) { - ++routeAmount; + struct UcsXmlRoute *sinkRoute = priv->pRtLst; + while (NULL != sinkRoute) + { + if (sourceRoute != sinkRoute + && !sinkRoute->isSource + && (0 == strncmp(sourceRoute->routeName, sinkRoute->routeName, sizeof(sourceRoute->routeName)))) + { + routeAmount++; + } + sinkRoute = sinkRoute->next; + } } sourceRoute = sourceRoute->next; } @@ -1559,22 +1571,30 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv) && !sinkRoute->isSource && (0 == strncmp(sourceRoute->routeName, sinkRoute->routeName, sizeof(sourceRoute->routeName)))) { - Ucs_Rm_Route_t *route = &ucs->pRoutes[ucs->routesSize++]; + Ucs_Rm_Route_t *route; + if(ucs->routesSize >= routeAmount) + { + RETURN_ASSERT(Parse_MemoryError); + } + route = &ucs->pRoutes[ucs->routesSize++]; route->source_endpoint_ptr = sourceRoute->ep; route->sink_endpoint_ptr = sinkRoute->ep; - route->active = sinkRoute->isActive; - route->route_id = sinkRoute->routeId; + if (!IsAutoRouteId(sourceRoute->routeId, priv)) + { + route->active = sourceRoute->isActive; + route->route_id = sourceRoute->routeId; + } + else + { + route->active = sinkRoute->isActive; + route->route_id = sinkRoute->routeId; + } } sinkRoute = sinkRoute->next; } } sourceRoute = sourceRoute->next; } - if (routeAmount != ucs->routesSize) - { - UcsXml_CB_OnError("At least one sink (num=%d) is not connected, because of wrong Route name!", 2, (routeAmount - ucs->routesSize)); - RETURN_ASSERT(Parse_XmlError); - } #ifdef DEBUG /* Third perform checks when running in debug mode*/ @@ -1610,3 +1630,10 @@ static ParseResult_t ParseRoutes(UcsXmlVal_t *ucs, PrivateData_t *priv) #endif return Parse_Success; } + +static bool IsAutoRouteId(uint16_t id, PrivateData_t *priv) +{ + assert(NULL != priv); + return (id >= ROUTE_AUTO_ID_START && id <= priv->autoRouteId); +} + |