def test_msg_with_op_aw(self): print "test_msg_with_aw_tlv" # Encode message with mandatory fields, decode buffer and compare objs msg = Message(gcp_msg_def.NotifyREQ) msg.msg_fields.TransactionID.set_val(5) msg.msg_fields.EventCode.set_val(1) msg.msg_fields.Mode.set_val(0b10000000) msg.msg_fields.Status.set_val(2) seq = self.vsp_tlv_seq.create_vendor_tlvs_sequence( gcp_msg_def.NotifyREQ, rcp_tlv_def.RCP_MSG_TYPE_IRA, rcp_tlv_def.RCP_OPERATION_TYPE_ALLOCATE_WRITE) rcp_msg = RCPMessage(gcp_msg_def.NotifyREQ, rcp_tlv_def.RCP_MSG_TYPE_NTF) msg.tlv_data.rcp_msgs.append(rcp_msg) rcp_msg.sequences.append(seq) buf = msg.encode() self.assertIsNotNone(buf) msg_dec = Message(gcp_msg_def.NotifyREQ) self.assertEqual(msg_dec.decode(buf, offset=0, buf_data_len=len(buf)), msg_dec.DECODE_DONE)
def test_msg_with_tlvs_of_multi_core(self): # Encode message with mandatory fields, decode buffer and compare objs msg = Message(gcp_msg_def.DataStructError) msg.msg_fields.TransactionID.set_val(5) msg.msg_fields.ExceptionCode.set_val( gcp_msg_def.GCP_RC_MESSAGE_FAILURE.rc) seq = RCPSequence(gcp_msg_def.DataStructError, rcp_tlv_def.RCP_MSG_TYPE_REX, 0, rcp_tlv_def.RCP_OPERATION_TYPE_WRITE, unittest=True) rcp_msg = RCPMessage(gcp_msg_def.DataStructError, rcp_tlv_def.RCP_MSG_TYPE_REX) msg.tlv_data.rcp_msgs.append(rcp_msg) rcp_msg.sequences.append(seq) resSet = seq.MultiCore.ResourceSet.add_new_repeated() resSet.ResourceSetIndex.set_val(1) resSet.CcapCoreOwner.set_val( utils.Convert.mac_to_tuple_of_bytes("00:00:00:00:00:00")) resSet.DsRfPortStart.set_val(0) resSet.DsRfPortEnd.set_val(0) dsChanGroup = resSet.DsChanGroup.add_new_repeated() dsChanGroup.DsChanGroupIndex.set_val(1) dsChanGroup.DsChanType.set_val(3) dsChanGroup.DsChanIndexStart.set_val(0) dsChanGroup.DsChanIndexEnd.set_val(10) dsChanGroup = resSet.DsChanGroup.add_new_repeated() dsChanGroup.DsChanGroupIndex.set_val(2) dsChanGroup.DsChanType.set_val(4) dsChanGroup.DsChanIndexStart.set_val(11) dsChanGroup.DsChanIndexEnd.set_val(12) resSet.UsRfPortStart.set_val(0) resSet.UsRfPortEnd.set_val(1) usChanGroup = resSet.UsChanGroup.add_new_repeated() usChanGroup.UsChanGroupIndex.set_val(0) usChanGroup.UsChanType.set_val(5) usChanGroup.UsChanIndexStart.set_val(0) usChanGroup.UsChanIndexEnd.set_val(2) usChanGroup = resSet.UsChanGroup.add_new_repeated() usChanGroup.UsChanGroupIndex.set_val(1) usChanGroup.UsChanType.set_val(6) usChanGroup.UsChanIndexStart.set_val(3) usChanGroup.UsChanIndexEnd.set_val(4) buf = msg.encode() self.assertNotEqual(buf, None) msg_dec = Message(gcp_msg_def.DataStructError) self.assertEqual(msg_dec.decode(buf, offset=0, buf_data_len=len(buf)), msg_dec.DECODE_DONE)
def test_rcp_message_in_gcp_msg(self): msg = Message(gcp_msg_def.DataStructREQ) msg.msg_fields.TransactionID.set_val(5) msg.msg_fields.Mode.set_val(0) msg.msg_fields.Port.set_val(11) msg.msg_fields.Channel.set_val(111) msg.msg_fields.VendorID.set_val(1111) msg.msg_fields.VendorIndex.set_val(254) rcp_msg = RCPMessage(msg.message_id, rcp_tlv_def.RCP_MSG_TYPE_REX) msg.tlv_data.rcp_msgs.append(rcp_msg) seq = self.create_testing_cfg_sequence(msg.message_id, rcp_msg.rcp_message_id) rcp_msg.sequences.append(seq) buf_enc = msg.encode() msg_dec = Message() msg_dec.decode(buf_enc, 0, len(buf_enc))
def test_msg_with_tlv(self): # Encode message with mandatory fields, decode buffer and compare objs msg = Message(gcp_msg_def.NotifyREQ) msg.msg_fields.TransactionID.set_val(5) msg.msg_fields.EventCode.set_val(1) msg.msg_fields.Mode.set_val(0b10000000) msg.msg_fields.Status.set_val(2) seq = RCPSequence(gcp_msg_def.NotifyREQ, rcp_tlv_def.RCP_MSG_TYPE_NTF, 0, rcp_tlv_def.RCP_OPERATION_TYPE_WRITE) rcp_msg = RCPMessage(gcp_msg_def.NotifyREQ, rcp_tlv_def.RCP_MSG_TYPE_NTF) msg.tlv_data.rcp_msgs.append(rcp_msg) rcp_msg.sequences.append(seq) seq.RpdCapabilities.NumBdirPorts.set_val(1) buf = msg.encode() self.assertIsNotNone(buf) msg_dec = Message(gcp_msg_def.NotifyREQ) self.assertEqual(msg_dec.decode(buf, offset=0, buf_data_len=len(buf)), msg_dec.DECODE_DONE)
def test_msg_with_tlvs_of_all_classes(self): # Encode message with mandatory fields, decode buffer and compare objs msg = Message(gcp_msg_def.DataStructError) msg.msg_fields.TransactionID.set_val(5) msg.msg_fields.ExceptionCode.set_val( gcp_msg_def.GCP_RC_MESSAGE_FAILURE.rc) seq = RCPSequence(gcp_msg_def.DataStructError, rcp_tlv_def.RCP_MSG_TYPE_REX, 0, rcp_tlv_def.RCP_OPERATION_TYPE_WRITE, unittest=True) rcp_msg = RCPMessage(gcp_msg_def.DataStructError, rcp_tlv_def.RCP_MSG_TYPE_REX) msg.tlv_data.rcp_msgs.append(rcp_msg) rcp_msg.sequences.append(seq) seq.RpdCapabilities.RpdIdentification.VendorName.set_val('ABC') seq.RpdCapabilities.NumBdirPorts.set_val(1) # TODO this can be uncommented when conflicting numbering is solved # seq.RpdCapabilities.NumAsyncVideoChannels.set_val(2) seq.RpdCapabilities.RpdIdentification.VendorName.set_val('31') seq.RpdCapabilities.RpdIdentification.VendorId.set_val(9) seq.RpdCapabilities.RpdIdentification.DeviceMacAddress.set_val( (0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56)) seq.RpdCapabilities.RpdIdentification.SerialNumber.set_val('33') sub_tlv =\ seq.RpdCapabilities.LcceChannelReachability.add_new_repeated() sub_tlv.EnetPortIndex.set_val(4) sub_tlv.EndChannelIndex.set_val(5) seq.RpdCapabilities.PilotToneCapabilities.NumCwToneGens.set_val(6) seq.RpdCapabilities.PilotToneCapabilities.QamAsPilot.set_val(1) sub_tlv = seq.RpdCapabilities.AllocDsChanResources.add_new_repeated() sub_tlv.DsPortIndex.set_val(8) sub_tlv.AllocatedNdfChannels.set_val(9) sub_tlv = seq.RpdCapabilities.AllocUsChanResources.add_new_repeated() sub_tlv.UsPortIndex.set_val(10) sub_tlv.AllocatedNdrChannels.set_val(11) sub_tlv = seq.CcapCoreIdentification.add_new_repeated() sub_tlv.Index.set_val(12) sub_tlv.CoreIpAddress.set_val((0x01, 0x02, 0x03, 0x04)) sub_tlv.VendorId.set_val(13) sub_tlv = seq.RfPort.add_new_repeated() sub_tlv.RfPortSelector.RfPortIndex.set_val(0) # sub_tlv.DsRfPort.PortIndex.set_val(14) sub_tlv.DsRfPort.TiltMaximumFrequency.set_val(15) sub_tlv = seq.RfChannel.add_new_repeated() sub_tlv.RfChannelSelector.RfChannelIndex.set_val(0) sub_tlv.DsScQamChannelConfig.AdminState.set_val(1) sub_tlv.DsScQamChannelConfig.PowerAdjust.set_val(17) sub_tlv.DsOfdmChannelConfig.AdminState.set_val(2) sub_tlv.DsOfdmChannelConfig.SubcarrierSpacing.set_val(1) sub_tlv2 = sub_tlv.DsOfdmChannelConfig.DsOfdmSubcarrierType.add_new_repeated( ) sub_tlv2.StartSubcarrierId.set_val(21) sub_tlv2.EndSubcarrierId.set_val(22) sub_tlv2.SubcarrierUsage.set_val(1) sub_tlv2 = sub_tlv.DsOfdmProfile sub_tlv2.ProfileId.set_val(15) # sub_tlv3 = sub_tlv2.DsOfdmSubcarrierModulation.add_new_repeated() # sub_tlv3.StartSubcarrierId.set_val(21) # sub_tlv3.EndSubcarrierId.set_val(22) # sub_tlv3.Modulation.set_val(1) sub_tlv.UsScQamChannelConfig.AdminState.set_val(3) sub_tlv.UsScQamChannelConfig.TargetRxPower.set_val(24) sub_tlv2 = sub_tlv.UsScQamChannelConfig.IntervalUsageCode.\ add_new_repeated() sub_tlv2.Code.set_val(14) sub_tlv2.GuardTime.set_val(26) sub_tlv.UsOfdmaChannelConfig.AdminState.set_val(4) sub_tlv.UsOfdmaChannelConfig.TargetRxPowerAdjust.set_val(28) sub_tlv.UsOfdmaInitialRangingIuc.NumSubcarriers.set_val(10) sub_tlv.UsOfdmaInitialRangingIuc.Guardband.set_val(10) sub_tlv.UsOfdmaFineRangingIuc.NumSubcarriers.set_val(14) sub_tlv.UsOfdmaFineRangingIuc.Guardband.set_val(10) sub_tlv2 = sub_tlv.UsOfdmaDataIuc.add_new_repeated() sub_tlv2.DataIuc.set_val(5) sub_tlv2.DataSymbolModulation.set_val(1) sub_tlv2 = sub_tlv.UsOfdmaSubcarrierCfgState.add_new_repeated() sub_tlv2.StartingSubcarrierId.set_val(0) sub_tlv2.SubcarrierUsage.set_val(4) sub_tlv2 = sub_tlv.SidQos.add_new_repeated() sub_tlv2.StartSid.set_val(100) sub_tlv2.NumSids.set_val(10) sub_tlv2.SidSfType.set_val(2) sub_tlv2 = sub_tlv.SidQos.add_new_repeated() sub_tlv2.StartSid.set_val(15800) sub_tlv2.NumSids.set_val(5) sub_tlv2.SidSfType.set_val(3) buf = msg.encode() self.assertNotEqual(buf, None) msg_dec = Message(gcp_msg_def.DataStructError) self.assertEqual(msg_dec.decode(buf, offset=0, buf_data_len=len(buf)), msg_dec.DECODE_DONE)