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:
+44
-16
@@ -211,17 +211,29 @@ 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)
|
||||||
{
|
{
|
||||||
len += decode_unsigned16(&npdu[len], &dest->net);
|
if (npdu[1] & BIT5)
|
||||||
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
|
||||||
// DLEN > 0 specifies length of DADR field
|
|
||||||
dest->len = npdu[len++];
|
|
||||||
if (dest->len)
|
|
||||||
{
|
{
|
||||||
for (i = 0; i < dest->len; i++)
|
len += decode_unsigned16(&npdu[len], &dest->net);
|
||||||
|
// DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
||||||
|
// DLEN > 0 specifies length of DADR field
|
||||||
|
dest->len = npdu[len++];
|
||||||
|
if (dest->len)
|
||||||
{
|
{
|
||||||
dest->adr[i] = npdu[len++];
|
for (i = 0; i < dest->len; i++)
|
||||||
|
{
|
||||||
|
dest->adr[i] = npdu[len++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dest->net = 0;
|
||||||
|
dest->len = 0;
|
||||||
|
for (i = 0; i < MAX_MAC_LEN; i++)
|
||||||
|
{
|
||||||
|
dest->adr[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,17 +242,29 @@ int npdu_decode(
|
|||||||
// 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)
|
||||||
{
|
{
|
||||||
len += decode_unsigned16(&npdu[len], &src->net);
|
if (npdu[1] & BIT3)
|
||||||
// SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
|
|
||||||
// SLEN > 0 specifies length of SADR field
|
|
||||||
src->len = npdu[len++];
|
|
||||||
if (src->len)
|
|
||||||
{
|
{
|
||||||
for (i = 0; i < src->len; i++)
|
len += decode_unsigned16(&npdu[len], &src->net);
|
||||||
|
// SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
|
||||||
|
// SLEN > 0 specifies length of SADR field
|
||||||
|
src->len = npdu[len++];
|
||||||
|
if (src->len)
|
||||||
{
|
{
|
||||||
src->adr[i] = npdu[len++];
|
for (i = 0; i < src->len; i++)
|
||||||
|
{
|
||||||
|
src->adr[i] = npdu[len++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
src->net = 0;
|
||||||
|
src->len = 0;
|
||||||
|
for (i = 0; i < MAX_MAC_LEN; i++)
|
||||||
|
{
|
||||||
|
src->adr[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,6 +273,8 @@ int npdu_decode(
|
|||||||
// 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