Skip to content

Commit

Permalink
Enabled BACnetARRAY checking when using proplist.c and added to apps/…
Browse files Browse the repository at this point in the history
…epics (bacnet-stack#823)
  • Loading branch information
skarg authored Oct 23, 2024
1 parent d3de5c9 commit dcf79b0
Show file tree
Hide file tree
Showing 15 changed files with 420 additions and 296 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ option(
"enable property lists"
ON)

option(
BACNET_PROPERTY_ARRAY_LISTS
"enable property array lists"
ON)

option(
BACNET_BUILD_PIFACE_APP
"compile the piface app"
Expand Down Expand Up @@ -626,7 +621,6 @@ target_compile_definitions(
$<$<BOOL:${BACDL_ETHERNET}>:BACDL_ETHERNET>
$<$<BOOL:${BACDL_NONE}>:BACDL_NONE>
$<$<BOOL:${BACNET_PROPERTY_LISTS}>:BACNET_PROPERTY_LISTS=1>
$<$<BOOL:${BACNET_PROPERTY_ARRAY_LISTS}>:BACNET_PROPERTY_ARRAY_LISTS=1>
$<$<BOOL:${BAC_ROUTING}>:BAC_ROUTING>
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:BACNET_STACK_STATIC_DEFINE>
PRIVATE
Expand Down
1 change: 0 additions & 1 deletion apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ BACNET_DEFINES += -DBACFILE
BACNET_DEFINES += -DINTRINSIC_REPORTING
BACNET_DEFINES += -DBACNET_TIME_MASTER
BACNET_DEFINES += -DBACNET_PROPERTY_LISTS=1
BACNET_DEFINES += -DBACNET_PROPERTY_ARRAY_LISTS=1
BACNET_DEFINES += -DBACNET_PROTOCOL_REVISION=24

# put all the flags together
Expand Down
332 changes: 169 additions & 163 deletions apps/epics/main.c

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/bacnet/basic/object/access_rights.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ bool Access_Rights_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_APPLICATION_DATA_VALUE value = { 0 };
unsigned object_index = 0;

/* only array properties can have array options */
is_array = property_list_bacnet_array_member(
wp_data->object_type, wp_data->object_property);
if (!is_array && (wp_data->array_index != BACNET_ARRAY_ALL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
}
/* decode the some of the request */
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
Expand All @@ -310,14 +318,6 @@ bool Access_Rights_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
/* only array properties can have array options */
is_array = property_list_bacnet_array_member(
wp_data->object_type, wp_data->object_property);
if (is_array && (wp_data->array_index != BACNET_ARRAY_ALL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
}
object_index = Access_Rights_Instance_To_Index(wp_data->object_instance);
switch (wp_data->object_property) {
case PROP_GLOBAL_IDENTIFIER:
Expand Down
11 changes: 9 additions & 2 deletions src/bacnet/basic/object/schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,16 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
bool status = false; /* return value */
int len;
BACNET_APPLICATION_DATA_VALUE value = { 0 };
bool is_array;

/* only array properties can have array options */
is_array = property_list_bacnet_array_member(
wp_data->object_type, wp_data->object_property);
if (!is_array && (wp_data->array_index != BACNET_ARRAY_ALL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
}
/* decode the some of the request */
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
Expand All @@ -432,12 +441,10 @@ bool Schedule_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}

object_index = Schedule_Instance_To_Index(wp_data->object_instance);
if (object_index >= MAX_SCHEDULES) {
return false;
}

switch ((int)wp_data->object_property) {
case PROP_OUT_OF_SERVICE:
status = write_property_type_valid(
Expand Down
22 changes: 13 additions & 9 deletions src/bacnet/basic/object/trendlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ int Trend_Log_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_CHARACTER_STRING char_string;
TL_LOG_INFO *CurrentLog;
uint8_t *apdu = NULL;
bool is_array;

if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
Expand Down Expand Up @@ -405,8 +406,9 @@ int Trend_Log_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
break;
}
/* only array properties can have array options */
if ((apdu_len >= 0) &&
(rpdata->object_property != PROP_EVENT_TIME_STAMPS) &&
is_array = property_list_bacnet_array_member(
rpdata->object_type, rpdata->object_property);
if ((apdu_len >= 0) && (!is_array) &&
(rpdata->array_index != BACNET_ARRAY_ALL)) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
Expand All @@ -427,7 +429,16 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE TempSource;
bool bEffectiveEnable;
int log_index;
bool is_array;

/* only array properties can have array options */
is_array = property_list_bacnet_array_member(
wp_data->object_type, wp_data->object_property);
if (!is_array && (wp_data->array_index != BACNET_ARRAY_ALL)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
}
/* Pin down which log to look at */
log_index = Trend_Log_Instance_To_Index(wp_data->object_instance);
CurrentLog = &LogInfo[log_index];
Expand All @@ -442,13 +453,6 @@ bool Trend_Log_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return false;
}
if ((wp_data->object_property != PROP_EVENT_TIME_STAMPS) &&
(wp_data->array_index != BACNET_ARRAY_ALL)) {
/* only array properties can have array options */
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
return false;
}
switch (wp_data->object_property) {
case PROP_ENABLE:
status = write_property_type_valid(
Expand Down
96 changes: 0 additions & 96 deletions src/bacnet/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
#define BACNET_PROPERTY_LISTS 0
#endif

#ifndef BACNET_PROPERTY_ARRAY_LISTS
#define BACNET_PROPERTY_ARRAY_LISTS 0
#endif

#if BACNET_PROPERTY_LISTS
/** @file property.c List of Required and Optional object properties */
/* note: the PROP_PROPERTY_LIST is NOT included in these lists, on purpose */
Expand Down Expand Up @@ -3194,98 +3190,6 @@ unsigned property_list_special_count(
}
#endif

#if BACNET_PROPERTY_ARRAY_LISTS
/* standard properties that are arrays
but not necessary supported in every object */

static const int Properties_BACnetARRAY[] = {
/* unordered list of properties */
PROP_AUTHENTICATION_FACTORS,
PROP_ASSIGNED_ACCESS_RIGHTS,
PROP_PRIORITY_ARRAY,
PROP_VALUE_SOURCE_ARRAY,
PROP_COMMAND_TIME_ARRAY,
PROP_ALARM_VALUES,
PROP_FAULT_VALUES,
PROP_EVENT_TIME_STAMPS,
PROP_EVENT_MESSAGE_TEXTS,
PROP_EVENT_MESSAGE_TEXTS_CONFIG,
PROP_SUPPORTED_FORMATS,
PROP_SUPPORTED_FORMAT_CLASSES,
PROP_SUBORDINATE_LIST,
PROP_SUBORDINATE_ANNOTATIONS,
PROP_SUBORDINATE_TAGS,
PROP_SUBORDINATE_NODE_TYPES,
PROP_SUBORDINATE_RELATIONSHIPS,
PROP_GROUP_MEMBERS,
PROP_GROUP_MEMBER_NAMES,
PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES,
PROP_EXECUTION_DELAY,
PROP_CONTROL_GROUPS,
PROP_BIT_TEXT,
PROP_PORT_FILTER,
PROP_NOTIFICATION_CLASS,
PROP_STATE_CHANGE_VALUES,
PROP_LINK_SPEEDS,
PROP_IP_DNS_SERVER,
PROP_IPV6_DNS_SERVER,
PROP_FLOOR_TEXT,
PROP_CAR_DOOR_TEXT,
PROP_ASSIGNED_LANDING_CALLS,
PROP_MAKING_CAR_CALL,
PROP_REGISTERED_CAR_CALL,
PROP_CAR_DOOR_STATUS,
PROP_CAR_DOOR_COMMAND,
PROP_LANDING_DOOR_STATUS,
PROP_STAGES,
PROP_STAGE_NAMES,
PROP_TARGET_REFERENCES,
PROP_MONITORED_OBJECTS,
PROP_TAGS,
-1
};

/**
* Function that returns the list of Required properties
* of known standard objects.
*
* @param object_type - enumerated BACNET_OBJECT_TYPE
* @return returns a pointer to a '-1' terminated array of
* type 'int' that contain BACnet object properties for the given object
* type.
*/
const int *property_list_bacnet_array(void)
{
return Properties_BACnetARRAY;
}

/**
* @brief Determine if the object property is a BACnetARRAY property
* @param object_type - object-type to be checked
* @param object_property - object-property to be checked
* @return true if the property is a BACnetARRAY property
*/
bool property_list_bacnet_array_member(
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID object_property)
{
switch (object_type) {
case OBJECT_GLOBAL_GROUP:
switch (object_property) {
case PROP_PRESENT_VALUE:
/* special - the only present-value that is an array! */
return true;
default:
break;
}
break;
default:
break;
}

return property_list_member(Properties_BACnetARRAY, object_property);
}
#endif

/**
* @brief Determine if this property is required to be writable
* @note Property Conformance Code of W means writable
Expand Down
6 changes: 0 additions & 6 deletions src/bacnet/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ BACNET_PROPERTY_ID property_list_special_property(
BACNET_STACK_EXPORT
unsigned property_list_special_count(
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID special_property);

BACNET_STACK_EXPORT
const int *property_list_bacnet_array(void);
BACNET_STACK_EXPORT
bool property_list_bacnet_array_member(
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID object_property);
BACNET_STACK_EXPORT
bool property_list_writable_member(
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID object_property);
Expand Down
Loading

0 comments on commit dcf79b0

Please sign in to comment.