Exemplo n.º 1
0
    def test_lcceID_good_recvCfgMsgRspCb(self):
        self.conn.fsm.recvGoodSCCRQ()
        self.conn.fsm.recvGoodSCCCN()
        rsp = L2tpv3Hal_pb2.t_l2tpLcceAssignmentRsp()
        rsp.lcce_id = self.conn.localConnID
        rsp.lcce_info.local_ip = "10.79.41.138"
        rsp.lcce_info.remote_ip = "10.79.41.139"
        rsp.lcce_info.local_mac = L2tpHalClient.get_mac_of_ip(rsp.lcce_info.local_ip)
        rsp.lcce_info.remote_mac = L2tpHalClient.get_mac_of_ip(rsp.lcce_info.remote_ip)
        rsp.lcce_info.mtu = 2342
        rsp.result = True
        payload = rsp.SerializeToString()
        msg = HalMessage("HalConfigRsp", SrcClientID="123", SeqNum=3,
                         Rsp={
                             "Status": HalCommon_pb2.SUCCESS,
                             "ErrorDescription": ""
                         },
                         CfgMsgType=HalConfigMsg.MsgTypeL2tpv3LcceIdAssignment,
                         CfgMsgPayload=payload)
        ret = self.hal_client.recvCfgMsgRspCb(msg)
        self.assertTrue(ret)

        # case exception
        self.hal_client.handler = None
        try:
            ret = self.hal_client.recvCfgMsgRspCb(msg)
            self.hal_client.handler = L2tpv3GlobalSettings.Dispatcher.receive_hal_message
        except L2tpHalClientError as e:
            pass
Exemplo n.º 2
0
    def test_lcceId_bad_recvCfgMsgRspCb_NOTSUUPPORT(self):
        self.conn.fsm.recvGoodSCCRQ()
        self.conn.fsm.recvGoodSCCCN()
        rsp = L2tpv3Hal_pb2.t_l2tpLcceAssignmentReq()
        rsp.lcce_id = self.conn.localConnID
        rsp.lcce_info.local_ip = "10.79.41.138"
        rsp.lcce_info.remote_ip = "10.79.41.139"
        rsp.lcce_info.local_mac = L2tpHalClient.get_mac_of_ip(rsp.lcce_info.local_ip)
        rsp.lcce_info.remote_mac = L2tpHalClient.get_mac_of_ip(rsp.lcce_info.remote_ip)
        rsp.lcce_info.mtu = 2342
        rsp.msg_type = L2tpv3Hal_pb2.t_l2tpLcceAssignmentReq.ADD_L2TPv3_LCCE
        payload = rsp.SerializeToString()
        msg = HalMessage("HalConfigRsp", SrcClientID="123", SeqNum=3,
                         Rsp={
                             "Status": HalCommon_pb2.NOTSUPPORTED,
                             "ErrorDescription": ""
                         },
                         CfgMsgType=HalConfigMsg.MsgTypeL2tpv3LcceIdAssignment,
                         CfgMsgPayload=payload)
        ret = self.hal_client.recvCfgMsgRspCb(msg)
        self.assertFalse(ret)

        # case exception
        fake_msg = HalMessage("HalClientRegisterRsp",
                              Rsp={
                                  "Status": HalCommon_pb2.NOTSUPPORTED,
                                  "ErrorDescription": ""
                              },
                              ClientID="214")
        ret = self.hal_client.recvCfgMsgRspCb(cfg=fake_msg)
        self.assertFalse(ret)
Exemplo n.º 3
0
 def test_get_mac_of_ip(self):
     ipaddr = "127.0.0.1"
     ret = L2tpHalClient.get_mac_of_ip(ipaddr)
     self.assertEqual(ret, "00:00:00:00:00:00")
     ipaddr = "10.79.41.137"
     ret = L2tpHalClient.get_mac_of_ip(ipaddr)
     print ret
     ipaddr = "10.1.1.1"
     ret = L2tpHalClient.get_mac_of_ip(ipaddr)
     print ret
     ipaddr = "::1"
     ret = L2tpHalClient.get_mac_of_ip(ipaddr)
     self.assertEqual(ret, "00:00:00:00:00:00")
     ipaddr = "202:201:304:506::1"
     ret = L2tpHalClient.get_mac_of_ip(ipaddr)
     print ret