예제 #1
0
 public bool Decode(byte[] buf, ref int iptr)
 {
     networkNumber = BACnetUtil.ExtractUInt16(buf, ref iptr);
     portID        = buf[iptr++];
     portInfoLen   = buf[iptr++];
     if (portInfoLen != 0)
     {
         // we are not ready to handle this.
         throw new Exception("m0154-Cannot deal with portInfoLen > 0");
     }
     iptr += (int)portInfoLen;
     return(true);
 }
예제 #2
0
        public void Decode(byte[] buffer, ref int pos)
        {
            networkNumber = BACnetUtil.ExtractUInt16(buffer, ref pos);

            if (networkNumber == 0)
            {
                throw new Exception("m0205-Illegal network number of 0 in decode");
            }

            switch (buffer[pos++])
            {
            case 0:
                // indicates a remote, or possibly a global, broadcast, perfectly legal.
                isBroadcast      = true;
                isLocalBroadcast = false;
                if (networkNumber != 0xffff)
                {
                    isRemoteBroadcast = true;
                }
                else
                {
                    // a remote b'cast with a dest network number is a global broadcast
                    isRemoteBroadcast = false;
                }
                break;

            case 1:
                MACaddress = new BACnetMACaddress(buffer[pos++]);
                //MACaddress.length = buffer[pos++];
                //MACaddress.uintMACaddress = buffer[pos++];
                break;

            case 6:
                // extract the IP address
                myIPEndPoint ipep = new myIPEndPoint();
                ipep.Decode(buffer, ref pos);
                MACaddress = new BACnetMACaddress(ipep);
                //MACaddress.ipMACaddress = ipep;
                // pos += 6;
                break;

            default:
                throw new Exception("m0178-Illegal MAC address length??");
                //break;
            }
        }
예제 #3
0
        public virtual void Decode(byte[] buffer, ref int pos, bool tolerate0NN)
        {
            networkNumber = BACnetUtil.ExtractUInt16(buffer, ref pos);

            if (!tolerate0NN && networkNumber == 0)
            {
                throw new Exception("m0161-Illegal network number of 0 in decode");

                // So there is at least one router out there that includes a 0 in the NN part of the SADR when sending a who-is-router. This is benign, because routers
                // broadcast their i-am routers. In any event FOR NOW, tolerate this transgression or else comms will not happen on these networks.
                // but we do need to find a cleaner way of dealing with this!!
            }


            switch (buffer[pos++])
            {
            case 0:
                // illegal for sadr
                throw new Exception("m0506-MAC length of 0 illegal for SADR");

            // break;
            case 1:
                MACaddress = new BACnetMACaddress(buffer[pos++]);
                break;

            case 6:
                // extract the IP address
                myIPEndPoint ipep = new myIPEndPoint();
                ipep.Decode(buffer, ref pos);
                MACaddress = new BACnetMACaddress(ipep);
                //MACaddress.ipMACaddress = ipep;
                break;

            default:
                throw new Exception("m0178-Illegal MAC address length??");
            }
        }