Indented according to standard indent rules for this project.
This commit is contained in:
@@ -53,8 +53,8 @@ void handler_i_am_add(
|
||||
if (len != -1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, " from %u, MAC = %d.%d.%d.%d.%d.%d\n", device_id,
|
||||
src->mac[0],src->mac[1],src->mac[2],
|
||||
src->mac[3],src->mac[4],src->mac[5]);
|
||||
src->mac[0], src->mac[1], src->mac[2], src->mac[3], src->mac[4],
|
||||
src->mac[5]);
|
||||
#endif
|
||||
address_add(device_id, max_apdu, src);
|
||||
} else {
|
||||
|
||||
@@ -90,18 +90,14 @@ bool handler_lso(
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Life Safety Operation: Received operation %d from process id %d for object %id\n",
|
||||
data.operation,
|
||||
data.processId,
|
||||
data.targetObject.instance);
|
||||
data.operation, data.processId, data.targetObject.instance);
|
||||
#endif
|
||||
|
||||
len =
|
||||
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
|
||||
service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION);
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_LIFE_SAFETY_OPERATION);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Life Safety Operation: " "Sending Simple Ack!\n");
|
||||
fprintf(stderr, "Life Safety Operation: " "Sending Simple Ack!\n");
|
||||
#endif
|
||||
|
||||
LSO_ABORT:
|
||||
@@ -111,11 +107,9 @@ bool handler_lso(
|
||||
pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Life Safety Operation: " "Failed to send PDU (%s)!\n",
|
||||
fprintf(stderr, "Life Safety Operation: " "Failed to send PDU (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,15 +421,14 @@ void handler_read_property_multiple(
|
||||
/* handle the error code - but use the special property */
|
||||
len =
|
||||
RPM_Encode_Property(&Handler_Transmit_Buffer[0],
|
||||
npdu_len + apdu_len, MAX_APDU,
|
||||
object_type, object_instance, object_property,
|
||||
array_index);
|
||||
npdu_len + apdu_len, MAX_APDU, object_type,
|
||||
object_instance, object_property, array_index);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
apdu_len =
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id,
|
||||
abort_encode_apdu(&Handler_Transmit_Buffer
|
||||
[npdu_len], service_data->invoke_id,
|
||||
ABORT_REASON_SEGMENTATION_NOT_SUPPORTED, true);
|
||||
goto RPM_ABORT;
|
||||
}
|
||||
@@ -440,9 +439,8 @@ void handler_read_property_multiple(
|
||||
special_object_property, index);
|
||||
len =
|
||||
RPM_Encode_Property(&Handler_Transmit_Buffer[0],
|
||||
npdu_len + apdu_len, MAX_APDU,
|
||||
object_type, object_instance, object_property,
|
||||
array_index);
|
||||
npdu_len + apdu_len, MAX_APDU, object_type,
|
||||
object_instance, object_property, array_index);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
|
||||
@@ -108,12 +108,12 @@ static int rpm_ack_decode_service_request(
|
||||
while (value && (apdu_len > 0)) {
|
||||
if (decode_is_context_specific(apdu)) {
|
||||
len =
|
||||
bacapp_decode_context_data(
|
||||
apdu, apdu_len, value,
|
||||
bacapp_decode_context_data(apdu, apdu_len, value,
|
||||
rpm_property->propertyIdentifier);
|
||||
} else {
|
||||
len =
|
||||
bacapp_decode_application_data(apdu, apdu_len, value);
|
||||
bacapp_decode_application_data(apdu, apdu_len,
|
||||
value);
|
||||
}
|
||||
decoded_len += len;
|
||||
apdu_len -= len;
|
||||
@@ -137,8 +137,7 @@ static int rpm_ack_decode_service_request(
|
||||
apdu++;
|
||||
/* decode the class and code sequence */
|
||||
len =
|
||||
decode_tag_number_and_value(apdu, &tag_number,
|
||||
&len_value);
|
||||
decode_tag_number_and_value(apdu, &tag_number, &len_value);
|
||||
decoded_len += len;
|
||||
apdu_len -= len;
|
||||
apdu += len;
|
||||
@@ -149,8 +148,7 @@ static int rpm_ack_decode_service_request(
|
||||
apdu_len -= len;
|
||||
apdu += len;
|
||||
len =
|
||||
decode_tag_number_and_value(apdu, &tag_number,
|
||||
&len_value);
|
||||
decode_tag_number_and_value(apdu, &tag_number, &len_value);
|
||||
decoded_len += len;
|
||||
apdu_len -= len;
|
||||
apdu += len;
|
||||
@@ -242,10 +240,10 @@ static void PrintReadPropertyMultipleData(
|
||||
#if PRINT_ENABLED
|
||||
/* AccessError */
|
||||
fprintf(stdout, "BACnet Error: %s: %s\r\n",
|
||||
bactext_error_class_name(
|
||||
(int)listOfProperties->error.error_class),
|
||||
bactext_error_code_name(
|
||||
(int)listOfProperties->error.error_code));
|
||||
bactext_error_class_name((int) listOfProperties->error.
|
||||
error_class),
|
||||
bactext_error_code_name((int) listOfProperties->error.
|
||||
error_code));
|
||||
#endif
|
||||
}
|
||||
listOfProperties = listOfProperties->next;
|
||||
|
||||
@@ -325,8 +325,7 @@ static void address_parse(BACNET_ADDRESS * dst,
|
||||
dst->mac_len = 6;
|
||||
for (index = 0; index < 4; index++) {
|
||||
dst->mac[index] = mac[index];
|
||||
}
|
||||
encode_unsigned16(&dst->mac[4],
|
||||
} encode_unsigned16(&dst->mac[4],
|
||||
port);
|
||||
} else {
|
||||
count =
|
||||
|
||||
@@ -99,7 +99,8 @@ static void dlmstp_millisecond_timer(
|
||||
}
|
||||
|
||||
#if !defined (_WIN32)
|
||||
void Sleep(unsigned long milliseconds)
|
||||
void Sleep(
|
||||
unsigned long milliseconds)
|
||||
{
|
||||
struct timespec timeOut, remains;
|
||||
|
||||
@@ -165,7 +166,8 @@ uint16_t MSTP_Get_Reply(
|
||||
static char Capture_Filename[32] = "mstp_20090123091200.cap";
|
||||
static FILE *pFile = NULL; /* stream pointer */
|
||||
|
||||
static void filename_create(char *filename)
|
||||
static void filename_create(
|
||||
char *filename)
|
||||
{
|
||||
time_t my_time;
|
||||
struct tm *today;
|
||||
@@ -174,12 +176,8 @@ static void filename_create(char *filename)
|
||||
my_time = time(NULL);
|
||||
today = localtime(&my_time);
|
||||
sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap",
|
||||
1900+today->tm_year,
|
||||
1+today->tm_mon,
|
||||
today->tm_mday,
|
||||
today->tm_hour,
|
||||
today->tm_min,
|
||||
today->tm_sec);
|
||||
1900 + today->tm_year, 1 + today->tm_mon, today->tm_mday,
|
||||
today->tm_hour, today->tm_min, today->tm_sec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +285,8 @@ void signal_init(
|
||||
}
|
||||
#endif
|
||||
|
||||
void filename_create_new(void)
|
||||
void filename_create_new(
|
||||
void)
|
||||
{
|
||||
if (pFile) {
|
||||
fclose(pFile);
|
||||
@@ -320,14 +319,11 @@ int main(
|
||||
"Captures MS/TP packets from a serial interface\r\n"
|
||||
"and save them to a file. Saves packets in a\r\n"
|
||||
"filename mstp_20090123091200.cap that has data and time.\r\n"
|
||||
"After receiving 65535 packets, a new file is created.\r\n"
|
||||
"\r\n"
|
||||
"Command line options:\r\n"
|
||||
"[interface] - serial interface.\r\n"
|
||||
"After receiving 65535 packets, a new file is created.\r\n" "\r\n"
|
||||
"Command line options:\r\n" "[interface] - serial interface.\r\n"
|
||||
" defaults to COM4 on Windows, and /dev/ttyUSB0 on linux.\r\n"
|
||||
"[baud] - baud rate. 9600, 19200, 38400, 57600, 115200\r\n"
|
||||
" defaults to 38400.\r\n"
|
||||
"");
|
||||
" defaults to 38400.\r\n" "");
|
||||
return 0;
|
||||
}
|
||||
if (argc > 1) {
|
||||
|
||||
@@ -230,7 +230,8 @@ void cleanup(void) {
|
||||
old_rpm_property = rpm_property;
|
||||
rpm_property = rpm_property->next;
|
||||
free(old_rpm_property);
|
||||
} old_rpm_object = rpm_object;
|
||||
}
|
||||
old_rpm_object = rpm_object;
|
||||
rpm_object = rpm_object->next;
|
||||
free(old_rpm_object);
|
||||
}
|
||||
|
||||
@@ -212,8 +212,8 @@ int main(int argc, char *argv[]) {
|
||||
filename_remove_path(argv[0]), filename_remove_path(argv[0]));
|
||||
return 0;
|
||||
}
|
||||
/* decode the command line parameters */ cov_data.
|
||||
subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||
/* decode the command line parameters */
|
||||
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
||||
cov_data.monitoredObjectIdentifier.type = strtol(argv[3], NULL, 0);
|
||||
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
||||
|
||||
@@ -898,11 +898,9 @@ typedef enum {
|
||||
OBJECT_ACCESS_ZONE = 36,
|
||||
OBJECT_AUTHENTICATION_FACTOR_INPUT = 37,
|
||||
MAX_ASHRAE_OBJECT_TYPE = 38
|
||||
|
||||
/* Enumerated values 0-127 are reserved for definition by ASHRAE. */
|
||||
/* Enumerated values 128-1023 may be used by others subject to */
|
||||
/* the procedures and constraints described in Clause 23. */
|
||||
|
||||
} BACNET_OBJECT_TYPE;
|
||||
/* used for bit string loop */
|
||||
#define MAX_BACNET_OBJECT_TYPE 1023
|
||||
|
||||
@@ -117,5 +117,4 @@ extern void datalink_set(
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -116,5 +116,4 @@ int Keylist_Count(
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,8 +46,7 @@ extern "C" {
|
||||
|
||||
/* Life Safety Operation Service */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint32_t processId;
|
||||
BACNET_CHARACTER_STRING requestingSrc;
|
||||
BACNET_LIFE_SAFETY_OPERATION operation;
|
||||
|
||||
@@ -23,5 +23,4 @@ void DLL_EXPORT SomeFunction(
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -267,16 +267,12 @@ int main(
|
||||
printf("mstsnap [serial] [baud] [network]\r\n"
|
||||
"Captures MS/TP packets from a serial interface\r\n"
|
||||
"and sends them to a network interface using SNAP \r\n"
|
||||
"protocol packets (mimics Cimetrics U+4 packet).\r\n"
|
||||
"\r\n"
|
||||
"Command line options:\r\n"
|
||||
"[serial] - serial interface.\r\n"
|
||||
"protocol packets (mimics Cimetrics U+4 packet).\r\n" "\r\n"
|
||||
"Command line options:\r\n" "[serial] - serial interface.\r\n"
|
||||
" defaults to /dev/ttyUSB0.\r\n"
|
||||
"[baud] - baud rate. 9600, 19200, 38400, 57600, 115200\r\n"
|
||||
" defaults to 38400.\r\n"
|
||||
"[network] - network interface.\r\n"
|
||||
" defaults to eth0.\r\n"
|
||||
"");
|
||||
" defaults to 38400.\r\n" "[network] - network interface.\r\n"
|
||||
" defaults to eth0.\r\n" "");
|
||||
return 0;
|
||||
}
|
||||
/* initialize our interface */
|
||||
|
||||
@@ -123,14 +123,15 @@ void apdu_handler(
|
||||
if (service_choice == SERVICE_CONFIRMED_READ_PROPERTY) {
|
||||
handler_read_property(service_request, service_request_len,
|
||||
src, &service_data);
|
||||
}
|
||||
else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) {
|
||||
} else if (service_choice == SERVICE_CONFIRMED_WRITE_PROPERTY) {
|
||||
handler_write_property(service_request,
|
||||
service_request_len, src, &service_data);
|
||||
} else if (service_choice == SERVICE_CONFIRMED_REINITIALIZE_DEVICE) {
|
||||
} else if (service_choice ==
|
||||
SERVICE_CONFIRMED_REINITIALIZE_DEVICE) {
|
||||
handler_reinitialize_device(service_request,
|
||||
service_request_len, src, &service_data);
|
||||
} else if (service_choice == SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) {
|
||||
} else if (service_choice ==
|
||||
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) {
|
||||
handler_device_communication_control(service_request,
|
||||
service_request_len, src, &service_data);
|
||||
} else {
|
||||
|
||||
@@ -54,7 +54,8 @@ static struct Address_Cache_Entry {
|
||||
BACNET_ADDRESS address;
|
||||
} Address_Cache[MAX_ADDRESS_CACHE];
|
||||
|
||||
bool address_match(BACNET_ADDRESS * dest,
|
||||
bool address_match(
|
||||
BACNET_ADDRESS * dest,
|
||||
BACNET_ADDRESS * src)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
+28
-13
@@ -704,9 +704,7 @@ int encode_context_bitstring(
|
||||
|
||||
/* 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;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -951,7 +951,8 @@ 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);
|
||||
@@ -972,7 +973,8 @@ int encode_context_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], tag_number, true, (uint32_t) string_len);
|
||||
if ((len + string_len) < MAX_APDU) {
|
||||
len += encode_bacnet_character_string(&apdu[len], char_string);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ 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],
|
||||
len =
|
||||
encode_application_enumerated(&apdu[apdu_len],
|
||||
(uint32_t) segmentation);
|
||||
apdu_len += len;
|
||||
len = encode_application_unsigned(&apdu[apdu_len], vendor_id);
|
||||
|
||||
@@ -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 =
|
||||
|
||||
+19
-21
@@ -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 =
|
||||
@@ -70,9 +68,9 @@ int lso_encode_adpu(
|
||||
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;
|
||||
}
|
||||
@@ -93,20 +91,22 @@ int lso_decode_service_request(
|
||||
if (apdu_len && data) {
|
||||
/* Tag 0: Object ID */
|
||||
|
||||
if ( (section_length = decode_context_unsigned(&apdu[len], 0, &data->processId)) == -1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if ((section_length =
|
||||
decode_context_enumerated(&apdu[len], 2, &operation)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
data->operation = operation;
|
||||
@@ -115,18 +115,15 @@ int lso_decode_service_request(
|
||||
/*
|
||||
** 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,
|
||||
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 )
|
||||
{
|
||||
&data->targetObject.instance)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
len += section_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
data->targetObject.type = 0;
|
||||
data->targetObject.instance = 0;
|
||||
}
|
||||
@@ -169,7 +166,8 @@ void testLSO(
|
||||
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
|
||||
|
||||
@@ -59,10 +59,12 @@ int ptransfer_encode_apdu(
|
||||
serviceParameters [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);
|
||||
@@ -154,10 +156,12 @@ 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,
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 1,
|
||||
private_data->vendorID);
|
||||
apdu_len += len;
|
||||
len = encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
len =
|
||||
encode_context_unsigned(&apdu[apdu_len], 2,
|
||||
private_data->serviceNumber);
|
||||
apdu_len += len;
|
||||
len = encode_opening_tag(&apdu[apdu_len], 3);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -329,8 +336,9 @@ int ptransfer_decode_apdu(
|
||||
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;
|
||||
@@ -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;
|
||||
@@ -385,9 +393,8 @@ 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;
|
||||
@@ -412,12 +419,10 @@ void test_Private_Transfer_Ack(
|
||||
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,19 +432,18 @@ 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,
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -466,25 +470,22 @@ void test_Private_Transfer_Error(
|
||||
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);
|
||||
@@ -493,10 +494,9 @@ void test_Private_Transfer_Error(
|
||||
ct_test(pTest, test_error_code == error_code);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
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;
|
||||
|
||||
+24
-16
@@ -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;
|
||||
}
|
||||
@@ -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 +=
|
||||
@@ -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 +=
|
||||
|
||||
Reference in New Issue
Block a user