Example #1
0
    def setUpClass(cls):
        # open logger
        setup_logging("L2TP")
        setup_test_redis()

        cls.conn_address = '127.0.0.1'
        global_dispatcher = Dispatcher()
        dispatcher = L2tpv3Dispatcher(
            global_dispatcher, cls.conn_address, False, None)
        L2tpv3GlobalSettings.Dispatcher = dispatcher
        # setup the halclient

        notification_list = list()
        notification_list.append(
            HalConfigMsg.MsgTypeL2tpv3SessionStatusNotification)

        cls.hal_client = L2tpHalClient("L2TP_HAL_CLIENT",
                                       "the HAL client of L2TP feature",
                                       "1.0", tuple(L2tpHalClient.notification_list.keys()), global_dispatcher)

        cls.hal_client.handler = dispatcher.receive_hal_message
        cls.conn = L2tpConnection(
            6661, 6662, cls.conn_address, cls.conn_address)
        cls.session = L2tpv3Session(6661, 6662, 'receiver', cls.conn)
        cls.conn.addSession(cls.session)
        localSessionId = L2tpv3RFC3931AVPs.LocalSessionID(6661)
        remoteSessionId = L2tpv3RFC3931AVPs.RemoteSessionID(6662)
        remoteEnd = L2tpv3RFC3931AVPs.RemoteEndID(
            (((0, 3, 0), 0), ((0, 3, 1), 1), ((0, 3, 2), 2)))
        remoteEnd_1 = L2tpv3RFC3931AVPs.RemoteEndID(
            (((0, 3, 3), 3), ((0, 3, 4), 4), ((0, 3, 5), 5)))
        pw_type = L2tpv3RFC3931AVPs.L2SpecificSublayer(3)
        DepiL2SpecificSublayerSubtype = L2tpv3CableLabsAvps.DepiL2SpecificSublayerSubtype(3)
        LocalMTUCableLabs = L2tpv3CableLabsAvps.LocalMTUCableLabs(1500)
        DepiRemoteMulticastJoin = L2tpv3CableLabsAvps.DepiRemoteMulticastJoin(("5.5.5.1", "229.1.1.255"))
        DepiResourceAllocReq = L2tpv3CableLabsAvps.DepiResourceAllocReq(((0, 1), (1, 2)))
        UpstreamFlow = L2tpv3CableLabsAvps.UpstreamFlow(((0, 1), (1, 2)))

        cls.session.avps_icrq.append(localSessionId)
        cls.session.avps_icrq.append(remoteSessionId)
        cls.session.avps_icrq.append(remoteEnd)
        cls.session.avps_icrq.append(remoteEnd_1)
        cls.session.avps_icrq.append(DepiL2SpecificSublayerSubtype)
        cls.session.avps_icrq.append(LocalMTUCableLabs)
        cls.session.avps_icrq.append(pw_type)
        cls.session.avps_icrq.append(DepiRemoteMulticastJoin)
        cls.session.avps_icrq.append(DepiResourceAllocReq)
        cls.session.avps_icrq.append(UpstreamFlow)
Example #2
0
    def setUpClass(cls):
        setupDB()
        time.sleep(2)

        HalGlobal.gClientMgr = None
        HalGlobal.gPoller = None
        t = threading.Thread(target=demoHalmain)
        t.daemon = True
        t.start()
        time.sleep(2)
        threads_list.append(t)
        if not HalGlobal.gClientMgr or not HalGlobal.gPoller:
            raise Exception("Cannot start the demo halMain")
        t = threading.Thread(target=demoL2tp)
        t.daemon = True
        t.start()
        time.sleep(2)
        threads_list.append(t)
        t = threading.Thread(target=demoDrvmain)
        t.daemon = True
        t.start()
        threads_list.append(t)
        time.sleep(2)

        setup_logging('HAL', filename="hal.log", logging_level=logging.DEBUG)
        cls.logger = logging.getLogger("L2tpHalDrvVspAvpTest")
        cls.logger.info("hello L2tpHalDrvVspAvpTest Log")

        cls.stop = False
        cls.conn_address = '127.0.0.1'
        # Setup connection/session: set it here since global variables are already only after threads are up.
        cls.dispatcher = L2tpv3GlobalSettings.Dispatcher
        cls.hal_client = L2tpv3GlobalSettings.l2tp_hal_client
        # cls.conn = L2tpConnection.L2tpConnection(
        #    6661, 6662, cls.conn_address, cls.conn_address)
        #cls.session = L2tpv3Session.L2tpv3Session(6661, 6662, 'receiver',cls.conn)
        # cls.conn.addSession(cls.session)
        localSessionId = L2tpv3RFC3931AVPs.LocalSessionID(6661)
        remoteSessionId = L2tpv3RFC3931AVPs.RemoteSessionID(6662)
        remoteEnd = L2tpv3RFC3931AVPs.RemoteEndID(
            (((0, 3, 0), 0), ((0, 3, 1), 1), ((0, 3, 2), 2)))
        remoteEnd_1 = L2tpv3RFC3931AVPs.RemoteEndID(
            (((0, 3, 3), 3), ((0, 3, 4), 4), ((0, 3, 5), 5)))
        pw_type = L2tpv3RFC3931AVPs.L2SpecificSublayer(3)
        DepiL2SpecificSublayerSubtype = L2tpv3CableLabsAvps.DepiL2SpecificSublayerSubtype(
            3)
        LocalMTUCableLabs = L2tpv3CableLabsAvps.LocalMTUCableLabs(1500)

        cls.avps_icrq = []
        cls.avps_icrq.append(localSessionId)
        cls.avps_icrq.append(remoteSessionId)
        cls.avps_icrq.append(remoteEnd)
        cls.avps_icrq.append(remoteEnd_1)
        cls.avps_icrq.append(DepiL2SpecificSublayerSubtype)
        cls.avps_icrq.append(LocalMTUCableLabs)
        cls.avps_icrq.append(pw_type)

        cls.icrq_buf = struct.pack(
            '!206B',
            0xc8,
            0x03,
            0x0,
            206,
            0x0,
            0x0,
            0x0,
            0x0,
            0x0,
            0x3,
            0x0,
            0x4,
            0xc,
            8,
            0x0,
            0x0,
            0x0,
            0x0,
            0x0,
            10,
            0xc,
            10,
            0x0,
            0x0,
            0,
            15,
            0,
            0,
            0,
            0,
            0xc,
            10,
            0x0,
            0x0,
            0,
            63,
            0x40,
            0x01,
            0x00,
            0x01,
            0xc,
            10,
            0x0,
            0x0,
            0,
            64,
            0x0,
            0x0,
            0x0,
            0x0,
            0xc,
            40,
            0x0,
            0x0,
            0x0,
            66,
            0x0,
            0x0,
            0x00,
            0x03,
            0x00,
            0x00,
            0x00,
            0x03,
            0x01,
            0x01,
            0x00,
            0x03,
            0x02,
            0x02,
            0x00,
            0x03,
            0x03,
            0x03,
            0x00,
            0x03,
            0x04,
            0x04,
            0x00,
            0x03,
            0x05,
            0x05,
            0x00,
            0x03,
            0x06,
            0x06,
            0x00,
            0x03,
            0x07,
            0x07,
            0xc,
            8,
            0,
            0,
            0,
            68,
            0,
            12,
            0xc,
            8,
            0,
            0,
            0,
            69,
            0,
            3,
            0xc,
            8,
            0,
            0,
            0,
            71,
            0,
            2,
            0xc,
            8,
            0x11,
            0x8b,
            0x0,
            0x2,
            0x1,
            0x0,
            0xc,
            8,
            0x11,
            0x8b,
            0x0,
            0x4,
            0x7,
            0xD0,
            0xc,
            20,
            0x11,
            0x8b,
            0x0,
            15,
            0x0,
            0x1,
            0x0,
            0x2,
            0x0,
            0x3,
            0x0,
            0x6,
            0x0,
            0x8,
            0x0,
            11,
            0x0,
            13,
            0xc,
            8,
            0x11,
            0x8b,
            0x0,
            16,
            0x0,
            0x3,
            0xc,
            8,
            0x11,
            0x8b,
            0x0,
            17,
            0x0,
            0x3,
            0xc,
            40,
            0x11,
            0x8b,
            0x0,
            11,
            0,
            0,
            0x5,
            0x6,
            0x7,
            0x8,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            229,
            1,
            1,
            255,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
        )