Secured event decoding by refactoring deprecated functions. (#1126)
* Secured event and authentication decoding by removing deprecated functions. * Added extended, discrete-value, double-out-of-range, signed-out-of-range, unsigned-out-of-range, change-of-characterstring, change-of-status-flags, change-of-reliability, and change-of-timer event notification encode, decode, and unit testing with #ifdef disabled by default.
This commit is contained in:
+239
-9
@@ -34,10 +34,47 @@ typedef enum {
|
||||
** Based on UnconfirmedEventNotification-Request
|
||||
*/
|
||||
|
||||
/** Enable decoding of complex-event-type property-values. If set to 0, the
|
||||
* values are decoded and discarded. */
|
||||
/** Enable decoding of certain large event parameters.
|
||||
* If set to 0, the values are decoded and discarded,
|
||||
* and the encoders are disabled. */
|
||||
#ifndef BACNET_EVENT_EXTENDED_ENABLED
|
||||
#define BACNET_EVENT_EXTENDED_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_DOUBLE_OUT_OF_RANGE_ENABLED
|
||||
#define BACNET_EVENT_DOUBLE_OUT_OF_RANGE_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_SIGNED_OUT_OF_RANGE_ENABLED
|
||||
#define BACNET_EVENT_SIGNED_OUT_OF_RANGE_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_UNSIGNED_OUT_OF_RANGE_ENABLED
|
||||
#define BACNET_EVENT_UNSIGNED_OUT_OF_RANGE_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_CHANGE_OF_CHARACTERSTRING_ENABLED
|
||||
#define BACNET_EVENT_CHANGE_OF_CHARACTERSTRING_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_CHANGE_OF_STATUS_FLAGS_ENABLED
|
||||
#define BACNET_EVENT_CHANGE_OF_STATUS_FLAGS_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_CHANGE_OF_RELIABILITY_ENABLED
|
||||
#define BACNET_EVENT_CHANGE_OF_RELIABILITY_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_CHANGE_OF_DISCRETE_VALUE_ENABLED
|
||||
#define BACNET_EVENT_CHANGE_OF_DISCRETE_VALUE_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_EVENT_CHANGE_OF_TIMER_ENABLED
|
||||
#define BACNET_EVENT_CHANGE_OF_TIMER_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef BACNET_DECODE_COMPLEX_EVENT_TYPE_PARAMETERS
|
||||
#define BACNET_DECODE_COMPLEX_EVENT_TYPE_PARAMETERS 1
|
||||
#define BACNET_DECODE_COMPLEX_EVENT_TYPE_PARAMETERS 0
|
||||
#endif
|
||||
|
||||
/** Max complex-event-type property-values to decode. Events with more values
|
||||
@@ -46,6 +83,43 @@ typedef enum {
|
||||
#define BACNET_COMPLEX_EVENT_TYPE_MAX_PARAMETERS 5
|
||||
#endif
|
||||
|
||||
typedef struct BACnetEventExtendedParameter {
|
||||
uint8_t tag; /* application tag data type */
|
||||
union {
|
||||
/* NULL - not needed as it is encoded in the tag alone */
|
||||
float Real;
|
||||
bool Boolean;
|
||||
BACNET_UNSIGNED_INTEGER Unsigned_Int;
|
||||
int32_t Signed_Int;
|
||||
double Double;
|
||||
BACNET_OCTET_STRING *Octet_String;
|
||||
BACNET_CHARACTER_STRING *Character_String;
|
||||
BACNET_BIT_STRING *Bit_String;
|
||||
uint32_t Enumerated;
|
||||
BACNET_DATE Date;
|
||||
BACNET_TIME Time;
|
||||
BACNET_OBJECT_ID Object_Id;
|
||||
BACNET_DATE_TIME Date_Time;
|
||||
BACNET_PROPERTY_VALUE *Property_Value;
|
||||
} type;
|
||||
} BACNET_EVENT_EXTENDED_PARAMETER;
|
||||
|
||||
typedef struct BACnetEventDiscreteValue {
|
||||
uint8_t tag; /* application tag data type */
|
||||
union {
|
||||
bool Boolean;
|
||||
BACNET_UNSIGNED_INTEGER Unsigned_Int;
|
||||
int32_t Signed_Int;
|
||||
uint32_t Enumerated;
|
||||
BACNET_CHARACTER_STRING *Character_String;
|
||||
BACNET_OCTET_STRING *Octet_String;
|
||||
BACNET_DATE Date;
|
||||
BACNET_TIME Time;
|
||||
BACNET_OBJECT_ID Object_Id;
|
||||
BACNET_DATE_TIME Date_Time;
|
||||
} type;
|
||||
} BACNET_EVENT_DISCRETE_VALUE;
|
||||
|
||||
typedef struct BACnet_Event_Notification_Data {
|
||||
uint32_t processIdentifier;
|
||||
BACNET_OBJECT_ID initiatingObjectIdentifier;
|
||||
@@ -133,11 +207,34 @@ typedef struct BACnet_Event_Notification_Data {
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
BACNET_LIFE_SAFETY_OPERATION operationExpected;
|
||||
} changeOfLifeSafety;
|
||||
/*
|
||||
** EVENT_EXTENDED
|
||||
**
|
||||
** Not Supported!
|
||||
*/
|
||||
#if BACNET_EVENT_EXTENDED_ENABLED
|
||||
/* EVENT_EXTENDED
|
||||
extended [9] SEQUENCE {
|
||||
vendor-id [0] Unsigned16,
|
||||
extended-event-type [1] Unsigned,
|
||||
parameters [2] SEQUENCE OF CHOICE {
|
||||
null NULL,
|
||||
real REAL,
|
||||
unsigned Unsigned,
|
||||
boolean BOOLEAN,
|
||||
integer INTEGER,
|
||||
double Double,
|
||||
octetstring OCTET STRING,
|
||||
characterstring CharacterString,
|
||||
bitstring BIT STRING,
|
||||
enumerated ENUMERATED,
|
||||
date Date,
|
||||
time Time,
|
||||
objectidentifier BACnetObjectIdentifier,
|
||||
property-value [0] BACnetDeviceObjectPropertyValue
|
||||
}
|
||||
} */
|
||||
struct {
|
||||
uint16_t vendorID;
|
||||
BACNET_UNSIGNED_INTEGER extendedEventType;
|
||||
BACNET_EVENT_EXTENDED_PARAMETER parameters;
|
||||
} extended;
|
||||
#endif
|
||||
/*
|
||||
** EVENT_BUFFER_READY
|
||||
*/
|
||||
@@ -167,7 +264,140 @@ typedef struct BACnet_Event_Notification_Data {
|
||||
/* OPTIONAL - Set authenticationFactor.format_type to
|
||||
AUTHENTICATION_FACTOR_MAX if not being used */
|
||||
} accessEvent;
|
||||
#if (BACNET_DECODE_COMPLEX_EVENT_TYPE_PARAMETERS == 1)
|
||||
#if BACNET_EVENT_DOUBLE_OUT_OF_RANGE_ENABLED
|
||||
/* EVENT_DOUBLE_OUT_OF_RANGE
|
||||
double-out-of-range[14] SEQUENCE {
|
||||
exceeding-value[0] Double,
|
||||
status-flags[1] BACnetStatusFlags,
|
||||
deadband[2] Double,
|
||||
exceeded-limit[3] Double
|
||||
} */
|
||||
struct {
|
||||
double exceedingValue;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
double deadband;
|
||||
double exceededLimit;
|
||||
} doubleOutOfRange;
|
||||
#endif
|
||||
#if BACNET_EVENT_SIGNED_OUT_OF_RANGE_ENABLED
|
||||
/* EVENT_SIGNED_OUT_OF_RANGE
|
||||
signed-out-of-range[14] SEQUENCE {
|
||||
exceeding-value[0] Integer,
|
||||
status-flags[1] BACnetStatusFlags,
|
||||
deadband[2] Unsigned,
|
||||
exceeded-limit[3] Integer
|
||||
} */
|
||||
struct {
|
||||
int32_t exceedingValue;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
uint32_t deadband;
|
||||
int32_t exceededLimit;
|
||||
} signedOutOfRange;
|
||||
#endif
|
||||
#if BACNET_EVENT_UNSIGNED_OUT_OF_RANGE_ENABLED
|
||||
/* EVENT_UNSIGNED_OUT_OF_RANGE
|
||||
unsigned-out-of-range[14] SEQUENCE {
|
||||
exceeding-value[0] Unsigned,
|
||||
status-flags[1] BACnetStatusFlags,
|
||||
deadband[2] Unsigned,
|
||||
exceeded-limit[3] Unsigned
|
||||
} */
|
||||
struct {
|
||||
BACNET_UNSIGNED_INTEGER exceedingValue;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
BACNET_UNSIGNED_INTEGER deadband;
|
||||
BACNET_UNSIGNED_INTEGER exceededLimit;
|
||||
} unsignedOutOfRange;
|
||||
#endif
|
||||
#if BACNET_EVENT_CHANGE_OF_CHARACTERSTRING_ENABLED
|
||||
/* EVENT_CHANGE_OF_CHARACTERSTRING
|
||||
change-of-characterstring [17] SEQUENCE {
|
||||
changed-value [0] CharacterString,
|
||||
status-flags [1] BACnetStatusFlags,
|
||||
alarm-value [2] CharacterString
|
||||
} */
|
||||
struct {
|
||||
BACNET_CHARACTER_STRING *changedValue;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
BACNET_CHARACTER_STRING *alarmValue;
|
||||
} changeOfCharacterstring;
|
||||
#endif
|
||||
#if BACNET_EVENT_CHANGE_OF_STATUS_FLAGS_ENABLED
|
||||
/* EVENT_CHANGE_OF_STATUS_FLAGS
|
||||
change-of-status-flags [18] SEQUENCE {
|
||||
present-value [0] ABSTRACT-SYNTAX.&Type OPTIONAL,
|
||||
-- depends on referenced property
|
||||
referenced-flags [1] BACnetStatusFlags
|
||||
} */
|
||||
/* OPTIONAL - Set present-value.tag to
|
||||
BACNET_APPLICATION_TAG_EMPTYLIST if not used */
|
||||
struct {
|
||||
BACNET_EVENT_EXTENDED_PARAMETER presentValue;
|
||||
BACNET_BIT_STRING referencedFlags;
|
||||
} changeOfStatusFlags;
|
||||
#endif
|
||||
#if BACNET_EVENT_CHANGE_OF_RELIABILITY_ENABLED
|
||||
/* EVENT_CHANGE_OF_RELIABILITY
|
||||
change-of-reliability [19] SEQUENCE {
|
||||
reliability [0] BACnetReliability,
|
||||
status-flags [1] BACnetStatusFlags,
|
||||
property-values [2] SEQUENCE OF BACnetPropertyValue
|
||||
} */
|
||||
struct {
|
||||
BACNET_RELIABILITY reliability;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
BACNET_PROPERTY_VALUE *propertyValues;
|
||||
} changeOfReliability;
|
||||
#endif
|
||||
#if BACNET_EVENT_CHANGE_OF_DISCRETE_VALUE_ENABLED
|
||||
/* EVENT_CHANGE_OF_DISCRETE_VALUE
|
||||
change-of-discrete-value [21] SEQUENCE {
|
||||
new-value [0] CHOICE {
|
||||
boolean BOOLEAN,
|
||||
unsigned Unsigned,
|
||||
integer INTEGER,
|
||||
enumerated ENUMERATED,
|
||||
characterstring CharacterString,
|
||||
octetstring OCTET STRING,
|
||||
date Date,
|
||||
time Time,
|
||||
objectidentifier BACnetObjectIdentifier,
|
||||
datetime [0] BACnetDateTime
|
||||
},
|
||||
status-flags [1] BACnetStatusFlags
|
||||
}*/
|
||||
struct {
|
||||
BACNET_EVENT_DISCRETE_VALUE newValue;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
} changeOfDiscreteValue;
|
||||
#endif
|
||||
#if BACNET_EVENT_CHANGE_OF_TIMER_ENABLED
|
||||
/* EVENT_CHANGE_OF_TIMER
|
||||
change-of-timer [22] SEQUENCE {
|
||||
new-state [0] BACnetTimerState,
|
||||
status-flags [1] BACnetStatusFlags,
|
||||
update-time [2] BACnetDateTime,
|
||||
last-state-change [3] BACnetTimerTransition OPTIONAL,
|
||||
initial-timeout [4] Unsigned OPTIONAL,
|
||||
expiration-time [5] BACnetDateTime OPTIONAL
|
||||
} */
|
||||
/* OPTIONAL - Set last-state-change to TIMER_TRANSITION_MAX
|
||||
if not used. */
|
||||
/* OPTIONAL - Set expiration-time to wildcards if not used. */
|
||||
/* OPTIONAL - Set initial-timeout to 0 if not used. */
|
||||
struct {
|
||||
BACNET_TIMER_STATE newState;
|
||||
BACNET_BIT_STRING statusFlags;
|
||||
BACNET_DATE_TIME updateTime;
|
||||
BACNET_TIMER_TRANSITION lastStateChange;
|
||||
BACNET_UNSIGNED_INTEGER initialTimeout;
|
||||
BACNET_DATE_TIME expirationTime;
|
||||
} changeOfTimer;
|
||||
#endif
|
||||
/*
|
||||
** EVENT_NONE - tag only
|
||||
*/
|
||||
#if BACNET_DECODE_COMPLEX_EVENT_TYPE_PARAMETERS
|
||||
/*
|
||||
* complex-event-type - a sequence of values, used for proprietary event
|
||||
* types
|
||||
|
||||
Reference in New Issue
Block a user