Added some javadoc-type function comments.
Reduced the default hop count from way-big 255 to 15.
This commit is contained in:
@@ -40,6 +40,26 @@
|
||||
|
||||
/** @file h_npdu.c Handles messages at the NPDU level of the BACnet stack. */
|
||||
|
||||
/** Handler for the NPDU portion of a received packet.
|
||||
* Aside from error-checking, if the NPDU doesn't contain routing info,
|
||||
* this handler doesn't do much besides stepping over the NPDU header
|
||||
* and passing the remaining bytes to the apdu_handler.
|
||||
* @note The routing (except src) and NCPI information, including
|
||||
* npdu_data->data_expecting_reply, are discarded.
|
||||
*
|
||||
* @param src [out] Returned with routing source information if the NPDU
|
||||
* has any and if this points to non-null storage for it.
|
||||
* If src->net and src->len are 0 on return, there is no
|
||||
* routing source information.
|
||||
* This src describes the original source of the message when
|
||||
* it had to be routed to reach this BACnet Device, and this
|
||||
* is passed down into the apdu_handler; however, I don't
|
||||
* think this project's code has any use for the src info
|
||||
* on return from this handler, since the response has
|
||||
* already been sent via the apdu_handler.
|
||||
* @param pdu [in] Buffer containing the NPDU and APDU of the received packet.
|
||||
* @param pdu_len [in] The size of the received message in the pdu[] buffer.
|
||||
*/
|
||||
void npdu_handler(
|
||||
BACNET_ADDRESS * src, /* source address */
|
||||
uint8_t * pdu, /* PDU data */
|
||||
|
||||
@@ -56,7 +56,7 @@ static void npdu_encode_npdu_network(
|
||||
npdu_data->network_message_type = network_message_type; /* optional */
|
||||
npdu_data->vendor_id = 0; /* optional, if net message type is > 0x80 */
|
||||
npdu_data->priority = priority;
|
||||
npdu_data->hop_count = 255;
|
||||
npdu_data->hop_count = 15; /* Set a generous but reasonable upper bound */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,10 @@ void Send_Who_Is_Router_To_Network(
|
||||
#endif
|
||||
}
|
||||
|
||||
/* pDNET_list: list of networks for which I am a router,
|
||||
terminated with -1 */
|
||||
/** Broadcast an I-am-router-to-network message, giving the list of networks we can reach.
|
||||
* The message will be sent to our normal DataLink Layer interface, not the routed backend.
|
||||
* @param DNET_list [in] list of BACnet network numbers for which I am a router, terminated with -1
|
||||
*/
|
||||
void Send_I_Am_Router_To_Network(
|
||||
const int DNET_list[])
|
||||
{
|
||||
@@ -121,7 +123,7 @@ void Send_I_Am_Router_To_Network(
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], NULL, NULL, &npdu_data);
|
||||
/* encode the optional DNET list portion of the packet */
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Send I-Am-Router-To-Network message to:\n");
|
||||
fprintf(stderr, "Sending I-Am-Router-To-Network message for networks:\n");
|
||||
#endif
|
||||
while (DNET_list[index] != -1) {
|
||||
dnet = (uint16_t) DNET_list[index];
|
||||
@@ -129,7 +131,7 @@ void Send_I_Am_Router_To_Network(
|
||||
pdu_len += len;
|
||||
index++;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "%u\n", dnet);
|
||||
fprintf(stderr, " %u\n", dnet);
|
||||
#endif
|
||||
}
|
||||
/* I-Am-Router-To-Network shall always be transmitted with
|
||||
|
||||
Reference in New Issue
Block a user