Added reject response to unknown reserved network layer message types. (#690)
This commit is contained in:
@@ -1714,6 +1714,8 @@ typedef enum {
|
|||||||
NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER = 18,
|
NETWORK_MESSAGE_WHAT_IS_NETWORK_NUMBER = 18,
|
||||||
NETWORK_MESSAGE_NETWORK_NUMBER_IS = 19,
|
NETWORK_MESSAGE_NETWORK_NUMBER_IS = 19,
|
||||||
/* X'14' to X'7F': Reserved for use by ASHRAE, */
|
/* X'14' to X'7F': Reserved for use by ASHRAE, */
|
||||||
|
NETWORK_MESSAGE_ASHRAE_RESERVED_MIN = 20,
|
||||||
|
NETWORK_MESSAGE_ASHRAE_RESERVED_MAX = 127,
|
||||||
/* X'80' to X'FF': Available for vendor proprietary messages */
|
/* X'80' to X'FF': Available for vendor proprietary messages */
|
||||||
NETWORK_MESSAGE_INVALID = 0x100
|
NETWORK_MESSAGE_INVALID = 0x100
|
||||||
} BACNET_NETWORK_MESSAGE_TYPE;
|
} BACNET_NETWORK_MESSAGE_TYPE;
|
||||||
|
|||||||
@@ -194,6 +194,13 @@ static void network_control_handler(BACNET_ADDRESS *src,
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if ((npdu_data->network_message_type >=
|
||||||
|
NETWORK_MESSAGE_ASHRAE_RESERVED_MIN) &&
|
||||||
|
(npdu_data->network_message_type <=
|
||||||
|
NETWORK_MESSAGE_ASHRAE_RESERVED_MAX)) {
|
||||||
|
npdu_send_reject_message_to_network(
|
||||||
|
src, dnet, status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handler for the NPDU portion of a received packet.
|
/** Handler for the NPDU portion of a received packet.
|
||||||
@@ -275,3 +282,37 @@ void npdu_handler(BACNET_ADDRESS *src, uint8_t *pdu, uint16_t pdu_len)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send NPDU reject message to network
|
||||||
|
*
|
||||||
|
* @param dst - the destination address for the message
|
||||||
|
* @param net - local network number
|
||||||
|
* @param status - 0=learned, 1=assigned
|
||||||
|
* @return number of bytes sent
|
||||||
|
*/
|
||||||
|
int npdu_send_reject_message_to_network(
|
||||||
|
BACNET_ADDRESS *dst, uint16_t net, uint8_t status)
|
||||||
|
{
|
||||||
|
uint16_t len = 0;
|
||||||
|
int pdu_len = 0;
|
||||||
|
int bytes_sent = 0;
|
||||||
|
bool data_expecting_reply = false;
|
||||||
|
BACNET_NPDU_DATA npdu_data;
|
||||||
|
BACNET_ADDRESS my_address = { 0 };
|
||||||
|
uint8_t pdu[MAX_NPDU + 2 + 1] = { 0 };
|
||||||
|
|
||||||
|
datalink_get_my_address(&my_address);
|
||||||
|
npdu_encode_npdu_network(&npdu_data,
|
||||||
|
NETWORK_MESSAGE_REJECT_MESSAGE_TO_NETWORK,
|
||||||
|
data_expecting_reply, MESSAGE_PRIORITY_NORMAL);
|
||||||
|
pdu_len = npdu_encode_pdu(pdu, dst, &my_address, &npdu_data);
|
||||||
|
pdu[pdu_len++] = NETWORK_REJECT_UNKNOWN_MESSAGE_TYPE;
|
||||||
|
if ((pdu_len > 0) && (pdu_len <= MAX_NPDU)) {
|
||||||
|
len = encode_unsigned16(&pdu[pdu_len], net);
|
||||||
|
pdu_len += len;
|
||||||
|
bytes_sent = datalink_send_pdu(dst, &npdu_data, pdu, pdu_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes_sent;
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ extern "C" {
|
|||||||
void npdu_router_get_my_address(
|
void npdu_router_get_my_address(
|
||||||
uint16_t dnet,
|
uint16_t dnet,
|
||||||
BACNET_ADDRESS * my_address);
|
BACNET_ADDRESS * my_address);
|
||||||
|
BACNET_STACK_EXPORT
|
||||||
|
int npdu_send_reject_message_to_network(
|
||||||
|
BACNET_ADDRESS *dst,
|
||||||
|
uint16_t net,
|
||||||
|
uint8_t status);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user