Commit 2c813fdd authored by Ayesha Ayub's avatar Ayesha Ayub
Browse files

fix minor issue in POST method in BWM

parent 18904d33
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -915,13 +915,19 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {

	// Validate Mandatory attribute "FixedAllocation"
	if bwInfo.FixedAllocation != "" {
		n, err := strconv.ParseUint(bwInfo.FixedAllocation, 10, 64)
		valFixedBuff, err := strconv.ParseUint(bwInfo.FixedAllocation, 10, 64)
		if err == nil {
			_, valUpBuff, _ := getUplinkBuff()
			_, valDownBuff, _ := getDownlinkBuff()

			if valFixedBuff == 0 {
				log.Error("Value of FixedAllocation should be non-zero")
				errHandlerProblemDetails(w, "Value of FixedAllocation should be non-zero", http.StatusBadRequest)
				return
			}

			// validate if the requested Allocation is within range of Available Bandwidth Resorce
			if (bwInfo.AllocationDirection == "01" && n > valUpBuff) || (bwInfo.AllocationDirection == "00" && n > valDownBuff) {
			if (bwInfo.AllocationDirection == "01" && valFixedBuff > valUpBuff) || (bwInfo.AllocationDirection == "00" && valFixedBuff > valDownBuff) {
				log.Error("Requested Allocation exceeds Resource buffer")
				errHandlerProblemDetails(w, "Requested Allocation exceeds Resource buffer.", http.StatusBadRequest)
				return
@@ -950,8 +956,8 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {
			}
		}
	} else if *bwInfo.RequestType == 1 && len(bwInfo.SessionFilter) == 0 {
		log.Error("sessionFilter attribute is Missing.")
		errHandlerProblemDetails(w, "sessionFilter attribute is Missing.", http.StatusBadRequest)
		log.Error("sessionFilter attribute is Empty.")
		errHandlerProblemDetails(w, "sessionFilter attribute is Empty..", http.StatusBadRequest)
		return
	}