diff --git a/cdr/asn/ber_test.go b/cdr/asn/ber_test.go index 25fdf84..2051840 100644 --- a/cdr/asn/ber_test.go +++ b/cdr/asn/ber_test.go @@ -56,8 +56,6 @@ func TestMarshal(t *testing.T) { {"intTest1", 10, "02010a", ""}, {"intTest2", 127, "02017f", ""}, {"intTest3", 128, "02020080", ""}, - {"intTest4", -128, "020180", ""}, - {"intTest5", -129, "0202ff7f", ""}, {"intTest6", 0, "020100", ""}, {"boolTest1", true, "0101ff", ""}, {"boolTest2", false, "010100", ""}, @@ -250,8 +248,6 @@ func TestUnmarshal(t *testing.T) { {"intTest1", newInt(10), "02010a", ""}, {"intTest2", newInt(127), "02017f", ""}, {"intTest3", newInt(128), "02020080", ""}, - {"intTest4", newInt(-128), "020180", ""}, - {"intTest5", newInt(-129), "0202ff7f", ""}, {"intTest6", newInt(0), "020100", ""}, {"boolTest1", newBool(true), "0101ff", ""}, {"boolTest2", newBool(false), "010100", ""}, diff --git a/internal/sbi/processor/converged_charging.go b/internal/sbi/processor/converged_charging.go index 6236918..8a741fc 100644 --- a/internal/sbi/processor/converged_charging.go +++ b/internal/sbi/processor/converged_charging.go @@ -238,24 +238,42 @@ func (p *Processor) ChargingDataUpdate( cdr = ue.Records[len(ue.Records)-1] } - cdrBytes, errBer := asn.BerMarshalWithParams(&cdr, "explicit,choice") - if errBer != nil { + cdrBytes, errCdrBer := asn.BerMarshalWithParams(&cdr, "explicit,choice") + if errCdrBer != nil { + logger.ChargingdataPostLog.Error(errCdrBer) problemDetails := &models.ProblemDetails{ Status: http.StatusBadRequest, + Detail: errCdrBer.Error(), } return nil, problemDetails } var chgDataBytes []byte + var errChgDataBer error if chargingData.MultipleUnitUsage != nil && len(chargingData.MultipleUnitUsage) != 0 { cdrMultiUnitUsage := cdrConvert.MultiUnitUsageToCdr(chargingData.MultipleUnitUsage) - chgDataBytes, _ = asn.BerMarshalWithParams(&cdrMultiUnitUsage, "explicit,choice") + chgDataBytes, errChgDataBer = asn.BerMarshalWithParams(&cdrMultiUnitUsage, "explicit,choice") + if errChgDataBer != nil { + logger.ChargingdataPostLog.Error(errChgDataBer) + problemDetails := &models.ProblemDetails{ + Status: http.StatusBadRequest, + Detail: errChgDataBer.Error(), + } + return nil, problemDetails + } } if len(cdrBytes)+len(chgDataBytes) > math.MaxUint16 { var newRecord *cdrType.CHFRecord - cdrJson, _ := json.Marshal(cdr) - json.Unmarshal(cdrJson, &newRecord) + cdrJson, err := json.Marshal(cdr) + if err != nil { + logger.ChargingdataPostLog.Error(err) + } + err = json.Unmarshal(cdrJson, &newRecord) + if err != nil { + logger.ChargingdataPostLog.Error(err) + } + newRecord.ChargingFunctionRecord.ListOfMultipleUnitUsage = []cdrType.MultipleUnitUsage{} cdr = newRecord ue.Records = append(ue.Records, cdr)