Commit 04a90cdb authored by Yann Garcia's avatar Yann Garcia
Browse files

Bug fixed on TTF 043

parent 9291182d
Loading
Loading
Loading
Loading
+69 −30
Original line number Diff line number Diff line
@@ -689,6 +689,12 @@ func bandwidthAllocationListGet(w http.ResponseWriter, r *http.Request) {
		return
	}

	// If filters were provided but no match found → return 404
	if (len(appInstanceId) > 0 || len(appName) > 0 || len(sessionId) > 0) && len(bwInfoList.SessionList) == 0 {
		errHandlerProblemDetails(w, "No bandwidth allocations found matching the filter criteria", http.StatusNotFound)
		return
	}

	// Prepare & send response
	jsonResponse, err := json.Marshal(bwInfoList.SessionList)
	if err != nil {
@@ -853,25 +859,31 @@ func bandwidthAllocationPatch(w http.ResponseWriter, r *http.Request) {
		Seconds:     int32(seconds),
	}

	if (bwInfoDeltaInput.AllocationDirection != "") || (bwInfoDeltaInput.FixedAllocation != "") {
		// validate and update the request changes in Allocation direction or Fixed Allocation (bps)
	// Validate and assign allocationDirection
	if bwInfoDeltaInput.AllocationDirection != "" {
			if (bwInfoDeltaInput.AllocationDirection == "00") || (bwInfoDeltaInput.AllocationDirection == "01") || (bwInfoDeltaInput.AllocationDirection == "10") {
		switch bwInfoDeltaInput.AllocationDirection {
		case "00", "01", "10":
			newBwInfo.AllocationDirection = bwInfoDeltaInput.AllocationDirection
		default:
			errHandlerProblemDetails(w, "Invalid allocationDirection value. Allowed values: 00, 01, 10.", http.StatusBadRequest)
			return
		}
	} else {
		newBwInfo.AllocationDirection = bwInfoStored.AllocationDirection
	}

	// Assign FixedAllocation, defaulting to stored value
	if bwInfoDeltaInput.FixedAllocation != "" {
		newBwInfo.FixedAllocation = bwInfoDeltaInput.FixedAllocation
	} else {
		newBwInfo.FixedAllocation = bwInfoStored.FixedAllocation
	}

	// Call the update function
	err = UpdateAllocationDirection(&newBwInfo, &bwInfoStored, w)
	if err != nil {
		return
	}
	}

	// setBwInfo function takes input of new BW allocation information and
	//	store it in json format in redis with new allocation ID.
@@ -913,19 +925,12 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {
		return
	}

	// verify RequestType attribute is either 1 or 0
	// Check requestType is provided
	if bwInfo.RequestType != nil {
		if (*bwInfo.RequestType == 0) || (*bwInfo.RequestType == 1) {
			if (bwInfo.AllocationDirection == "00") || (bwInfo.AllocationDirection == "01") || (bwInfo.AllocationDirection == "10") {
				log.Debug("Valid Mandatory attribute allocationDirection")
			} else {
				log.Error("Valid allocationDirection value should be present")
				errHandlerProblemDetails(w, "Valid allocationDirection value should be present in the request body", http.StatusBadRequest)
				return
			}
		} else {
			log.Error("Valid requestType value should be present")
			errHandlerProblemDetails(w, "Valid requestType value should be present in the request body", http.StatusBadRequest)
		// Check requestType value is valid (0 or 1)
		if *bwInfo.RequestType != 0 && *bwInfo.RequestType != 1 {
			log.Error("Valid requestType value should be 0 or 1")
			errHandlerProblemDetails(w, "Valid requestType value should be 0 or 1", http.StatusBadRequest)
			return
		}
	} else {
@@ -934,6 +939,27 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {
		return
	}

	// sessionFilter must not be present when requestType is 0 (application-specific)
	if *bwInfo.RequestType == 0 && len(bwInfo.SessionFilter) != 0 {
		log.Error("sessionFilter must not be present for application-specific bandwidth allocations.")
		errHandlerProblemDetails(w, "sessionFilter must not be present when requestType is 0 (application-specific).", http.StatusBadRequest)
		return
	}

	// Check allocationDirection and fixedAllocation are provided
	if bwInfo.AllocationDirection == "" || bwInfo.FixedAllocation == "" {
		log.Error("Mandatory attribute allocationDirection or fixedAllocation is missing")
		errHandlerProblemDetails(w, "Mandatory attribute allocationDirection or fixedAllocation is missing", http.StatusBadRequest)
		return
	}

	// Check allocationDirection value is valid
	if bwInfo.AllocationDirection != "00" && bwInfo.AllocationDirection != "01" && bwInfo.AllocationDirection != "10" {
		log.Error("Invalid value for allocationDirection")
		errHandlerProblemDetails(w, "allocationDirection must be one of: '00', '01', or '10'", http.StatusBadRequest)
		return
	}

	// Validate Mandatory attribute "FixedAllocation"
	if bwInfo.FixedAllocation != "" {
		valFixedBuff, err := strconv.ParseUint(bwInfo.FixedAllocation, 10, 64)
@@ -982,8 +1008,10 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {
		return
	}

	if *bwInfo.RequestType == 0 {
		bwInfo.SessionFilter = nil
	if *bwInfo.RequestType == 0 && len(bwInfo.SessionFilter) != 0 {
		log.Error("sessionFilter must not be present for application-specific bandwidth allocations.")
		errHandlerProblemDetails(w, "sessionFilter must not be present when requestType is 0 (application-specific).", http.StatusBadRequest)
		return
	}

	if *bwInfo.RequestType == 1 && bwInfo.SessionFilter != nil {
@@ -1108,6 +1136,10 @@ func bandwidthAllocationPost(w http.ResponseWriter, r *http.Request) {
		errHandlerProblemDetails(w, "Unable to store new Allocation in redis", http.StatusInternalServerError)
		return
	}

	// Set Location header using AllocationId
	location := fmt.Sprintf("%s%s", hostUrl.String(), basePath) + "bw_allocations/" + bwInfo.AllocationId
	w.Header().Set("Location", location)
	w.WriteHeader(http.StatusCreated)
	fmt.Fprint(w, string(jsonResponse))
}
@@ -1171,6 +1203,13 @@ func bandwidthAllocationPut(w http.ResponseWriter, r *http.Request) {
		}
	}

	// Reject sessionFilter if requestType is 0 (application-specific)
	if *bwInfoInput.RequestType == 0 && len(bwInfoInput.SessionFilter) > 0 {
		log.Error("sessionFilter must not be present for application-specific allocations (requestType=0)")
		errHandlerProblemDetails(w, "sessionFilter must not be present for application-specific allocations (requestType=0)", http.StatusBadRequest)
		return
	}

	if (bwInfoInput.AllocationDirection == "") || (bwInfoInput.FixedAllocation == "") {
		log.Error("Mandatory attribute allocationDirection or fixedAllocation is Missing")
		errHandlerProblemDetails(w, "Mandatory attribute allocationDirection or fixedAllocation is Missing", http.StatusBadRequest)
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ type MtsSessionInfo struct {
	// Name of the application
	AppName string `json:"appName,omitempty"`
	// Traffic flow filtering criteria, applicable only if when requestType is set as FLOW_SPECIFIC_MTS_SESSION. Any filtering criteria shall define a single session only. In case multiple sessions match flowFilter the request shall be rejected. If the flowFilter field is included, at least one of its subfields shall be included. Any flowFilter subfield that is not included shall be ignored in traffic flow filtering
	FlowFilter []MtsSessionInfoFlowFilter `json:"flowFilter"`
	FlowFilter []MtsSessionInfoFlowFilter `json:"flowFilter,omitempty"`
	// Numeric value (0 to 255) corresponding to a specific MTS mode of the MTS session: 0 = low cost, i.e. using the unmetered access network connection whenever it is available 1 = low latency, i.e. using the access network connection with lower latency 2 = high throughput, i.e. using the access network connection with higher throughput, or multiple access network connection simultaneously 3 = redundancy, i.e. sending duplicated (redundancy) packets over multiple access network connections for high-reliability and low-latency applications 4 = QoS, i.e. performing MTS based on the QoS requirement (qosD)
	MtsMode *uint32 `json:"mtsMode"`
	// Indicates the requested ratio between multiple access networks for the network aggregation\\ \\ required for higher throughput. Indicates the requested ratio between multiple access networks for \\ \\ the network aggregation required for higher throughput. This is based on the existing 3GPP ATSSS feature\\ \\ specified in clause 5.32.8 of ETSI TS 123 501 [i.5].
+9 −0
Original line number Diff line number Diff line
@@ -796,6 +796,9 @@ func mtsSessionPost(w http.ResponseWriter, r *http.Request) {
	// Prepare & send response
	jsonResponse := convertMtsSessionInfoToJson(&requestBody)

	// Set Location header using AllocationId
	location := fmt.Sprintf("%s%s", hostUrl.String(), basePath) + "mts_sessions/" + sessionIdStr
	w.Header().Set("Location", location)
	w.WriteHeader(http.StatusCreated)
	fmt.Fprint(w, jsonResponse)
}
@@ -1262,6 +1265,12 @@ func mtsSessionsListGet(w http.ResponseWriter, r *http.Request) {
		return
	}

	// If filters were provided but no match found → return 404
	if (len(appInstanceId) > 0 || len(appName) > 0 || len(sessionId) > 0) && len(mtsSessionInfoList.SessionList) == 0 {
		errHandlerProblemDetails(w, "No MTS sessions found matching the filter criteria", http.StatusNotFound)
		return
	}

	// Prepare & send response
	jsonResponse, err := json.Marshal(mtsSessionInfoList.SessionList)
	if err != nil {