Esempio n. 1
0
        public DADR(BACnetManager bnm, BACnetPacket.ADDRESS_TYPE adrtyp)
        {
            switch (adrtyp)
            {
            case BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST:
                isBroadcast      = true;
                isLocalBroadcast = true;
                viaIPEP          = new myIPEndPoint(IPAddress.Broadcast, bnm.insideSocket.ourSocketPort);
                break;

            case BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST:
                this.networkNumber = 0xffff;
                isBroadcast        = true;
                isLocalBroadcast   = false;
                isRemoteBroadcast  = false;
                MACaddress         = new BACnetMACaddress();
                break;

            case BACnetPacket.ADDRESS_TYPE.REMOTE_BROADCAST:
                isRemoteBroadcast = true;
                isLocalBroadcast  = false;
                throw new Exception("m0167-A remote broadcast requires an IP address, network number, cannot use this constructor for this");

            default:
                throw new Exception("m0508-Bad parameter");
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 3
0
        public DADR(BACnetPacket.ADDRESS_TYPE adrtyp)
        {
            switch (adrtyp)
            {
            case BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST:
                throw new Exception("m0509-A local broadcast requires an IP address, network number, cannot use this constructor for this");

            case BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST:
                this.networkNumber = 0xffff;
                isBroadcast        = true;
                isLocalBroadcast   = false;
                isRemoteBroadcast  = false;
                MACaddress         = new BACnetMACaddress();
                break;

            case BACnetPacket.ADDRESS_TYPE.REMOTE_BROADCAST:
                throw new Exception("m0203-A remote broadcast requires an IP address, network number, cannot use this constructor for this");

            default:
                throw new Exception("m0204-Bad parameter");
            }
        }
Esempio n. 4
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??");
            }
        }
Esempio n. 5
0
 public ADR(myIPEndPoint ipep)
 {
     // if there is _only_ an ipep, then this has to be directly connected.
     directlyConnected = true;
     this.MACaddress   = new BACnetMACaddress(ipep);
 }
Esempio n. 6
0
 public ADR(UInt16 networkNumber, myIPEndPoint ipep)
 {
     // todo if (networkNumber == 0) throw new Exception("m0507-Network Number of 0 is illegal");
     this.networkNumber = networkNumber;
     this.MACaddress    = new BACnetMACaddress(ipep);
 }
Esempio n. 7
0
 public ADR(UInt16 networkNumber, string MACaddr)
 {
     MACaddress         = new BACnetMACaddress(MACaddr);
     this.networkNumber = networkNumber;
 }