Corrected Send_I_Am_Unicast. Removed the NULL src feature of sending broadcast for now.

This commit is contained in:
skarg
2010-02-18 22:40:23 +00:00
parent d5e49c7cc1
commit 0529106e73
+11 -14
View File
@@ -118,37 +118,34 @@ int iam_unicast_encode_pdu(
BACNET_ADDRESS * dest, BACNET_ADDRESS * dest,
BACNET_NPDU_DATA * npdu_data) BACNET_NPDU_DATA * npdu_data)
{ {
int len = 0; int npdu_len = 0;
int apdu_len = 0;
int pdu_len = 0; int pdu_len = 0;
BACNET_ADDRESS my_address;
if ( ( src == NULL ) || ( src->mac_len == 0 ) ) datalink_get_my_address(&my_address);
datalink_get_broadcast_address(dest);
else {
memcpy( dest, src, sizeof( BACNET_ADDRESS ) );
dest->net = 0;
}
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL);
pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data); npdu_len =
npdu_encode_pdu(&buffer[0], src, &my_address,
npdu_data);
/* encode the APDU portion of the packet */ /* encode the APDU portion of the packet */
len = apdu_len =
iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(), iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(),
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
pdu_len += len; pdu_len = npdu_len + apdu_len;
return pdu_len; return pdu_len;
} }
/** Send an I-Am message by unicasting directly back to the src. /** Send an I-Am message by unicasting directly back to the src.
* @note If no src address is given, the I-Am will be broadcast instead.
* @note As of Addendum 135-2008q-1, unicast responses are allowed; * @note As of Addendum 135-2008q-1, unicast responses are allowed;
* in modern firewalled corporate networks, this may be the * in modern firewalled corporate networks, this may be the
* only type of response that will reach the source on * only type of response that will reach the source on
* another subnet (without using the BBMD). * another subnet (without using the BBMD).
* *
* @param buffer [in] The buffer to use for building and sending the message. * @param buffer [in] The buffer to use for building and sending the message.
* @param src [in] The source address information, if any (may be NULL). * @param src [in] The source address information from service handler.
*/ */
void Send_I_Am_Unicast( void Send_I_Am_Unicast(
uint8_t * buffer, uint8_t * buffer,