Added checking in with each device (in the BAC_ROUTING case) to see whether it supports RD or DCC.

Sends a Reject message if not supported.  Added to the respective handlers.
This commit is contained in:
tbrennan3
2011-10-21 17:02:11 +00:00
parent 0291493fd2
commit 710ac3d34c
4 changed files with 68 additions and 11 deletions
+11 -5
View File
@@ -98,7 +98,6 @@ void handler_device_communication_control(
BACNET_CHARACTER_STRING password;
int len = 0;
int pdu_len = 0;
int bytes_sent = 0;
BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS my_address;
@@ -156,6 +155,15 @@ void handler_device_communication_control(
"Sending Reject - undefined enumeration\n");
#endif
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL, (int) state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id );
if ( len > 0 )
goto DCC_ABORT;
#endif
if (characterstring_ansi_same(&password, My_Password)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
@@ -181,17 +189,15 @@ void handler_device_communication_control(
}
DCC_ABORT:
pdu_len += len;
bytes_sent =
len =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0) {
if (len <= 0) {
fprintf(stderr,
"DeviceCommunicationControl: " "Failed to send PDU (%s)!\n",
strerror(errno));
}
#else
bytes_sent = bytes_sent;
#endif
return;
+11 -5
View File
@@ -73,7 +73,6 @@ void handler_reinitialize_device(
int len = 0;
int pdu_len = 0;
BACNET_NPDU_DATA npdu_data;
int bytes_sent = 0;
BACNET_ADDRESS my_address;
/* encode the NPDU portion of the packet */
@@ -130,6 +129,15 @@ void handler_reinitialize_device(
"ReinitializeDevice: Sending Reject - undefined enumeration\n");
#endif
} else {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
len = Routed_Device_Service_Approval(
SERVICE_CONFIRMED_REINITIALIZE_DEVICE, (int) rd_data.state,
&Handler_Transmit_Buffer[pdu_len], service_data->invoke_id );
if ( len > 0 )
goto RD_ABORT;
#endif
if (Device_Reinitialize(&rd_data)) {
len =
encode_simple_ack(&Handler_Transmit_Buffer[pdu_len],
@@ -150,16 +158,14 @@ void handler_reinitialize_device(
}
RD_ABORT:
pdu_len += len;
bytes_sent =
len =
datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0],
pdu_len);
#if PRINT_ENABLED
if (bytes_sent <= 0) {
if (len <= 0) {
fprintf(stderr, "ReinitializeDevice: Failed to send PDU (%s)!\n",
strerror(errno));
}
#else
bytes_sent = bytes_sent;
#endif
return;