Indented project.

This commit is contained in:
skarg
2011-08-17 02:27:11 +00:00
parent 7e503510c7
commit 3e1cb1847f
125 changed files with 3548 additions and 3353 deletions
+4 -2
View File
@@ -149,7 +149,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
if ((pMatch->
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) == BAC_ADDR_IN_USE) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
ulTime = pMatch->TimeToLive;
@@ -168,7 +169,8 @@ static struct Address_Cache_Entry *address_remove_oldest(
/* Second pass - try in use and un bound as last resort */
pMatch = Address_Cache;
while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
if ((pMatch->
Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ |
BAC_ADDR_STATIC)) ==
((uint8_t) (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ))) {
if (pMatch->TimeToLive <= ulTime) { /* Shorter lived entry found */
+12 -12
View File
@@ -1008,8 +1008,8 @@ bool bacapp_print_value(
case PROP_OBJECT_TYPE:
if (value->type.Enumerated < MAX_ASHRAE_OBJECT_TYPE) {
fprintf(stream, "%s",
bactext_object_type_name(value->
type.Enumerated));
bactext_object_type_name(value->type.
Enumerated));
} else if (value->type.Enumerated < 128) {
fprintf(stream, "reserved %lu",
(unsigned long) value->type.Enumerated);
@@ -1025,8 +1025,8 @@ bool bacapp_print_value(
case PROP_UNITS:
if (value->type.Enumerated < 256) {
fprintf(stream, "%s",
bactext_engineering_unit_name(value->type.
Enumerated));
bactext_engineering_unit_name(value->
type.Enumerated));
} else {
fprintf(stream, "proprietary %lu",
(unsigned long) value->type.Enumerated);
@@ -1034,14 +1034,14 @@ bool bacapp_print_value(
break;
case PROP_POLARITY:
fprintf(stream, "%s",
bactext_binary_polarity_name(value->type.
Enumerated));
bactext_binary_polarity_name(value->
type.Enumerated));
break;
case PROP_PRESENT_VALUE:
if (object_type < PROPRIETARY_BACNET_OBJECT_TYPE) {
fprintf(stream, "%s",
bactext_binary_present_value_name(value->
type.Enumerated));
bactext_binary_present_value_name(value->type.
Enumerated));
} else {
fprintf(stream, "%lu",
(unsigned long) value->type.Enumerated);
@@ -1053,8 +1053,8 @@ bool bacapp_print_value(
break;
case PROP_SYSTEM_STATUS:
fprintf(stream, "%s",
bactext_device_status_name(value->type.
Enumerated));
bactext_device_status_name(value->
type.Enumerated));
break;
case PROP_SEGMENTATION_SUPPORTED:
fprintf(stream, "%s",
@@ -1425,8 +1425,8 @@ void testBACnetApplicationData_Safe(
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
characterstring_init_ansi(&input_value[i].
type.Character_String, "Hello There!");
characterstring_init_ansi(&input_value[i].type.
Character_String, "Hello There!");
break;
case BACNET_APPLICATION_TAG_BIT_STRING:
+1 -2
View File
@@ -2277,8 +2277,7 @@ void testBACDCodeObject(
uint32_t decoded_instance = 0;
encode_bacnet_object_id(&encoded_array[0], type, instance);
decode_object_id(&encoded_array[0], &decoded_type,
&decoded_instance);
decode_object_id(&encoded_array[0], &decoded_type, &decoded_instance);
ct_test(pTest, decoded_type == type);
ct_test(pTest, decoded_instance == instance);
encode_bacnet_object_id(&object_array[0], type, instance);
+1 -2
View File
@@ -51,8 +51,7 @@ int bacapp_decode_property_state(
uint8_t tagnum;
section_length =
decode_tag_number_and_value(&apdu[len], &tagnum,
&len_value_type);
decode_tag_number_and_value(&apdu[len], &tagnum, &len_value_type);
if (-1 == section_length) {
return -1;
+49 -34
View File
@@ -496,26 +496,36 @@ bool characterstring_printable(
by Jeff Bezanson
placed in the public domain Fall 2005 */
static const char trailingBytesForUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4,
4, 4, 4, 5, 5, 5, 5
};
/* based on the valid_utf8 routine from the PCRE library by Philip Hazel
length is in bytes, since without knowing whether the string is valid
it's hard to know how many characters there are! */
static int utf8_isvalid(const char *str, int length)
static int utf8_isvalid(
const char *str,
int length)
{
const unsigned char *p, *pend = (unsigned char*)str + length;
const unsigned char *p, *pend = (unsigned char *) str + length;
unsigned char c;
int ab;
for (p = (unsigned char*)str; p < pend; p++) {
for (p = (unsigned char *) str; p < pend; p++) {
c = *p;
/* null in middle of string */
if (c == 0) {
@@ -541,37 +551,42 @@ static int utf8_isvalid(const char *str, int length)
}
/* Check for overlong sequences for each different length */
switch (ab) {
/* Check for xx00 000x */
case 1:
if ((c & 0x3e) == 0) return 0;
continue; /* We know there aren't any more bytes to check */
/* Check for xx00 000x */
case 1:
if ((c & 0x3e) == 0)
return 0;
continue; /* We know there aren't any more bytes to check */
/* Check for 1110 0000, xx0x xxxx */
case 2:
if (c == 0xe0 && (*p & 0x20) == 0) return 0;
break;
/* Check for 1110 0000, xx0x xxxx */
case 2:
if (c == 0xe0 && (*p & 0x20) == 0)
return 0;
break;
/* Check for 1111 0000, xx00 xxxx */
case 3:
if (c == 0xf0 && (*p & 0x30) == 0) return 0;
break;
/* Check for 1111 0000, xx00 xxxx */
case 3:
if (c == 0xf0 && (*p & 0x30) == 0)
return 0;
break;
/* Check for 1111 1000, xx00 0xxx */
case 4:
if (c == 0xf8 && (*p & 0x38) == 0) return 0;
break;
/* Check for 1111 1000, xx00 0xxx */
case 4:
if (c == 0xf8 && (*p & 0x38) == 0)
return 0;
break;
/* Check for leading 0xfe or 0xff,
and then for 1111 1100, xx00 00xx */
case 5:
if (c == 0xfe || c == 0xff ||
(c == 0xfc && (*p & 0x3c) == 0)) return 0;
break;
/* Check for leading 0xfe or 0xff,
and then for 1111 1100, xx00 00xx */
case 5:
if (c == 0xfe || c == 0xff || (c == 0xfc && (*p & 0x3c) == 0))
return 0;
break;
}
/* Check for valid bytes after the 2nd, if any; all must start 10 */
while (--ab > 0) {
if ((*(++p) & 0xc0) != 0x80) return 0;
if ((*(++p) & 0xc0) != 0x80)
return 0;
}
}
+1 -1
View File
@@ -2002,7 +2002,7 @@ INDTEXT_DATA network_layer_msg_names[] = {
{NETWORK_MESSAGE_I_AM_ROUTER_TO_NETWORK, "I-Am-Router-To-Network"}
,
{NETWORK_MESSAGE_I_COULD_BE_ROUTER_TO_NETWORK,
"I-Could-Be-Router-To-Network"}
"I-Could-Be-Router-To-Network"}
,
{NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK, "Reject-Message-to-Network"}
,
+2 -2
View File
@@ -656,8 +656,8 @@ static void bvlc_bdt_forward_npdu(
mask in the BDT entry and logically ORing it with the
BBMD address of the same entry. */
bip_dest.sin_addr.s_addr =
((~BBMD_Table[i].broadcast_mask.s_addr) | BBMD_Table[i].
dest_address.s_addr);
((~BBMD_Table[i].broadcast_mask.
s_addr) | BBMD_Table[i].dest_address.s_addr);
bip_dest.sin_port = BBMD_Table[i].dest_port;
/* don't send to my broadcast address and same port */
if ((bip_dest.sin_addr.s_addr == bip_get_broadcast_addr())
+171 -164
View File
@@ -192,14 +192,14 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 0,
&data->notificationParams.changeOfBitstring.
referencedBitString);
&data->notificationParams.
changeOfBitstring.referencedBitString);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfBitstring.
statusFlags);
&data->notificationParams.
changeOfBitstring.statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 0);
@@ -223,8 +223,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfState.
statusFlags);
&data->notificationParams.
changeOfState.statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 1);
@@ -242,8 +242,8 @@ int event_notify_encode_service_request(
case CHANGE_OF_VALUE_REAL:
len =
encode_context_real(&apdu[apdu_len], 1,
data->notificationParams.changeOfValue.
newValue.changeValue);
data->notificationParams.
changeOfValue.newValue.changeValue);
apdu_len += len;
break;
@@ -251,8 +251,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len],
0,
&data->notificationParams.changeOfValue.
newValue.changedBits);
&data->notificationParams.
changeOfValue.newValue.changedBits);
apdu_len += len;
break;
@@ -265,8 +265,8 @@ int event_notify_encode_service_request(
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.changeOfValue.
statusFlags);
&data->notificationParams.
changeOfValue.statusFlags);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 2);
@@ -280,20 +280,20 @@ int event_notify_encode_service_request(
len =
encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.floatingLimit.
referenceValue);
data->notificationParams.
floatingLimit.referenceValue);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.floatingLimit.
statusFlags);
&data->notificationParams.
floatingLimit.statusFlags);
apdu_len += len;
len =
encode_context_real(&apdu[apdu_len], 2,
data->notificationParams.floatingLimit.
setPointValue);
data->notificationParams.
floatingLimit.setPointValue);
apdu_len += len;
len =
@@ -312,8 +312,8 @@ int event_notify_encode_service_request(
len =
encode_context_real(&apdu[apdu_len], 0,
data->notificationParams.outOfRange.
exceedingValue);
data->notificationParams.
outOfRange.exceedingValue);
apdu_len += len;
len =
@@ -341,26 +341,26 @@ int event_notify_encode_service_request(
len =
encode_context_enumerated(&apdu[apdu_len], 0,
data->notificationParams.changeOfLifeSafety.
newState);
data->notificationParams.
changeOfLifeSafety.newState);
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 1,
data->notificationParams.changeOfLifeSafety.
newMode);
data->notificationParams.
changeOfLifeSafety.newMode);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 2,
&data->notificationParams.changeOfLifeSafety.
statusFlags);
&data->notificationParams.
changeOfLifeSafety.statusFlags);
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 3,
data->notificationParams.changeOfLifeSafety.
operationExpected);
data->notificationParams.
changeOfLifeSafety.operationExpected);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 8);
@@ -374,20 +374,20 @@ int event_notify_encode_service_request(
len =
bacapp_encode_context_device_obj_property_ref(&apdu
[apdu_len], 0,
&data->notificationParams.bufferReady.
bufferProperty);
&data->notificationParams.
bufferReady.bufferProperty);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 1,
data->notificationParams.bufferReady.
previousNotification);
data->notificationParams.
bufferReady.previousNotification);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.bufferReady.
currentNotification);
data->notificationParams.
bufferReady.currentNotification);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 10);
@@ -399,20 +399,20 @@ int event_notify_encode_service_request(
len =
encode_context_unsigned(&apdu[apdu_len], 0,
data->notificationParams.unsignedRange.
exceedingValue);
data->notificationParams.
unsignedRange.exceedingValue);
apdu_len += len;
len =
encode_context_bitstring(&apdu[apdu_len], 1,
&data->notificationParams.unsignedRange.
statusFlags);
&data->notificationParams.
unsignedRange.statusFlags);
apdu_len += len;
len =
encode_context_unsigned(&apdu[apdu_len], 2,
data->notificationParams.unsignedRange.
exceededLimit);
data->notificationParams.
unsignedRange.exceededLimit);
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 11);
@@ -595,16 +595,18 @@ int event_notify_decode_service_request(
case EVENT_CHANGE_OF_BITSTRING:
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0,
&data->notificationParams.
changeOfBitstring.referencedBitString))) {
&data->
notificationParams.changeOfBitstring.
referencedBitString))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.
changeOfBitstring.statusFlags))) {
&data->
notificationParams.changeOfBitstring.
statusFlags))) {
return -1;
}
len += section_length;
@@ -615,16 +617,16 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
bacapp_decode_context_property_state(&apdu
[len], 0,
&data->notificationParams.changeOfState.
newState))) {
&data->notificationParams.
changeOfState.newState))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.changeOfState.
statusFlags))) {
&data->notificationParams.
changeOfState.statusFlags))) {
return -1;
}
len += section_length;
@@ -642,8 +644,9 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 0,
&data->notificationParams.
changeOfValue.newValue.changedBits))) {
&data->
notificationParams.changeOfValue.
newValue.changedBits))) {
return -1;
}
@@ -654,8 +657,9 @@ int event_notify_decode_service_request(
CHANGE_OF_VALUE_REAL)) {
if (-1 == (section_length =
decode_context_real(&apdu[len], 1,
&data->notificationParams.
changeOfValue.newValue.changeValue))) {
&data->
notificationParams.changeOfValue.
newValue.changeValue))) {
return -1;
}
@@ -673,8 +677,8 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.changeOfValue.
statusFlags))) {
&data->notificationParams.
changeOfValue.statusFlags))) {
return -1;
}
len += section_length;
@@ -683,31 +687,31 @@ int event_notify_decode_service_request(
case EVENT_FLOATING_LIMIT:
if (-1 == (section_length =
decode_context_real(&apdu[len], 0,
&data->notificationParams.floatingLimit.
referenceValue))) {
&data->notificationParams.
floatingLimit.referenceValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.floatingLimit.
statusFlags))) {
&data->notificationParams.
floatingLimit.statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 2,
&data->notificationParams.floatingLimit.
setPointValue))) {
&data->notificationParams.
floatingLimit.setPointValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 3,
&data->notificationParams.floatingLimit.
errorLimit))) {
&data->notificationParams.
floatingLimit.errorLimit))) {
return -1;
}
len += section_length;
@@ -716,31 +720,31 @@ int event_notify_decode_service_request(
case EVENT_OUT_OF_RANGE:
if (-1 == (section_length =
decode_context_real(&apdu[len], 0,
&data->notificationParams.outOfRange.
exceedingValue))) {
&data->notificationParams.
outOfRange.exceedingValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.outOfRange.
statusFlags))) {
&data->notificationParams.
outOfRange.statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 2,
&data->notificationParams.outOfRange.
deadband))) {
&data->notificationParams.
outOfRange.deadband))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_real(&apdu[len], 3,
&data->notificationParams.outOfRange.
exceededLimit))) {
&data->notificationParams.
outOfRange.exceededLimit))) {
return -1;
}
len += section_length;
@@ -768,8 +772,9 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 2,
&data->notificationParams.
changeOfLifeSafety.statusFlags))) {
&data->
notificationParams.changeOfLifeSafety.
statusFlags))) {
return -1;
}
len += section_length;
@@ -779,8 +784,8 @@ int event_notify_decode_service_request(
&value))) {
return -1;
}
data->notificationParams.changeOfLifeSafety.
operationExpected =
data->notificationParams.
changeOfLifeSafety.operationExpected =
(BACNET_LIFE_SAFETY_OPERATION) value;
len += section_length;
break;
@@ -789,24 +794,24 @@ int event_notify_decode_service_request(
if (-1 == (section_length =
bacapp_decode_context_device_obj_property_ref
(&apdu[len], 0,
&data->notificationParams.bufferReady.
bufferProperty))) {
&data->notificationParams.
bufferReady.bufferProperty))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 1,
&data->notificationParams.bufferReady.
previousNotification))) {
&data->notificationParams.
bufferReady.previousNotification))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.bufferReady.
currentNotification))) {
&data->notificationParams.
bufferReady.currentNotification))) {
return -1;
}
len += section_length;
@@ -815,24 +820,24 @@ int event_notify_decode_service_request(
case EVENT_UNSIGNED_RANGE:
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 0,
&data->notificationParams.unsignedRange.
exceedingValue))) {
&data->notificationParams.
unsignedRange.exceedingValue))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_bitstring(&apdu[len], 1,
&data->notificationParams.unsignedRange.
statusFlags))) {
&data->notificationParams.
unsignedRange.statusFlags))) {
return -1;
}
len += section_length;
if (-1 == (section_length =
decode_context_unsigned(&apdu[len], 2,
&data->notificationParams.unsignedRange.
exceededLimit))) {
&data->notificationParams.
unsignedRange.exceededLimit))) {
return -1;
}
len += section_length;
@@ -1020,9 +1025,9 @@ void testEventEventState(
data.notificationParams.changeOfState.newState.state.units ==
data2.notificationParams.changeOfState.newState.state.units);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfState.statusFlags,
&data2.notificationParams.changeOfState.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfState.statusFlags,
&data2.notificationParams.changeOfState.statusFlags));
/**********************************************************************************/
/**********************************************************************************/
@@ -1078,16 +1083,16 @@ void testEventEventState(
data.eventType = EVENT_CHANGE_OF_BITSTRING;
bitstring_init(&data.notificationParams.changeOfBitstring.
referencedBitString);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams.changeOfBitstring.
referencedBitString, 2, false);
bitstring_init(&data.notificationParams.
changeOfBitstring.referencedBitString);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 0, true);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 1, false);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 2, true);
bitstring_set_bit(&data.notificationParams.
changeOfBitstring.referencedBitString, 2, false);
bitstring_init(&data.notificationParams.changeOfBitstring.statusFlags);
@@ -1110,13 +1115,14 @@ void testEventEventState(
ct_test(pTest, inLen == outLen);
testBaseEventState(pTest);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfBitstring.referencedBitString,
&data2.notificationParams.changeOfBitstring.referencedBitString));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfBitstring.
referencedBitString,
&data2.notificationParams.changeOfBitstring.referencedBitString));
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfBitstring.statusFlags,
&data2.notificationParams.changeOfBitstring.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfBitstring.statusFlags,
&data2.notificationParams.changeOfBitstring.statusFlags));
/**********************************************************************************/
/**********************************************************************************/
@@ -1154,9 +1160,9 @@ void testEventEventState(
ct_test(pTest, inLen == outLen);
testBaseEventState(pTest);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfValue.statusFlags,
&data2.notificationParams.changeOfValue.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfValue.statusFlags,
&data2.notificationParams.changeOfValue.statusFlags));
ct_test(pTest,
data.notificationParams.changeOfValue.tag ==
@@ -1174,16 +1180,16 @@ void testEventEventState(
data.notificationParams.changeOfValue.tag = CHANGE_OF_VALUE_BITS;
bitstring_init(&data.notificationParams.changeOfValue.newValue.
changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.newValue.
changedBits, 3, false);
bitstring_init(&data.notificationParams.changeOfValue.
newValue.changedBits);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 0, true);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 1, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 2, false);
bitstring_set_bit(&data.notificationParams.changeOfValue.
newValue.changedBits, 3, false);
memset(buffer, 0, MAX_APDU);
inLen = event_notify_encode_service_request(&buffer[0], &data);
@@ -1195,17 +1201,18 @@ void testEventEventState(
ct_test(pTest, inLen == outLen);
testBaseEventState(pTest);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfValue.statusFlags,
&data2.notificationParams.changeOfValue.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfValue.statusFlags,
&data2.notificationParams.changeOfValue.statusFlags));
ct_test(pTest,
data.notificationParams.changeOfValue.tag ==
data2.notificationParams.changeOfValue.tag);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfValue.newValue.changedBits,
&data2.notificationParams.changeOfValue.newValue.changedBits));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfValue.newValue.
changedBits,
&data2.notificationParams.changeOfValue.newValue.changedBits));
/**********************************************************************************/
/**********************************************************************************/
@@ -1254,9 +1261,9 @@ void testEventEventState(
ct_test(pTest,
data.notificationParams.floatingLimit.errorLimit ==
data2.notificationParams.floatingLimit.errorLimit);
ct_test(pTest, bitstring_same(
&data.notificationParams.floatingLimit.statusFlags,
&data2.notificationParams.floatingLimit.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.floatingLimit.statusFlags,
&data2.notificationParams.floatingLimit.statusFlags));
/**********************************************************************************/
@@ -1306,9 +1313,9 @@ void testEventEventState(
ct_test(pTest,
data.notificationParams.outOfRange.exceedingValue ==
data2.notificationParams.outOfRange.exceedingValue);
ct_test(pTest, bitstring_same(
&data.notificationParams.outOfRange.statusFlags,
&data2.notificationParams.outOfRange.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.outOfRange.statusFlags,
&data2.notificationParams.outOfRange.statusFlags));
/**********************************************************************************/
/**********************************************************************************/
@@ -1361,9 +1368,9 @@ void testEventEventState(
data.notificationParams.changeOfLifeSafety.operationExpected ==
data2.notificationParams.changeOfLifeSafety.operationExpected);
ct_test(pTest, bitstring_same(
&data.notificationParams.changeOfLifeSafety.statusFlags,
&data2.notificationParams.changeOfLifeSafety.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.changeOfLifeSafety.statusFlags,
&data2.notificationParams.changeOfLifeSafety.statusFlags));
/**********************************************************************************/
/**********************************************************************************/
@@ -1408,9 +1415,9 @@ void testEventEventState(
data.notificationParams.unsignedRange.exceededLimit ==
data2.notificationParams.unsignedRange.exceededLimit);
ct_test(pTest, bitstring_same(
&data.notificationParams.unsignedRange.statusFlags,
&data2.notificationParams.unsignedRange.statusFlags));
ct_test(pTest,
bitstring_same(&data.notificationParams.unsignedRange.statusFlags,
&data2.notificationParams.unsignedRange.statusFlags));
/**********************************************************************************/
/**********************************************************************************/
@@ -1427,12 +1434,12 @@ void testEventEventState(
data.notificationParams.bufferReady.currentNotification = 2345;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.type =
OBJECT_DEVICE;
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance = 500;
data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.instance = 500;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.type =
OBJECT_ANALOG_INPUT;
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance = 100;
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance = 100;
data.notificationParams.bufferReady.bufferProperty.propertyIdentifier =
PROP_PRESENT_VALUE;
data.notificationParams.bufferReady.bufferProperty.arrayIndex = 0;
@@ -1457,34 +1464,34 @@ void testEventEventState(
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
type ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
type);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.deviceIndentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type ==
data2.notificationParams.bufferReady.bufferProperty.objectIdentifier.
type);
data.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.
deviceIndentifier.type);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
propertyIdentifier ==
deviceIndentifier.instance ==
data2.notificationParams.bufferReady.bufferProperty.
propertyIdentifier);
deviceIndentifier.instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.instance);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type ==
data2.notificationParams.bufferReady.bufferProperty.
objectIdentifier.type);
ct_test(pTest,
data.notificationParams.bufferReady.
bufferProperty.propertyIdentifier ==
data2.notificationParams.bufferReady.
bufferProperty.propertyIdentifier);
ct_test(pTest,
data.notificationParams.bufferReady.bufferProperty.arrayIndex ==
+1 -2
View File
@@ -642,8 +642,7 @@ void test_Unconfirmed_Private_Transfer_Request(
len = uptransfer_encode_apdu(&apdu[0], &private_data);
ct_test(pTest, len != 0);
apdu_len = len;
len =
uptransfer_decode_apdu(&apdu[0], apdu_len, &test_data);
len = uptransfer_decode_apdu(&apdu[0], apdu_len, &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);
+5 -13
View File
@@ -198,7 +198,7 @@ void Ringbuf_Init(
/* test the ring buffer */
void testRingAroundBuffer(
Test * pTest,
RING_BUFFER *test_buffer,
RING_BUFFER * test_buffer,
uint8_t * data_element,
unsigned element_size,
unsigned element_count)
@@ -319,22 +319,14 @@ void testRingBuf(
}
ct_test(pTest, Ringbuf_Empty(&test_buffer));
testRingAroundBuffer(
pTest,
&test_buffer,
data_element,
element_size,
testRingAroundBuffer(pTest, &test_buffer, data_element, element_size,
element_count);
/* adjust the internal index of Ringbuf to test unsigned wrapping */
test_buffer.head = UINT_MAX-1;
test_buffer.tail = UINT_MAX-1;
test_buffer.head = UINT_MAX - 1;
test_buffer.tail = UINT_MAX - 1;
testRingAroundBuffer(
pTest,
&test_buffer,
data_element,
element_size,
testRingAroundBuffer(pTest, &test_buffer, data_element, element_size,
element_count);
return;
+64 -59
View File
@@ -33,38 +33,39 @@
/** @file wpm.c Encode/Decode BACnet Write Property Multiple APDUs */
/* decode service */
int wpm_decode_object_id(uint8_t * apdu, uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * data)
int wpm_decode_object_id(
uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * data)
{
uint8_t tag_number = 0;
uint32_t len_value = 0;
uint8_t tag_number = 0;
uint32_t len_value = 0;
uint32_t object_instance = 0;
uint16_t object_type = 0;
uint16_t len = 0;
if((apdu )&& (apdu_len))
{
if ((apdu) && (apdu_len)) {
/* Context tag 0 - Object ID */
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if(tag_number == 0)
{
len += decode_object_id(&apdu[len], &object_type, &object_instance);
len +=
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if (tag_number == 0) {
len +=
decode_object_id(&apdu[len], &object_type, &object_instance);
data->object_type = object_type;
data->object_instance = object_instance;
}
else
} else
return -1;
}
else
} else
return -1;
return len;
}
int wpm_decode_object_property(uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * wp_data)
int wpm_decode_object_property(
uint8_t * apdu,
uint16_t apdu_len,
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
uint8_t tag_number = 0;
uint32_t len_value = 0;
@@ -72,68 +73,70 @@ int wpm_decode_object_property(uint8_t * apdu,
int len = 0, i = 0;
if((apdu) && (apdu_len) && (wp_data))
{
if ((apdu) && (apdu_len) && (wp_data)) {
wp_data->array_index = BACNET_ARRAY_ALL;
wp_data->priority = BACNET_MAX_PRIORITY;
wp_data->priority = BACNET_MAX_PRIORITY;
wp_data->application_data_len = 0;
/* tag 0 - Property Identifier */
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if(tag_number == 0)
{
len +=
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if (tag_number == 0) {
len += decode_enumerated(&apdu[len], len_value, &ulVal);
wp_data->object_property = ulVal;
}
else
} else
return -1;
/* tag 1 - Property Array Index - optional */
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if(tag_number == 1)
{
len += decode_unsigned(&apdu[len],len_value, &ulVal);
len +=
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if (tag_number == 1) {
len += decode_unsigned(&apdu[len], len_value, &ulVal);
wp_data->array_index = ulVal;
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
len +=
decode_tag_number_and_value(&apdu[len], &tag_number,
&len_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--;
wp_data->application_data_len = bacapp_data_len(&apdu[len],
apdu_len - len, wp_data->object_property);
wp_data->application_data_len =
bacapp_data_len(&apdu[len], apdu_len - len,
wp_data->object_property);
len++;
/* copy application data */
for(i = 0; i < wp_data->application_data_len; i++)
wp_data->application_data[i] = apdu[len+i];
for (i = 0; i < wp_data->application_data_len; i++)
wp_data->application_data[i] = apdu[len + i];
len += wp_data->application_data_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);
/* 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])))
return -1;
}
else
} else
return -1;
/* tag 3 - Priority - optional */
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if(tag_number == 3) {
len +=
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
if (tag_number == 3) {
len += decode_unsigned(&apdu[len], len_value, &ulVal);
wp_data->priority = ulVal;
}
else
} else
len--;
}
else
} else
return -1;
return len;
}
int wpm_ack_encode_apdu_init(uint8_t * apdu, uint8_t invoke_id)
int wpm_ack_encode_apdu_init(
uint8_t * apdu,
uint8_t invoke_id)
{
int len = 0;
@@ -146,13 +149,14 @@ int wpm_ack_encode_apdu_init(uint8_t * apdu, uint8_t invoke_id)
return len;
}
int wpm_error_ack_encode_apdu(uint8_t * apdu, uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * wp_data)
int wpm_error_ack_encode_apdu(
uint8_t * apdu,
uint8_t invoke_id,
BACNET_WRITE_PROPERTY_DATA * wp_data)
{
int len = 0;
if (apdu)
{
if (apdu) {
apdu[len++] = PDU_TYPE_ERROR;
apdu[len++] = invoke_id;
apdu[len++] = SERVICE_CONFIRMED_WRITE_PROP_MULTIPLE;
@@ -160,18 +164,19 @@ int wpm_error_ack_encode_apdu(uint8_t * apdu, uint8_t invoke_id,
len += encode_opening_tag(&apdu[len], 0);
len += encode_application_enumerated(&apdu[len], wp_data->error_class);
len += encode_application_enumerated(&apdu[len], wp_data->error_code);
len += encode_closing_tag(&apdu[len], 0);
len += encode_closing_tag(&apdu[len], 0);
len += encode_opening_tag(&apdu[len], 1);
len += encode_context_object_id(&apdu[len], 0,
wp_data->object_type, wp_data->object_instance);
len += encode_context_enumerated(&apdu[len], 1,
wp_data->object_property);
len +=
encode_context_object_id(&apdu[len], 0, wp_data->object_type,
wp_data->object_instance);
len +=
encode_context_enumerated(&apdu[len], 1, wp_data->object_property);
if(wp_data->array_index != BACNET_ARRAY_ALL)
len += encode_context_unsigned(&apdu[len], 2, wp_data->array_index);
if (wp_data->array_index != BACNET_ARRAY_ALL)
len +=
encode_context_unsigned(&apdu[len], 2, wp_data->array_index);
len += encode_closing_tag(&apdu[len], 1);
}
return len;
}