public void Decode(byte[] buffer, ref int pos) { networkNumber = (uint)buffer[pos++] << 8; networkNumber |= buffer[pos++]; MACaddress.length = buffer[pos++]; switch (MACaddress.length) { case 0: // indicates a broadcast, perfectly legal. break; case 1: MACaddress.uintMACaddress = buffer[pos++]; break; case 6: // extract the IP address myIPEndPoint ipep = new myIPEndPoint(); ipep.Decode(buffer, pos); MACaddress.ipMACaddress = ipep; pos += 6; break; default: BACnetLibraryCL.Panic("Illegal MAC address length??"); break; } }
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"); } }
public bool Equals(myIPEndPoint ep) { if (!this.Address.Equals(ep.Address)) { return(false); } if (!this.Port.Equals(ep.Port)) { return(false); } return(true); }
public DADR(UInt16 networkNumber, myIPEndPoint ipep) : base(networkNumber, ipep) { // todo if (networkNumber == 0) throw new Exception("m0160-Network Number of 0 is illegal"); //this.networkNumber = networkNumber; //this.MACaddress = new BACnetMACaddress(ipep); if (networkNumber == 0xffff) { isLocalBroadcast = false; isRemoteBroadcast = false; isBroadcast = true; } }
public ADR(uint networkNumber, myIPEndPoint ipep) { this.networkNumber = networkNumber; if (networkNumber == 0) { // we can argue whether a network number of 0 indicates directly connected or not later... for now we will // assume no network number == directly connected directlyConnected = true; } this.MACaddress = new MACaddress(ipep); }
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; } }
public DADR(BACnetManager bnm, BACnetPacket.ADDRESS_TYPE adrtyp, UInt16 networkNumber) { switch (adrtyp) { case BACnetPacket.ADDRESS_TYPE.REMOTE_BROADCAST: isBroadcast = true; viaIPEP = new myIPEndPoint(IPAddress.Broadcast, bnm.insideSocket.ourSocketPort); this.networkNumber = networkNumber; break; case BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST: case BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST: throw new Exception("m0169-cannot use this constructor for this"); default: throw new Exception("m0168-Bad parameter"); } }
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??"); } }
public BACnetMACaddress(myIPEndPoint madr) { mat = MACaddrType.IPEP; length = 6; ipMACaddress = madr; }
public ADR(myIPEndPoint ipep) { // if there is _only_ an ipep, then this has to be directly connected. directlyConnected = true; this.MACaddress = new BACnetMACaddress(ipep); }
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); }
public Device(UInt16 networkNumber, myIPEndPoint mac) { adr = new ADR(networkNumber, mac); }
public MACaddress(myIPEndPoint madr) { length = 6; ipMACaddress = madr; }