Skip to content

Commit

Permalink
- MMS server: fixed problem in read with component access
Browse files Browse the repository at this point in the history
  • Loading branch information
mzillgith committed Jan 30, 2019
1 parent 080b294 commit 9973ea1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/mms/iso_mms/asn1c/constr_SET_OF.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return 0;
}

#if 0
asn_dec_rval_t
SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
Expand Down Expand Up @@ -909,4 +910,4 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
rv.consumed = 0;
return rv;
}

#endif
65 changes: 38 additions & 27 deletions src/mms/iso_mms/server/mms_read_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ isAccessToArrayComponent(AlternateAccess_t* alternateAccess)
}

static MmsValue*
getComponent(AlternateAccess_t* alternateAccess, MmsVariableSpecification* namedVariable, MmsValue* variableValue)
getComponent(MmsServerConnection connection, MmsDomain* domain, AlternateAccess_t* alternateAccess, MmsVariableSpecification* namedVariable, char* variableName)
{
MmsValue* retValue = NULL;

Expand All @@ -171,33 +171,39 @@ getComponent(AlternateAccess_t* alternateAccess, MmsVariableSpecification* named

int i;

for (i = 0; i < namedVariable->typeSpec.structure.elementCount;
i++) {
for (i = 0; i < namedVariable->typeSpec.structure.elementCount; i++) {

if (strlen(namedVariable->typeSpec.structure.elements[i]->name)
if ((int) strlen(namedVariable->typeSpec.structure.elements[i]->name)
== component.size) {
if (strncmp(
namedVariable->typeSpec.structure.elements[i]->name,
(char*) component.buf, component.size) == 0) {
MmsValue* value = MmsValue_getElement(variableValue, i);

if (alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.alternateAccess
!= NULL) {
retValue =
getComponent(
alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.alternateAccess,
namedVariable->typeSpec.structure.elements[i],
value);
if (!strncmp(namedVariable->typeSpec.structure.elements[i]->name,
(char*) component.buf, component.size))
{
if (strlen(variableName) + component.size < 199) {

strcat(variableName, "$");
strncat(variableName, (const char*) component.buf, component.size);


if (alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.alternateAccess
!= NULL) {
retValue =
getComponent(connection, domain,
alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.alternateAccess,
namedVariable->typeSpec.structure.elements[i],
variableName);
}
else {
retValue = mmsServer_getValue(connection->server, domain, variableName, connection);
}
}
else
retValue = value;
}
}
}
}
}

exit_function: return retValue;
exit_function:
return retValue;
}

static MmsValue*
Expand Down Expand Up @@ -226,7 +232,7 @@ getComponentOfArrayElement(AlternateAccess_t* alternateAccess, MmsVariableSpecif
int i;
for (i = 0; i < structSpec->typeSpec.structure.elementCount; i++) {

if (strlen(structSpec->typeSpec.structure.elements[i]->name)
if ((int) strlen(structSpec->typeSpec.structure.elements[i]->name)
== component.size) {
if (strncmp(structSpec->typeSpec.structure.elements[i]->name,
(char*) component.buf, component.size) == 0) {
Expand Down Expand Up @@ -341,14 +347,19 @@ addNamedVariableToResultList(MmsVariableSpecification* namedVariable, MmsDomain*
MmsValue* value = mmsServer_getValue(connection->server, domain, nameIdStr, connection);

if (alternateAccess != NULL) {
value = getComponent(alternateAccess, namedVariable, value);

if (value != NULL) {
appendValueToResultList(value, values);
}
else {
appendErrorToResultList(values, DATA_ACCESS_ERROR_OBJECT_NONE_EXISTENT);
}
char variableName[200];
variableName[0] = 0;
strcat(variableName, nameIdStr);

value = getComponent(connection, domain, alternateAccess, namedVariable, variableName);

if (value != NULL) {
appendValueToResultList(value, values);
}
else {
appendErrorToResultList(values, DATA_ACCESS_ERROR_OBJECT_NONE_EXISTENT);
}
}
else {
if (value != NULL) {
Expand Down

0 comments on commit 9973ea1

Please sign in to comment.