added initialization to the src and dest address when portions of it were not decoded. This corrects a bug preventing proper communication on Ethernet.
This commit is contained in:
+30
-2
@@ -211,7 +211,9 @@ int npdu_decode(
|
|||||||
// 1 = DNET, DLEN, and Hop Count present
|
// 1 = DNET, DLEN, and Hop Count present
|
||||||
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
||||||
// DLEN > 0 specifies length of DADR field
|
// DLEN > 0 specifies length of DADR field
|
||||||
if (dest && (npdu[1] & BIT5))
|
if (dest)
|
||||||
|
{
|
||||||
|
if (npdu[1] & BIT5)
|
||||||
{
|
{
|
||||||
len += decode_unsigned16(&npdu[len], &dest->net);
|
len += decode_unsigned16(&npdu[len], &dest->net);
|
||||||
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
||||||
@@ -225,12 +227,24 @@ int npdu_decode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dest->net = 0;
|
||||||
|
dest->len = 0;
|
||||||
|
for (i = 0; i < MAX_MAC_LEN; i++)
|
||||||
|
{
|
||||||
|
dest->adr[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Bit 3: Source specifier where:
|
// Bit 3: Source specifier where:
|
||||||
// 0 = SNET, SLEN, and SADR absent
|
// 0 = SNET, SLEN, and SADR absent
|
||||||
// 1 = SNET, SLEN, and SADR present
|
// 1 = SNET, SLEN, and SADR present
|
||||||
// SLEN = 0 Invalid
|
// SLEN = 0 Invalid
|
||||||
// SLEN > 0 specifies length of SADR field
|
// SLEN > 0 specifies length of SADR field
|
||||||
if (src && (npdu[1] & BIT3))
|
if (src)
|
||||||
|
{
|
||||||
|
if (npdu[1] & BIT3)
|
||||||
{
|
{
|
||||||
len += decode_unsigned16(&npdu[len], &src->net);
|
len += decode_unsigned16(&npdu[len], &src->net);
|
||||||
// SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
|
// SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
|
||||||
@@ -244,11 +258,23 @@ int npdu_decode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
src->net = 0;
|
||||||
|
src->len = 0;
|
||||||
|
for (i = 0; i < MAX_MAC_LEN; i++)
|
||||||
|
{
|
||||||
|
src->adr[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// The Hop Count field shall be present only if the message is
|
// The Hop Count field shall be present only if the message is
|
||||||
// destined for a remote network, i.e., if DNET is present.
|
// destined for a remote network, i.e., if DNET is present.
|
||||||
// This is a one-octet field that is initialized to a value of 0xff.
|
// This is a one-octet field that is initialized to a value of 0xff.
|
||||||
if (dest && dest->net)
|
if (dest && dest->net)
|
||||||
npdu_data->hop_count = npdu[len++];
|
npdu_data->hop_count = npdu[len++];
|
||||||
|
else
|
||||||
|
npdu_data->hop_count = 0;
|
||||||
// Indicates that the NSDU conveys a network layer message.
|
// Indicates that the NSDU conveys a network layer message.
|
||||||
// Message Type field is present.
|
// Message Type field is present.
|
||||||
if (npdu_data->network_layer_message)
|
if (npdu_data->network_layer_message)
|
||||||
@@ -259,6 +285,8 @@ int npdu_decode(
|
|||||||
if (npdu_data->network_message_type >= 0x80)
|
if (npdu_data->network_message_type >= 0x80)
|
||||||
len += decode_unsigned16(&npdu[len], &npdu_data->vendor_id);
|
len += decode_unsigned16(&npdu[len], &npdu_data->vendor_id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
npdu_data->network_message_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|||||||
Reference in New Issue
Block a user