Example #1
0
 private void FillDataIndexes()
 {
     if (IsMulticast)
     {
         ListReference lRef = (ListReference)Destination.Item;
         lRef.IndexOfSize = new DataIndex();
         ProcessHeader(lRef.IndexOfSize, lRef.SizeRef);
         lRef.Index = new DataIndex();
         ProcessHeader(lRef.Index, lRef.Ref);
     }
     else
     {
         ItemReference iRef = (ItemReference)Destination.Item;
         iRef.Index = new DataIndex();
         ProcessHeader(iRef.Index, iRef.Ref);
     }
     if (IsRouted)
     {
         Hops.Index = new DataIndex();
         ProcessHeader(Hops.Index, Hops.Ref);
         Repeaters.IndexOfSize = new DataIndex();
         ProcessHeader(Repeaters.IndexOfSize, Repeaters.SizeRef);
         Repeaters.Index = new DataIndex();
         ProcessHeader(Repeaters.Index, Repeaters.Ref);
     }
 }
Example #2
0
 public byte[] GetDestination(byte[] store, int dataLength)
 {
     byte[] ret = null;
     if (IsMulticast)
     {
         ListReference lref = (ListReference)Destination.Item;
         int           len  = (store[lref.IndexOfSize.IndexInData] & lref.IndexOfSize.MaskInData) >> lref.IndexOfSize.OffsetInData;
         if (len > 0 && dataLength > len + lref.Index.IndexInData)
         {
             IList <byte> tmp     = new List <byte>();
             byte         nodeIdx = 0;
             for (int i = 0; i < len; i++)
             {
                 byte availabilityMask = store[lref.Index.IndexInData + i];
                 for (byte bit = 0; bit < 8; bit++)
                 {
                     nodeIdx++;
                     if ((availabilityMask & (1 << bit)) > 0)
                     {
                         tmp.Add(nodeIdx);
                     }
                 }
             }
             if (tmp.Count > 0)
             {
                 ret = tmp.ToArray();
             }
         }
     }
     else
     {
         ItemReference iref = (ItemReference)Destination.Item;
         ret    = new byte[1];
         ret[0] = store[iref.Index.IndexInData];
     }
     return(ret);
 }
Example #3
0
        private static byte GetLength(byte[] store, Param param)
        {
            int ret = 0;

            if (param.ItemRef != null)
            {
                ItemReference iref = param.ItemRef;
                if (iref.IndexOfOpt == null ||
                    iref.IndexOfOpt != null && (store[iref.IndexOfOpt.IndexInData] & iref.IndexOfOpt.MaskInData) >> iref.IndexOfOpt.OffsetInData > 0)
                {
                    int bCount = param.Bits / 8 * (param.Size > 0 ? param.Size : 1);
                    if (bCount >= 0)
                    {
                        ret += iref.Index.IndexInData + bCount;
                    }
                }
                else
                {
                    ret += iref.Index.IndexInData;
                }
            }
            else
            {
                ListReference lref = param.ListRef;
                if (lref.IndexOfOpt == null ||
                    lref.IndexOfOpt != null && (store[lref.IndexOfOpt.IndexInData] & lref.IndexOfOpt.MaskInData) >> lref.IndexOfOpt.OffsetInData > 0)
                {
                    if (param.PreviousVariableParam != null)
                    {
                        byte prevLen = (byte)(GetLength(store, param.PreviousVariableParam) + lref.Index.IndexInData);
                        if (store.Length > prevLen - 1 + lref.IndexOfSize.IndexInData)
                        {
                            int len = (store[prevLen - 1 + lref.IndexOfSize.IndexInData] & lref.IndexOfSize.MaskInData) >> lref.IndexOfSize.OffsetInData;
                            if (len >= 0)
                            {
                                int bCount = param.Bits / 8 * len + (param.SizeCorrectionSpecified ? param.SizeCorrection : 0);
                                if (bCount >= 0)
                                {
                                    ret += lref.Index.IndexInData + bCount;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (store.Length > lref.IndexOfSize.IndexInData)
                        {
                            int len = (store[lref.IndexOfSize.IndexInData] & lref.IndexOfSize.MaskInData) >> lref.IndexOfSize.OffsetInData;
                            if (len >= 0)
                            {
                                int bCount = param.Bits / 8 * len + (param.SizeCorrectionSpecified ? param.SizeCorrection : 0);
                                if (bCount >= 0)
                                {
                                    ret += lref.Index.IndexInData + bCount;
                                }
                            }
                        }
                    }
                }
                else
                {
                    ret += lref.Index.IndexInData;
                }
            }
            if (param.PreviousVariableParam != null)
            {
                ret += GetLength(store, param.PreviousVariableParam);
            }
            if (ret < 0 || ret > 0xFF)
            {
                ret = 0;
            }
            return((byte)ret);
        }