Added checks for DeviceCommunicationControl that were in src/apdu.c but are missing from this port. Thanks, Vu!

This commit is contained in:
skarg
2012-08-14 16:27:50 +00:00
parent 609c24b741
commit 288a47edea
+69
View File
@@ -102,6 +102,61 @@ uint16_t apdu_decode_confirmed_service_request(
return len;
}
/* When network communications are completely disabled,
only DeviceCommunicationControl and ReinitializeDevice APDUs
shall be processed and no messages shall be initiated.
When the initiation of communications is disabled,
all APDUs shall be processed and responses returned as
required... */
static bool apdu_confirmed_dcc_disabled(
uint8_t service_choice)
{
bool status = false;
if (dcc_communication_disabled()) {
switch (service_choice) {
case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL:
case SERVICE_CONFIRMED_REINITIALIZE_DEVICE:
break;
default:
status = true;
break;
}
}
return status;
}
/* When network communications are completely disabled,
only DeviceCommunicationControl and ReinitializeDevice APDUs
shall be processed and no messages shall be initiated. */
/* If the request is valid and the 'Enable/Disable' parameter is
DISABLE_INITIATION, the responding BACnet-user shall
discontinue the initiation of messages except for I-Am
requests issued in accordance with the Who-Is service procedure.*/
static bool apdu_unconfirmed_dcc_disabled(
uint8_t service_choice)
{
bool status = false;
if (dcc_communication_disabled()) {
/* there are no Unconfirmed messages that
can be processed in this state */
status = true;
} else if (dcc_communication_initiation_disabled()) {
/* WhoIs will be processed and I-Am initiated as response. */
switch (service_choice) {
case SERVICE_UNCONFIRMED_WHO_IS:
break;
default:
status = true;
break;
}
}
return status;
}
void apdu_handler(
BACNET_ADDRESS * src,
uint8_t * apdu, /* APDU data */
@@ -120,6 +175,12 @@ void apdu_handler(
len = apdu_decode_confirmed_service_request(&apdu[0], /* APDU data */
apdu_len, &service_data, &service_choice, &service_request,
&service_request_len);
if (apdu_confirmed_dcc_disabled(service_choice)) {
/* When network communications are completely disabled,
only DeviceCommunicationControl and ReinitializeDevice APDUs
shall be processed and no messages shall be initiated. */
break;
}
if (service_choice == SERVICE_CONFIRMED_READ_PROPERTY) {
handler_read_property(service_request, service_request_len,
src, &service_data);
@@ -143,6 +204,14 @@ void apdu_handler(
service_choice = apdu[1];
service_request = &apdu[2];
service_request_len = apdu_len - 2;
if (apdu_unconfirmed_dcc_disabled(service_choice)) {
/* When network communications are disabled,
only DeviceCommunicationControl and ReinitializeDevice APDUs
shall be processed and no messages shall be initiated.
If communications have been initiation disabled, then
WhoIs may be processed. */
break;
}
if (service_choice == SERVICE_UNCONFIRMED_WHO_IS) {
handler_who_is(service_request, service_request_len, src);
}