diff --git a/py25/bacpypes/bvllservice.py b/py25/bacpypes/bvllservice.py index 5713976c..42b87b26 100755 --- a/py25/bacpypes/bvllservice.py +++ b/py25/bacpypes/bvllservice.py @@ -72,10 +72,15 @@ def __init__(self, addr=None, noBroadcast=False): else: self.address = Address(addr) - # check for a special broadcast address + # promote the normal and broadcast tuples self.addrTuple = self.address.addrTuple self.addrBroadcastTuple = self.address.addrBroadcastTuple - if (self.addrTuple == self.addrBroadcastTuple): + + # check for no broadcasting (loopback interface) + if not self.addrBroadcastTuple: + noBroadcast = True + elif (self.addrTuple == self.addrBroadcastTuple): + # old school broadcast address self.addrBroadcastTuple = ('255.255.255.255', self.addrTuple[1]) else: specialBroadcast = True @@ -117,9 +122,15 @@ def indication(self, server, pdu): if pdu.pduDestination.addrType == Address.localBroadcastAddr: dest = self.addrBroadcastTuple if _debug: UDPMultiplexer._debug(" - requesting local broadcast: %r", dest) + + # interface might not support broadcasts + if not dest: + return + elif pdu.pduDestination.addrType == Address.localStationAddr: dest = unpack_ip_addr(pdu.pduDestination.addrAddr) if _debug: UDPMultiplexer._debug(" - requesting local station: %r", dest) + else: raise RuntimeError("invalid destination address type") diff --git a/py27/bacpypes/bvllservice.py b/py27/bacpypes/bvllservice.py index 8fc67fce..f4b6006c 100755 --- a/py27/bacpypes/bvllservice.py +++ b/py27/bacpypes/bvllservice.py @@ -73,10 +73,15 @@ def __init__(self, addr=None, noBroadcast=False): else: self.address = Address(addr) - # check for a special broadcast address + # promote the normal and broadcast tuples self.addrTuple = self.address.addrTuple self.addrBroadcastTuple = self.address.addrBroadcastTuple - if (self.addrTuple == self.addrBroadcastTuple): + + # check for no broadcasting (loopback interface) + if not self.addrBroadcastTuple: + noBroadcast = True + elif (self.addrTuple == self.addrBroadcastTuple): + # old school broadcast address self.addrBroadcastTuple = ('255.255.255.255', self.addrTuple[1]) else: specialBroadcast = True @@ -118,9 +123,15 @@ def indication(self, server, pdu): if pdu.pduDestination.addrType == Address.localBroadcastAddr: dest = self.addrBroadcastTuple if _debug: UDPMultiplexer._debug(" - requesting local broadcast: %r", dest) + + # interface might not support broadcasts + if not dest: + return + elif pdu.pduDestination.addrType == Address.localStationAddr: dest = unpack_ip_addr(pdu.pduDestination.addrAddr) if _debug: UDPMultiplexer._debug(" - requesting local station: %r", dest) + else: raise RuntimeError("invalid destination address type") diff --git a/py34/bacpypes/bvllservice.py b/py34/bacpypes/bvllservice.py index 087b88df..ca1903db 100755 --- a/py34/bacpypes/bvllservice.py +++ b/py34/bacpypes/bvllservice.py @@ -73,10 +73,15 @@ def __init__(self, addr=None, noBroadcast=False): else: self.address = Address(addr) - # check for a special broadcast address + # promote the normal and broadcast tuples self.addrTuple = self.address.addrTuple self.addrBroadcastTuple = self.address.addrBroadcastTuple - if (self.addrTuple == self.addrBroadcastTuple): + + # check for no broadcasting (loopback interface) + if not self.addrBroadcastTuple: + noBroadcast = True + elif (self.addrTuple == self.addrBroadcastTuple): + # old school broadcast address self.addrBroadcastTuple = ('255.255.255.255', self.addrTuple[1]) else: specialBroadcast = True @@ -98,6 +103,7 @@ def __init__(self, addr=None, noBroadcast=False): bind(self.direct, self.broadcastPort) else: self.broadcast = None + # create and bind the Annex H and J servers self.annexH = _MultiplexServer(self) self.annexJ = _MultiplexServer(self) @@ -117,9 +123,15 @@ def indication(self, server, pdu): if pdu.pduDestination.addrType == Address.localBroadcastAddr: dest = self.addrBroadcastTuple if _debug: UDPMultiplexer._debug(" - requesting local broadcast: %r", dest) + + # interface might not support broadcasts + if not dest: + return + elif pdu.pduDestination.addrType == Address.localStationAddr: dest = pdu.pduDestination.addrTuple if _debug: UDPMultiplexer._debug(" - requesting local station: %r", dest) + else: raise RuntimeError("invalid destination address type")