Indented according to standard indent rules for this project.

This commit is contained in:
skarg
2009-04-18 20:50:04 +00:00
parent b3fab21603
commit b85c4355d0
43 changed files with 501 additions and 502 deletions
+34 -33
View File
@@ -54,39 +54,40 @@ static struct Address_Cache_Entry {
BACNET_ADDRESS address;
} Address_Cache[MAX_ADDRESS_CACHE];
bool address_match(BACNET_ADDRESS * dest,
BACNET_ADDRESS * src)
bool address_match(
BACNET_ADDRESS * dest,
BACNET_ADDRESS * src)
{
uint8_t i = 0;
uint8_t max_len = 0;
uint8_t i = 0;
uint8_t max_len = 0;
if (dest->mac_len != src->mac_len)
return false;
max_len = dest->mac_len;
if (max_len > MAX_MAC_LEN)
max_len = MAX_MAC_LEN;
for (i = 0; i < max_len; i++) {
if (dest->mac[i] != src->mac[i])
return false;
}
if (dest->net != src->net)
return false;
if (dest->mac_len != src->mac_len)
return false;
max_len = dest->mac_len;
if (max_len > MAX_MAC_LEN)
max_len = MAX_MAC_LEN;
for (i = 0; i < max_len; i++) {
if (dest->mac[i] != src->mac[i])
return false;
}
if (dest->net != src->net)
return false;
/* if local, ignore remaining fields */
if (dest->net == 0)
return true;
/* if local, ignore remaining fields */
if (dest->net == 0)
return true;
if (dest->len != src->len)
return false;
max_len = dest->len;
if (max_len > MAX_MAC_LEN)
max_len = MAX_MAC_LEN;
for (i = 0; i < max_len; i++) {
if (dest->adr[i] != src->adr[i])
return false;
}
if (dest->len != src->len)
return false;
max_len = dest->len;
if (max_len > MAX_MAC_LEN)
max_len = MAX_MAC_LEN;
for (i = 0; i < max_len; i++) {
if (dest->adr[i] != src->adr[i])
return false;
}
return true;
return true;
}
void address_remove_device(
@@ -129,7 +130,7 @@ void address_file_init(
pFile = fopen(pFilename, "r");
if (pFile) {
while (fgets(line, (int)sizeof(line), pFile) != NULL) {
while (fgets(line, (int) sizeof(line), pFile) != NULL) {
/* ignore comments */
if (line[0] != ';') {
if (sscanf(line, "%ld %s %d %s %u", &device_id, &mac_string[0],
@@ -137,16 +138,16 @@ void address_file_init(
count =
sscanf(mac_string, "%x:%x:%x:%x:%x:%x", &mac[0],
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.mac_len = (uint8_t)count;
src.mac_len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.mac[index] = mac[index];
}
src.net = (uint16_t)snet;
src.net = (uint16_t) snet;
if (snet) {
count =
sscanf(sadr_string, "%x:%x:%x:%x:%x:%x", &mac[0],
&mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
src.len = (uint8_t)count;
src.len = (uint8_t) count;
for (index = 0; index < MAX_MAC_LEN; index++) {
src.adr[index] = mac[index];
}
@@ -156,7 +157,7 @@ void address_file_init(
src.adr[index] = 0;
}
}
address_add((uint32_t)device_id, max_apdu, &src);
address_add((uint32_t) device_id, max_apdu, &src);
}
}
}
+2 -2
View File
@@ -60,8 +60,8 @@ bool bacnet_address_same(
BACNET_ADDRESS * dest,
BACNET_ADDRESS * src)
{
uint8_t i = 0; /* loop counter */
uint8_t max_len = 0; /* used for dynamic max */
uint8_t i = 0; /* loop counter */
uint8_t max_len = 0; /* used for dynamic max */
bool match = true; /* return value */
if (dest->mac_len != src->mac_len)
+3 -3
View File
@@ -135,7 +135,7 @@ int bacapp_encode_application_data(
case BACNET_APPLICATION_TAG_OBJECT_ID:
apdu_len =
encode_application_object_id(&apdu[0],
(int)value->type.Object_Id.type,
(int) value->type.Object_Id.type,
value->type.Object_Id.instance);
break;
#endif
@@ -376,7 +376,7 @@ int bacapp_encode_context_data_value(
case BACNET_APPLICATION_TAG_OBJECT_ID:
apdu_len =
encode_context_object_id(&apdu[0], context_tag_number,
(int)value->type.Object_Id.type,
(int) value->type.Object_Id.type,
value->type.Object_Id.instance);
break;
#endif
@@ -686,7 +686,7 @@ int bacapp_data_len(
break;
}
}
if ((unsigned)apdu_len > max_apdu_len) {
if ((unsigned) apdu_len > max_apdu_len) {
/* error: exceeding our buffer limit */
total_len = -1;
break;
+50 -35
View File
@@ -682,7 +682,7 @@ int encode_application_bitstring(
BACNET_BIT_STRING * bit_string)
{
int len = 0;
uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */
uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */
/* bit string may use more than 1 octet for the tag, so find out how many */
bit_string_encoded_length += bitstring_bytes_used(bit_string);
@@ -700,13 +700,11 @@ int encode_context_bitstring(
BACNET_BIT_STRING * bit_string)
{
int len = 0;
uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */
uint32_t bit_string_encoded_length = 1; /* 1 for the bits remaining octet */
/* bit string may use more than 1 octet for the tag, so find out how many */
bit_string_encoded_length += bitstring_bytes_used(bit_string);
len =
encode_tag(&apdu[0], tag_number, true,
bit_string_encoded_length);
len = encode_tag(&apdu[0], tag_number, true, bit_string_encoded_length);
len += encode_bitstring(&apdu[len], bit_string);
return len;
@@ -757,7 +755,7 @@ int encode_bacnet_object_id(
uint32_t type = 0;
int len = 0;
type = (uint32_t)object_type;
type = (uint32_t) object_type;
value =
((type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) | (instance &
BACNET_MAX_INSTANCE);
@@ -781,7 +779,7 @@ int encode_context_object_id(
len = encode_bacnet_object_id(&apdu[1], object_type, instance);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -801,7 +799,9 @@ int encode_application_object_id(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_object_id(&apdu[1], object_type, instance);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OBJECT_ID, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_OBJECT_ID, false,
(uint32_t) len);
return len;
}
@@ -819,7 +819,7 @@ int encode_octet_string(
if (octet_string) {
/* FIXME: might need to pass in the length of the APDU
to bounds check since it might not be the only data chunk */
len = (int)octetstring_length(octet_string);
len = (int) octetstring_length(octet_string);
value = octetstring_value(octet_string);
for (i = 0; i < len; i++) {
apdu[i] = value[i];
@@ -891,7 +891,7 @@ int decode_octet_string(
status = octetstring_init(octet_string, &apdu[0], len_value);
if (status) {
len = (int)len_value;
len = (int) len_value;
}
return len;
@@ -931,11 +931,11 @@ int encode_bacnet_character_string(
int len, i;
char *pString;
len = (int)characterstring_length(char_string);
len = (int) characterstring_length(char_string);
apdu[0] = characterstring_encoding(char_string);
pString = characterstring_value(char_string);
for (i = 0; i < len; i++) {
apdu[1 + i] = (uint8_t)pString[i];
apdu[1 + i] = (uint8_t) pString[i];
}
return len + 1 /* for encoding */ ;
@@ -951,10 +951,11 @@ int encode_application_character_string(
int len = 0;
int string_len = 0;
string_len = (int)characterstring_length(char_string) + 1 /* for encoding */ ;
string_len =
(int) characterstring_length(char_string) + 1 /* for encoding */ ;
len =
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_CHARACTER_STRING, false,
(uint32_t)string_len);
(uint32_t) string_len);
if ((len + string_len) < MAX_APDU) {
len += encode_bacnet_character_string(&apdu[len], char_string);
} else {
@@ -972,8 +973,9 @@ int encode_context_character_string(
int len = 0;
int string_len = 0;
string_len = (int)characterstring_length(char_string) + 1 /* for encoding */ ;
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)string_len);
string_len =
(int) characterstring_length(char_string) + 1 /* for encoding */ ;
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) string_len);
if ((len + string_len) < MAX_APDU) {
len += encode_bacnet_character_string(&apdu[len], char_string);
} else {
@@ -998,7 +1000,7 @@ int decode_character_string(
characterstring_init(char_string, apdu[0], (char *) &apdu[1],
len_value - 1);
if (status) {
len = (int)len_value;
len = (int) len_value;
}
return len;
@@ -1061,7 +1063,7 @@ int decode_unsigned(
}
}
return (int)len_value;
return (int) len_value;
}
int decode_context_unsigned(
@@ -1119,7 +1121,7 @@ int encode_context_unsigned(
len = encode_bacnet_unsigned(&apdu[1], value);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1138,7 +1140,8 @@ int encode_application_unsigned(
len = encode_bacnet_unsigned(&apdu[1], value);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, false, (uint32_t)len);
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_UNSIGNED_INT, false,
(uint32_t) len);
return len;
}
@@ -1149,7 +1152,7 @@ int encode_application_unsigned(
int decode_enumerated(
uint8_t * apdu,
uint32_t len_value,
uint32_t *value)
uint32_t * value)
{
uint32_t unsigned_value = 0;
int len;
@@ -1165,7 +1168,7 @@ int decode_enumerated(
int decode_context_enumerated(
uint8_t * apdu,
uint8_t tag_value,
uint32_t *value)
uint32_t * value)
{
int len = 0;
uint8_t tag_number;
@@ -1202,7 +1205,9 @@ int encode_application_enumerated(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_enumerated(&apdu[1], value);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_ENUMERATED, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_ENUMERATED, false,
(uint32_t) len);
return len;
}
@@ -1221,7 +1226,7 @@ int encode_context_enumerated(
len = encode_bacnet_enumerated(&apdu[1], value);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1257,7 +1262,7 @@ int decode_signed(
}
}
return (int)len_value;
return (int) len_value;
}
int decode_context_signed(
@@ -1316,7 +1321,9 @@ int encode_application_signed(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_signed(&apdu[1], value);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_SIGNED_INT, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_SIGNED_INT, false,
(uint32_t) len);
return len;
}
@@ -1335,7 +1342,7 @@ int encode_context_signed(
len = encode_bacnet_signed(&apdu[1], value);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1354,7 +1361,9 @@ int encode_application_real(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_real(value, &apdu[1]);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_REAL, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_REAL, false,
(uint32_t) len);
return len;
}
@@ -1370,7 +1379,7 @@ int encode_context_real(
len = encode_bacnet_real(value, &apdu[1]);
/* we only reserved 1 byte for encoding the tag - check the limits */
if (tag_number <= 14) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1389,7 +1398,9 @@ int encode_application_double(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_double(value, &apdu[1]);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DOUBLE, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DOUBLE, false,
(uint32_t) len);
return len;
}
@@ -1405,7 +1416,7 @@ int encode_context_double(
len = encode_bacnet_double(value, &apdu[1]);
/* we only reserved 1 byte for encoding the tag - check the limits */
if (tag_number <= 14) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1439,7 +1450,9 @@ int encode_application_time(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_time(&apdu[1], btime);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_TIME, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_TIME, false,
(uint32_t) len);
return len;
}
@@ -1455,7 +1468,7 @@ int encode_context_time(
len = encode_bacnet_time(&apdu[1], btime);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
@@ -1558,7 +1571,9 @@ int encode_application_date(
/* assumes that the tag only consumes 1 octet */
len = encode_bacnet_date(&apdu[1], bdate);
len += encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DATE, false, (uint32_t)len);
len +=
encode_tag(&apdu[0], BACNET_APPLICATION_TAG_DATE, false,
(uint32_t) len);
return len;
@@ -1575,7 +1590,7 @@ int encode_context_date(
len = encode_bacnet_date(&apdu[1], bdate);
/* we only reserved 1 byte for encoding the tag - check the limits */
if ((tag_number <= 14) && (len <= 4)) {
len += encode_tag(&apdu[0], tag_number, true, (uint32_t)len);
len += encode_tag(&apdu[0], tag_number, true, (uint32_t) len);
} else {
len = 0;
}
+3 -2
View File
@@ -68,7 +68,7 @@ int bacapp_encode_device_obj_property_ref(
len =
encode_context_object_id(&apdu[apdu_len], 0,
(int)value->objectIdentifier.type, value->objectIdentifier.instance);
(int) value->objectIdentifier.type, value->objectIdentifier.instance);
apdu_len += len;
len =
@@ -82,7 +82,8 @@ int bacapp_encode_device_obj_property_ref(
}
len =
encode_context_object_id(&apdu[apdu_len], 3,
(int)value->deviceIndentifier.type, value->deviceIndentifier.instance);
(int) value->deviceIndentifier.type,
value->deviceIndentifier.instance);
apdu_len += len;
return apdu_len;
+1 -1
View File
@@ -301,7 +301,7 @@ int bacapp_encode_property_state(
}
#ifdef TEST
#include <string.h> /* for memset */
#include <string.h> /* for memset */
void testPropStates(
Test * pTest)
+5 -5
View File
@@ -68,7 +68,7 @@ static int notify_encode_adpu(
/* tag 2 - monitoredObjectIdentifier */
len =
encode_context_object_id(&apdu[apdu_len], 2,
(int)data->monitoredObjectIdentifier.type,
(int) data->monitoredObjectIdentifier.type,
data->monitoredObjectIdentifier.instance);
apdu_len += len;
/* tag 3 - timeRemaining */
@@ -173,7 +173,7 @@ int cov_notify_decode_service_request(
uint32_t len_value = 0;
uint32_t decoded_value = 0; /* for decoding */
uint16_t decoded_type = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
BACNET_PROPERTY_VALUE *value = NULL; /* value in list */
if (apdu_len && data) {
@@ -338,7 +338,7 @@ int cov_subscribe_encode_adpu(
/* tag 1 - monitoredObjectIdentifier */
len =
encode_context_object_id(&apdu[apdu_len], 1,
(int)data->monitoredObjectIdentifier.type,
(int) data->monitoredObjectIdentifier.type,
data->monitoredObjectIdentifier.instance);
apdu_len += len;
/*
@@ -467,7 +467,7 @@ int cov_subscribe_property_encode_adpu(
/* tag 1 - monitoredObjectIdentifier */
len =
encode_context_object_id(&apdu[apdu_len], 1,
(int)data->monitoredObjectIdentifier.type,
(int) data->monitoredObjectIdentifier.type,
data->monitoredObjectIdentifier.instance);
apdu_len += len;
if (!data->cancellationRequest) {
@@ -518,7 +518,7 @@ int cov_subscribe_property_decode_service_request(
uint32_t len_value = 0;
uint32_t decoded_value = 0; /* for decoding */
uint16_t decoded_type = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
if (apdu_len && data) {
/* tag 0 - subscriberProcessIdentifier */
+12 -12
View File
@@ -106,14 +106,14 @@ int event_notify_encode_service_request(
/* tag 1 - initiatingObjectIdentifier */
len =
encode_context_object_id(&apdu[apdu_len], 1,
(int)data->initiatingObjectIdentifier.type,
(int) data->initiatingObjectIdentifier.type,
data->initiatingObjectIdentifier.instance);
apdu_len += len;
/* tag 2 - eventObjectIdentifier */
len =
encode_context_object_id(&apdu[apdu_len], 2,
(int)data->eventObjectIdentifier.type,
(int) data->eventObjectIdentifier.type,
data->eventObjectIdentifier.instance);
apdu_len += len;
@@ -442,7 +442,7 @@ int event_notify_decode_service_request(
int len = 0; /* return value */
int section_length = 0;
uint32_t value = 0;
if (apdu_len && data) {
/* tag 0 - processIdentifier */
if ((section_length =
@@ -501,8 +501,7 @@ int event_notify_decode_service_request(
}
/* tag 6 - eventType */
if ((section_length =
decode_context_enumerated(&apdu[len], 6,
&value)) == -1) {
decode_context_enumerated(&apdu[len], 6, &value)) == -1) {
return -1;
} else {
data->eventType = value;
@@ -531,8 +530,7 @@ int event_notify_decode_service_request(
/* tag 8 - notifyType */
if ((section_length =
decode_context_enumerated(&apdu[len], 8,
&value)) == -1) {
decode_context_enumerated(&apdu[len], 8, &value)) == -1) {
return -1;
} else {
data->notifyType = value;
@@ -568,8 +566,7 @@ int event_notify_decode_service_request(
}
/* tag 11 - toState */
if ((section_length =
decode_context_enumerated(&apdu[len], 11,
&value)) == -1) {
decode_context_enumerated(&apdu[len], 11, &value)) == -1) {
return -1;
} else {
data->toState = value;
@@ -753,7 +750,8 @@ int event_notify_decode_service_request(
&value))) {
return -1;
}
data->notificationParams.changeOfLifeSafety.newState = value;
data->notificationParams.changeOfLifeSafety.newState =
value;
len += section_length;
if (-1 == (section_length =
@@ -761,7 +759,8 @@ int event_notify_decode_service_request(
&value))) {
return -1;
}
data->notificationParams.changeOfLifeSafety.newMode = value;
data->notificationParams.changeOfLifeSafety.newMode =
value;
len += section_length;
if (-1 == (section_length =
@@ -777,7 +776,8 @@ int event_notify_decode_service_request(
&value))) {
return -1;
}
data->notificationParams.changeOfLifeSafety.operationExpected = value;
data->notificationParams.changeOfLifeSafety.
operationExpected = value;
len += section_length;
break;
+15 -15
View File
@@ -47,7 +47,7 @@
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
static unsigned FIFO_Count (
static unsigned FIFO_Count(
FIFO_BUFFER const *b)
{
return (b ? (b->head - b->tail) : 0);
@@ -59,7 +59,7 @@ static unsigned FIFO_Count (
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
static bool FIFO_Full (
static bool FIFO_Full(
FIFO_BUFFER const *b)
{
return (b ? (FIFO_Count(b) == b->buffer_len) : true);
@@ -71,7 +71,7 @@ static bool FIFO_Full (
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
static bool FIFO_Available (
static bool FIFO_Available(
FIFO_BUFFER const *b,
unsigned count)
{
@@ -85,7 +85,7 @@ static bool FIFO_Available (
* NOTES: none
*****************************************************************************/
bool FIFO_Empty(
FIFO_BUFFER const *b)
FIFO_BUFFER const *b)
{
return (b ? (FIFO_Count(b) == 0) : true);
}
@@ -97,7 +97,7 @@ bool FIFO_Empty(
* NOTES: Use Empty function to see if there is data to retrieve
*****************************************************************************/
uint8_t FIFO_Peek(
FIFO_BUFFER const *b)
FIFO_BUFFER const *b)
{
if (b) {
return (b->buffer[b->tail % b->buffer_len]);
@@ -113,7 +113,7 @@ uint8_t FIFO_Peek(
* NOTES: Use Empty function to see if there is data to retrieve
*****************************************************************************/
uint8_t FIFO_Get(
FIFO_BUFFER * b)
FIFO_BUFFER * b)
{
uint8_t data_byte = 0;
@@ -131,8 +131,8 @@ uint8_t FIFO_Get(
* NOTES: none
*****************************************************************************/
bool FIFO_Put(
FIFO_BUFFER * b,
uint8_t data_byte)
FIFO_BUFFER * b,
uint8_t data_byte)
{
bool status = false; /* return value */
@@ -155,14 +155,14 @@ bool FIFO_Put(
* NOTES: none
*****************************************************************************/
bool FIFO_Add(
FIFO_BUFFER * b,
uint8_t *data_bytes,
unsigned count)
FIFO_BUFFER * b,
uint8_t * data_bytes,
unsigned count)
{
bool status = false; /* return value */
/* limit the ring to prevent overwriting */
if (FIFO_Available (b, count)) {
if (FIFO_Available(b, count)) {
while (count) {
b->buffer[b->head % b->buffer_len] = *data_bytes;
b->head++;
@@ -182,7 +182,7 @@ bool FIFO_Add(
* NOTES: none
*****************************************************************************/
void FIFO_Flush(
FIFO_BUFFER * b)
FIFO_BUFFER * b)
{
if (b) {
b->tail = b->head;
@@ -197,7 +197,7 @@ void FIFO_Flush(
*****************************************************************************/
void FIFO_Init(
FIFO_BUFFER * b,
volatile uint8_t *buffer,
volatile uint8_t * buffer,
unsigned buffer_len)
{
if (b) {
@@ -224,7 +224,7 @@ void testFIFOBuffer(
{
FIFO_BUFFER test_buffer;
volatile uint8_t data_store[FIFO_BUFFER_SIZE];
uint8_t test_add_data[40] = {"RoseSteveLouPatRachelJessicaDaniAmyHerb"};
uint8_t test_add_data[40] = { "RoseSteveLouPatRachelJessicaDaniAmyHerb" };
uint8_t test_data;
uint8_t index;
uint8_t count;
+5 -4
View File
@@ -61,8 +61,9 @@ int iam_encode_apdu(
apdu_len += len;
len = encode_application_unsigned(&apdu[apdu_len], max_apdu);
apdu_len += len;
len = encode_application_enumerated(&apdu[apdu_len],
(uint32_t)segmentation);
len =
encode_application_enumerated(&apdu[apdu_len],
(uint32_t) segmentation);
apdu_len += len;
len = encode_application_unsigned(&apdu[apdu_len], vendor_id);
apdu_len += len;
@@ -107,7 +108,7 @@ int iam_decode_service_request(
len = decode_unsigned(&apdu[apdu_len], len_value, &decoded_value);
apdu_len += len;
if (pMax_apdu)
*pMax_apdu = (unsigned)decoded_value;
*pMax_apdu = (unsigned) decoded_value;
/* Segmentation - enumerated */
len =
decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value);
@@ -119,7 +120,7 @@ int iam_decode_service_request(
if (decoded_value >= MAX_BACNET_SEGMENTATION)
return -1;
if (pSegmentation)
*pSegmentation = (int)decoded_value;
*pSegmentation = (int) decoded_value;
/* Vendor ID - unsigned16 */
len =
decode_tag_number_and_value(&apdu[apdu_len], &tag_number, &len_value);
+4 -4
View File
@@ -50,13 +50,13 @@ int ihave_encode_apdu(
apdu_len = 2;
/* deviceIdentifier */
len =
encode_application_object_id(&apdu[apdu_len], (int)data->device_id.type,
data->device_id.instance);
encode_application_object_id(&apdu[apdu_len],
(int) data->device_id.type, data->device_id.instance);
apdu_len += len;
/* objectIdentifier */
len =
encode_application_object_id(&apdu[apdu_len], (int)data->object_id.type,
data->object_id.instance);
encode_application_object_id(&apdu[apdu_len],
(int) data->object_id.type, data->object_id.instance);
apdu_len += len;
/* objectName */
len =
+2 -2
View File
@@ -44,8 +44,8 @@ int stricmp(
unsigned char c1, c2;
do {
c1 = (unsigned char)*s1;
c2 = (unsigned char)*s2;
c1 = (unsigned char) *s1;
c2 = (unsigned char) *s2;
c1 = (unsigned char) tolower(c1);
c2 = (unsigned char) tolower(c2);
s1++;
+63 -65
View File
@@ -52,9 +52,7 @@ int lso_encode_adpu(
apdu[3] = SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION;
apdu_len = 4;
/* tag 0 - requestingProcessId */
len =
encode_context_unsigned(&apdu[apdu_len], 0,
data->processId);
len = encode_context_unsigned(&apdu[apdu_len], 0, data->processId);
apdu_len += len;
/* tag 1 - requestingSource */
len =
@@ -62,17 +60,17 @@ int lso_encode_adpu(
&data->requestingSrc);
apdu_len += len;
/*
Operation
Operation
*/
len = encode_context_enumerated(&apdu[apdu_len], 2, data->operation);
len = encode_context_enumerated(&apdu[apdu_len], 2, data->operation);
apdu_len += len;
/*
Object ID
Object ID
*/
len = encode_context_object_id(&apdu[apdu_len], 3,
(int)data->targetObject.type,
data->targetObject.instance);
len =
encode_context_object_id(&apdu[apdu_len], 3,
(int) data->targetObject.type, data->targetObject.instance);
apdu_len += len;
}
@@ -81,60 +79,59 @@ int lso_encode_adpu(
}
int lso_decode_service_request(
uint8_t *apdu,
unsigned apdu_len,
BACNET_LSO_DATA *data)
uint8_t * apdu,
unsigned apdu_len,
BACNET_LSO_DATA * data)
{
int len = 0; /* return value */
int section_length = 0; /* length returned from decoding */
uint32_t operation = 0; /* handles decoded value */
int section_length = 0; /* length returned from decoding */
uint32_t operation = 0; /* handles decoded value */
/* check for value pointers */
if (apdu_len && data) {
/* Tag 0: Object ID */
if ( (section_length = decode_context_unsigned(&apdu[len], 0, &data->processId)) == -1)
{
return -1;
}
len += section_length;
if ((section_length =
decode_context_unsigned(&apdu[len], 0,
&data->processId)) == -1) {
return -1;
}
len += section_length;
if ( (section_length = decode_context_character_string(&apdu[len], 1, &data->requestingSrc)) == -1)
{
return -1;
}
len += section_length;
if ((section_length =
decode_context_character_string(&apdu[len], 1,
&data->requestingSrc)) == -1) {
return -1;
}
len += section_length;
if ( (section_length = decode_context_enumerated(&apdu[len], 2, &operation)) == -1)
{
return -1;
}
data->operation = operation;
len += section_length;
if ((section_length =
decode_context_enumerated(&apdu[len], 2, &operation)) == -1) {
return -1;
}
data->operation = operation;
len += section_length;
/*
** This is an optional parameter, so dont fail if it doesnt exist
*/
if ( decode_is_context_tag(&apdu[len], 3) )
{
if ( (section_length = decode_context_object_id(&apdu[len], 3,
&data->targetObject.type,
&data->targetObject.instance)) == -1 )
{
return -1;
}
len += section_length;
}
else
{
data->targetObject.type = 0;
data->targetObject.instance = 0;
}
return len;
/*
** This is an optional parameter, so dont fail if it doesnt exist
*/
if (decode_is_context_tag(&apdu[len], 3)) {
if ((section_length =
decode_context_object_id(&apdu[len], 3,
&data->targetObject.type,
&data->targetObject.instance)) == -1) {
return -1;
}
len += section_length;
} else {
data->targetObject.type = 0;
data->targetObject.instance = 0;
}
return len;
}
return 0;
}
return 0;
}
#ifdef TEST
@@ -146,30 +143,31 @@ int lso_decode_service_request(
void testLSO(
Test * pTest)
{
uint8_t apdu[1000];
int len;
uint8_t apdu[1000];
int len;
BACNET_LSO_DATA data;
BACNET_LSO_DATA rxdata;
BACNET_LSO_DATA data;
BACNET_LSO_DATA rxdata;
memset(&rxdata, 0, sizeof(rxdata));
memset(&rxdata, 0, sizeof(rxdata));
characterstring_init_ansi(&data.requestingSrc, "foobar");
data.operation = LIFE_SAFETY_OP_RESET;
data.processId = 0x1234;
data.targetObject.instance = 0x1000;
data.targetObject.type = OBJECT_BINARY_INPUT;
characterstring_init_ansi(&data.requestingSrc, "foobar");
data.operation = LIFE_SAFETY_OP_RESET;
data.processId = 0x1234;
data.targetObject.instance = 0x1000;
data.targetObject.type = OBJECT_BINARY_INPUT;
len = lso_encode_adpu(apdu, 100, &data);
len = lso_encode_adpu(apdu, 100, &data);
lso_decode_service_request(&apdu[4], len, &rxdata);
lso_decode_service_request(&apdu[4], len, &rxdata);
ct_test(pTest, data.operation == rxdata.operation);
ct_test(pTest, data.processId == rxdata.processId);
ct_test(pTest, data.targetObject.instance == rxdata.targetObject.instance);
ct_test(pTest, data.targetObject.type == rxdata.targetObject.type);
ct_test(pTest, memcmp(data.requestingSrc.value, rxdata.requestingSrc.value, rxdata.requestingSrc.length) == 0);
ct_test(pTest, memcmp(data.requestingSrc.value, rxdata.requestingSrc.value,
rxdata.requestingSrc.length) == 0);
}
#ifdef TEST_LSO
+4 -4
View File
@@ -103,7 +103,7 @@ int npdu_encode_pdu(
BACNET_NPDU_DATA * npdu_data)
{
int len = 0; /* return value - number of octets loaded in this function */
uint8_t i = 0; /* counter */
uint8_t i = 0; /* counter */
if (npdu && npdu_data) {
@@ -248,7 +248,7 @@ int npdu_decode(
BACNET_NPDU_DATA * npdu_data)
{
int len = 0; /* return value - number of octets loaded in this function */
uint8_t i = 0; /* counter */
uint8_t i = 0; /* counter */
uint16_t src_net = 0;
uint16_t dest_net = 0;
uint8_t address_len = 0;
@@ -297,7 +297,7 @@ int npdu_decode(
dest->len = address_len;
}
if (address_len) {
if ( address_len > MAX_MAC_LEN ) {
if (address_len > MAX_MAC_LEN) {
/* address is too large could be a malformed message */
return -1;
}
@@ -332,7 +332,7 @@ int npdu_decode(
src->len = address_len;
}
if (address_len) {
if ( address_len > MAX_MAC_LEN ) {
if (address_len > MAX_MAC_LEN) {
/* address is too large could be a malformed message */
return -1;
}
+83 -85
View File
@@ -59,11 +59,13 @@ int ptransfer_encode_apdu(
serviceParameters [2] ABSTRACT-SYNTAX.&Type OPTIONAL
}
*/
len = encode_context_unsigned(&apdu[apdu_len], 0,
private_data->vendorID);
len =
encode_context_unsigned(&apdu[apdu_len], 0,
private_data->vendorID);
apdu_len += len;
len = encode_context_unsigned(&apdu[apdu_len], 1,
private_data->serviceNumber);
len =
encode_context_unsigned(&apdu[apdu_len], 1,
private_data->serviceNumber);
apdu_len += len;
len = encode_opening_tag(&apdu[apdu_len], 2);
apdu_len += len;
@@ -84,10 +86,10 @@ int ptransfer_decode_service_request(
unsigned apdu_len,
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0; /* return value */
int len = 0; /* return value */
int decode_len = 0; /* return value */
uint32_t unsigned_value = 0;
/* check for value pointers */
if (apdu_len && private_data) {
/* Tag 0: vendorID */
@@ -110,10 +112,10 @@ int ptransfer_decode_service_request(
len++;
/* don't decode the serviceParameters here */
private_data->serviceParameters = &apdu[len];
private_data->serviceParametersLen =
(int)apdu_len - len - 1 /*closing tag */ ;
private_data->serviceParametersLen =
(int) apdu_len - len - 1 /*closing tag */ ;
/* len includes the data and the closing tag */
len = (int)apdu_len;
len = (int) apdu_len;
} else {
return -1;
}
@@ -127,10 +129,10 @@ int ptransfer_error_encode_apdu(
uint8_t invoke_id,
BACNET_ERROR_CLASS error_class,
BACNET_ERROR_CODE error_code,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int apdu_len = 0; /* total length of the apdu, return value */
int len = 0; /* length of the part of the encoding */
int len = 0; /* length of the part of the encoding */
if (apdu) {
apdu[0] = PDU_TYPE_ERROR;
@@ -154,11 +156,13 @@ int ptransfer_error_encode_apdu(
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0);
apdu_len += len;
len = encode_context_unsigned(&apdu[apdu_len], 1,
private_data->vendorID);
len =
encode_context_unsigned(&apdu[apdu_len], 1,
private_data->vendorID);
apdu_len += len;
len = encode_context_unsigned(&apdu[apdu_len], 2,
private_data->serviceNumber);
len =
encode_context_unsigned(&apdu[apdu_len], 2,
private_data->serviceNumber);
apdu_len += len;
len = encode_opening_tag(&apdu[apdu_len], 3);
apdu_len += len;
@@ -181,7 +185,7 @@ int ptransfer_error_decode_service_request(
BACNET_ERROR_CODE * error_code,
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0; /* return value */
int len = 0; /* return value */
int decode_len = 0; /* return value */
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
@@ -196,12 +200,12 @@ int ptransfer_error_decode_service_request(
/* error class */
decode_len =
decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);
&len_value_type);
len += decode_len;
if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) {
return 0;
}
decode_len =
decode_len =
decode_enumerated(&apdu[len], len_value_type, &unsigned_value);
len += decode_len;
if (error_class) {
@@ -210,12 +214,12 @@ int ptransfer_error_decode_service_request(
/* error code */
decode_len =
decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);
&len_value_type);
len += decode_len;
if (tag_number != BACNET_APPLICATION_TAG_ENUMERATED) {
return 0;
}
decode_len =
decode_len =
decode_enumerated(&apdu[len], len_value_type, &unsigned_value);
len += decode_len;
if (error_code) {
@@ -248,7 +252,8 @@ int ptransfer_error_decode_service_request(
len++;
/* don't decode the serviceParameters here */
private_data->serviceParameters = &apdu[len];
private_data->serviceParametersLen = (int)apdu_len - len - 1 /*closing tag */ ;
private_data->serviceParametersLen =
(int) apdu_len - len - 1 /*closing tag */ ;
} else {
return -1;
}
@@ -261,7 +266,7 @@ int ptransfer_error_decode_service_request(
int ptransfer_ack_encode_apdu(
uint8_t * apdu,
uint8_t invoke_id,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0; /* length of each encoding */
int apdu_len = 0; /* total length of the apdu, return value */
@@ -269,7 +274,7 @@ int ptransfer_ack_encode_apdu(
if (apdu) {
apdu[0] = PDU_TYPE_COMPLEX_ACK; /* complex ACK service */
apdu[1] = invoke_id; /* original invoke id from request */
apdu[2] = SERVICE_CONFIRMED_PRIVATE_TRANSFER; /* service choice */
apdu[2] = SERVICE_CONFIRMED_PRIVATE_TRANSFER; /* service choice */
apdu_len = 3;
/* service ack follows */
/*
@@ -279,10 +284,12 @@ int ptransfer_ack_encode_apdu(
resultBlock [2] ABSTRACT-SYNTAX.&Type OPTIONAL
}
*/
len = encode_context_unsigned(&apdu[apdu_len], 0,
len =
encode_context_unsigned(&apdu[apdu_len], 0,
private_data->vendorID);
apdu_len += len;
len = encode_context_unsigned(&apdu[apdu_len], 1,
len =
encode_context_unsigned(&apdu[apdu_len], 1,
private_data->serviceNumber);
apdu_len += len;
len = encode_opening_tag(&apdu[apdu_len], 2);
@@ -311,7 +318,7 @@ int ptransfer_decode_apdu(
uint8_t * apdu,
unsigned apdu_len,
uint8_t * invoke_id,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0;
unsigned offset = 0;
@@ -323,16 +330,17 @@ int ptransfer_decode_apdu(
return -1;
/* apdu[1] = encode_max_segs_max_apdu(0, MAX_APDU); */
/* invoke id - filled in by net layer */
*invoke_id = apdu[2];
*invoke_id = apdu[2];
if (apdu[3] != SERVICE_CONFIRMED_PRIVATE_TRANSFER)
return -1;
offset = 4;
if (apdu_len > offset) {
len = ptransfer_decode_service_request(
&apdu[offset], apdu_len - offset, private_data);
len =
ptransfer_decode_service_request(&apdu[offset], apdu_len - offset,
private_data);
}
return len;
}
@@ -340,7 +348,7 @@ int ptransfer_ack_decode_apdu(
uint8_t * apdu,
int apdu_len, /* total length of the apdu */
uint8_t * invoke_id,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0;
int offset = 0;
@@ -356,8 +364,8 @@ int ptransfer_ack_decode_apdu(
offset = 3;
if (apdu_len > offset) {
len =
ptransfer_decode_service_request(
&apdu[offset], apdu_len - offset, private_data);
ptransfer_decode_service_request(&apdu[offset], apdu_len - offset,
private_data);
}
return len;
@@ -369,7 +377,7 @@ int ptransfer_error_decode_apdu(
uint8_t * invoke_id,
BACNET_ERROR_CLASS * error_class,
BACNET_ERROR_CODE * error_code,
BACNET_PRIVATE_TRANSFER_DATA *private_data)
BACNET_PRIVATE_TRANSFER_DATA * private_data)
{
int len = 0;
int offset = 0;
@@ -385,16 +393,15 @@ int ptransfer_error_decode_apdu(
offset = 3;
if (apdu_len > offset) {
len =
ptransfer_error_decode_service_request(
&apdu[offset], apdu_len - offset,
error_class, error_code, private_data);
ptransfer_error_decode_service_request(&apdu[offset],
apdu_len - offset, error_class, error_code, private_data);
}
return len;
}
void test_Private_Transfer_Ack(
Test * pTest)
Test * pTest)
{
uint8_t apdu[480] = { 0 };
int len = 0;
@@ -405,19 +412,17 @@ void test_Private_Transfer_Ack(
BACNET_PRIVATE_TRANSFER_DATA test_data;
uint8_t test_value[480] = { 0 };
int private_data_len = 0;
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
uint8_t private_data_chunk[32] = { "I Love You, Patricia!" };
BACNET_APPLICATION_DATA_VALUE data_value;
BACNET_APPLICATION_DATA_VALUE test_data_value;
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
bacapp_parse_application_data(
BACNET_APPLICATION_TAG_OCTET_STRING,
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
private_data_len = bacapp_encode_application_data(
&test_value[0],
&data_value);
private_data_len =
bacapp_encode_application_data(&test_value[0], &data_value);
private_data.serviceParameters = &test_value[0];
private_data.serviceParametersLen = private_data_len;
@@ -427,24 +432,23 @@ void test_Private_Transfer_Ack(
ct_test(pTest, len != 0);
ct_test(pTest, len != -1);
apdu_len = len;
len = ptransfer_ack_decode_apdu(
&apdu[0], apdu_len,
&test_invoke_id, &test_data);
len =
ptransfer_ack_decode_apdu(&apdu[0], apdu_len, &test_invoke_id,
&test_data);
ct_test(pTest, len != -1);
ct_test(pTest, test_invoke_id == invoke_id);
ct_test(pTest, test_data.vendorID == private_data.vendorID);
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
ct_test(pTest,
ct_test(pTest,
test_data.serviceParametersLen == private_data.serviceParametersLen);
len = bacapp_decode_application_data(
test_data.serviceParameters,
test_data.serviceParametersLen,
&test_data_value);
len =
bacapp_decode_application_data(test_data.serviceParameters,
test_data.serviceParametersLen, &test_data_value);
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
}
void test_Private_Transfer_Error(
Test * pTest)
Test * pTest)
{
uint8_t apdu[480] = { 0 };
int len = 0;
@@ -459,49 +463,45 @@ void test_Private_Transfer_Error(
BACNET_PRIVATE_TRANSFER_DATA test_data;
uint8_t test_value[480] = { 0 };
int private_data_len = 0;
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
uint8_t private_data_chunk[32] = { "I Love You, Patricia!" };
BACNET_APPLICATION_DATA_VALUE data_value;
BACNET_APPLICATION_DATA_VALUE test_data_value;
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
bacapp_parse_application_data(
BACNET_APPLICATION_TAG_OCTET_STRING,
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
private_data_len = bacapp_encode_application_data(
&test_value[0],
&data_value);
private_data_len =
bacapp_encode_application_data(&test_value[0], &data_value);
private_data.serviceParameters = &test_value[0];
private_data.serviceParametersLen = private_data_len;
len = ptransfer_error_encode_apdu(&apdu[0], invoke_id,
error_class, error_code, &private_data);
len =
ptransfer_error_encode_apdu(&apdu[0], invoke_id, error_class,
error_code, &private_data);
ct_test(pTest, len != 0);
ct_test(pTest, len != -1);
apdu_len = len;
len = ptransfer_error_decode_apdu(
&apdu[0], apdu_len,
&test_invoke_id,
&test_error_class, &test_error_code,
&test_data);
len =
ptransfer_error_decode_apdu(&apdu[0], apdu_len, &test_invoke_id,
&test_error_class, &test_error_code, &test_data);
ct_test(pTest, len != -1);
ct_test(pTest, test_invoke_id == invoke_id);
ct_test(pTest, test_data.vendorID == private_data.vendorID);
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
ct_test(pTest, test_error_class == error_class);
ct_test(pTest, test_error_code == error_code);
ct_test(pTest,
ct_test(pTest,
test_data.serviceParametersLen == private_data.serviceParametersLen);
len = bacapp_decode_application_data(
test_data.serviceParameters,
test_data.serviceParametersLen,
&test_data_value);
len =
bacapp_decode_application_data(test_data.serviceParameters,
test_data.serviceParametersLen, &test_data_value);
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
}
void test_Private_Transfer_Request(
Test * pTest)
Test * pTest)
{
uint8_t apdu[480] = { 0 };
uint8_t test_value[480] = { 0 };
@@ -510,7 +510,7 @@ void test_Private_Transfer_Request(
uint8_t invoke_id = 128;
uint8_t test_invoke_id = 0;
int private_data_len = 0;
uint8_t private_data_chunk[32] = {"I Love You, Patricia!"};
uint8_t private_data_chunk[32] = { "I Love You, Patricia!" };
BACNET_APPLICATION_DATA_VALUE data_value;
BACNET_APPLICATION_DATA_VALUE test_data_value;
BACNET_PRIVATE_TRANSFER_DATA private_data;
@@ -519,28 +519,26 @@ void test_Private_Transfer_Request(
private_data.vendorID = BACNET_VENDOR_ID;
private_data.serviceNumber = 1;
bacapp_parse_application_data(
BACNET_APPLICATION_TAG_OCTET_STRING,
bacapp_parse_application_data(BACNET_APPLICATION_TAG_OCTET_STRING,
&private_data_chunk[0], &data_value);
private_data_len = bacapp_encode_application_data(
&test_value[0],
&data_value);
private_data_len =
bacapp_encode_application_data(&test_value[0], &data_value);
private_data.serviceParameters = &test_value[0];
private_data.serviceParametersLen = private_data_len;
len = ptransfer_encode_apdu(&apdu[0], invoke_id, &private_data);
ct_test(pTest, len != 0);
apdu_len = len;
len = ptransfer_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_data);
len =
ptransfer_decode_apdu(&apdu[0], apdu_len, &test_invoke_id, &test_data);
ct_test(pTest, len != -1);
ct_test(pTest, test_data.vendorID == private_data.vendorID);
ct_test(pTest, test_data.serviceNumber == private_data.serviceNumber);
ct_test(pTest,
ct_test(pTest,
test_data.serviceParametersLen == private_data.serviceParametersLen);
len = bacapp_decode_application_data(
test_data.serviceParameters,
test_data.serviceParametersLen,
&test_data_value);
len =
bacapp_decode_application_data(test_data.serviceParameters,
test_data.serviceParametersLen, &test_data_value);
ct_test(pTest, bacapp_same_value(&data_value, &test_data_value) == true);
return;
@@ -548,7 +546,7 @@ void test_Private_Transfer_Request(
#ifdef TEST_PRIVATE_TRANSFER
int main(
void)
void)
{
Test *pTest;
bool rc;
+3 -3
View File
@@ -82,7 +82,7 @@ int rp_decode_service_request(
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint16_t type = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t array_value = 0; /* for decoding */
/* check for value pointers */
@@ -215,7 +215,7 @@ int rp_ack_decode_service_request(
int tag_len = 0; /* length of tag decode */
int len = 0; /* total length of decodes */
uint16_t object = 0; /* object type */
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t array_value = 0; /* for decoding */
/* FIXME: check apdu_len against the len during decode */
@@ -247,7 +247,7 @@ int rp_ack_decode_service_request(
len++;
/* don't decode the application tag number or its data here */
rpdata->application_data = &apdu[len];
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */;
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */ ;
/* len includes the data and the closing tag */
len = apdu_len;
} else {
+26 -18
View File
@@ -119,8 +119,9 @@ int rpm_encode_apdu(
BACNET_PROPERTY_REFERENCE *rpm_property; /* current property */
len = rpm_encode_apdu_init(&apdu_temp[0], invoke_id);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len, (size_t) len,
(size_t) max_apdu);
if (len == 0) {
return 0;
}
@@ -130,16 +131,18 @@ int rpm_encode_apdu(
len =
encode_context_object_id(&apdu_temp[0], 0, rpm_object->object_type,
rpm_object->object_instance);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len,
(size_t) len, (size_t) max_apdu);
if (len == 0) {
return 0;
}
apdu_len += len;
/* Tag 1: sequence of ReadAccessSpecification */
len = encode_opening_tag(&apdu_temp[0], 1);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len,
(size_t) len, (size_t) max_apdu);
if (len == 0) {
return 0;
}
@@ -150,8 +153,9 @@ int rpm_encode_apdu(
len =
encode_context_enumerated(&apdu_temp[0], 0,
rpm_property->propertyIdentifier);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len,
(size_t) len, (size_t) max_apdu);
if (len == 0) {
return 0;
}
@@ -161,8 +165,9 @@ int rpm_encode_apdu(
len =
encode_context_unsigned(&apdu_temp[0], 1,
rpm_property->propertyArrayIndex);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len,
(size_t) len, (size_t) max_apdu);
if (len == 0) {
return 0;
}
@@ -171,8 +176,9 @@ int rpm_encode_apdu(
rpm_property = rpm_property->next;
}
len = encode_closing_tag(&apdu_temp[0], 1);
len = (int)memcopy(&apdu[0], &apdu_temp[0],
(size_t)apdu_len, (size_t)len, (size_t)max_apdu);
len =
(int) memcopy(&apdu[0], &apdu_temp[0], (size_t) apdu_len,
(size_t) len, (size_t) max_apdu);
if (len == 0) {
return 0;
}
@@ -242,7 +248,7 @@ int rpm_decode_object_property(
unsigned option_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t array_value = 0; /* for decoding */
/* check for valid pointers */
@@ -261,8 +267,9 @@ int rpm_decode_object_property(
/* Tag 1: Optional propertyArrayIndex */
if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) &&
(!decode_is_closing_tag(&apdu[len]))) {
option_len = (unsigned)decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
option_len =
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);
if (tag_number == 1) {
len += option_len;
len +=
@@ -434,7 +441,7 @@ int rpm_ack_decode_object_property(
unsigned tag_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t array_value = 0; /* for decoding */
/* check for valid pointers */
@@ -453,8 +460,9 @@ int rpm_ack_decode_object_property(
/* Tag 3: Optional propertyArrayIndex */
if ((len < apdu_len) && decode_is_context_specific(&apdu[len]) &&
(!decode_is_closing_tag(&apdu[len]))) {
tag_len = (unsigned)decode_tag_number_and_value(
&apdu[len], &tag_number, &len_value_type);
tag_len =
(unsigned) decode_tag_number_and_value(&apdu[len], &tag_number,
&len_value_type);
if (tag_number == 3) {
len += tag_len;
len +=
+1 -1
View File
@@ -69,7 +69,7 @@ int whohas_encode_apdu(
} else {
len =
encode_context_object_id(&apdu[apdu_len], 2,
(int)data->object.identifier.type,
(int) data->object.identifier.type,
data->object.identifier.instance);
apdu_len += len;
}
+1 -1
View File
@@ -100,7 +100,7 @@ int wp_decode_service_request(
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint16_t type = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t property = 0; /* for decoding */
uint32_t unsigned_value = 0;
int i = 0; /* loop counter */