Ejemplo n.º 1
0
    def __init__(self, localAddress, eID=None):
        if _debug:
            BIPNetworkApplication._debug("__init__ %r eID=%r", localAddress,
                                         eID)
        NetworkServiceElement.__init__(self, eID)

        # allow the address to be cast to the correct type
        if isinstance(localAddress, Address):
            self.localAddress = localAddress
        else:
            self.localAddress = Address(localAddress)

        # a network service access point will be needed
        self.nsap = NetworkServiceAccessPoint()

        # give the NSAP a generic network layer service element
        bind(self, self.nsap)

        # create a generic BIP stack, bound to the Annex J server
        # on the UDP multiplexer
        self.bip = BIPSimple()
        self.annexj = AnnexJCodec()
        self.mux = UDPMultiplexer(self.localAddress)

        # bind the bottom layers
        bind(self.bip, self.annexj, self.mux.annexJ)

        # bind the NSAP to the stack, no network number
        self.nsap.bind(self.bip)
Ejemplo n.º 2
0
    def __init__(self, localAddress, eID=None):
        if _debug: BIPNetworkApplication._debug("__init__ %r eID=%r", localAddress, eID)
        NetworkServiceElement.__init__(self, eID)

        # allow the address to be cast to the correct type
        if isinstance(localAddress, Address):
            self.localAddress = localAddress
        else:
            self.localAddress = Address(localAddress)

        # a network service access point will be needed
        self.nsap = NetworkServiceAccessPoint()

        # give the NSAP a generic network layer service element
        bind(self, self.nsap)

        # create a generic BIP stack, bound to the Annex J server
        # on the UDP multiplexer
        self.bip = BIPSimple()
        self.annexj = AnnexJCodec()
        self.mux = UDPMultiplexer(self.localAddress)

        # bind the bottom layers
        bind(self.bip, self.annexj, self.mux.annexJ)

        # bind the NSAP to the stack, no network number
        self.nsap.bind(self.bip)
Ejemplo n.º 3
0
    def __init__(self, addr=None, noBroadcast=False):
        if _debug:
            UDPMultiplexer._debug("__init__ %r noBroadcast=%r", addr,
                                  noBroadcast)

        # check for some options
        specialBroadcast = False
        if addr is None:
            self.address = Address()
            self.addrTuple = ('', 47808)
            self.addrBroadcastTuple = ('255.255.255.255', 47808)
        else:
            # allow the address to be cast
            if isinstance(addr, Address):
                self.address = addr
            else:
                self.address = Address(addr)

            # check for a special broadcast address
            self.addrTuple = self.address.addrTuple
            self.addrBroadcastTuple = self.address.addrBroadcastTuple
            if (self.addrTuple == self.addrBroadcastTuple):
                self.addrBroadcastTuple = ('255.255.255.255',
                                           self.addrTuple[1])
            else:
                specialBroadcast = True

        if _debug:
            UDPMultiplexer._debug("    - address: %r", self.address)
            UDPMultiplexer._debug("    - addrTuple: %r", self.addrTuple)
            UDPMultiplexer._debug("    - addrBroadcastTuple: %r",
                                  self.addrBroadcastTuple)

        # create and bind the direct address
        self.direct = _MultiplexClient(self)
        self.directPort = udp.UDPDirector(self.addrTuple)
        bind(self.direct, self.directPort)

        # create and bind the broadcast address
        if specialBroadcast and (not noBroadcast):
            self.broadcast = _MultiplexClient(self)
            self.broadcastPort = udp.UDPDirector(self.addrBroadcastTuple,
                                                 reuse=True)
            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)
Ejemplo n.º 4
0
    def __init__(self, addr=None, noBroadcast=False):
        if _debug: UDPMultiplexer._debug("__init__ %r noBroadcast=%r", addr, noBroadcast)

        # check for some options
        specialBroadcast = False
        if addr is None:
            self.address = Address()
            self.addrTuple = ('', 47808)
            self.addrBroadcastTuple = ('255.255.255.255', 47808)
        else:
            # allow the address to be cast
            if isinstance(addr, Address):
                self.address = addr
            else:
                self.address = Address(addr)

            # check for a special broadcast address
            self.addrTuple = self.address.addrTuple
            self.addrBroadcastTuple = self.address.addrBroadcastTuple
            if (self.addrTuple == self.addrBroadcastTuple):
                self.addrBroadcastTuple = ('255.255.255.255', self.addrTuple[1])
            else:
                specialBroadcast = True

        if _debug:
            UDPMultiplexer._debug("    - address: %r", self.address)
            UDPMultiplexer._debug("    - addrTuple: %r", self.addrTuple)
            UDPMultiplexer._debug("    - addrBroadcastTuple: %r", self.addrBroadcastTuple)

        # create and bind the direct address
        self.direct = _MultiplexClient(self)
        self.directPort = udp.UDPDirector(self.addrTuple)
        bind(self.direct, self.directPort)

        # create and bind the broadcast address
        if specialBroadcast and (not noBroadcast):
            self.broadcast = _MultiplexClient(self)
            self.broadcastPort = udp.UDPDirector(self.addrBroadcastTuple, reuse=True)
            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)
Ejemplo n.º 5
0
    def bind(self, server, net=None, address=None):
        """Create a network adapter object and bind."""
        if _debug:
            NetworkServiceAccessPoint._debug("bind %r net=%r address=%r",
                                             server, net, address)

        if (net is None) and self.adapters:
            raise RuntimeError, "already bound"

        # create an adapter object
        adapter = NetworkAdapter(self, net)

        # if the address was given, make it the "local" one
        if address:
            self.localAdapter = adapter
            self.localAddress = address

        # bind to the server
        bind(adapter, server)
Ejemplo n.º 6
0
    def __init__(self):
        if _debug: TCPClientMultiplexer._debug("__init__")
        Client.__init__(self)

        # create and bind
        self.director = TCPClientDirector()
        bind(self, _StreamToPacket(), self.director)

        # create an application service element and bind
        self.ase = TCPMultiplexerASE(self)
        bind(self.ase, self.director)

        # keep a dictionary of connections
        self.connections = {}

        # no services available until they are created, they are
        # instances of ServiceAdapter
        self.deviceToDeviceService = None
        self.routerToRouterService = None
        self.proxyService = None
        self.laneService = None
Ejemplo n.º 7
0
    def __init__(self, localDevice, localAddress, aseID=None):
        if _debug: BIPSimpleApplication._debug("__init__ %r %r aseID=%r", localDevice, localAddress, aseID)
        Application.__init__(self, localDevice, localAddress, aseID)

        # include a application decoder
        self.asap = ApplicationServiceAccessPoint()

        # pass the device object to the state machine access point so it
        # can know if it should support segmentation
        self.smap = StateMachineAccessPoint(localDevice)

        # a network service access point will be needed
        self.nsap = NetworkServiceAccessPoint()

        # give the NSAP a generic network layer service element
        self.nse = NetworkServiceElement()
        bind(self.nse, self.nsap)

        # bind the top layers
        bind(self, self.asap, self.smap, self.nsap)

        # create a generic BIP stack, bound to the Annex J server
        # on the UDP multiplexer
        self.bip = BIPSimple()
        self.annexj = AnnexJCodec()
        self.mux = UDPMultiplexer(self.localAddress)

        # bind the bottom layers
        bind(self.bip, self.annexj, self.mux.annexJ)

        # bind the BIP stack to the network, no network number
        self.nsap.bind(self.bip)
Ejemplo n.º 8
0
    def __init__(self, localDevice, localAddress, aseID=None):
        if _debug:
            BIPSimpleApplication._debug("__init__ %r %r aseID=%r", localDevice,
                                        localAddress, aseID)
        Application.__init__(self, localDevice, localAddress, aseID)

        # include a application decoder
        self.asap = ApplicationServiceAccessPoint()

        # pass the device object to the state machine access point so it
        # can know if it should support segmentation
        self.smap = StateMachineAccessPoint(localDevice)

        # a network service access point will be needed
        self.nsap = NetworkServiceAccessPoint()

        # give the NSAP a generic network layer service element
        self.nse = NetworkServiceElement()
        bind(self.nse, self.nsap)

        # bind the top layers
        bind(self, self.asap, self.smap, self.nsap)

        # create a generic BIP stack, bound to the Annex J server
        # on the UDP multiplexer
        self.bip = BIPSimple()
        self.annexj = AnnexJCodec()
        self.mux = UDPMultiplexer(self.localAddress)

        # bind the bottom layers
        bind(self.bip, self.annexj, self.mux.annexJ)

        # bind the BIP stack to the network, no network number
        self.nsap.bind(self.bip)
Ejemplo n.º 9
0
    def __init__(self, addr=None):
        if _debug: TCPServerMultiplexer._debug("__init__ %r", addr)
        Client.__init__(self)

        # check for some options
        if addr is None:
            self.address = Address()
            self.addrTuple = ('', 47808)
        else:
            # allow the address to be cast
            if isinstance(addr, Address):
                self.address = addr
            else:
                self.address = Address(addr)

            # extract the tuple for binding
            self.addrTuple = self.address.addrTuple

        if _debug:
            TCPServerMultiplexer._debug("    - address: %r", self.address)
            TCPServerMultiplexer._debug("    - addrTuple: %r", self.addrTuple)

        # create and bind
        self.director = TCPServerDirector(self.addrTuple)
        bind(self, _StreamToPacket(), self.director)

        # create an application service element and bind
        self.ase = TCPMultiplexerASE(self)
        bind(self.ase, self.director)

        # keep a dictionary of connections
        self.connections = {}

        # no services available until they are created, they are
        # instances of ServiceAdapter
        self.deviceToDeviceService = None
        self.routerToRouterService = None
        self.proxyService = None
        self.laneService = None