make pretty using clang-format 10

This commit is contained in:
Steve Karg
2020-06-19 14:44:32 -05:00
parent be57c73508
commit 15dce68947
71 changed files with 660 additions and 597 deletions
+5 -4
View File
@@ -170,8 +170,10 @@ int abort_encode_apdu(
* *
* @param apdu Receive buffer * @param apdu Receive buffer
* @param apdu_len Count of bytes valid in the received buffer. * @param apdu_len Count of bytes valid in the received buffer.
* @param invoke_id Pointer to a variable, taking the invoked ID from the message. * @param invoke_id Pointer to a variable, taking the invoked ID from the
* @param abort_reason Pointer to a variable, taking the abort reason, see ABORT_REASON_X enumeration for details * message.
* @param abort_reason Pointer to a variable, taking the abort reason, see
* ABORT_REASON_X enumeration for details
* *
* @return Total length of the apdu, typically 2 on success, zero otherwise. * @return Total length of the apdu, typically 2 on success, zero otherwise.
*/ */
@@ -314,8 +316,7 @@ static void testAbortError(Test *pTest)
error_code = abort_convert_to_error_code(abort_code); error_code = abort_convert_to_error_code(abort_code);
test_abort_code = abort_convert_error_code(error_code); test_abort_code = abort_convert_error_code(error_code);
if (test_abort_code != abort_code) { if (test_abort_code != abort_code) {
printf("Abort: result=%u abort-code=%u\n", printf("Abort: result=%u abort-code=%u\n", test_abort_code,
test_abort_code,
abort_code); abort_code);
} }
ct_test(pTest, test_abort_code == abort_code); ct_test(pTest, test_abort_code == abort_code);
+2 -2
View File
@@ -122,8 +122,8 @@ int bacapp_decode_access_rule(uint8_t *apdu, BACNET_ACCESS_RULE *rule)
} }
if (decode_is_context_tag(&apdu[apdu_len], 2)) { if (decode_is_context_tag(&apdu[apdu_len], 2)) {
len = decode_context_enumerated( len =
&apdu[apdu_len], 2, &location_specifier); decode_context_enumerated(&apdu[apdu_len], 2, &location_specifier);
if (len < 0) { if (len < 0) {
return -1; return -1;
} else if (location_specifier < LOCATION_SPECIFIER_MAX) { } else if (location_specifier < LOCATION_SPECIFIER_MAX) {
+2 -2
View File
@@ -158,8 +158,8 @@ int awf_decode_service_request(
if (apdu_len >= apdu_len_max) { if (apdu_len >= apdu_len_max) {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
len = bacnet_unsigned_application_decode(&apdu[apdu_len], len = bacnet_unsigned_application_decode(
apdu_len_max, &unsigned_value); &apdu[apdu_len], apdu_len_max, &unsigned_value);
if (len <= 0) { if (len <= 0) {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
+1 -2
View File
@@ -141,8 +141,7 @@ int bacapp_encode_application_data(
#if defined(BACAPP_OBJECT_ID) #if defined(BACAPP_OBJECT_ID)
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
apdu_len = encode_application_object_id(&apdu[0], apdu_len = encode_application_object_id(&apdu[0],
value->type.Object_Id.type, value->type.Object_Id.type, value->type.Object_Id.instance);
value->type.Object_Id.instance);
break; break;
#endif #endif
#if defined(BACAPP_LIGHTING_COMMAND) #if defined(BACAPP_LIGHTING_COMMAND)
+32 -21
View File
@@ -725,14 +725,14 @@ int encode_context_bitstring(
/* from clause 20.2.14 Encoding of an Object Identifier Value */ /* from clause 20.2.14 Encoding of an Object Identifier Value */
/* returns the number of apdu bytes consumed */ /* returns the number of apdu bytes consumed */
int decode_object_id( int decode_object_id(
uint8_t *apdu, BACNET_OBJECT_TYPE *object_type,uint32_t *instance) uint8_t *apdu, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
{ {
uint32_t value = 0; uint32_t value = 0;
int len = 0; int len = 0;
len = decode_unsigned32(apdu, &value); len = decode_unsigned32(apdu, &value);
*object_type = (BACNET_OBJECT_TYPE) *object_type = (BACNET_OBJECT_TYPE)(
(((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT)); ((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
*instance = (value & BACNET_MAX_INSTANCE); *instance = (value & BACNET_MAX_INSTANCE);
return len; return len;
@@ -866,14 +866,15 @@ int decode_context_object_id(uint8_t *apdu,
/* from clause 20.2.14 Encoding of an Object Identifier Value */ /* from clause 20.2.14 Encoding of an Object Identifier Value */
/* returns the number of apdu bytes consumed */ /* returns the number of apdu bytes consumed */
int encode_bacnet_object_id int encode_bacnet_object_id(
(uint8_t *apdu, BACNET_OBJECT_TYPE object_type, uint32_t instance) uint8_t *apdu, BACNET_OBJECT_TYPE object_type, uint32_t instance)
{ {
uint32_t value = 0; uint32_t value = 0;
int len = 0; int len = 0;
value = (((uint32_t)object_type & BACNET_MAX_OBJECT) value =
<< BACNET_INSTANCE_BITS) | (instance & BACNET_MAX_INSTANCE); (((uint32_t)object_type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) |
(instance & BACNET_MAX_INSTANCE);
len = encode_unsigned32(apdu, value); len = encode_unsigned32(apdu, value);
return len; return len;
@@ -1313,8 +1314,10 @@ int decode_context_character_string(
* *
* @return number of bytes decoded, or zero if errors occur * @return number of bytes decoded, or zero if errors occur
*/ */
int bacnet_unsigned_decode( int bacnet_unsigned_decode(uint8_t *apdu,
uint8_t *apdu, uint16_t apdu_len_max, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value) uint16_t apdu_len_max,
uint32_t len_value,
BACNET_UNSIGNED_INTEGER *value)
{ {
int len = 0; int len = 0;
uint16_t unsigned16_value = 0; uint16_t unsigned16_value = 0;
@@ -1388,8 +1391,10 @@ int bacnet_unsigned_decode(
* @return number of bytes decoded, zero if wrong tag number, * @return number of bytes decoded, zero if wrong tag number,
* or error (-1) if malformed * or error (-1) if malformed
*/ */
int bacnet_unsigned_context_decode( int bacnet_unsigned_context_decode(uint8_t *apdu,
uint8_t *apdu, uint16_t apdu_len_max, uint8_t tag_value, BACNET_UNSIGNED_INTEGER *value) uint16_t apdu_len_max,
uint8_t tag_value,
BACNET_UNSIGNED_INTEGER *value)
{ {
int apdu_len = 0; int apdu_len = 0;
unsigned len = 0; unsigned len = 0;
@@ -1473,7 +1478,8 @@ int bacnet_unsigned_application_decode(
* *
* @return number of bytes decoded, or zero if errors occur * @return number of bytes decoded, or zero if errors occur
*/ */
int decode_unsigned(uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value) int decode_unsigned(
uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value)
{ {
#ifdef UINT64_MAX #ifdef UINT64_MAX
const uint16_t apdu_len_max = 8; const uint16_t apdu_len_max = 8;
@@ -1496,13 +1502,13 @@ int decode_unsigned(uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *
* @return number of bytes decoded, #BACNET_STATUS_ERROR (-1) if * @return number of bytes decoded, #BACNET_STATUS_ERROR (-1) if
* wrong tag number, or error (-1) if malformed * wrong tag number, or error (-1) if malformed
*/ */
int decode_context_unsigned(uint8_t *apdu, uint8_t tag_value, int decode_context_unsigned(
BACNET_UNSIGNED_INTEGER *value) uint8_t *apdu, uint8_t tag_value, BACNET_UNSIGNED_INTEGER *value)
{ {
#ifdef UINT64_MAX #ifdef UINT64_MAX
const uint16_t apdu_len_max = 3+8; const uint16_t apdu_len_max = 3 + 8;
#else #else
const uint16_t apdu_len_max = 2+4; const uint16_t apdu_len_max = 2 + 4;
#endif #endif
int len = 0; int len = 0;
@@ -1552,7 +1558,8 @@ int encode_bacnet_unsigned(uint8_t *apdu, BACNET_UNSIGNED_INTEGER value)
/* from clause 20.2.4 Encoding of an Unsigned Integer Value */ /* from clause 20.2.4 Encoding of an Unsigned Integer Value */
/* and 20.2.1 General Rules for Encoding BACnet Tags */ /* and 20.2.1 General Rules for Encoding BACnet Tags */
/* returns the number of apdu bytes consumed */ /* returns the number of apdu bytes consumed */
int encode_context_unsigned(uint8_t *apdu, uint8_t tag_number, BACNET_UNSIGNED_INTEGER value) int encode_context_unsigned(
uint8_t *apdu, uint8_t tag_number, BACNET_UNSIGNED_INTEGER value)
{ {
int len = 0; int len = 0;
@@ -1597,7 +1604,8 @@ int bacnet_enumerated_decode(
BACNET_UNSIGNED_INTEGER unsigned_value = 0; BACNET_UNSIGNED_INTEGER unsigned_value = 0;
int len; int len;
len = bacnet_unsigned_decode(apdu, apdu_len_max, len_value, &unsigned_value); len =
bacnet_unsigned_decode(apdu, apdu_len_max, len_value, &unsigned_value);
if (len > 0) { if (len > 0) {
*value = unsigned_value; *value = unsigned_value;
} }
@@ -2434,7 +2442,8 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
if (destination) { if (destination) {
/* network number */ /* network number */
apdu_len += encode_application_unsigned(&apdu[apdu_len], destination->net); apdu_len +=
encode_application_unsigned(&apdu[apdu_len], destination->net);
/* encode mac address as an octet-string */ /* encode mac address as an octet-string */
if (destination->len != 0) { if (destination->len != 0) {
octetstring_init(&mac_addr, destination->adr, destination->len); octetstring_init(&mac_addr, destination->adr, destination->len);
@@ -2450,7 +2459,8 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
* Dencode a BACnetAddress and returns the number of apdu bytes consumed. * Dencode a BACnetAddress and returns the number of apdu bytes consumed.
* *
* @param apdu Receive buffer * @param apdu Receive buffer
* @param destination Pointer to the destination address structure to be filled in. * @param destination Pointer to the destination address structure to be filled
* in.
* *
* @return number of apdu bytes consumed * @return number of apdu bytes consumed
*/ */
@@ -2765,7 +2775,8 @@ static void testBACDCodeDouble(Test *pTest)
return; return;
} }
static void testBACDCodeUnsignedValue(Test *pTest, BACNET_UNSIGNED_INTEGER value) static void testBACDCodeUnsignedValue(
Test *pTest, BACNET_UNSIGNED_INTEGER value)
{ {
uint8_t array[5] = { 0 }; uint8_t array[5] = { 0 };
uint8_t encoded_array[5] = { 0 }; uint8_t encoded_array[5] = { 0 };
+2 -4
View File
@@ -96,8 +96,7 @@ int bacapp_encode_device_obj_property_ref(
* omit */ * omit */
if (value->deviceIdentifier.type == OBJECT_DEVICE) { if (value->deviceIdentifier.type == OBJECT_DEVICE) {
len = encode_context_object_id(&apdu[apdu_len], 3, len = encode_context_object_id(&apdu[apdu_len], 3,
value->deviceIdentifier.type, value->deviceIdentifier.type, value->deviceIdentifier.instance);
value->deviceIdentifier.instance);
apdu_len += len; apdu_len += len;
} }
return apdu_len; return apdu_len;
@@ -231,8 +230,7 @@ int bacapp_encode_device_obj_ref(
* omit */ * omit */
if (value->deviceIdentifier.type == OBJECT_DEVICE) { if (value->deviceIdentifier.type == OBJECT_DEVICE) {
len = encode_context_object_id(&apdu[apdu_len], 0, len = encode_context_object_id(&apdu[apdu_len], 0,
value->deviceIdentifier.type, value->deviceIdentifier.type, value->deviceIdentifier.instance);
value->deviceIdentifier.instance);
apdu_len += len; apdu_len += len;
} }
/* object-identifier [1] BACnetObjectIdentifier */ /* object-identifier [1] BACnetObjectIdentifier */
+1 -3
View File
@@ -300,9 +300,7 @@ bool characterstring_init(BACNET_CHARACTER_STRING *char_string,
} }
bool characterstring_init_ansi_safe( bool characterstring_init_ansi_safe(
BACNET_CHARACTER_STRING * char_string, BACNET_CHARACTER_STRING *char_string, const char *value, size_t tmax)
const char *value,
size_t tmax)
{ {
return characterstring_init(char_string, CHARACTER_ANSI_X34, value, return characterstring_init(char_string, CHARACTER_ANSI_X34, value,
value ? strnlen(value, tmax) : 0); value ? strnlen(value, tmax) : 0);
+6 -5
View File
@@ -45,7 +45,8 @@ static const char *Vendor_Proprietary_String = "Vendor Proprietary Value";
/* Search for a text value first based on the corresponding text list, then by /* Search for a text value first based on the corresponding text list, then by
* attempting to convert to an integer value. */ * attempting to convert to an integer value. */
static bool bactext_strtol_index(INDTEXT_DATA *istring, const char *search_name, unsigned *found_index) static bool bactext_strtol_index(
INDTEXT_DATA *istring, const char *search_name, unsigned *found_index)
{ {
char *endptr; char *endptr;
long value; long value;
@@ -934,13 +935,13 @@ INDTEXT_DATA bacnet_engineering_unit_names[] = {
const char *bactext_engineering_unit_name(unsigned index) const char *bactext_engineering_unit_name(unsigned index)
{ {
if (index <= UNITS_RESERVED_RANGE_MAX) { if (index <= UNITS_RESERVED_RANGE_MAX) {
return indtext_by_index_default(bacnet_engineering_unit_names, return indtext_by_index_default(
index, ASHRAE_Reserved_String); bacnet_engineering_unit_names, index, ASHRAE_Reserved_String);
} else if (index <= UNITS_PROPRIETARY_RANGE_MAX) { } else if (index <= UNITS_PROPRIETARY_RANGE_MAX) {
return Vendor_Proprietary_String; return Vendor_Proprietary_String;
} else if (index <= UNITS_RESERVED_RANGE_MAX2) { } else if (index <= UNITS_RESERVED_RANGE_MAX2) {
return indtext_by_index_default(bacnet_engineering_unit_names, return indtext_by_index_default(
index, ASHRAE_Reserved_String); bacnet_engineering_unit_names, index, ASHRAE_Reserved_String);
} else if (index <= UNITS_PROPRIETARY_RANGE_MAX2) { } else if (index <= UNITS_PROPRIETARY_RANGE_MAX2) {
return Vendor_Proprietary_String; return Vendor_Proprietary_String;
} }
+2 -2
View File
@@ -1026,8 +1026,8 @@ void bvlc6_init(void)
VMAC_Init(); VMAC_Init();
BVLC6_Result_Code = BVLC6_RESULT_SUCCESSFUL_COMPLETION; BVLC6_Result_Code = BVLC6_RESULT_SUCCESSFUL_COMPLETION;
BVLC6_Function_Code = BVLC6_RESULT; BVLC6_Function_Code = BVLC6_RESULT;
bvlc6_address_set(&Remote_BBMD, 0, 0, 0, 0, 0, 0, 0, bvlc6_address_set(
BIP6_MULTICAST_GROUP_ID); &Remote_BBMD, 0, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID);
#if defined(BACDL_BIP6) && BBMD6_ENABLED #if defined(BACDL_BIP6) && BBMD6_ENABLED
memset(&BBMD_Table, 0, sizeof(BBMD_Table)); memset(&BBMD_Table, 0, sizeof(BBMD_Table));
memset(&FD_Table, 0, sizeof(FD_Table)); memset(&FD_Table, 0, sizeof(FD_Table));
+21 -13
View File
@@ -121,7 +121,7 @@ bool address_match(BACNET_ADDRESS *dest, BACNET_ADDRESS *src)
uint8_t max_len = 0; uint8_t max_len = 0;
if (dest == src) { if (dest == src) {
return(true); return (true);
} }
if (dest->mac_len != src->mac_len) { if (dest->mac_len != src->mac_len) {
return false; return false;
@@ -624,7 +624,8 @@ void address_add(uint32_t device_id, unsigned max_apdu, BACNET_ADDRESS *src)
} }
} }
/* If adding has failed, see if we can squeeze it in by removed the oldest entry. */ /* If adding has failed, see if we can squeeze it in by removed the oldest
* entry. */
if (!found) { if (!found) {
pMatch = address_remove_oldest(); pMatch = address_remove_oldest();
if (pMatch != NULL) { if (pMatch != NULL) {
@@ -775,8 +776,10 @@ void address_add_binding(
* *
* @param index Table index [0..MAX_ADDRESS_CACHE-1] * @param index Table index [0..MAX_ADDRESS_CACHE-1]
* @param device_id Pointer to the variable taking the device id. * @param device_id Pointer to the variable taking the device id.
* @param device_ttl Pointer to the variable taking the Time To Life for the device. * @param device_ttl Pointer to the variable taking the Time To Life for the
* @param max_apdu Pointer to the variable taking the max APDU size of the device. * device.
* @param max_apdu Pointer to the variable taking the max APDU size of the
* device.
* @param src Pointer to the BACnet address. * @param src Pointer to the BACnet address.
* *
* @return true/false * @return true/false
@@ -818,7 +821,8 @@ bool address_device_get_by_index(unsigned index,
* *
* @param index Table index [0..MAX_ADDRESS_CACHE-1] * @param index Table index [0..MAX_ADDRESS_CACHE-1]
* @param device_id Pointer to the variable taking the device id. * @param device_id Pointer to the variable taking the device id.
* @param max_apdu Pointer to the variable taking the max APDU size of the device. * @param max_apdu Pointer to the variable taking the max APDU size of the
* device.
* @param src Pointer to the BACnet address. * @param src Pointer to the BACnet address.
* *
* @return true/false * @return true/false
@@ -876,8 +880,9 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) ==
BAC_ADDR_IN_USE) { BAC_ADDR_IN_USE) {
iLen += encode_application_object_id( iLen += encode_application_object_id(
&apdu[iLen], OBJECT_DEVICE, pMatch->device_id); &apdu[iLen], OBJECT_DEVICE, pMatch->device_id);
iLen += encode_application_unsigned(&apdu[iLen], pMatch->address.net); iLen +=
encode_application_unsigned(&apdu[iLen], pMatch->address.net);
if ((unsigned)iLen >= apdu_len) { if ((unsigned)iLen >= apdu_len) {
break; break;
} }
@@ -891,7 +896,8 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
} }
octetstring_init( octetstring_init(
&MAC_Address, pMatch->address.adr, pMatch->address.len); &MAC_Address, pMatch->address.adr, pMatch->address.len);
iLen += encode_application_octet_string(&apdu[iLen], &MAC_Address); iLen +=
encode_application_octet_string(&apdu[iLen], &MAC_Address);
} else { } else {
/* MAC*/ /* MAC*/
if ((unsigned)(iLen + pMatch->address.mac_len) >= apdu_len) { if ((unsigned)(iLen + pMatch->address.mac_len) >= apdu_len) {
@@ -899,7 +905,8 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
} }
octetstring_init( octetstring_init(
&MAC_Address, pMatch->address.mac, pMatch->address.mac_len); &MAC_Address, pMatch->address.mac, pMatch->address.mac_len);
iLen += encode_application_octet_string(&apdu[iLen], &MAC_Address); iLen +=
encode_application_octet_string(&apdu[iLen], &MAC_Address);
} }
/* Any space left? */ /* Any space left? */
if ((unsigned)iLen >= apdu_len) { if ((unsigned)iLen >= apdu_len) {
@@ -1030,7 +1037,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
pMatch++; pMatch++;
/* Shall not happen as the count has been checked first. */ /* Shall not happen as the count has been checked first. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) { if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
return(0); /* Issue with the table. */ return (0); /* Issue with the table. */
} }
} }
@@ -1045,7 +1052,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
} }
/* Shall not happen as the count has been checked first. */ /* Shall not happen as the count has been checked first. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) { if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
return(0); /* Issue with the table. */ return (0); /* Issue with the table. */
} }
} }
@@ -1093,7 +1100,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
pMatch++; pMatch++;
/* Can normally not happen. */ /* Can normally not happen. */
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) { if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
return(0); /* Issue with the table. */ return (0); /* Issue with the table. */
} }
} }
} }
@@ -1116,7 +1123,8 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
* is never called at all the whole cache is effectivly rendered static and * is never called at all the whole cache is effectivly rendered static and
* entries never expire unless explictely deleted. * entries never expire unless explictely deleted.
* *
* @param uSeconds Approximate number of seconds since last call to this function * @param uSeconds Approximate number of seconds since last call to this
* function
*/ */
void address_cache_timer(uint16_t uSeconds) void address_cache_timer(uint16_t uSeconds)
{ {
+2 -1
View File
@@ -76,7 +76,8 @@ void npdu_handler(BACNET_ADDRESS *src, /* source address */
/* only handle the version that we know how to handle */ /* only handle the version that we know how to handle */
if (pdu[0] == BACNET_PROTOCOL_VERSION) { if (pdu[0] == BACNET_PROTOCOL_VERSION) {
apdu_offset = bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data); apdu_offset =
bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
if (npdu_data.network_layer_message) { if (npdu_data.network_layer_message) {
/*FIXME: network layer message received! Handle it! */ /*FIXME: network layer message received! Handle it! */
#if PRINT_ENABLED #if PRINT_ENABLED
+52 -77
View File
@@ -44,28 +44,14 @@ struct object_data {
static struct object_data Object_List[MAX_ACCUMULATORS]; static struct object_data Object_List[MAX_ACCUMULATORS];
/* These three arrays are used by the ReadPropertyMultiple handler */ /* These three arrays are used by the ReadPropertyMultiple handler */
static const int Properties_Required[] = { static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
PROP_OBJECT_NAME, PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_SCALE, PROP_UNITS,
PROP_OBJECT_TYPE, PROP_MAX_PRES_VALUE, -1 };
PROP_PRESENT_VALUE,
PROP_STATUS_FLAGS,
PROP_EVENT_STATE,
PROP_OUT_OF_SERVICE,
PROP_SCALE,
PROP_UNITS,
PROP_MAX_PRES_VALUE,
-1
};
static const int Properties_Optional[] = { static const int Properties_Optional[] = { PROP_DESCRIPTION, -1 };
PROP_DESCRIPTION,
-1
};
static const int Properties_Proprietary[] = { static const int Properties_Proprietary[] = { -1 };
-1
};
/** /**
* Returns the list of required, optional, and proprietary properties. * Returns the list of required, optional, and proprietary properties.
@@ -79,9 +65,7 @@ static const int Properties_Proprietary[] = {
* BACnet proprietary properties for this object. * BACnet proprietary properties for this object.
*/ */
void Accumulator_Property_Lists( void Accumulator_Property_Lists(
const int **pRequired, const int **pRequired, const int **pOptional, const int **pProprietary)
const int **pOptional,
const int **pProprietary)
{ {
if (pRequired) if (pRequired)
*pRequired = Properties_Required; *pRequired = Properties_Required;
@@ -100,8 +84,7 @@ void Accumulator_Property_Lists(
* *
* @return true if the instance is valid, and false if not * @return true if the instance is valid, and false if not
*/ */
bool Accumulator_Valid_Instance( bool Accumulator_Valid_Instance(uint32_t object_instance)
uint32_t object_instance)
{ {
if (object_instance < MAX_ACCUMULATORS) if (object_instance < MAX_ACCUMULATORS)
return true; return true;
@@ -141,8 +124,7 @@ uint32_t Accumulator_Index_To_Instance(unsigned index)
* @return index for the given instance-number, or MAX_ACCUMULATORS * @return index for the given instance-number, or MAX_ACCUMULATORS
* if not valid. * if not valid.
*/ */
unsigned Accumulator_Instance_To_Index( unsigned Accumulator_Instance_To_Index(uint32_t object_instance)
uint32_t object_instance)
{ {
unsigned index = MAX_ACCUMULATORS; unsigned index = MAX_ACCUMULATORS;
@@ -163,15 +145,14 @@ unsigned Accumulator_Instance_To_Index(
* @return true if object-name was retrieved * @return true if object-name was retrieved
*/ */
bool Accumulator_Object_Name( bool Accumulator_Object_Name(
uint32_t object_instance, uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
BACNET_CHARACTER_STRING * object_name)
{ {
static char text_string[32]; /* okay for single thread */ static char text_string[32]; /* okay for single thread */
bool status = false; bool status = false;
if (object_instance < MAX_ACCUMULATORS) { if (object_instance < MAX_ACCUMULATORS) {
sprintf(text_string, "ACCUMULATOR-%lu", sprintf(
(long unsigned int)object_instance); text_string, "ACCUMULATOR-%lu", (long unsigned int)object_instance);
status = characterstring_init_ansi(object_name, text_string); status = characterstring_init_ansi(object_name, text_string);
} }
@@ -205,8 +186,7 @@ BACNET_UNSIGNED_INTEGER Accumulator_Present_Value(uint32_t object_instance)
* @return true if values are within range and present-value is set. * @return true if values are within range and present-value is set.
*/ */
bool Accumulator_Present_Value_Set( bool Accumulator_Present_Value_Set(
uint32_t object_instance, uint32_t object_instance, BACNET_UNSIGNED_INTEGER value)
BACNET_UNSIGNED_INTEGER value)
{ {
bool status = false; bool status = false;
@@ -233,7 +213,7 @@ uint16_t Accumulator_Units(uint32_t object_instance)
units = UNITS_WATT_HOURS; units = UNITS_WATT_HOURS;
} }
return units; return units;
} }
/** /**
@@ -255,7 +235,7 @@ int32_t Accumulator_Scale_Integer(uint32_t object_instance)
scale = Object_List[object_instance].Scale; scale = Object_List[object_instance].Scale;
} }
return scale; return scale;
} }
/** /**
@@ -279,7 +259,7 @@ bool Accumulator_Scale_Integer_Set(uint32_t object_instance, int32_t scale)
status = true; status = true;
} }
return status; return status;
} }
/** /**
@@ -301,7 +281,7 @@ BACNET_UNSIGNED_INTEGER Accumulator_Max_Pres_Value(uint32_t object_instance)
max_value = BACNET_UNSIGNED_INTEGER_MAX; max_value = BACNET_UNSIGNED_INTEGER_MAX;
} }
return max_value; return max_value;
} }
/** /**
@@ -314,10 +294,9 @@ BACNET_UNSIGNED_INTEGER Accumulator_Max_Pres_Value(uint32_t object_instance)
* @return number of APDU bytes in the response, or * @return number of APDU bytes in the response, or
* BACNET_STATUS_ERROR on error. * BACNET_STATUS_ERROR on error.
*/ */
int Accumulator_Read_Property( int Accumulator_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
BACNET_READ_PROPERTY_DATA * rpdata)
{ {
int apdu_len = 0; /* return value */ int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string; BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string; BACNET_CHARACTER_STRING char_string;
uint8_t *apdu = NULL; uint8_t *apdu = NULL;
@@ -327,11 +306,10 @@ int Accumulator_Read_Property(
return 0; return 0;
} }
apdu = rpdata->application_data; apdu = rpdata->application_data;
switch ((int) rpdata->object_property) { switch ((int)rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER: case PROP_OBJECT_IDENTIFIER:
apdu_len = apdu_len = encode_application_object_id(
encode_application_object_id(&apdu[0], OBJECT_ACCUMULATOR, &apdu[0], OBJECT_ACCUMULATOR, rpdata->object_instance);
rpdata->object_instance);
break; break;
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
@@ -340,21 +318,21 @@ int Accumulator_Read_Property(
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
break; break;
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
apdu_len = encode_application_enumerated(&apdu[0], OBJECT_ACCUMULATOR); apdu_len =
encode_application_enumerated(&apdu[0], OBJECT_ACCUMULATOR);
break; break;
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
apdu_len = encode_application_unsigned(&apdu[0], apdu_len = encode_application_unsigned(
Accumulator_Present_Value(rpdata->object_instance)); &apdu[0], Accumulator_Present_Value(rpdata->object_instance));
break; break;
case PROP_SCALE: case PROP_SCALE:
/* context tagged choice: [0]=REAL, [1]=INTEGER */ /* context tagged choice: [0]=REAL, [1]=INTEGER */
apdu_len = encode_context_signed(&apdu[apdu_len], 1, apdu_len = encode_context_signed(&apdu[apdu_len], 1,
Accumulator_Scale_Integer(rpdata->object_instance)); Accumulator_Scale_Integer(rpdata->object_instance));
break; break;
case PROP_MAX_PRES_VALUE: case PROP_MAX_PRES_VALUE:
apdu_len = apdu_len = encode_application_unsigned(
encode_application_unsigned(&apdu[0], &apdu[0], Accumulator_Max_Pres_Value(rpdata->object_instance));
Accumulator_Max_Pres_Value(rpdata->object_instance));
break; break;
case PROP_STATUS_FLAGS: case PROP_STATUS_FLAGS:
bitstring_init(&bit_string); bitstring_init(&bit_string);
@@ -372,7 +350,8 @@ int Accumulator_Read_Property(
apdu_len = encode_application_boolean(&apdu[0], false); apdu_len = encode_application_boolean(&apdu[0], false);
break; break;
case PROP_UNITS: case PROP_UNITS:
apdu_len = encode_application_enumerated(&apdu[0], Accumulator_Units(rpdata->object_instance)); apdu_len = encode_application_enumerated(
&apdu[0], Accumulator_Units(rpdata->object_instance));
break; break;
default: default:
rpdata->error_class = ERROR_CLASS_PROPERTY; rpdata->error_class = ERROR_CLASS_PROPERTY;
@@ -398,16 +377,14 @@ int Accumulator_Read_Property(
* *
* @return false if an error is loaded, true if no errors * @return false if an error is loaded, true if no errors
*/ */
bool Accumulator_Write_Property( bool Accumulator_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_WRITE_PROPERTY_DATA * wp_data)
{ {
int len = 0; int len = 0;
BACNET_APPLICATION_DATA_VALUE value; BACNET_APPLICATION_DATA_VALUE value;
/* decode the some of the request */ /* decode the some of the request */
len = len = bacapp_decode_application_data(
bacapp_decode_application_data(wp_data->application_data, wp_data->application_data, wp_data->application_data_len, &value);
wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */ /* FIXME: len < application_data_len: more data? */
if (len < 0) { if (len < 0) {
/* error while decoding - a value larger than we can handle */ /* error while decoding - a value larger than we can handle */
@@ -427,7 +404,7 @@ bool Accumulator_Write_Property(
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
case PROP_OBJECT_TYPE: case PROP_OBJECT_TYPE:
case PROP_PRESENT_VALUE: case PROP_PRESENT_VALUE:
case PROP_SCALE: case PROP_SCALE:
case PROP_MAX_PRES_VALUE: case PROP_MAX_PRES_VALUE:
case PROP_STATUS_FLAGS: case PROP_STATUS_FLAGS:
case PROP_EVENT_STATE: case PROP_EVENT_STATE:
@@ -454,9 +431,9 @@ void Accumulator_Init(void)
unsigned i = 0; unsigned i = 0;
for (i = 0; i < MAX_ACCUMULATORS; i++) { for (i = 0; i < MAX_ACCUMULATORS; i++) {
Accumulator_Scale_Integer_Set(i, i+1); Accumulator_Scale_Integer_Set(i, i + 1);
Accumulator_Present_Value_Set(i, unsigned_value); Accumulator_Present_Value_Set(i, unsigned_value);
unsigned_value |= (unsigned_value<<1); unsigned_value |= (unsigned_value << 1);
} }
} }
@@ -466,14 +443,13 @@ void Accumulator_Init(void)
#include "ctest.h" #include "ctest.h"
#include "bactext.h" #include "bactext.h"
void test_Accumulator( void test_Accumulator(Test *pTest)
Test * pTest)
{ {
uint8_t apdu[MAX_APDU] = { 0 }; uint8_t apdu[MAX_APDU] = { 0 };
int len = 0; int len = 0;
int test_len = 0; int test_len = 0;
BACNET_READ_PROPERTY_DATA rpdata = {0}; BACNET_READ_PROPERTY_DATA rpdata = { 0 };
BACNET_APPLICATION_DATA_VALUE value = {0}; BACNET_APPLICATION_DATA_VALUE value = { 0 };
const int *property = &Properties_Required[0]; const int *property = &Properties_Required[0];
BACNET_UNSIGNED_INTEGER unsigned_value = 1; BACNET_UNSIGNED_INTEGER unsigned_value = 1;
@@ -489,11 +465,11 @@ void test_Accumulator(
len = Accumulator_Read_Property(&rpdata); len = Accumulator_Read_Property(&rpdata);
ct_test(pTest, len != 0); ct_test(pTest, len != 0);
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) { if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
test_len = bacapp_decode_context_data(rpdata.application_data, test_len = bacapp_decode_context_data(
len, &value, rpdata.object_property); rpdata.application_data, len, &value, rpdata.object_property);
} else { } else {
test_len = bacapp_decode_application_data(rpdata.application_data, test_len = bacapp_decode_application_data(
len, &value); rpdata.application_data, len, &value);
} }
if (len != test_len) { if (len != test_len) {
printf("property '%s': failed to decode!\n", printf("property '%s': failed to decode!\n",
@@ -508,17 +484,16 @@ void test_Accumulator(
Accumulator_Present_Value_Set(0, unsigned_value); Accumulator_Present_Value_Set(0, unsigned_value);
len = Accumulator_Read_Property(&rpdata); len = Accumulator_Read_Property(&rpdata);
ct_test(pTest, len != 0); ct_test(pTest, len != 0);
test_len = bacapp_decode_application_data(rpdata.application_data, test_len = bacapp_decode_application_data(
len, &value); rpdata.application_data, len, &value);
ct_test(pTest, len == test_len); ct_test(pTest, len == test_len);
unsigned_value |= (unsigned_value<<1); unsigned_value |= (unsigned_value << 1);
} }
return; return;
} }
int main( int main(void)
void)
{ {
Test *pTest; Test *pTest;
bool rc; bool rc;
@@ -530,7 +505,7 @@ int main(
ct_setStream(pTest, stdout); ct_setStream(pTest, stdout);
ct_run(pTest); ct_run(pTest);
(void) ct_report(pTest); (void)ct_report(pTest);
ct_destroy(pTest); ct_destroy(pTest);
return 0; return 0;
+3 -2
View File
@@ -190,7 +190,7 @@ bool Access_Door_Present_Value_Set(
index = Access_Door_Instance_To_Index(object_instance); index = Access_Door_Instance_To_Index(object_instance);
if (index < MAX_ACCESS_DOORS) { if (index < MAX_ACCESS_DOORS) {
if (priority && (priority <= BACNET_MAX_PRIORITY) && if (priority && (priority <= BACNET_MAX_PRIORITY) &&
(priority != 6 /* reserved */) && (priority != 6 /* reserved */) &&
(value <= DOOR_VALUE_EXTENDED_PULSE_UNLOCK)) { (value <= DOOR_VALUE_EXTENDED_PULSE_UNLOCK)) {
ad_descr[index].value_active[priority - 1] = true; ad_descr[index].value_active[priority - 1] = true;
ad_descr[index].priority_array[priority - 1] = value; ad_descr[index].priority_array[priority - 1] = value;
@@ -467,7 +467,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
algorithm and may not be used for other purposes in any algorithm and may not be used for other purposes in any
object. */ object. */
status = Access_Door_Present_Value_Set(wp_data->object_instance, status = Access_Door_Present_Value_Set(wp_data->object_instance,
(BACNET_DOOR_VALUE)value.type.Enumerated, wp_data->priority); (BACNET_DOOR_VALUE)value.type.Enumerated,
wp_data->priority);
if (wp_data->priority == 6) { if (wp_data->priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off /* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any algorithm and may not be used for other purposes in any
+6 -3
View File
@@ -64,7 +64,8 @@ static const int Analog_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Analog_Value_Properties_Proprietary[] = { -1 }; static const int Analog_Value_Properties_Proprietary[] = { -1 };
/** /**
* Initialize the pointers for the required, the optional and the properitary value properties. * Initialize the pointers for the required, the optional and the properitary
* value properties.
* *
* @param pRequired - Pointer to the pointer of required values. * @param pRequired - Pointer to the pointer of required values.
* @param pOptional - Pointer to the pointer of optional values. * @param pOptional - Pointer to the pointer of optional values.
@@ -477,7 +478,8 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
if (Analog_Value_Object_Name(rpdata->object_instance, &char_string)) { if (Analog_Value_Object_Name(
rpdata->object_instance, &char_string)) {
apdu_len = apdu_len =
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
} }
@@ -667,7 +669,8 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
/** /**
* Set the requested property of the analog value. * Set the requested property of the analog value.
* *
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details. * @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
* details.
* *
* @return true if successful * @return true if successful
*/ */
+6 -3
View File
@@ -63,7 +63,8 @@ static const int Binary_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Binary_Value_Properties_Proprietary[] = { -1 }; static const int Binary_Value_Properties_Proprietary[] = { -1 };
/** /**
* Initialize the pointers for the required, the optional and the properitary value properties. * Initialize the pointers for the required, the optional and the properitary
* value properties.
* *
* @param pRequired - Pointer to the pointer of required values. * @param pRequired - Pointer to the pointer of required values.
* @param pOptional - Pointer to the pointer of optional values. * @param pOptional - Pointer to the pointer of optional values.
@@ -302,7 +303,8 @@ int Binary_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
You could make Description writable and different */ You could make Description writable and different */
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
if (Binary_Value_Object_Name(rpdata->object_instance, &char_string)) { if (Binary_Value_Object_Name(
rpdata->object_instance, &char_string)) {
apdu_len = apdu_len =
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
} }
@@ -405,7 +407,8 @@ int Binary_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
/** /**
* Set the requested property of the binary value. * Set the requested property of the binary value.
* *
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details. * @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
* details.
* *
* @return true if successful * @return true if successful
*/ */
@@ -115,9 +115,9 @@ static object_functions_t Object_Table[] = {
Device_Count, Device_Index_To_Instance, Device_Count, Device_Index_To_Instance,
Device_Valid_Object_Instance_Number, Device_Object_Name, Device_Valid_Object_Instance_Number, Device_Object_Name,
Device_Read_Property_Local, NULL /* Write_Property */, Device_Read_Property_Local, NULL /* Write_Property */,
Device_Property_Lists, NULL /* ReadRangeInfo */, Device_Property_Lists, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */, NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ }, NULL /* Intrinsic Reporting */ },
#if (BACNET_PROTOCOL_REVISION >= 17) #if (BACNET_PROTOCOL_REVISION >= 17)
{ OBJECT_NETWORK_PORT, Network_Port_Init, Network_Port_Count, { OBJECT_NETWORK_PORT, Network_Port_Init, Network_Port_Count,
Network_Port_Index_To_Instance, Network_Port_Valid_Instance, Network_Port_Index_To_Instance, Network_Port_Valid_Instance,
@@ -225,8 +225,7 @@ static const int Device_Properties_Optional[] = {
#if defined(BACDL_MSTP) #if defined(BACDL_MSTP)
PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES, PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES,
#endif #endif
PROP_DESCRIPTION, PROP_LOCATION, PROP_ACTIVE_COV_SUBSCRIPTIONS, PROP_DESCRIPTION, PROP_LOCATION, PROP_ACTIVE_COV_SUBSCRIPTIONS, -1
-1
}; };
static const int Device_Properties_Proprietary[] = { -1 }; static const int Device_Properties_Proprietary[] = { -1 };
@@ -650,8 +649,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up. * @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device. * @return True if found, else False if no such Object in this device.
*/ */
bool Device_Valid_Object_Id bool Device_Valid_Object_Id(
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance) BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{ {
bool status = false; /* return value */ bool status = false; /* return value */
struct object_functions *pObject = NULL; struct object_functions *pObject = NULL;
+2 -4
View File
@@ -204,8 +204,7 @@ int cl_decode_apdu(uint8_t *apdu,
len = decode_tag_number_and_value( len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type); &apdu[dec_len], &tag_number, &len_value_type);
dec_len += len; dec_len += len;
len = decode_unsigned( len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) { if (len < 0) {
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
@@ -229,8 +228,7 @@ int cl_decode_apdu(uint8_t *apdu,
&apdu[dec_len], 4, &bcl->Value.type.Boolean); &apdu[dec_len], 4, &bcl->Value.type.Boolean);
break; break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT: case BACNET_APPLICATION_TAG_UNSIGNED_INT:
len = decode_context_unsigned( len = decode_context_unsigned(&apdu[dec_len], 4, &unsigned_value);
&apdu[dec_len], 4, &unsigned_value);
if (len < 0) { if (len < 0) {
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
+17 -9
View File
@@ -62,7 +62,8 @@ static const int Properties_Optional[] = { PROP_EVENT_STATE,
static const int Properties_Proprietary[] = { -1 }; static const int Properties_Proprietary[] = { -1 };
/** /**
* Initialize the pointers for the required, the optional and the properitary value properties. * Initialize the pointers for the required, the optional and the properitary
* value properties.
* *
* @param pRequired - Pointer to the pointer of required values. * @param pRequired - Pointer to the pointer of required values.
* @param pOptional - Pointer to the pointer of optional values. * @param pOptional - Pointer to the pointer of optional values.
@@ -278,7 +279,8 @@ static char *CharacterString_Value_Description(uint32_t object_instance)
* For a given object instance-number, set the description text. * For a given object instance-number, set the description text.
* *
* @param object_instance - object-instance number of the object * @param object_instance - object-instance number of the object
* @param new_descr - C-String pointer to the string, representing the description text * @param new_descr - C-String pointer to the string, representing the
* description text
* *
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
@@ -300,7 +302,8 @@ bool CharacterString_Value_Description_Set(
} }
} }
} else { } else {
memset(&Object_Description[index][0], 0, sizeof(Object_Description[index])); memset(&Object_Description[index][0], 0,
sizeof(Object_Description[index]));
} }
} }
@@ -311,7 +314,8 @@ bool CharacterString_Value_Description_Set(
* For a given object instance-number, return the object text. * For a given object instance-number, return the object text.
* *
* @param object_instance - object-instance number of the object * @param object_instance - object-instance number of the object
* @param object_name - Pointer to the BACnet string object that shall take the object name * @param object_name - Pointer to the BACnet string object that shall take the
* object name
* *
* @return True on success, false otherwise. * @return True on success, false otherwise.
*/ */
@@ -390,7 +394,8 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
} }
/* Valid object? */ /* Valid object? */
object_index = CharacterString_Value_Instance_To_Index(rpdata->object_instance); object_index =
CharacterString_Value_Instance_To_Index(rpdata->object_instance);
if (object_index >= MAX_CHARACTERSTRING_VALUES) { if (object_index >= MAX_CHARACTERSTRING_VALUES) {
rpdata->error_class = ERROR_CLASS_OBJECT; rpdata->error_class = ERROR_CLASS_OBJECT;
rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT; rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
@@ -408,14 +413,15 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
You could make Description writable and different */ You could make Description writable and different */
case PROP_OBJECT_NAME: case PROP_OBJECT_NAME:
if (CharacterString_Value_Object_Name( if (CharacterString_Value_Object_Name(
rpdata->object_instance, &char_string)) { rpdata->object_instance, &char_string)) {
apdu_len = apdu_len =
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
} }
break; break;
case PROP_DESCRIPTION: case PROP_DESCRIPTION:
if (characterstring_init_ansi(&char_string, if (characterstring_init_ansi(&char_string,
CharacterString_Value_Description(rpdata->object_instance))) { CharacterString_Value_Description(
rpdata->object_instance))) {
apdu_len = apdu_len =
encode_application_character_string(&apdu[0], &char_string); encode_application_character_string(&apdu[0], &char_string);
} }
@@ -474,7 +480,8 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
/** /**
* Set the requested property of the character string value. * Set the requested property of the character string value.
* *
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details. * @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
* details.
* *
* @return true if successful * @return true if successful
*/ */
@@ -504,7 +511,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
} }
/* Valid object? */ /* Valid object? */
object_index = CharacterString_Value_Instance_To_Index(wp_data->object_instance); object_index =
CharacterString_Value_Instance_To_Index(wp_data->object_instance);
if (object_index >= MAX_CHARACTERSTRING_VALUES) { if (object_index >= MAX_CHARACTERSTRING_VALUES) {
wp_data->error_class = ERROR_CLASS_OBJECT; wp_data->error_class = ERROR_CLASS_OBJECT;
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT; wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
+5 -6
View File
@@ -251,13 +251,12 @@ static object_functions_t My_Object_Table[] = {
Schedule_Property_Lists, NULL /* ReadRangeInfo */, NULL /* Iterator */, Schedule_Property_Lists, NULL /* ReadRangeInfo */, NULL /* Iterator */,
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */, NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
NULL /* Intrinsic Reporting */ }, NULL /* Intrinsic Reporting */ },
{OBJECT_ACCUMULATOR, Accumulator_Init, Accumulator_Count, { OBJECT_ACCUMULATOR, Accumulator_Init, Accumulator_Count,
Accumulator_Index_To_Instance, Accumulator_Valid_Instance, Accumulator_Index_To_Instance, Accumulator_Valid_Instance,
Accumulator_Object_Name, Accumulator_Read_Property, Accumulator_Object_Name, Accumulator_Read_Property,
Accumulator_Write_Property, Accumulator_Property_Lists, Accumulator_Write_Property, Accumulator_Property_Lists,
NULL /* ReadRangeInfo */ , NULL /* Iterator */ , NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */,
NULL /* Value_Lists */ , NULL /* COV */ , NULL /* COV Clear */ , NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
NULL /* Intrinsic Reporting */ },
{ MAX_BACNET_OBJECT_TYPE, NULL /* Init */, NULL /* Count */, { MAX_BACNET_OBJECT_TYPE, NULL /* Init */, NULL /* Count */,
NULL /* Index_To_Instance */, NULL /* Valid_Instance */, NULL /* Index_To_Instance */, NULL /* Valid_Instance */,
NULL /* Object_Name */, NULL /* Read_Property */, NULL /* Object_Name */, NULL /* Read_Property */,
@@ -926,8 +925,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
* @param object_instance [in] The object instance number to be looked up. * @param object_instance [in] The object instance number to be looked up.
* @return True if found, else False if no such Object in this device. * @return True if found, else False if no such Object in this device.
*/ */
bool Device_Valid_Object_Id bool Device_Valid_Object_Id(
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance) BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
{ {
bool status = false; /* return value */ bool status = false; /* return value */
struct object_functions *pObject = NULL; struct object_functions *pObject = NULL;
+2 -4
View File
@@ -1210,8 +1210,7 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
BACNET_LIGHTING_COMMAND *pCommand, BACNET_LIGHTING_COMMAND *pCommand,
uint16_t milliseconds) uint16_t milliseconds)
{ {
if (pLight && pCommand) { if (pLight && pCommand) { }
}
} }
/** /**
@@ -1226,8 +1225,7 @@ static void Lighting_Output_Fade_Handler(struct lighting_output_object *pLight,
BACNET_LIGHTING_COMMAND *pCommand, BACNET_LIGHTING_COMMAND *pCommand,
uint16_t milliseconds) uint16_t milliseconds)
{ {
if (pLight && pCommand) { if (pLight && pCommand) { }
}
} }
/** /**
+5 -5
View File
@@ -933,8 +933,8 @@ bool Network_Port_IP_Subnet(
if ((prefix > 0) && (prefix <= 32)) { if ((prefix > 0) && (prefix <= 32)) {
mask = (0xFFFFFFFF << (32 - prefix)) & 0xFFFFFFFF; mask = (0xFFFFFFFF << (32 - prefix)) & 0xFFFFFFFF;
encode_unsigned32(ip_mask, mask); encode_unsigned32(ip_mask, mask);
status = octetstring_init(subnet_mask, ip_mask, status =
sizeof(ip_mask)); octetstring_init(subnet_mask, ip_mask, sizeof(ip_mask));
} }
} }
} }
@@ -1319,7 +1319,7 @@ bool Network_Port_BIP6_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
if (index < BACNET_NETWORK_PORTS_MAX) { if (index < BACNET_NETWORK_PORTS_MAX) {
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) { if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
if (Object_List[index].Network.IPv4.Mode != value) { if (Object_List[index].Network.IPv4.Mode != value) {
Object_List[index].Changes_Pending = true; Object_List[index].Changes_Pending = true;
} }
Object_List[index].Network.IPv6.Mode = value; Object_List[index].Network.IPv6.Mode = value;
status = true; status = true;
@@ -1857,8 +1857,8 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
(rpdata->application_data_len == 0)) { (rpdata->application_data_len == 0)) {
return 0; return 0;
} }
Network_Port_Property_List(rpdata->object_instance, Network_Port_Property_List(
&pRequired, &pOptional, &pProprietary); rpdata->object_instance, &pRequired, &pOptional, &pProprietary);
if ((!property_list_member(pRequired, rpdata->object_property)) && if ((!property_list_member(pRequired, rpdata->object_property)) &&
(!property_list_member(pOptional, rpdata->object_property)) && (!property_list_member(pOptional, rpdata->object_property)) &&
(!property_list_member(pProprietary, rpdata->object_property))) { (!property_list_member(pProprietary, rpdata->object_property))) {
-1
View File
@@ -125,4 +125,3 @@ OBJECT_DEVICE_T *objects_device_delete(int index)
} }
return pDevice; return pDevice;
} }
+2 -4
View File
@@ -89,10 +89,8 @@ void Schedule_Init(void)
psched->Present_Value = &psched->Schedule_Default; psched->Present_Value = &psched->Schedule_Default;
psched->Schedule_Default.context_specific = false; psched->Schedule_Default.context_specific = false;
psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL; psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL;
psched->Schedule_Default.type.Real = psched->Schedule_Default.type.Real = 21.0; /* 21 C, room temperature */
21.0; /* 21 C, room temperature */ psched->obj_prop_ref_cnt = 0; /* no references, add as needed */
psched->obj_prop_ref_cnt =
0; /* no references, add as needed */
psched->Priority_For_Writing = 16; /* lowest priority */ psched->Priority_For_Writing = 16; /* lowest priority */
psched->Out_Of_Service = false; psched->Out_Of_Service = false;
} }
+2 -2
View File
@@ -187,8 +187,8 @@ AA_ABORT:
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+36 -24
View File
@@ -307,7 +307,8 @@ static error_function Error_Function[MAX_BACNET_CONFIRMED_SERVICE];
* @brief Set a error handler function for the given confirmed service. * @brief Set a error handler function for the given confirmed service.
* *
* @param service_choice Service, see SERVICE_CONFIRMED_X enumeration. * @param service_choice Service, see SERVICE_CONFIRMED_X enumeration.
* @param pFunction Pointer to the function, being in charge of the error handling. * @param pFunction Pointer to the function, being in charge of the error
* handling.
*/ */
void apdu_set_error_handler( void apdu_set_error_handler(
BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction) BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction)
@@ -374,7 +375,7 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t *apdu, /* APDU data */
service_data->invoke_id = apdu[2]; service_data->invoke_id = apdu[2];
len = 3; len = 3;
if (service_data->segmented_message) { if (service_data->segmented_message) {
if (apdu_len >= (len+2)) { if (apdu_len >= (len + 2)) {
service_data->sequence_number = apdu[len++]; service_data->sequence_number = apdu[len++];
service_data->proposed_window_number = apdu[len++]; service_data->proposed_window_number = apdu[len++];
} else { } else {
@@ -386,7 +387,7 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t *apdu, /* APDU data */
*service_choice = apdu[len++]; *service_choice = apdu[len++];
*service_request = NULL; *service_request = NULL;
*service_request_len = 0; *service_request_len = 0;
} else if (apdu_len >= (len+2)) { } else if (apdu_len >= (len + 2)) {
*service_choice = apdu[len++]; *service_choice = apdu[len++];
*service_request = &apdu[len]; *service_request = &apdu[len];
*service_request_len = apdu_len - len; *service_request_len = apdu_len - len;
@@ -534,10 +535,11 @@ void apdu_handler(BACNET_ADDRESS *src,
service_request_len = apdu_len - 2; service_request_len = apdu_len - 2;
if (apdu_unconfirmed_dcc_disabled(service_choice)) { if (apdu_unconfirmed_dcc_disabled(service_choice)) {
/* When network communications are disabled, /* When network communications are disabled,
only DeviceCommunicationControl and ReinitializeDevice only DeviceCommunicationControl and
APDUs shall be processed and no messages shall be ReinitializeDevice APDUs shall be processed and no
initiated. If communications have been initiation messages shall be initiated. If communications have
disabled, then WhoIs may be processed. */ been initiation disabled, then WhoIs may be
processed. */
break; break;
} }
if (service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) { if (service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) {
@@ -573,7 +575,8 @@ void apdu_handler(BACNET_ADDRESS *src,
case SERVICE_CONFIRMED_VT_CLOSE: case SERVICE_CONFIRMED_VT_CLOSE:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_REQUEST_KEY: case SERVICE_CONFIRMED_REQUEST_KEY:
if (Confirmed_ACK_Function[service_choice] != NULL) { if (Confirmed_ACK_Function[service_choice] !=
NULL) {
((confirmed_simple_ack_function) ((confirmed_simple_ack_function)
Confirmed_ACK_Function[service_choice])( Confirmed_ACK_Function[service_choice])(
src, invoke_id); src, invoke_id);
@@ -619,7 +622,8 @@ void apdu_handler(BACNET_ADDRESS *src,
case SERVICE_CONFIRMED_VT_DATA: case SERVICE_CONFIRMED_VT_DATA:
/* Security Services */ /* Security Services */
case SERVICE_CONFIRMED_AUTHENTICATE: case SERVICE_CONFIRMED_AUTHENTICATE:
if (Confirmed_ACK_Function[service_choice] != NULL) { if (Confirmed_ACK_Function[service_choice] !=
NULL) {
(Confirmed_ACK_Function[service_choice])( (Confirmed_ACK_Function[service_choice])(
service_request, service_request_len, src, service_request, service_request_len, src,
&service_ack_data); &service_ack_data);
@@ -642,18 +646,20 @@ void apdu_handler(BACNET_ADDRESS *src,
service_choice = apdu[2]; service_choice = apdu[2];
len = 3; len = 3;
/* FIXME: Currently special case for C_P_T but there are others /* FIXME: Currently special case for C_P_T but there are
which may need consideration such as ChangeList-Error, others which may need consideration such as
CreateObject-Error, WritePropertyMultiple-Error and ChangeList-Error, CreateObject-Error,
VTClose_Error but they may be left as is for now until WritePropertyMultiple-Error and VTClose_Error but they
support for these services is added */ may be left as is for now until support for these
services is added */
if (service_choice == if (service_choice ==
SERVICE_CONFIRMED_PRIVATE_TRANSFER) { /* skip over SERVICE_CONFIRMED_PRIVATE_TRANSFER) { /* skip over
opening tag 0 */ opening tag 0
*/
if (decode_is_opening_tag_number(&apdu[len], 0)) { if (decode_is_opening_tag_number(&apdu[len], 0)) {
len++; /* a tag number of 0 is not extended so only one len++; /* a tag number of 0 is not extended so only
octet */ one octet */
} }
} }
@@ -662,24 +668,30 @@ void apdu_handler(BACNET_ADDRESS *src,
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
if (len < apdu_len) { if (len < apdu_len) {
/* FIXME: we could validate that the tag is enumerated... */ /* FIXME: we could validate that the tag is
len += decode_enumerated(&apdu[len], len_value, &error_class); * enumerated... */
len += decode_enumerated(
&apdu[len], len_value, &error_class);
if (len < apdu_len) { if (len < apdu_len) {
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
if (len < apdu_len) { if (len < apdu_len) {
/* FIXME: we could validate that the tag is enumerated... */ /* FIXME: we could validate that the tag is
len += decode_enumerated(&apdu[len], len_value, &error_code); * enumerated... */
len += decode_enumerated(
&apdu[len], len_value, &error_code);
if (service_choice == if (service_choice ==
SERVICE_CONFIRMED_PRIVATE_TRANSFER) { SERVICE_CONFIRMED_PRIVATE_TRANSFER) {
if (len < apdu_len) { if (len < apdu_len) {
/* skip over closing tag 0 */ /* skip over closing tag 0 */
if (decode_is_closing_tag_number(&apdu[len], 0)) { if (decode_is_closing_tag_number(
len++; /* a tag number of 0 is not extended so &apdu[len], 0)) {
only one octet */ len++; /* a tag number of 0 is
not extended so only
one octet */
} }
} }
} }
+2 -2
View File
@@ -227,8 +227,8 @@ GET_EVENT_ABORT:
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
+2 -2
View File
@@ -111,8 +111,8 @@ LSO_ABORT:
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+113 -91
View File
@@ -208,9 +208,9 @@ void handler_read_property_multiple(uint8_t *service_request,
if (service_data->segmented_message) { if (service_data->segmented_message) {
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Segmented message. Sending Abort!\r\n"); fprintf(stderr, "RPM: Segmented message. Sending Abort!\r\n");
#endif #endif
} else { } else {
/* decode apdu request & encode apdu reply /* decode apdu request & encode apdu reply
encode complex ack, invoke id, service choice */ encode complex ack, invoke id, service choice */
@@ -219,16 +219,16 @@ void handler_read_property_multiple(uint8_t *service_request,
for (;;) { for (;;) {
/* Start by looking for an object ID */ /* Start by looking for an object ID */
len = rpm_decode_object_id( len = rpm_decode_object_id(&service_request[decode_len],
&service_request[decode_len], service_len - decode_len, &rpmdata); service_len - decode_len, &rpmdata);
if (len >= 0) { if (len >= 0) {
/* Got one so skip to next stage */ /* Got one so skip to next stage */
decode_len += len; decode_len += len;
} else { } else {
/* bad encoding - skip to error/reject/abort handling */ /* bad encoding - skip to error/reject/abort handling */
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Bad Encoding.\n"); fprintf(stderr, "RPM: Bad Encoding.\n");
#endif #endif
error = len; error = len;
berror = true; berror = true;
break; break;
@@ -242,14 +242,14 @@ void handler_read_property_multiple(uint8_t *service_request,
/* Stick this object id into the reply - if it will fit */ /* Stick this object id into the reply - if it will fit */
len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], &rpmdata); len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], &rpmdata);
copy_len = copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0], &Temp_Buf[0], apdu_len, len, MAX_APDU);
apdu_len, len, MAX_APDU);
if (copy_len == 0) { if (copy_len == 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Response too big!\r\n"); fprintf(stderr, "RPM: Response too big!\r\n");
#endif #endif
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
berror = true; berror = true;
break; break;
@@ -259,16 +259,18 @@ void handler_read_property_multiple(uint8_t *service_request,
/* do each property of this object of the RPM request */ /* do each property of this object of the RPM request */
for (;;) { for (;;) {
/* Fetch a property */ /* Fetch a property */
len = rpm_decode_object_property(&service_request[decode_len], len =
service_len - decode_len, &rpmdata); rpm_decode_object_property(&service_request[decode_len],
service_len - decode_len, &rpmdata);
if (len < 0) { if (len < 0) {
/* bad encoding - skip to error/reject/abort handling */ /* bad encoding - skip to error/reject/abort handling */
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Bad Encoding.\n"); fprintf(stderr, "RPM: Bad Encoding.\n");
#endif #endif
error = len; error = len;
berror = true; berror = true;
break; // The berror flag ensures that both loops will be broken! break; // The berror flag ensures that both loops will
// be broken!
} }
decode_len += len; decode_len += len;
/* handle the special properties */ /* handle the special properties */
@@ -281,43 +283,49 @@ void handler_read_property_multiple(uint8_t *service_request,
BACNET_PROPERTY_ID special_object_property; BACNET_PROPERTY_ID special_object_property;
if (rpmdata.array_index != BACNET_ARRAY_ALL) { if (rpmdata.array_index != BACNET_ARRAY_ALL) {
/* No array index options for this special property. /* No array index options for this special property.
Encode error for this object property response */ Encode error for this object property response */
len = rpm_ack_encode_apdu_object_property(&Temp_Buf[0], len = rpm_ack_encode_apdu_object_property(
rpmdata.object_property, rpmdata.array_index); &Temp_Buf[0], rpmdata.object_property,
rpmdata.array_index);
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len], copy_len =
&Temp_Buf[0], apdu_len, len, MAX_APDU); memcopy(&Handler_Transmit_Buffer[npdu_len],
&Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) { if (copy_len == 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf( fprintf(stderr,
stderr, "RPM: Too full to encode property!\r\n"); "RPM: Too full to encode property!\r\n");
#endif #endif
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT;
berror = true;
break; // The berror flag ensures that both loops will be broken!
}
apdu_len += len;
len = rpm_ack_encode_apdu_object_property_error(
&Temp_Buf[0], ERROR_CLASS_PROPERTY,
ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY);
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
&Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) {
#if PRINT_ENABLED
fprintf(stderr, "RPM: Too full to encode error!\r\n");
#endif
rpmdata.error_code = rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
berror = true; berror = true;
break; // The berror flag ensures that both loops will be broken! break; // The berror flag ensures that both
// loops will be broken!
}
apdu_len += len;
len = rpm_ack_encode_apdu_object_property_error(
&Temp_Buf[0], ERROR_CLASS_PROPERTY,
ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY);
copy_len =
memcopy(&Handler_Transmit_Buffer[npdu_len],
&Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) {
#if PRINT_ENABLED
fprintf(stderr,
"RPM: Too full to encode error!\r\n");
#endif
rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT;
berror = true;
break; // The berror flag ensures that both
// loops will be broken!
} }
apdu_len += len; apdu_len += len;
} else { } else {
@@ -328,65 +336,75 @@ void handler_read_property_multiple(uint8_t *service_request,
&property_list, special_object_property); &property_list, special_object_property);
if (property_count == 0) { if (property_count == 0) {
/* This only happens with the OPTIONAL property */ /* This only happens with the OPTIONAL property
*/
/* 135-2016bl-2. Clarify ReadPropertyMultiple /* 135-2016bl-2. Clarify ReadPropertyMultiple
response on OPTIONAL when empty. */ response on OPTIONAL when empty. */
/* If no optional properties are supported then /* If no optional properties are supported then
an empty 'List of Results' shall be returned an empty 'List of Results' shall be returned
for the specified property.*/ for the specified property.*/
} else { } else {
for (index = 0; index < property_count; index++) { for (index = 0; index < property_count;
rpmdata.object_property = RPM_Object_Property( index++) {
&property_list, special_object_property, index); rpmdata.object_property =
RPM_Object_Property(&property_list,
special_object_property, index);
len = RPM_Encode_Property( len = RPM_Encode_Property(
&Handler_Transmit_Buffer[npdu_len], &Handler_Transmit_Buffer[npdu_len],
(uint16_t)apdu_len, MAX_APDU, &rpmdata); (uint16_t)apdu_len, MAX_APDU, &rpmdata);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
} else { } else {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf( fprintf(stderr,
stderr, "RPM: Too full for property!\r\n"); "RPM: Too full for property!\r\n");
#endif #endif
error = len; error = len;
berror = true; berror = true;
break; // The berror flag ensures that both loops will be broken! break; // The berror flag ensures that
// both loops will be broken!
} }
} }
} }
} }
} else { } else {
/* handle an individual property */ /* handle an individual property */
len = RPM_Encode_Property(&Handler_Transmit_Buffer[npdu_len], len = RPM_Encode_Property(
(uint16_t)apdu_len, MAX_APDU, &rpmdata); &Handler_Transmit_Buffer[npdu_len],
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
if (len > 0) { if (len > 0) {
apdu_len += len; apdu_len += len;
} else { } else {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf( fprintf(stderr,
stderr, "RPM: Too full for individual property!\r\n"); "RPM: Too full for individual property!\r\n");
#endif #endif
error = len; error = len;
berror = true; berror = true;
break; // The berror flag ensures that both loops will be broken! break; // The berror flag ensures that both loops
// will be broken!
} }
} }
if (decode_is_closing_tag_number(&service_request[decode_len], 1)) { if (decode_is_closing_tag_number(
/* Reached end of property list so cap the result list */ &service_request[decode_len], 1)) {
/* Reached end of property list so cap the result list
*/
decode_len++; decode_len++;
len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]); len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]);
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len], copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
&Temp_Buf[0], apdu_len, len, MAX_APDU); &Temp_Buf[0], apdu_len, len, MAX_APDU);
if (copy_len == 0) { if (copy_len == 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Too full to encode object end!\r\n"); fprintf(stderr,
#endif "RPM: Too full to encode object end!\r\n");
#endif
rpmdata.error_code = rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
berror = true; berror = true;
break; // The berror flag ensures that both loops will be broken! break; // The berror flag ensures that both loops
// will be broken!
} else { } else {
apdu_len += copy_len; apdu_len += copy_len;
} }
@@ -406,11 +424,13 @@ void handler_read_property_multiple(uint8_t *service_request,
if (!berror) { if (!berror) {
if (apdu_len > service_data->max_resp) { if (apdu_len > service_data->max_resp) {
/* too big for the sender - send an abort */ /* too big for the sender - send an abort */
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; rpmdata.error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
error = BACNET_STATUS_ABORT; error = BACNET_STATUS_ABORT;
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Message too large. Sending Abort!\n"); fprintf(
#endif stderr, "RPM: Message too large. Sending Abort!\n");
#endif
} }
} }
} }
@@ -419,34 +439,36 @@ void handler_read_property_multiple(uint8_t *service_request,
if (error) { if (error) {
if (error == BACNET_STATUS_ABORT) { if (error == BACNET_STATUS_ABORT) {
apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len], apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
service_data->invoke_id, service_data->invoke_id,
abort_convert_error_code(rpmdata.error_code), true); abort_convert_error_code(rpmdata.error_code), true);
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Sending Abort!\n"); fprintf(stderr, "RPM: Sending Abort!\n");
#endif #endif
} else if (error == BACNET_STATUS_ERROR) { } else if (error == BACNET_STATUS_ERROR) {
apdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len], apdu_len = bacerror_encode_apdu(
service_data->invoke_id, SERVICE_CONFIRMED_READ_PROP_MULTIPLE, &Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
rpmdata.error_class, rpmdata.error_code); SERVICE_CONFIRMED_READ_PROP_MULTIPLE, rpmdata.error_class,
#if PRINT_ENABLED rpmdata.error_code);
#if PRINT_ENABLED
fprintf(stderr, "RPM: Sending Error!\n"); fprintf(stderr, "RPM: Sending Error!\n");
#endif #endif
} else if (error == BACNET_STATUS_REJECT) { } else if (error == BACNET_STATUS_REJECT) {
apdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len], apdu_len = reject_encode_apdu(
service_data->invoke_id, &Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
reject_convert_error_code(rpmdata.error_code)); reject_convert_error_code(rpmdata.error_code));
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Sending Reject!\n"); fprintf(stderr, "RPM: Sending Reject!\n");
#endif #endif
} }
} }
pdu_len = apdu_len + npdu_len; pdu_len = apdu_len + npdu_len;
bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); bytes_sent = datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) { if (bytes_sent <= 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "RPM: Failed to send PDU (%s)!\n", strerror(errno)); fprintf(stderr, "RPM: Failed to send PDU (%s)!\n", strerror(errno));
#endif #endif
} }
} }
} }
+4 -5
View File
@@ -293,8 +293,7 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
* @param rpm_data - #BACNET_READ_ACCESS_DATA * @param rpm_data - #BACNET_READ_ACCESS_DATA
* @return RPM data from the next element in the linked list * @return RPM data from the next element in the linked list
*/ */
static BACNET_READ_ACCESS_DATA *rpm_data_free( static BACNET_READ_ACCESS_DATA *rpm_data_free(BACNET_READ_ACCESS_DATA *rpm_data)
BACNET_READ_ACCESS_DATA *rpm_data)
{ {
BACNET_READ_ACCESS_DATA *old_rpm_data = NULL; BACNET_READ_ACCESS_DATA *old_rpm_data = NULL;
BACNET_PROPERTY_REFERENCE *rpm_property = NULL; BACNET_PROPERTY_REFERENCE *rpm_property = NULL;
@@ -343,7 +342,7 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data) BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
{ {
int len = 0; int len = 0;
BACNET_READ_ACCESS_DATA * rpm_data; BACNET_READ_ACCESS_DATA *rpm_data;
(void)src; (void)src;
(void)service_data; /* we could use these... */ (void)service_data; /* we could use these... */
@@ -358,9 +357,9 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
rpm_data = rpm_data_free(rpm_data); rpm_data = rpm_data_free(rpm_data);
} }
} else { } else {
#if 1 #if 1
fprintf(stderr, "RPM Ack Malformed! Freeing memory...\n"); fprintf(stderr, "RPM Ack Malformed! Freeing memory...\n");
#endif #endif
while (rpm_data) { while (rpm_data) {
rpm_data = rpm_data_free(rpm_data); rpm_data = rpm_data_free(rpm_data);
} }
+2 -2
View File
@@ -185,8 +185,8 @@ RR_ABORT:
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
+2 -2
View File
@@ -79,8 +79,8 @@ void handler_ucov_notification(
#if PRINT_ENABLED #if PRINT_ENABLED
len = len =
#endif #endif
cov_notify_decode_service_request( cov_notify_decode_service_request(
service_request, service_len, &cov_data); service_request, service_len, &cov_data);
#if PRINT_ENABLED #if PRINT_ENABLED
if (len > 0) { if (len > 0) {
fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier); fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
+3 -2
View File
@@ -98,7 +98,8 @@ void handler_write_property(uint8_t *service_request,
#if PRINT_ENABLED #if PRINT_ENABLED
if (len > 0) if (len > 0)
fprintf(stderr, fprintf(stderr,
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n", "WP: type=%lu instance=%lu property=%lu priority=%lu "
"index=%ld\n",
(unsigned long)wp_data.object_type, (unsigned long)wp_data.object_type,
(unsigned long)wp_data.object_instance, (unsigned long)wp_data.object_instance,
(unsigned long)wp_data.object_property, (unsigned long)wp_data.object_property,
@@ -137,7 +138,7 @@ void handler_write_property(uint8_t *service_request,
/* Send PDU */ /* Send PDU */
pdu_len += len; pdu_len += len;
bytes_sent = datalink_send_pdu( bytes_sent = datalink_send_pdu(
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) { if (bytes_sent <= 0) {
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "WP: Failed to send PDU (%s)!\n", strerror(errno)); fprintf(stderr, "WP: Failed to send PDU (%s)!\n", strerror(errno));
+2 -2
View File
@@ -90,8 +90,8 @@ uint8_t Send_Alarm_Acknowledgement(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Alarm Ack Request (%s)!\n", fprintf(stderr, "Failed to Send Alarm Ack Request (%s)!\n",
+2 -2
View File
@@ -97,8 +97,8 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send AtomicReadFile Request (%s)!\n", fprintf(stderr, "Failed to Send AtomicReadFile Request (%s)!\n",
+2 -2
View File
@@ -99,8 +99,8 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(&dest, &npdu_data,
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+2 -2
View File
@@ -91,8 +91,8 @@ uint8_t Send_CEvent_Notify(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) { if (bytes_sent <= 0) {
fprintf(stderr, fprintf(stderr,
+2 -2
View File
@@ -103,8 +103,8 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+2 -2
View File
@@ -75,8 +75,8 @@ uint8_t Send_GetEvent(BACNET_ADDRESS *target_address,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(target_address, &npdu_data,
target_address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+2 -2
View File
@@ -90,8 +90,8 @@ uint8_t Send_Life_Safety_Operation_Data(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Life Safe Op Request (%s)!\n", fprintf(stderr, "Failed to Send Life Safe Op Request (%s)!\n",
+2 -2
View File
@@ -100,8 +100,8 @@ uint8_t Send_Reinitialize_Device_Request(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+2 -2
View File
@@ -96,8 +96,8 @@ uint8_t Send_ReadRange_Request(uint32_t device_id, /* destination device */
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send ReadRange Request (%s)!\n", fprintf(stderr, "Failed to Send ReadRange Request (%s)!\n",
+1 -1
View File
@@ -103,7 +103,7 @@ uint8_t Send_Read_Property_Multiple_Request(uint8_t *pdu,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len); datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+4 -4
View File
@@ -76,8 +76,8 @@ void Send_TimeSync_Remote(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n", fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n",
@@ -133,8 +133,8 @@ void Send_TimeSyncUTC_Remote(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, fprintf(stderr,
+4 -4
View File
@@ -88,8 +88,8 @@ void Send_WhoHas_Name(
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf( fprintf(
@@ -146,8 +146,8 @@ void Send_WhoHas_Object(int32_t low_limit,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu( datalink_send_pdu(
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); &dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf( fprintf(
+1 -1
View File
@@ -104,7 +104,7 @@ uint8_t Send_Write_Property_Multiple_Request(uint8_t *pdu,
#if PRINT_ENABLED #if PRINT_ENABLED
bytes_sent = bytes_sent =
#endif #endif
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len); datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) { if (bytes_sent <= 0) {
fprintf(stderr, fprintf(stderr,
+2 -3
View File
@@ -103,8 +103,7 @@ static int CheckArraySize(OS_Keylist list)
} }
if (new_size) { if (new_size) {
/* Allocate more room for node pointer array */ /* Allocate more room for node pointer array */
new_array = calloc((size_t)new_size, new_array = calloc((size_t)new_size, sizeof(struct Keylist_Node *));
sizeof(struct Keylist_Node *));
/* See if we got the memory we wanted */ /* See if we got the memory we wanted */
if (!new_array) { if (!new_array) {
@@ -453,7 +452,7 @@ int Keylist_Count(OS_Keylist list)
cnt = list->count; cnt = list->count;
} }
return(cnt); return (cnt);
} }
/******************************************************************** */ /******************************************************************** */
+1 -1
View File
@@ -118,7 +118,7 @@ unsigned long mstimer_remaining(struct mstimer *t)
*/ */
unsigned long mstimer_elapsed(struct mstimer *t) unsigned long mstimer_elapsed(struct mstimer *t)
{ {
return mstimer_now() - t->start; return mstimer_now() - t->start;
} }
/** /**
+1 -2
View File
@@ -154,8 +154,7 @@ uint8_t tsm_transaction_idle_count(void)
const BACNET_TSM_DATA *plist = TSM_List; const BACNET_TSM_DATA *plist = TSM_List;
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++, plist++) { for (i = 0; i < MAX_TSM_TRANSACTIONS; i++, plist++) {
if ((plist->InvokeID == 0) && if ((plist->InvokeID == 0) && (plist->state == TSM_STATE_IDLE)) {
(plist->state == TSM_STATE_IDLE)) {
/* one is available! */ /* one is available! */
count++; count++;
} }
+4 -3
View File
@@ -469,7 +469,7 @@ int cov_subscribe_decode_service_request(
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
/* tag 1 - monitoredObjectIdentifier */ /* tag 1 - monitoredObjectIdentifier */
if ((unsigned) len >= apdu_len) { if ((unsigned)len >= apdu_len) {
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
if (decode_is_context_tag(&apdu[len], 1)) { if (decode_is_context_tag(&apdu[len], 1)) {
@@ -496,11 +496,12 @@ int cov_subscribe_decode_service_request(
data->cancellationRequest = true; data->cancellationRequest = true;
} }
/* tag 3 - lifetime - optional */ /* tag 3 - lifetime - optional */
if ((unsigned) len < apdu_len) { if ((unsigned)len < apdu_len) {
if (decode_is_context_tag(&apdu[len], 3)) { if (decode_is_context_tag(&apdu[len], 3)) {
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
len += decode_unsigned(&apdu[len], len_value, &unsigned_value); len +=
decode_unsigned(&apdu[len], len_value, &unsigned_value);
data->lifetime = unsigned_value; data->lifetime = unsigned_value;
} else { } else {
data->lifetime = 0; data->lifetime = 0;
+4 -3
View File
@@ -430,14 +430,15 @@ int encode_set_master_key(uint8_t *apdu, BACNET_SET_MASTER_KEY *set_master_key)
// (uint32_t)(real_len - enc_begin), wrapper->signature)) { // (uint32_t)(real_len - enc_begin), wrapper->signature)) {
// return -SEC_RESP_MALFORMED_MESSAGE; // return -SEC_RESP_MALFORMED_MESSAGE;
// } // }
// curr += decode_unsigned16(&apdu[real_len - 2], &wrapper->padding_len); // curr += decode_unsigned16(&apdu[real_len - 2],
// real_len -= wrapper->padding_len; // &wrapper->padding_len); real_len -= wrapper->padding_len;
// memcpy(wrapper->padding, &apdu[wrapper->padding_len], // memcpy(wrapper->padding, &apdu[wrapper->padding_len],
// wrapper->padding_len - 2); // wrapper->padding_len - 2);
// } // }
// /* destination device instance */ // /* destination device instance */
// curr += // curr +=
// decode_unsigned24(&apdu[curr], &wrapper->destination_device_instance); // decode_unsigned24(&apdu[curr],
// &wrapper->destination_device_instance);
// /* dst address */ // /* dst address */
// curr += decode_unsigned16(&apdu[curr], &wrapper->dnet); // curr += decode_unsigned16(&apdu[curr], &wrapper->dnet);
// wrapper->dlen = apdu[curr++]; // wrapper->dlen = apdu[curr++];
+4 -5
View File
@@ -520,7 +520,6 @@ bool bvlc_broadcast_distribution_table_entry_forward_address(
return status; return status;
} }
/** /**
* @brief J.2.2 Write-Broadcast-Distribution-Table: encode * @brief J.2.2 Write-Broadcast-Distribution-Table: encode
* *
@@ -1060,7 +1059,7 @@ bool bvlc_foreign_device_table_entry_add(
a BBMD shall start a timer with a value equal to the a BBMD shall start a timer with a value equal to the
Time-to-Live parameter supplied plus a fixed grace Time-to-Live parameter supplied plus a fixed grace
period of 30 seconds. */ period of 30 seconds. */
if (ttl_seconds < (UINT16_MAX-30)) { if (ttl_seconds < (UINT16_MAX - 30)) {
fdt_entry->ttl_seconds_remaining = ttl_seconds + 30; fdt_entry->ttl_seconds_remaining = ttl_seconds + 30;
} else { } else {
fdt_entry->ttl_seconds_remaining = UINT16_MAX; fdt_entry->ttl_seconds_remaining = UINT16_MAX;
@@ -1077,7 +1076,7 @@ bool bvlc_foreign_device_table_entry_add(
/* add to the first empty entry */ /* add to the first empty entry */
bvlc_address_copy(&fdt_entry->dest_address, addr); bvlc_address_copy(&fdt_entry->dest_address, addr);
fdt_entry->ttl_seconds = ttl_seconds; fdt_entry->ttl_seconds = ttl_seconds;
if (ttl_seconds < (UINT16_MAX-30)) { if (ttl_seconds < (UINT16_MAX - 30)) {
fdt_entry->ttl_seconds_remaining = ttl_seconds + 30; fdt_entry->ttl_seconds_remaining = ttl_seconds + 30;
} else { } else {
fdt_entry->ttl_seconds_remaining = UINT16_MAX; fdt_entry->ttl_seconds_remaining = UINT16_MAX;
@@ -1756,8 +1755,8 @@ bool bvlc_address_different(
* @param mask - B/IPv4 broadcast distribution mask * @param mask - B/IPv4 broadcast distribution mask
* @return true if the addresses are different * @return true if the addresses are different
*/ */
bool bvlc_address_mask( bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src, const BACNET_IP_ADDRESS *src,
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask) const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
{ {
bool status = false; bool status = false;
+23 -32
View File
@@ -1308,8 +1308,7 @@ int bvlc6_decode_delete_foreign_device(uint8_t *pdu,
} }
offset += 3; offset += 3;
if (bip6_address) { if (bip6_address) {
bvlc6_decode_address( bvlc6_decode_address(&pdu[offset], pdu_len - offset, bip6_address);
&pdu[offset], pdu_len - offset, bip6_address);
} }
bytes_consumed = (int)length; bytes_consumed = (int)length;
} }
@@ -1988,8 +1987,8 @@ static void test_BVLC6_Delete_Foreign_Device_Message(Test *pTest,
ct_test(pTest, len == test_len); ct_test(pTest, len == test_len);
ct_test(pTest, msg_len == test_len); ct_test(pTest, msg_len == test_len);
ct_test(pTest, vmac_src == test_vmac_src); ct_test(pTest, vmac_src == test_vmac_src);
test_BVLC6_Address(pTest, &fdt_entry->bip6_address, test_BVLC6_Address(
&test_fdt_entry.bip6_address); pTest, &fdt_entry->bip6_address, &test_fdt_entry.bip6_address);
} }
static void test_BVLC6_Delete_Foreign_Device(Test *pTest) static void test_BVLC6_Delete_Foreign_Device(Test *pTest)
@@ -2161,48 +2160,40 @@ static void test_BVLC6_Address_Get_Set(Test *pTest)
} }
/* test the ASCII hex to address */ /* test the ASCII hex to address */
/* test too short */ /* test too short */
status = bvlc6_address_from_ascii(&src,"[1234:5678]"); status = bvlc6_address_from_ascii(&src, "[1234:5678]");
ct_test(pTest, status == false); ct_test(pTest, status == false);
status = bvlc6_address_from_ascii(&src, status = bvlc6_address_from_ascii(
"[1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0]"); &src, "[1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0]");
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_set(&dst, status = bvlc6_address_set(
0x1234, 0x5678, 0x9ABC, 0xDEF0, &dst, 0x1234, 0x5678, 0x9ABC, 0xDEF0, 0x1234, 0x5678, 0x9ABC, 0xDEF0);
0x1234, 0x5678, 0x9ABC, 0xDEF0);
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_different(&dst, &src); status = bvlc6_address_different(&dst, &src);
ct_test(pTest, status == false); ct_test(pTest, status == false);
/* test zero compression */ /* test zero compression */
status = bvlc6_address_from_ascii(&src, status = bvlc6_address_from_ascii(&src, "[1234:5678:9ABC::5678:9ABC:DEF0]");
"[1234:5678:9ABC::5678:9ABC:DEF0]");
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_set(&dst, status = bvlc6_address_set(
0x1234, 0x5678, 0x9ABC, 0x0000, &dst, 0x1234, 0x5678, 0x9ABC, 0x0000, 0x0000, 0x5678, 0x9ABC, 0xDEF0);
0x0000, 0x5678, 0x9ABC, 0xDEF0);
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_different(&dst, &src); status = bvlc6_address_different(&dst, &src);
if (status) { if (status) {
status = bvlc6_address_get( status = bvlc6_address_get(&src, &hextet[0], &hextet[1], &hextet[2],
&src, &hextet[0], &hextet[1], &hextet[2], &hextet[3], &hextet[3], &hextet[4], &hextet[5], &hextet[6], &hextet[7]);
&hextet[4], &hextet[5], &hextet[6], &hextet[7]); printf("src:[%X:%X:%X:%X:%X:%X:%X:%X]\n", hextet[0], hextet[1],
printf("src:[%X:%X:%X:%X:%X:%X:%X:%X]\n", hextet[2], hextet[3], hextet[4], hextet[5], hextet[6], hextet[7]);
hextet[0], hextet[1], hextet[2], hextet[3], status = bvlc6_address_get(&dst, &hextet[0], &hextet[1], &hextet[2],
hextet[4], hextet[5], hextet[6], hextet[7]); &hextet[3], &hextet[4], &hextet[5], &hextet[6], &hextet[7]);
status = bvlc6_address_get( printf("dst:[%X:%X:%X:%X:%X:%X:%X:%X]\n", hextet[0], hextet[1],
&dst, &hextet[0], &hextet[1], &hextet[2], &hextet[3], hextet[2], hextet[3], hextet[4], hextet[5], hextet[6], hextet[7]);
&hextet[4], &hextet[5], &hextet[6], &hextet[7]);
printf("dst:[%X:%X:%X:%X:%X:%X:%X:%X]\n",
hextet[0], hextet[1], hextet[2], hextet[3],
hextet[4], hextet[5], hextet[6], hextet[7]);
} }
ct_test(pTest, status == false); ct_test(pTest, status == false);
/* test some compressed 16-bit zero fields */ /* test some compressed 16-bit zero fields */
status = bvlc6_address_from_ascii(&src, status =
"[234:678:ABC:EF0:1234:5678:9ABC:DEF0]"); bvlc6_address_from_ascii(&src, "[234:678:ABC:EF0:1234:5678:9ABC:DEF0]");
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_set(&dst, status = bvlc6_address_set(
0x0234, 0x0678, 0x0ABC, 0x0EF0, &dst, 0x0234, 0x0678, 0x0ABC, 0x0EF0, 0x1234, 0x5678, 0x9ABC, 0xDEF0);
0x1234, 0x5678, 0x9ABC, 0xDEF0);
ct_test(pTest, status); ct_test(pTest, status);
status = bvlc6_address_different(&dst, &src); status = bvlc6_address_different(&dst, &src);
ct_test(pTest, status == false); ct_test(pTest, status == false);
+15 -20
View File
@@ -63,8 +63,7 @@ static bool BIP_DL_Debug = false;
* @param address - IPv4 address (uint32_t) of BBMD to register with, * @param address - IPv4 address (uint32_t) of BBMD to register with,
* in network byte order. * in network byte order.
*/ */
void dlenv_bbmd_address_set( void dlenv_bbmd_address_set(BACNET_IP_ADDRESS *address)
BACNET_IP_ADDRESS *address)
{ {
bvlc_address_copy(&BBMD_Address, address); bvlc_address_copy(&BBMD_Address, address);
BBMD_Address_Valid = true; BBMD_Address_Valid = true;
@@ -121,7 +120,7 @@ int dlenv_register_as_foreign_device(void)
char *pEnv = NULL; char *pEnv = NULL;
unsigned a[4] = { 0 }; unsigned a[4] = { 0 };
char bbmd_env[32] = ""; char bbmd_env[32] = "";
unsigned entry_number = 0;\ unsigned entry_number = 0;
long long_value = 0; long long_value = 0;
int c; int c;
@@ -154,20 +153,16 @@ int dlenv_register_as_foreign_device(void)
(unsigned)BBMD_Address.address[0], (unsigned)BBMD_Address.address[0],
(unsigned)BBMD_Address.address[1], (unsigned)BBMD_Address.address[1],
(unsigned)BBMD_Address.address[2], (unsigned)BBMD_Address.address[2],
(unsigned)BBMD_Address.address[3], (unsigned)BBMD_Address.address[3], (unsigned)BBMD_Address.port,
(unsigned)BBMD_Address.port,
(unsigned)BBMD_TTL_Seconds); (unsigned)BBMD_TTL_Seconds);
} }
retval = bvlc_register_with_bbmd(&BBMD_Address, retval = bvlc_register_with_bbmd(&BBMD_Address, BBMD_TTL_Seconds);
BBMD_TTL_Seconds);
if (retval < 0) { if (retval < 0) {
fprintf(stderr, fprintf(stderr, "FAILED to Register with BBMD at %u.%u.%u.%u:%u\n",
"FAILED to Register with BBMD at %u.%u.%u.%u:%u\n", (unsigned)BBMD_Address.address[0],
(unsigned)BBMD_Address.address[0], (unsigned)BBMD_Address.address[1],
(unsigned)BBMD_Address.address[1], (unsigned)BBMD_Address.address[2],
(unsigned)BBMD_Address.address[2], (unsigned)BBMD_Address.address[3], (unsigned)BBMD_Address.port);
(unsigned)BBMD_Address.address[3],
(unsigned)BBMD_Address.port);
} }
BBMD_Timer_Seconds = (uint16_t)BBMD_TTL_Seconds; BBMD_Timer_Seconds = (uint16_t)BBMD_TTL_Seconds;
} else { } else {
@@ -176,8 +171,8 @@ int dlenv_register_as_foreign_device(void)
sprintf(bbmd_env, "BACNET_BDT_ADDR_%u", entry_number); sprintf(bbmd_env, "BACNET_BDT_ADDR_%u", entry_number);
pEnv = getenv(bbmd_env); pEnv = getenv(bbmd_env);
if (pEnv) { if (pEnv) {
bdt_entry_valid = bip_get_addr_by_name(pEnv, bdt_entry_valid =
&BBMD_Table_Entry.dest_address); bip_get_addr_by_name(pEnv, &BBMD_Table_Entry.dest_address);
if (entry_number == 1) { if (entry_number == 1) {
if (BIP_DL_Debug) { if (BIP_DL_Debug) {
fprintf(stderr, "BBMD 1 is %s=%s!\n", bbmd_env, pEnv); fprintf(stderr, "BBMD 1 is %s=%s!\n", bbmd_env, pEnv);
@@ -211,15 +206,15 @@ int dlenv_register_as_foreign_device(void)
pEnv, "%3u.%3u.%3u.%3u", &a[0], &a[1], &a[2], &a[3]); pEnv, "%3u.%3u.%3u.%3u", &a[0], &a[1], &a[2], &a[3]);
if (c == 4) { if (c == 4) {
bvlc_broadcast_distribution_mask_set( bvlc_broadcast_distribution_mask_set(
&BBMD_Table_Entry.broadcast_mask, &BBMD_Table_Entry.broadcast_mask, a[0], a[1], a[2],
a[0], a[1], a[2], a[3]); a[3]);
} }
} }
bvlc_broadcast_distribution_table_entry_append( bvlc_broadcast_distribution_table_entry_append(
bvlc_bdt_list(), &BBMD_Table_Entry); bvlc_bdt_list(), &BBMD_Table_Entry);
if (BIP_DL_Debug) { if (BIP_DL_Debug) {
fprintf(stderr, fprintf(stderr, "BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n",
"BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n", entry_number, entry_number,
(unsigned)BBMD_Table_Entry.dest_address.address[0], (unsigned)BBMD_Table_Entry.dest_address.address[0],
(unsigned)BBMD_Table_Entry.dest_address.address[1], (unsigned)BBMD_Table_Entry.dest_address.address[1],
(unsigned)BBMD_Table_Entry.dest_address.address[2], (unsigned)BBMD_Table_Entry.dest_address.address[2],
+27 -35
View File
@@ -561,12 +561,11 @@ static void seconds_since_midnight_into_hms(
* @param btime [in] BACNET_TIME containing the time to convert * @param btime [in] BACNET_TIME containing the time to convert
*/ */
void datetime_seconds_since_midnight_into_time( void datetime_seconds_since_midnight_into_time(
uint32_t seconds, uint32_t seconds, BACNET_TIME *btime)
BACNET_TIME *btime)
{ {
if (btime) { if (btime) {
seconds_since_midnight_into_hms(seconds, seconds_since_midnight_into_hms(
&btime->hour, &btime->min, &btime->sec); seconds, &btime->hour, &btime->min, &btime->sec);
btime->hundredths = 0; btime->hundredths = 0;
} }
} }
@@ -660,8 +659,7 @@ void datetime_add_minutes(BACNET_DATE_TIME *bdatetime, int32_t minutes)
* @param bdatetime [in] the starting date and time * @param bdatetime [in] the starting date and time
* @return seconds since midnight * @return seconds since midnight
*/ */
uint64_t datetime_seconds_since_epoch( uint64_t datetime_seconds_since_epoch(BACNET_DATE_TIME *bdatetime)
BACNET_DATE_TIME * bdatetime)
{ {
uint64_t seconds = 0; uint64_t seconds = 0;
uint32_t days = 0; uint32_t days = 0;
@@ -683,9 +681,7 @@ uint64_t datetime_seconds_since_epoch(
* @param bdatetime [in] the starting date and time * @param bdatetime [in] the starting date and time
* @return seconds since midnight * @return seconds since midnight
*/ */
void datetime_since_epoch_seconds( void datetime_since_epoch_seconds(BACNET_DATE_TIME *bdatetime, uint64_t seconds)
BACNET_DATE_TIME * bdatetime,
uint64_t seconds)
{ {
uint32_t seconds_after_midnight = 0; uint32_t seconds_after_midnight = 0;
uint32_t days = 0; uint32_t days = 0;
@@ -1096,17 +1092,12 @@ int bacapp_decode_context_datetime(
#include <string.h> #include <string.h>
#include "ctest.h" #include "ctest.h"
static void datetime_print(const char *title, static void datetime_print(const char *title, BACNET_DATE_TIME *bdatetime)
BACNET_DATE_TIME *bdatetime)
{ {
printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", title,
title, (unsigned int)bdatetime->date.year, (unsigned int)bdatetime->date.month,
(unsigned int)bdatetime->date.year, (unsigned int)bdatetime->date.wday, (unsigned int)bdatetime->time.hour,
(unsigned int)bdatetime->date.month, (unsigned int)bdatetime->time.min, (unsigned int)bdatetime->time.sec,
(unsigned int)bdatetime->date.wday,
(unsigned int)bdatetime->time.hour,
(unsigned int)bdatetime->time.min,
(unsigned int)bdatetime->time.sec,
(unsigned int)bdatetime->time.hundredths); (unsigned int)bdatetime->time.hundredths);
} }
@@ -1423,22 +1414,25 @@ static void testDayOfYear(Test *pTest)
} }
static void testDateEpochConversionCompare(Test *pTest, static void testDateEpochConversionCompare(Test *pTest,
uint16_t year, uint8_t month, uint8_t day, uint16_t year,
uint8_t hour, uint8_t minute, uint8_t second, uint8_t hundredth) uint8_t month,
uint8_t day,
uint8_t hour,
uint8_t minute,
uint8_t second,
uint8_t hundredth)
{ {
uint64_t epoch_seconds = 0; uint64_t epoch_seconds = 0;
BACNET_DATE_TIME bdatetime = {0}; BACNET_DATE_TIME bdatetime = { 0 };
BACNET_DATE_TIME test_bdatetime = {0}; BACNET_DATE_TIME test_bdatetime = { 0 };
int compare = 0; int compare = 0;
datetime_set_date(&bdatetime.date, year, month, day); datetime_set_date(&bdatetime.date, year, month, day);
datetime_set_time(&bdatetime.time, hour, minute, second, datetime_set_time(&bdatetime.time, hour, minute, second, hundredth);
hundredth);
epoch_seconds = datetime_seconds_since_epoch(&bdatetime); epoch_seconds = datetime_seconds_since_epoch(&bdatetime);
datetime_since_epoch_seconds(&test_bdatetime, datetime_since_epoch_seconds(&test_bdatetime, epoch_seconds);
epoch_seconds); compare = datetime_compare(&bdatetime, &test_bdatetime);
compare = datetime_compare(&bdatetime,&test_bdatetime); ct_test(pTest, compare == 0);
ct_test(pTest,compare == 0);
if (compare != 0) { if (compare != 0) {
datetime_print("bdatetime", &bdatetime); datetime_print("bdatetime", &bdatetime);
datetime_print("test_bdatetime", &test_bdatetime); datetime_print("test_bdatetime", &test_bdatetime);
@@ -1448,14 +1442,12 @@ static void testDateEpochConversionCompare(Test *pTest,
static void testDateEpochConversion(Test *pTest) static void testDateEpochConversion(Test *pTest)
{ {
/* min */ /* min */
testDateEpochConversionCompare(pTest, testDateEpochConversionCompare(pTest, BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
/* middle */ /* middle */
testDateEpochConversionCompare(pTest, testDateEpochConversionCompare(pTest, 2020, 6, 26, 12, 30, 30, 0);
2020, 6, 26, 12, 30, 30, 0);
/* max */ /* max */
testDateEpochConversionCompare(pTest, testDateEpochConversionCompare(
BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0); pTest, BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0);
} }
static void testDateEpoch(Test *pTest) static void testDateEpoch(Test *pTest)
+4 -2
View File
@@ -196,7 +196,8 @@ int dcc_encode_apdu(uint8_t *apdu,
/* optional password */ /* optional password */
if (password) { if (password) {
if ((password->length >= 1) && (password->length <= 20)) { if ((password->length >= 1) && (password->length <= 20)) {
len = encode_context_character_string(&apdu[apdu_len], 2, password); len = encode_context_character_string(
&apdu[apdu_len], 2, password);
apdu_len += len; apdu_len += len;
} }
} }
@@ -212,7 +213,8 @@ int dcc_encode_apdu(uint8_t *apdu,
* @param apdu Pointer to the received request. * @param apdu Pointer to the received request.
* @param apdu_len_max Valid count of bytes in the buffer. * @param apdu_len_max Valid count of bytes in the buffer.
* @param timeDuration Pointer to the duration given in minutes [optional] * @param timeDuration Pointer to the duration given in minutes [optional]
* @param enable_disable Pointer to the variable takingthe communication enable/disable. * @param enable_disable Pointer to the variable takingthe communication
* enable/disable.
* @param password Pointer to the password [optional] * @param password Pointer to the password [optional]
* *
* @return Bytes decoded. * @return Bytes decoded.
+19 -17
View File
@@ -466,8 +466,8 @@ int event_notify_decode_service_request(
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
/* tag 6 - eventType */ /* tag 6 - eventType */
if ((section_length = if ((section_length = decode_context_enumerated(
decode_context_enumerated(&apdu[len], 6, &enum_value)) == -1) { &apdu[len], 6, &enum_value)) == -1) {
return -1; return -1;
} else { } else {
data->eventType = (BACNET_EVENT_TYPE)enum_value; data->eventType = (BACNET_EVENT_TYPE)enum_value;
@@ -494,8 +494,8 @@ int event_notify_decode_service_request(
} }
/* tag 8 - notifyType */ /* tag 8 - notifyType */
if ((section_length = if ((section_length = decode_context_enumerated(
decode_context_enumerated(&apdu[len], 8, &enum_value)) == -1) { &apdu[len], 8, &enum_value)) == -1) {
return -1; return -1;
} else { } else {
data->notifyType = (BACNET_NOTIFY_TYPE)enum_value; data->notifyType = (BACNET_NOTIFY_TYPE)enum_value;
@@ -529,8 +529,8 @@ int event_notify_decode_service_request(
break; break;
} }
/* tag 11 - toState */ /* tag 11 - toState */
if ((section_length = if ((section_length = decode_context_enumerated(
decode_context_enumerated(&apdu[len], 11, &enum_value)) == -1) { &apdu[len], 11, &enum_value)) == -1) {
return -1; return -1;
} else { } else {
data->toState = (BACNET_EVENT_STATE)enum_value; data->toState = (BACNET_EVENT_STATE)enum_value;
@@ -770,24 +770,26 @@ int event_notify_decode_service_request(
if (section_length > 0) { if (section_length > 0) {
len += section_length; len += section_length;
if (unsigned_value <= UINT32_MAX) { if (unsigned_value <= UINT32_MAX) {
data->notificationParams.bufferReady.previousNotification = data->notificationParams.bufferReady
.previousNotification =
(uint32_t)unsigned_value; (uint32_t)unsigned_value;
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
/* Tag 2 - currentNotification */ /* Tag 2 - currentNotification */
section_length = bacnet_unsigned_context_decode( section_length = bacnet_unsigned_context_decode(
&apdu[len], apdu_len - len, 2, &unsigned_value); &apdu[len], apdu_len - len, 2, &unsigned_value);
if (section_length > 0) { if (section_length > 0) {
len += section_length; len += section_length;
if (unsigned_value <= UINT32_MAX) { if (unsigned_value <= UINT32_MAX) {
data->notificationParams.bufferReady.currentNotification = data->notificationParams.bufferReady
.currentNotification =
(uint32_t)unsigned_value; (uint32_t)unsigned_value;
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
@@ -801,10 +803,10 @@ int event_notify_decode_service_request(
if (section_length > 0) { if (section_length > 0) {
len += section_length; len += section_length;
if (unsigned_value <= UINT32_MAX) { if (unsigned_value <= UINT32_MAX) {
data->notificationParams.unsignedRange.exceedingValue = data->notificationParams.unsignedRange
(uint32_t)unsigned_value; .exceedingValue = (uint32_t)unsigned_value;
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
@@ -824,10 +826,10 @@ int event_notify_decode_service_request(
if (section_length > 0) { if (section_length > 0) {
len += section_length; len += section_length;
if (unsigned_value <= UINT32_MAX) { if (unsigned_value <= UINT32_MAX) {
data->notificationParams.unsignedRange.exceededLimit = data->notificationParams.unsignedRange
(uint32_t)unsigned_value; .exceededLimit = (uint32_t)unsigned_value;
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
} }
} else { } else {
return BACNET_STATUS_ERROR; return BACNET_STATUS_ERROR;
+2 -1
View File
@@ -93,7 +93,8 @@ int getevent_decode_service_request(uint8_t *apdu,
return -1; return -1;
} }
if (len < apdu_len) { if (len < apdu_len) {
len += decode_object_id(&apdu[len], &lastReceivedObjectIdentifier->type, len += decode_object_id(&apdu[len],
&lastReceivedObjectIdentifier->type,
&lastReceivedObjectIdentifier->instance); &lastReceivedObjectIdentifier->instance);
} }
} }
+4 -4
View File
@@ -57,12 +57,12 @@ int ihave_encode_apdu(uint8_t *apdu, BACNET_I_HAVE_DATA *data)
apdu[1] = SERVICE_UNCONFIRMED_I_HAVE; apdu[1] = SERVICE_UNCONFIRMED_I_HAVE;
apdu_len = 2; apdu_len = 2;
/* deviceIdentifier */ /* deviceIdentifier */
len = encode_application_object_id(&apdu[apdu_len], len = encode_application_object_id(
data->device_id.type, data->device_id.instance); &apdu[apdu_len], data->device_id.type, data->device_id.instance);
apdu_len += len; apdu_len += len;
/* objectIdentifier */ /* objectIdentifier */
len = encode_application_object_id(&apdu[apdu_len], len = encode_application_object_id(
data->object_id.type, data->object_id.instance); &apdu[apdu_len], data->object_id.type, data->object_id.instance);
apdu_len += len; apdu_len += len;
/* objectName */ /* objectName */
len = encode_application_character_string( len = encode_application_character_string(
+1 -1
View File
@@ -269,7 +269,7 @@ bool lighting_command_same(
islessgreater(dst->target_level, src->target_level)) { islessgreater(dst->target_level, src->target_level)) {
status = false; status = false;
} }
if ((dst->use_ramp_rate) && if ((dst->use_ramp_rate) &&
islessgreater(dst->ramp_rate, src->ramp_rate)) { islessgreater(dst->ramp_rate, src->ramp_rate)) {
status = false; status = false;
} }
+8 -5
View File
@@ -286,7 +286,6 @@ void npdu_encode_npdu_data(BACNET_NPDU_DATA *npdu_data,
} }
} }
/** Decode the NPDU portion of a received message, particularly the NCPI byte. /** Decode the NPDU portion of a received message, particularly the NCPI byte.
* The Network Layer Protocol Control Information byte is described * The Network Layer Protocol Control Information byte is described
* in section 6.2.2 of the BACnet standard. * in section 6.2.2 of the BACnet standard.
@@ -392,7 +391,8 @@ int bacnet_npdu_decode(uint8_t *npdu,
if (npdu[1] & BIT(5)) { if (npdu[1] & BIT(5)) {
if (pdu_len >= (len + 3)) { if (pdu_len >= (len + 3)) {
len += decode_unsigned16(&npdu[len], &dest_net); len += decode_unsigned16(&npdu[len], &dest_net);
/* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent */ /* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
*/
/* DLEN > 0 specifies length of DADR field */ /* DLEN > 0 specifies length of DADR field */
dlen = npdu[len++]; dlen = npdu[len++];
if (dest) { if (dest) {
@@ -428,7 +428,8 @@ int bacnet_npdu_decode(uint8_t *npdu,
if (npdu[1] & BIT(3)) { if (npdu[1] & BIT(3)) {
if (pdu_len >= (len + 3)) { if (pdu_len >= (len + 3)) {
len += decode_unsigned16(&npdu[len], &src_net); len += decode_unsigned16(&npdu[len], &src_net);
/* SLEN = 0 denotes broadcast MAC SADR and SADR field is absent */ /* SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
*/
/* SLEN > 0 specifies length of SADR field */ /* SLEN > 0 specifies length of SADR field */
slen = npdu[len++]; slen = npdu[len++];
if (src) { if (src) {
@@ -480,11 +481,13 @@ int bacnet_npdu_decode(uint8_t *npdu,
if (pdu_len > len) { if (pdu_len > len) {
npdu_data->network_message_type = npdu_data->network_message_type =
(BACNET_NETWORK_MESSAGE_TYPE)npdu[len++]; (BACNET_NETWORK_MESSAGE_TYPE)npdu[len++];
/* Message Type field contains a value in the range 0x80 - 0xFF, */ /* Message Type field contains a value in the range 0x80 - 0xFF,
*/
/* then a Vendor ID field shall be present */ /* then a Vendor ID field shall be present */
if (npdu_data->network_message_type >= 0x80) { if (npdu_data->network_message_type >= 0x80) {
if (pdu_len >= (len + 2)) { if (pdu_len >= (len + 2)) {
len += decode_unsigned16(&npdu[len], &npdu_data->vendor_id); len += decode_unsigned16(
&npdu[len], &npdu_data->vendor_id);
} }
} }
} }
+82 -48
View File
@@ -59,7 +59,8 @@ static const int Access_Credential_Properties_Required[] = {
PROP_GLOBAL_IDENTIFIER, PROP_STATUS_FLAGS, PROP_RELIABILITY, PROP_GLOBAL_IDENTIFIER, PROP_STATUS_FLAGS, PROP_RELIABILITY,
PROP_CREDENTIAL_STATUS, PROP_REASON_FOR_DISABLE, PROP_CREDENTIAL_STATUS, PROP_REASON_FOR_DISABLE,
PROP_AUTHENTICATION_FACTORS, PROP_ACTIVATION_TIME, PROP_EXPIRATION_TIME, PROP_AUTHENTICATION_FACTORS, PROP_ACTIVATION_TIME, PROP_EXPIRATION_TIME,
PROP_CREDENTIAL_DISABLE, PROP_ASSIGNED_ACCESS_RIGHTS, -1 }; PROP_CREDENTIAL_DISABLE, PROP_ASSIGNED_ACCESS_RIGHTS, -1
};
static const int Access_Credential_Properties_Optional[] = { PROP_DESCRIPTION, static const int Access_Credential_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_DAYS_REMAINING, PROP_USES_REMAINING, PROP_ABSENTEE_LIMIT, PROP_DAYS_REMAINING, PROP_USES_REMAINING, PROP_ABSENTEE_LIMIT,
@@ -175,7 +176,8 @@ static const int Alert_Enrollment_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_EVENT_STATE, PROP_EVENT_DETECTION_ENABLE, PROP_PRESENT_VALUE, PROP_EVENT_STATE, PROP_EVENT_DETECTION_ENABLE,
PROP_NOTIFICATION_CLASS, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS, PROP_NOTIFICATION_CLASS, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS,
PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, -1 }; PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, -1
};
static const int Alert_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION, static const int Alert_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
@@ -242,10 +244,11 @@ static const int Averaging_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_PROPERTY_REFERENCE, PROP_WINDOW_INTERVAL, PROP_WINDOW_SAMPLES, PROP_OBJECT_PROPERTY_REFERENCE, PROP_WINDOW_INTERVAL, PROP_WINDOW_SAMPLES,
-1 }; -1 };
static const int Averaging_Properties_Optional[] = { static const int Averaging_Properties_Optional[] = {
PROP_MINIMUM_VALUE_TIMESTAMP, PROP_VARIANCE_VALUE, PROP_MINIMUM_VALUE_TIMESTAMP, PROP_VARIANCE_VALUE,
PROP_MAXIMUM_VALUE_TIMESTAMP, PROP_DESCRIPTION, PROP_TAGS, PROP_MAXIMUM_VALUE_TIMESTAMP, PROP_DESCRIPTION, PROP_TAGS,
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
};
static const int Binary_Input_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Binary_Input_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
@@ -269,7 +272,8 @@ static const int Binary_Lighting_Output_Properties_Required[] = {
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OUT_OF_SERVICE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OUT_OF_SERVICE,
PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE, PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE,
PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY, PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY,
-1 }; -1
};
static const int Binary_Lighting_Output_Properties_Optional[] = { static const int Binary_Lighting_Output_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_RELIABILITY, PROP_FEEDBACK_VALUE, PROP_POWER, PROP_DESCRIPTION, PROP_RELIABILITY, PROP_FEEDBACK_VALUE, PROP_POWER,
@@ -280,7 +284,8 @@ static const int Binary_Lighting_Output_Properties_Optional[] = {
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_VALUE_SOURCE, PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_VALUE_SOURCE,
PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY,
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
};
static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
@@ -324,7 +329,8 @@ static const int Binary_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int BitString_Value_Properties_Required[] = { static const int BitString_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int BitString_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int BitString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -343,8 +349,8 @@ static const int Calendar_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_DATE_LIST, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_DATE_LIST,
-1 }; -1 };
static const int Calendar_Properties_Optional[] = { PROP_DESCRIPTION, static const int Calendar_Properties_Optional[] = { PROP_DESCRIPTION, PROP_TAGS,
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
static const int Channel_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Channel_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_LAST_PRIORITY, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_LAST_PRIORITY,
@@ -358,8 +364,8 @@ static const int Channel_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE, PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT,
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
}; -1 };
static const int Command_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Command_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_IN_PROCESS, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_IN_PROCESS,
@@ -375,7 +381,8 @@ static const int Command_Properties_Optional[] = { PROP_DESCRIPTION,
static const int CharacterString_Value_Properties_Required[] = { static const int CharacterString_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int CharacterString_Value_Properties_Optional[] = { static const int CharacterString_Value_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -388,12 +395,14 @@ static const int CharacterString_Value_Properties_Optional[] = {
PROP_TIME_DELAY_NORMAL, PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_TIME_DELAY_NORMAL, PROP_RELIABILITY_EVALUATION_INHIBIT,
PROP_CURRENT_COMMAND_PRIORITY, PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_CURRENT_COMMAND_PRIORITY, PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY,
PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY, PROP_TAGS,
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
};
static const int Credential_Data_Input_Properties_Required[] = { static const int Credential_Data_Input_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_RELIABILITY, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_RELIABILITY,
PROP_OUT_OF_SERVICE, PROP_SUPPORTED_FORMATS, PROP_UPDATE_TIME, -1 }; PROP_OUT_OF_SERVICE, PROP_SUPPORTED_FORMATS, PROP_UPDATE_TIME, -1
};
static const int Credential_Data_Input_Properties_Optional[] = { static const int Credential_Data_Input_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_SUPPORTED_FORMAT_CLASSES, PROP_DESCRIPTION, PROP_SUPPORTED_FORMAT_CLASSES,
@@ -401,11 +410,13 @@ static const int Credential_Data_Input_Properties_Optional[] = {
PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE, PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT,
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
};
static const int Date_Pattern_Value_Properties_Required[] = { static const int Date_Pattern_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int Date_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int Date_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -435,7 +446,8 @@ static const int Date_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int DateTime_Pattern_Value_Properties_Required[] = { static const int DateTime_Pattern_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int DateTime_Pattern_Value_Properties_Optional[] = { static const int DateTime_Pattern_Value_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -446,11 +458,13 @@ static const int DateTime_Pattern_Value_Properties_Optional[] = {
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_CURRENT_COMMAND_PRIORITY, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_CURRENT_COMMAND_PRIORITY,
PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME, PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME,
PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION,
PROP_PROFILE_NAME, -1 }; PROP_PROFILE_NAME, -1
};
static const int DateTime_Value_Properties_Required[] = { static const int DateTime_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int DateTime_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int DateTime_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -496,7 +510,8 @@ static const int Device_Properties_Optional[] = { PROP_LOCATION,
static const int Elevator_Group_Properties_Required[] = { static const int Elevator_Group_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_MACHINE_ROOM_ID, PROP_GROUP_ID, PROP_GROUP_MEMBERS, -1 }; PROP_MACHINE_ROOM_ID, PROP_GROUP_ID, PROP_GROUP_MEMBERS, -1
};
static const int Elevator_Group_Properties_Optional[] = { PROP_DESCRIPTION, static const int Elevator_Group_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_GROUP_MODE, PROP_LANDING_CALLS, PROP_LANDING_CALL_CONTROL, PROP_TAGS, PROP_GROUP_MODE, PROP_LANDING_CALLS, PROP_LANDING_CALL_CONTROL, PROP_TAGS,
@@ -523,7 +538,8 @@ static const int Event_Enrollment_Properties_Required[] = {
PROP_NOTIFY_TYPE, PROP_EVENT_PARAMETERS, PROP_OBJECT_PROPERTY_REFERENCE, PROP_NOTIFY_TYPE, PROP_EVENT_PARAMETERS, PROP_OBJECT_PROPERTY_REFERENCE,
PROP_EVENT_STATE, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS, PROP_EVENT_STATE, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS,
PROP_NOTIFICATION_CLASS, PROP_EVENT_TIME_STAMPS, PROP_NOTIFICATION_CLASS, PROP_EVENT_TIME_STAMPS,
PROP_EVENT_DETECTION_ENABLE, PROP_STATUS_FLAGS, PROP_RELIABILITY, -1 }; PROP_EVENT_DETECTION_ENABLE, PROP_STATUS_FLAGS, PROP_RELIABILITY, -1
};
static const int Event_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION, static const int Event_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
@@ -552,8 +568,8 @@ static const int File_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_FILE_ACCESS_METHOD, -1 }; PROP_FILE_ACCESS_METHOD, -1 };
static const int File_Properties_Optional[] = { PROP_DESCRIPTION, static const int File_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_RECORD_COUNT, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 PROP_RECORD_COUNT, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
}; -1 };
static const int Global_Group_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Global_Group_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_GROUP_MEMBERS, PROP_PRESENT_VALUE, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_GROUP_MEMBERS, PROP_PRESENT_VALUE,
@@ -600,7 +616,8 @@ static const int Integer_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Large_Analog_Value_Properties_Required[] = { static const int Large_Analog_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1
};
static const int Large_Analog_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int Large_Analog_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -645,7 +662,8 @@ static const int Lighting_Output_Properties_Required[] = {
PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE, PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE,
PROP_DEFAULT_FADE_TIME, PROP_DEFAULT_RAMP_RATE, PROP_DEFAULT_STEP_INCREMENT, PROP_DEFAULT_FADE_TIME, PROP_DEFAULT_RAMP_RATE, PROP_DEFAULT_STEP_INCREMENT,
PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT,
PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, PROP_CURRENT_COMMAND_PRIORITY, -1 }; PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, PROP_CURRENT_COMMAND_PRIORITY, -1
};
static const int Lighting_Output_Properties_Optional[] = { PROP_DESCRIPTION, static const int Lighting_Output_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_RELIABILITY, PROP_TRANSITION, PROP_FEEDBACK_VALUE, PROP_POWER, PROP_RELIABILITY, PROP_TRANSITION, PROP_FEEDBACK_VALUE, PROP_POWER,
@@ -675,7 +693,8 @@ static const int Life_Safety_Point_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS, PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE,
PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED, -1 }; PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED, -1
};
static const int Life_Safety_Point_Properties_Optional[] = { PROP_DESCRIPTION, static const int Life_Safety_Point_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS, PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS,
@@ -694,18 +713,19 @@ static const int Life_Safety_Zone_Properties_Required[] = {
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS, PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE,
PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED, PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED,
PROP_ZONE_MEMBERS, -1 }; PROP_ZONE_MEMBERS, -1
};
static const int Life_Safety_Zone_Properties_Optional[] = { static const int Life_Safety_Zone_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_DESCRIPTION, PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS,
PROP_NOTIFICATION_CLASS, PROP_LIFE_SAFETY_ALARM_VALUES, PROP_ALARM_VALUES, PROP_LIFE_SAFETY_ALARM_VALUES, PROP_ALARM_VALUES, PROP_FAULT_VALUES,
PROP_FAULT_VALUES, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_DETECTION_ENABLE, PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_DETECTION_ENABLE,
PROP_EVENT_ALGORITHM_INHIBIT_REF, PROP_EVENT_ALGORITHM_INHIBIT, PROP_EVENT_ALGORITHM_INHIBIT_REF, PROP_EVENT_ALGORITHM_INHIBIT,
PROP_TIME_DELAY_NORMAL, PROP_MAINTENANCE_REQUIRED, PROP_MEMBER_OF, PROP_TIME_DELAY_NORMAL, PROP_MAINTENANCE_REQUIRED, PROP_MEMBER_OF,
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
}; -1 };
static const int Loop_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Loop_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
@@ -732,7 +752,8 @@ static const int Loop_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Multistate_Input_Properties_Required[] = { static const int Multistate_Input_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1 }; PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1
};
static const int Multistate_Input_Properties_Optional[] = { PROP_DESCRIPTION, static const int Multistate_Input_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY, PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY,
@@ -749,7 +770,8 @@ static const int Multistate_Output_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, PROP_PRIORITY_ARRAY, PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, PROP_PRIORITY_ARRAY,
PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY, -1 }; PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY, -1
};
static const int Multistate_Output_Properties_Optional[] = { PROP_DESCRIPTION, static const int Multistate_Output_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY, PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY,
@@ -766,7 +788,8 @@ static const int Multistate_Output_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Multistate_Value_Properties_Required[] = { static const int Multistate_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1 }; PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1
};
static const int Multistate_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int Multistate_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_RELIABILITY, PROP_STATE_TEXT, PROP_PRIORITY_ARRAY, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_PRIORITY_ARRAY,
@@ -819,7 +842,8 @@ static const int Network_Security_Properties_Required[] = {
PROP_SECURITY_TIME_WINDOW, PROP_PACKET_REORDER_TIME, PROP_SECURITY_TIME_WINDOW, PROP_PACKET_REORDER_TIME,
PROP_DISTRIBUTION_KEY_REVISION, PROP_KEY_SETS, PROP_LAST_KEY_SERVER, PROP_DISTRIBUTION_KEY_REVISION, PROP_KEY_SETS, PROP_LAST_KEY_SERVER,
PROP_SECURITY_PDU_TIMEOUT, PROP_UPDATE_KEY_SET_TIMEOUT, PROP_SECURITY_PDU_TIMEOUT, PROP_UPDATE_KEY_SET_TIMEOUT,
PROP_SUPPORTED_SECURITY_ALGORITHM, PROP_DO_NOT_HIDE, -1 }; PROP_SUPPORTED_SECURITY_ALGORITHM, PROP_DO_NOT_HIDE, -1
};
static const int Network_Security_Properties_Optional[] = { PROP_DESCRIPTION, static const int Network_Security_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
@@ -827,7 +851,8 @@ static const int Network_Security_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Notification_Class_Properties_Required[] = { static const int Notification_Class_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_NOTIFICATION_CLASS, PROP_PRIORITY, PROP_ACK_REQUIRED, PROP_NOTIFICATION_CLASS, PROP_PRIORITY, PROP_ACK_REQUIRED,
PROP_RECIPIENT_LIST, -1 }; PROP_RECIPIENT_LIST, -1
};
static const int Notification_Class_Properties_Optional[] = { PROP_DESCRIPTION, static const int Notification_Class_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_RELIABILITY,
@@ -840,15 +865,18 @@ static const int Notification_Forwarder_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_STATUS_FLAGS, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_STATUS_FLAGS, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
PROP_RECIPIENT_LIST, PROP_SUBSCRIBED_RECIPIENTS, PROP_RECIPIENT_LIST, PROP_SUBSCRIBED_RECIPIENTS,
PROP_PROCESS_IDENTIFIER_FILTER, PROP_LOCAL_FORWARDING_ONLY, -1 }; PROP_PROCESS_IDENTIFIER_FILTER, PROP_LOCAL_FORWARDING_ONLY, -1
};
static const int Notification_Forwarder_Properties_Optional[] = { static const int Notification_Forwarder_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_PORT_FILTER, PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_DESCRIPTION, PROP_PORT_FILTER, PROP_RELIABILITY_EVALUATION_INHIBIT,
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 }; PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
};
static const int OctetString_Value_Properties_Required[] = { static const int OctetString_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int OctetString_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int OctetString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -860,7 +888,8 @@ static const int OctetString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Positive_Integer_Value_Properties_Required[] = { static const int Positive_Integer_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1
};
static const int Positive_Integer_Value_Properties_Optional[] = { static const int Positive_Integer_Value_Properties_Optional[] = {
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -875,7 +904,8 @@ static const int Positive_Integer_Value_Properties_Optional[] = {
PROP_FAULT_HIGH_LIMIT, PROP_FAULT_LOW_LIMIT, PROP_CURRENT_COMMAND_PRIORITY, PROP_FAULT_HIGH_LIMIT, PROP_FAULT_LOW_LIMIT, PROP_CURRENT_COMMAND_PRIORITY,
PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME, PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME,
PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION,
PROP_PROFILE_NAME, -1 }; PROP_PROFILE_NAME, -1
};
static const int Program_Properties_Required[] = { PROP_OBJECT_IDENTIFIER, static const int Program_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PROGRAM_STATE, PROP_PROGRAM_CHANGE, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PROGRAM_STATE, PROP_PROGRAM_CHANGE,
@@ -895,7 +925,8 @@ static const int Pulse_Converter_Properties_Required[] = {
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
PROP_OUT_OF_SERVICE, PROP_UNITS, PROP_SCALE_FACTOR, PROP_ADJUST_VALUE, PROP_OUT_OF_SERVICE, PROP_UNITS, PROP_SCALE_FACTOR, PROP_ADJUST_VALUE,
PROP_COUNT, PROP_UPDATE_TIME, PROP_COUNT_CHANGE_TIME, PROP_COUNT, PROP_UPDATE_TIME, PROP_COUNT_CHANGE_TIME,
PROP_COUNT_BEFORE_CHANGE, -1 }; PROP_COUNT_BEFORE_CHANGE, -1
};
static const int Pulse_Converter_Properties_Optional[] = { PROP_DESCRIPTION, static const int Pulse_Converter_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_INPUT_REFERENCE, PROP_RELIABILITY, PROP_COV_INCREMENT, PROP_COV_PERIOD, PROP_INPUT_REFERENCE, PROP_RELIABILITY, PROP_COV_INCREMENT, PROP_COV_PERIOD,
@@ -937,7 +968,8 @@ static const int Staging_Properties_Optional[] = { PROP_STAGE_NAMES,
static const int Structured_View_Properties_Required[] = { static const int Structured_View_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_NODE_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_NODE_TYPE,
PROP_SUBORDINATE_LIST, -1 }; PROP_SUBORDINATE_LIST, -1
};
static const int Structured_View_Properties_Optional[] = { PROP_DESCRIPTION, static const int Structured_View_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_NODE_SUBTYPE, PROP_SUBORDINATE_ANNOTATIONS, PROP_SUBORDINATE_TAGS, PROP_NODE_SUBTYPE, PROP_SUBORDINATE_ANNOTATIONS, PROP_SUBORDINATE_TAGS,
@@ -947,7 +979,8 @@ static const int Structured_View_Properties_Optional[] = { PROP_DESCRIPTION,
static const int Time_Pattern_Value_Properties_Required[] = { static const int Time_Pattern_Value_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 }; PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
};
static const int Time_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION, static const int Time_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
@@ -1017,7 +1050,8 @@ static const int Trend_Log_Multiple_Properties_Required[] = {
PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_ENABLE, PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_ENABLE,
PROP_LOG_DEVICE_OBJECT_PROPERTY, PROP_LOGGING_TYPE, PROP_LOG_INTERVAL, PROP_LOG_DEVICE_OBJECT_PROPERTY, PROP_LOGGING_TYPE, PROP_LOG_INTERVAL,
PROP_STOP_WHEN_FULL, PROP_BUFFER_SIZE, PROP_LOG_BUFFER, PROP_RECORD_COUNT, PROP_STOP_WHEN_FULL, PROP_BUFFER_SIZE, PROP_LOG_BUFFER, PROP_RECORD_COUNT,
PROP_TOTAL_RECORD_COUNT, -1 }; PROP_TOTAL_RECORD_COUNT, -1
};
static const int Trend_Log_Multiple_Properties_Optional[] = { PROP_DESCRIPTION, static const int Trend_Log_Multiple_Properties_Optional[] = { PROP_DESCRIPTION,
PROP_RELIABILITY, PROP_START_TIME, PROP_STOP_TIME, PROP_ALIGN_INTERVALS, PROP_RELIABILITY, PROP_START_TIME, PROP_STOP_TIME, PROP_ALIGN_INTERVALS,
+4 -4
View File
@@ -70,7 +70,8 @@ int rd_encode_apdu(uint8_t *apdu,
if (password) { if (password) {
/* Must be at least 1 character, limited to 20 characters */ /* Must be at least 1 character, limited to 20 characters */
if ((password->length >= 1) && (password->length <= 20)) { if ((password->length >= 1) && (password->length <= 20)) {
len = encode_context_character_string(&apdu[apdu_len], 1, password); len = encode_context_character_string(
&apdu[apdu_len], 1, password);
apdu_len += len; apdu_len += len;
} }
} }
@@ -120,9 +121,8 @@ int rd_decode_service_request(uint8_t *apdu,
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (len < apdu_len) { if (len < apdu_len) {
if (password) { if (password) {
len += decode_character_string(&apdu[len], len += decode_character_string(
len_value_type, &apdu[len], len_value_type, password);
password);
} }
} }
} }
+24 -20
View File
@@ -169,7 +169,7 @@ int rr_decode_service_request(
rrdata->object_type = type; rrdata->object_type = type;
/* Tag 1: Property ID */ /* Tag 1: Property ID */
if (len >= apdu_len) { if (len >= apdu_len) {
return(-1); return (-1);
} }
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
@@ -188,8 +188,8 @@ int rr_decode_service_request(
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number == 2) { if (tag_number == 2) {
len += TagLen; len += TagLen;
len += len += decode_unsigned(
decode_unsigned(&apdu[len], len_value_type, &unsigned_value); &apdu[len], len_value_type, &unsigned_value);
rrdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value; rrdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
rrdata->Overhead += rrdata->Overhead +=
RR_INDEX_OVERHEAD; /* Allow for this in the response */ RR_INDEX_OVERHEAD; /* Allow for this in the response */
@@ -269,7 +269,7 @@ int rr_decode_service_request(
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
/* Allow for this in the response */ /* Allow for this in the response */
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD; rrdata->Overhead += RR_1ST_SEQ_OVERHEAD;
break; break;
case 7: /* ReadRange by time stamp */ case 7: /* ReadRange by time stamp */
@@ -318,7 +318,7 @@ int rr_decode_service_request(
} }
} }
} else { } else {
return(-1); return (-1);
} }
return (int)len; return (int)len;
@@ -434,15 +434,16 @@ int rr_ack_decode_service_request(uint8_t *apdu,
return -1; return -1;
} }
len = 1; len = 1;
len += decode_object_id(&apdu[len], &object_type, &rrdata->object_instance); len += decode_object_id(
&apdu[len], &object_type, &rrdata->object_instance);
rrdata->object_type = object_type; rrdata->object_type = object_type;
/* Tag 1: Property ID */ /* Tag 1: Property ID */
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
len += len += decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number != 1) { if (tag_number != 1) {
return -1; return -1;
} }
@@ -453,8 +454,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
tag_len = tag_len = decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number == 2) { if (tag_number == 2) {
len += tag_len; len += tag_len;
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value); len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
@@ -467,22 +468,23 @@ int rr_ack_decode_service_request(uint8_t *apdu,
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
len += len += decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number != 3) { if (tag_number != 3) {
return -1; return -1;
} }
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
len += decode_bitstring(&apdu[len], len_value_type, &rrdata->ResultFlags); len +=
decode_bitstring(&apdu[len], len_value_type, &rrdata->ResultFlags);
/* Tag 4: Item count */ /* Tag 4: Item count */
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
len += len += decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number != 4) { if (tag_number != 4) {
return -1; return -1;
} }
@@ -496,8 +498,9 @@ int rr_ack_decode_service_request(uint8_t *apdu,
} }
if (decode_is_opening_tag_number(&apdu[len], 5)) { if (decode_is_opening_tag_number(&apdu[len], 5)) {
len++; /* A tag number of 5 is not extended so only one octet len++; /* A tag number of 5 is not extended so only one octet
* Setup the start position and length of the data returned from the * Setup the start position and length of the data returned
* request don't decode the application tag number or its data here. */ * from the request don't decode the application tag number
* or its data here. */
rrdata->application_data = &apdu[len]; rrdata->application_data = &apdu[len];
start_len = len; start_len = len;
while (len < apdu_len) { while (len < apdu_len) {
@@ -511,8 +514,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], NULL, &len_value_type); &apdu[len], NULL, &len_value_type);
len += len_value_type; /* Skip over data value as well */ len += len_value_type; /* Skip over data value as well */
if (len >= apdu_len) { /* APDU is exhausted so we have failed to if (len >= apdu_len) { /* APDU is exhausted so we have
* find closing tag */ * failed to find closing tag */
return (-1); return (-1);
} }
} }
@@ -528,7 +531,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
return -1; return -1;
} }
if (len < apdu_len) { if (len < apdu_len) {
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value); len += decode_unsigned(
&apdu[len], len_value_type, &unsigned_value);
rrdata->FirstSequence = (uint32_t)unsigned_value; rrdata->FirstSequence = (uint32_t)unsigned_value;
} }
} }
+1 -2
View File
@@ -289,8 +289,7 @@ static void testRejectErrorCode(Test *pTest)
error_code = reject_convert_to_error_code(reject_reason); error_code = reject_convert_to_error_code(reject_reason);
test_reject_reason = reject_convert_error_code(error_code); test_reject_reason = reject_convert_error_code(error_code);
if (test_reject_reason != reject_reason) { if (test_reject_reason != reject_reason) {
printf("Reject: result=%u reject-code=%u\n", printf("Reject: result=%u reject-code=%u\n", test_reject_reason,
test_reject_reason,
reject_reason); reject_reason);
} }
ct_test(pTest, test_reject_reason == reject_reason); ct_test(pTest, test_reject_reason == reject_reason);
+10 -8
View File
@@ -136,8 +136,8 @@ int rp_decode_service_request(
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if ((tag_number == 2) && (len < apdu_len)) { if ((tag_number == 2) && (len < apdu_len)) {
len += len += decode_unsigned(
decode_unsigned(&apdu[len], len_value_type, &unsigned_value); &apdu[len], len_value_type, &unsigned_value);
rpdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value; rpdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
} else { } else {
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG; rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
@@ -283,14 +283,15 @@ int rp_ack_decode_service_request(uint8_t *apdu,
return -1; return -1;
} }
len = 1; len = 1;
len += decode_object_id(&apdu[len], &object_type, &rpdata->object_instance); len += decode_object_id(
&apdu[len], &object_type, &rpdata->object_instance);
rpdata->object_type = object_type; rpdata->object_type = object_type;
/* Tag 1: Property ID */ /* Tag 1: Property ID */
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
len += len += decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number != 1) { if (tag_number != 1) {
return -1; return -1;
} }
@@ -303,8 +304,8 @@ int rp_ack_decode_service_request(uint8_t *apdu,
if (len >= apdu_len) { if (len >= apdu_len) {
return -1; return -1;
} }
tag_len = tag_len = decode_tag_number_and_value(
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number == 2) { if (tag_number == 2) {
len += tag_len; len += tag_len;
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value); len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
@@ -323,7 +324,8 @@ int rp_ack_decode_service_request(uint8_t *apdu,
rpdata->application_data = &apdu[len]; rpdata->application_data = &apdu[len];
/* Just to ensure we do not create a wrapped over value here. */ /* Just to ensure we do not create a wrapped over value here. */
if (len < apdu_len) { if (len < apdu_len) {
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */; rpdata->application_data_len =
apdu_len - len - 1 /*closing tag */;
} else { } else {
rpdata->application_data_len = 0; rpdata->application_data_len = 0;
} }
+19 -15
View File
@@ -98,8 +98,9 @@ int rpm_encode_apdu_object_begin(
* *
* @return Bytes encoded or zero on error. * @return Bytes encoded or zero on error.
*/ */
int rpm_encode_apdu_object_property( int rpm_encode_apdu_object_property(uint8_t *apdu,
uint8_t *apdu, BACNET_PROPERTY_ID object_property, BACNET_ARRAY_INDEX array_index) BACNET_PROPERTY_ID object_property,
BACNET_ARRAY_INDEX array_index)
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
@@ -160,8 +161,8 @@ int rpm_encode_apdu(uint8_t *apdu,
apdu_len += len; apdu_len += len;
rpm_object = read_access_data; rpm_object = read_access_data;
while (rpm_object) { while (rpm_object) {
/* The encode function will return a length not more than 12. So the temp buffer /* The encode function will return a length not more than 12. So the
* being 16 bytes is fine enought. */ * temp buffer being 16 bytes is fine enought. */
len = encode_context_object_id(&apdu_temp[0], 0, len = encode_context_object_id(&apdu_temp[0], 0,
rpm_object->object_type, rpm_object->object_instance); rpm_object->object_type, rpm_object->object_instance);
len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len, len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len,
@@ -180,9 +181,9 @@ int rpm_encode_apdu(uint8_t *apdu,
apdu_len += len; apdu_len += len;
rpm_property = rpm_object->listOfProperties; rpm_property = rpm_object->listOfProperties;
while (rpm_property) { while (rpm_property) {
/* The encode function will return a length not more than 12. So the temp buffer /* The encode function will return a length not more than 12. So the
* being 16 bytes is fine enought. * temp buffer being 16 bytes is fine enought. Stuff as many
* Stuff as many properties into it as APDU length will allow. */ * properties into it as APDU length will allow. */
len = encode_context_enumerated( len = encode_context_enumerated(
&apdu_temp[0], 0, rpm_property->propertyIdentifier); &apdu_temp[0], 0, rpm_property->propertyIdentifier);
len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len, len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len,
@@ -341,8 +342,8 @@ int rpm_decode_object_property(
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER; ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
len += len += decode_unsigned(
decode_unsigned(&apdu[len], len_value_type, &unsigned_value); &apdu[len], len_value_type, &unsigned_value);
rpmdata->array_index = unsigned_value; rpmdata->array_index = unsigned_value;
} }
} }
@@ -402,8 +403,9 @@ int rpm_ack_encode_apdu_object_begin(uint8_t *apdu, BACNET_RPM_DATA *rpmdata)
* *
* @return Length of encoded bytes or 0 on failure. * @return Length of encoded bytes or 0 on failure.
*/ */
int rpm_ack_encode_apdu_object_property( int rpm_ack_encode_apdu_object_property(uint8_t *apdu,
uint8_t *apdu, BACNET_PROPERTY_ID object_property, BACNET_ARRAY_INDEX array_index) BACNET_PROPERTY_ID object_property,
BACNET_ARRAY_INDEX array_index)
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
@@ -412,7 +414,8 @@ int rpm_ack_encode_apdu_object_property(
apdu_len = encode_context_enumerated(&apdu[0], 2, object_property); apdu_len = encode_context_enumerated(&apdu[0], 2, object_property);
/* Tag 3: optional propertyArrayIndex */ /* Tag 3: optional propertyArrayIndex */
if (array_index != BACNET_ARRAY_ALL) { if (array_index != BACNET_ARRAY_ALL) {
apdu_len += encode_context_unsigned(&apdu[apdu_len], 3, array_index); apdu_len +=
encode_context_unsigned(&apdu[apdu_len], 3, array_index);
} }
} }
@@ -422,7 +425,8 @@ int rpm_ack_encode_apdu_object_property(
/** Encode the object property value for an acknowledge of a RPM. /** Encode the object property value for an acknowledge of a RPM.
* *
* @param apdu [in] Buffer of bytes to transmit. * @param apdu [in] Buffer of bytes to transmit.
* @param application_data [in] Pointer to the application data used to fill in the APDU. * @param application_data [in] Pointer to the application data used to fill in
* the APDU.
* @param application_data_len [in] Length of the application data. * @param application_data_len [in] Length of the application data.
* *
* @return Length of encoded bytes or 0 on failure. * @return Length of encoded bytes or 0 on failure.
@@ -570,8 +574,8 @@ int rpm_ack_decode_object_property(uint8_t *apdu,
&apdu[len], &tag_number, &len_value_type); &apdu[len], &tag_number, &len_value_type);
if (tag_number == 3) { if (tag_number == 3) {
len += tag_len; len += tag_len;
len += len += decode_unsigned(
decode_unsigned(&apdu[len], len_value_type, &unsigned_value); &apdu[len], len_value_type, &unsigned_value);
*array_index = unsigned_value; *array_index = unsigned_value;
} else { } else {
*array_index = BACNET_ARRAY_ALL; *array_index = BACNET_ARRAY_ALL;
+5 -5
View File
@@ -136,10 +136,10 @@ int timesync_decode_service_request(uint8_t *apdu,
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if (tag_number == BACNET_APPLICATION_TAG_TIME) { if (tag_number == BACNET_APPLICATION_TAG_TIME) {
if ((unsigned)(len + 4) <= apdu_len) { if ((unsigned)(len + 4) <= apdu_len) {
len += decode_bacnet_time(&apdu[len], my_time); len += decode_bacnet_time(&apdu[len], my_time);
} else { } else {
return -1; return -1;
} }
} else { } else {
return -1; return -1;
} }
@@ -181,7 +181,7 @@ int timesync_encode_timesync_recipients(
BACNET_RECIPIENT_LIST *pRecipient; BACNET_RECIPIENT_LIST *pRecipient;
if ((!apdu) || (max_apdu < 1) || (!recipient)) { if ((!apdu) || (max_apdu < 1) || (!recipient)) {
return(0); return (0);
} }
pRecipient = recipient; pRecipient = recipient;
+5 -5
View File
@@ -70,8 +70,7 @@ int whohas_encode_apdu(uint8_t *apdu, BACNET_WHO_HAS_DATA *data)
apdu_len += len; apdu_len += len;
} else { } else {
len = encode_context_object_id(&apdu[apdu_len], 2, len = encode_context_object_id(&apdu[apdu_len], 2,
data->object.identifier.type, data->object.identifier.type, data->object.identifier.instance);
data->object.identifier.instance);
apdu_len += len; apdu_len += len;
} }
} }
@@ -112,7 +111,8 @@ int whohas_decode_service_request(
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
if ((unsigned)len < apdu_len) { if ((unsigned)len < apdu_len) {
len += decode_unsigned(&apdu[len], len_value, &unsigned_value); len += decode_unsigned(
&apdu[len], len_value, &unsigned_value);
if (unsigned_value <= BACNET_MAX_INSTANCE) { if (unsigned_value <= BACNET_MAX_INSTANCE) {
data->high_limit = unsigned_value; data->high_limit = unsigned_value;
} }
@@ -130,8 +130,8 @@ int whohas_decode_service_request(
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
if ((unsigned)len < apdu_len) { if ((unsigned)len < apdu_len) {
len += decode_object_id( len += decode_object_id(&apdu[len], &decoded_type,
&apdu[len], &decoded_type, &data->object.identifier.instance); &data->object.identifier.instance);
data->object.identifier.type = decoded_type; data->object.identifier.type = decoded_type;
} }
} }
+2 -1
View File
@@ -95,7 +95,8 @@ int whois_decode_service_request(
decode_unsigned(&apdu[len], len_value, &unsigned_value); decode_unsigned(&apdu[len], len_value, &unsigned_value);
if (unsigned_value <= BACNET_MAX_INSTANCE) { if (unsigned_value <= BACNET_MAX_INSTANCE) {
if (pHigh_limit) { if (pHigh_limit) {
*pHigh_limit = (int32_t)unsigned_value;; *pHigh_limit = (int32_t)unsigned_value;
;
} }
} }
} else { } else {
+2 -2
View File
@@ -154,8 +154,8 @@ int wp_decode_service_request(
return -1; return -1;
} }
/* determine the length of the data blob */ /* determine the length of the data blob */
imax = bacapp_data_len( \ imax = bacapp_data_len(
&apdu[len], apdu_len - len, (BACNET_PROPERTY_ID)property); &apdu[len], apdu_len - len, (BACNET_PROPERTY_ID)property);
if (imax == BACNET_STATUS_ERROR) { if (imax == BACNET_STATUS_ERROR) {
return -2; return -2;
} }
+11 -9
View File
@@ -147,8 +147,8 @@ int wpm_decode_object_property(
/* tag 2 - Property Value */ /* tag 2 - Property Value */
if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) { if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) {
len--; len--;
imax = bacapp_data_len(&apdu[len], imax = bacapp_data_len(&apdu[len], (unsigned)(apdu_len - len),
(unsigned)(apdu_len - len), wp_data->object_property); wp_data->object_property);
len++; len++;
if (imax != BACNET_STATUS_ERROR) { if (imax != BACNET_STATUS_ERROR) {
@@ -165,7 +165,8 @@ int wpm_decode_object_property(
len += decode_tag_number_and_value( len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value); &apdu[len], &tag_number, &len_value);
/* closing tag 2 */ /* closing tag 2 */
if ((tag_number != 2) && (decode_is_closing_tag(&apdu[len - 1]))) { if ((tag_number != 2) &&
(decode_is_closing_tag(&apdu[len - 1]))) {
wp_data->error_code = ERROR_CODE_REJECT_INVALID_TAG; wp_data->error_code = ERROR_CODE_REJECT_INVALID_TAG;
return BACNET_STATUS_REJECT; return BACNET_STATUS_REJECT;
} }
@@ -184,7 +185,8 @@ int wpm_decode_object_property(
/* tag 3 - Priority - optional */ /* tag 3 - Priority - optional */
if (len < apdu_len) { if (len < apdu_len) {
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value); len += decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value);
if (tag_number == 3) { if (tag_number == 3) {
len += decode_unsigned(&apdu[len], len_value, &unsigned_value); len += decode_unsigned(&apdu[len], len_value, &unsigned_value);
wp_data->priority = (uint8_t)unsigned_value; wp_data->priority = (uint8_t)unsigned_value;
@@ -298,8 +300,8 @@ int wpm_encode_apdu_object_property(
apdu_len += encode_closing_tag(&apdu[apdu_len], 2); apdu_len += encode_closing_tag(&apdu[apdu_len], 2);
if (wpdata->priority != BACNET_NO_PRIORITY) { if (wpdata->priority != BACNET_NO_PRIORITY) {
if (apdu_len < MAX_APDU) { if (apdu_len < MAX_APDU) {
apdu_len += apdu_len += encode_context_unsigned(
encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority); &apdu[apdu_len], 3, wpdata->priority);
} }
} }
} }
@@ -351,9 +353,9 @@ int wpm_encode_apdu(uint8_t *apdu,
wpdata.object_property = wpm_property->propertyIdentifier; wpdata.object_property = wpm_property->propertyIdentifier;
wpdata.array_index = wpm_property->propertyArrayIndex; wpdata.array_index = wpm_property->propertyArrayIndex;
wpdata.priority = wpm_property->priority; wpdata.priority = wpm_property->priority;
usize = (size_t)bacapp_encode_data(&apdu_temp[0], &wpm_property->value); usize = (size_t)bacapp_encode_data(
if (usize > sizeof(wpdata.application_data)) &apdu_temp[0], &wpm_property->value);
{ if (usize > sizeof(wpdata.application_data)) {
usize = sizeof(wpdata.application_data); usize = sizeof(wpdata.application_data);
} }
wpdata.application_data_len = (int)usize; wpdata.application_data_len = (int)usize;