Commit 95e7de76 authored by M. Hamza's avatar M. Hamza
Browse files

fix MEC015 APIs after minor change in the spec

parent 9a03ec0d
Loading
Loading
Loading
Loading
+8 −29
Original line number Diff line number Diff line
@@ -457,21 +457,13 @@ components:
        requestType: 0
        sessionFilter:
        - protocol: protocol
          sourcePort:
          - sourcePort
          - sourcePort
          dstPort:
          - dstPort
          - dstPort
          sourcePort: sourcePort
          dstPort: dstPort
          sourceIp: sourceIp
          dstAddress: dstAddress
        - protocol: protocol
          sourcePort:
          - sourcePort
          - sourcePort
          dstPort:
          - dstPort
          - dstPort
          sourcePort: sourcePort
          dstPort: dstPort
          sourceIp: sourceIp
          dstAddress: dstAddress
        appName: appName
@@ -624,8 +616,6 @@ components:
        dstPort:
          type: string
          description: Destination port identity of session
          items:
            type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        protocol:
@@ -643,18 +633,12 @@ components:
        sourcePort:
          type: string
          description: Source port identity of session
          items:
            type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
      example:
        protocol: protocol
        sourcePort:
        - sourcePort
        - sourcePort
        dstPort:
        - dstPort
        - dstPort
        sourcePort: sourcePort
        dstPort: dstPort
        sourceIp: sourceIp
        dstAddress: dstAddress
    BwInfo_timeStamp:
@@ -695,8 +679,6 @@ components:
        dstPort:
          type: string
          description: Destination port identity of session
          items:
            type: string
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        protocol:
@@ -712,12 +694,9 @@ components:
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        sourcePort:
          minItems: 0
          type: array
          description: 'Source port identity of session '
          items:
          type: string
          x-etsi-mec-cardinality: 0..N
          description: 'Source port identity of session '
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
    AppTerminationNotification__links:
      required:
+20 −32
Original line number Diff line number Diff line
@@ -489,24 +489,16 @@ components:
        flowFilter:
        - flowlabel: 1
          protocol: 5
          sourcePort:
          - 5
          - 5
          sourcePort: 5
          dscp: 0
          dstPort:
          - 6
          - 6
          dstPort: 6
          sourceIp: sourceIp
          dstIp: dstIp
        - flowlabel: 1
          protocol: 5
          sourcePort:
          - 5
          - 5
          sourcePort: 5
          dscp: 0
          dstPort:
          - 6
          - 6
          dstPort: 6
          sourceIp: sourceIp
          dstIp: dstIp
        requestType: 7
@@ -671,17 +663,17 @@ components:
          x-etsi-mec-origin-type: Uint32
        dstIp:
          type: string
          description: Destination address identity of session (including range)
          description: Destination address identity of session. The string for a IPv4 address shall be
            formatted in the "dotted decimal" notation as defined in IETF RFC 1166 [10]. The string
            for a IPv6 address shall be formatted according to clause 4 of IETF RFC 5952 [11], with
            in CIDR notation [12] used to provide the routing prefix.
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        dstPort:
          minItems: 0
          type: array
          description: Destination port identity of session
          items:
          type: integer
          description: Destination port identity of session
          format: uint32
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Uint32
        flowlabel:
          type: integer
@@ -698,28 +690,24 @@ components:
          x-etsi-mec-origin-type: Uint32
        sourceIp:
          type: string
          description: Source address identity of session (including range)
          description: Source address identity of session. The string for a IPv4 address shall be
            formatted in the "dotted decimal" notation as defined in IETF RFC 1166 [10]. The string
            for a IPv6 address shall be formatted according to clause 4 of IETF RFC 5952 [11], with
            in CIDR notation [12] used to provide the routing prefix.
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: String
        sourcePort:
          minItems: 0
          type: array
          description: Source port identity of session
          items:
          type: integer
          description: Source port identity of session
          format: uint32
          x-etsi-mec-cardinality: 0..N
          x-etsi-mec-cardinality: 0..1
          x-etsi-mec-origin-type: Uint32
      example:
        flowlabel: 1
        protocol: 5
        sourcePort:
        - 5
        - 5
        sourcePort: 5
        dscp: 0
        dstPort:
        - 6
        - 6
        dstPort: 6
        sourceIp: sourceIp
        dstIp: dstIp
    MtsSessionInfo_qosD:
+1 −4
Original line number Diff line number Diff line
@@ -1426,7 +1426,6 @@ func validateAppInfo(appInfo map[string]string) (int, string, error) {
func checkSrcIP(bw *BwInfo) (err error) {
	ueNameList := activeModel.GetNodeNames("UE")
	// if the provided source IP range matches with the existing UE IP(s)

	if len(ueNameList) > 0 {
		for _, ip := range bw.SessionFilter {
			ipFound := true
@@ -1445,7 +1444,6 @@ func checkSrcIP(bw *BwInfo) (err error) {
						} else {
							ipFound = false
						}

					}
				}
				// Return error if IP not in ueNameList
@@ -1486,10 +1484,9 @@ func checkDstIP(bw *BwInfo) (err error) {
						} else {
							ipFound = false
						}

					}
				}

				// Return error if IP not in ueNameList
				if !ipFound {
					log.Error("Provided destination IP range is not valid against the existing UE IPs")
					err = errors.New("Provided destination IP range is not valid against the existing UE IPs in the request body")
+10 −4
Original line number Diff line number Diff line
@@ -26,16 +26,22 @@ package server
type MtsSessionInfoFlowFilter struct {
	// DSCP in the IPv4 header or Traffic Class in the IPv6 header
	Dscp *uint32 `json:"dscp,omitempty"`
	// Destination address identity of session (including range)
	// Destination address identity of session. The string for a IPv4 address shall be formatted in the
	// "dotted decimal" notation as defined in IETF RFC 1166 [10]. The string for a IPv6 address shall be
	// formatted according to clause 4 of IETF RFC 5952 [11], with in CIDR notation [12] used to provide
	// the routing prefix.
	DstIp string `json:"dstIp,omitempty"`
	// Destination port identity of session
	DstPort *[]uint32 `json:"dstPort,omitempty"`
	DstPort *uint32 `json:"dstPort,omitempty"`
	// Flow Label in the IPv6 header, applicable only if the flow is IPv6
	Flowlabel *uint32 `json:"flowlabel,omitempty"`
	// Protocol number
	Protocol *uint32 `json:"protocol,omitempty"`
	// Source address identity of session (including range)
	// Source address identity of session. The string for a IPv4 address shall be formatted in the
	// "dotted decimal" notation as defined in IETF RFC 1166 [10]. The string for a IPv6 address shall be
	// formatted according to clause 4 of IETF RFC 5952 [11], with in CIDR notation [12] used to provide
	// the routing prefix.
	SourceIp string `json:"sourceIp,omitempty"`
	// Source port identity of session
	SourcePort *[]uint32 `json:"sourcePort,omitempty"`
	SourcePort *uint32 `json:"sourcePort,omitempty"`
}
+30 −38
Original line number Diff line number Diff line
@@ -627,7 +627,7 @@ func mtsSessionPost(w http.ResponseWriter, r *http.Request) {

	if *requestBody.RequestType == 1 && requestBody.FlowFilter != nil {
		for _, flowFilterVal := range requestBody.FlowFilter {
			if flowFilterVal.SourceIp == "" && len(*flowFilterVal.SourcePort) == 0 && flowFilterVal.DstIp == "" && len(*flowFilterVal.DstPort) == 0 && flowFilterVal.Protocol == nil && flowFilterVal.Dscp == nil && flowFilterVal.Flowlabel == nil {
			if flowFilterVal.SourceIp == "" && *flowFilterVal.SourcePort == 0 && flowFilterVal.DstIp == "" && *flowFilterVal.DstPort == 0 && flowFilterVal.Protocol == nil && flowFilterVal.Dscp == nil && flowFilterVal.Flowlabel == nil {
				log.Error("At least one of flowFilter subfields shall be included")
				errHandlerProblemDetails(w, "At least one of flowFilter subfields shall be included in the request body.", http.StatusBadRequest)
				return
@@ -837,19 +837,14 @@ func checkSrcIP(requestBody *MtsSessionInfo) (err error) {
		for _, ip := range requestBody.FlowFilter {
			ipFound := true
			if ip.SourceIp != "" {
				_, ueNetIP, _ := net.ParseCIDR(ip.SourceIp)
				if ueNetIP == nil {
					log.Error("IP not provided in the CIDR notation")
					err = errors.New("IP not provided in the CIDR notation in the request body.")
					return err
				}
				ipName := net.ParseIP(ip.SourceIp)
				if ipName != nil {
					for _, name := range ueNameList {
						// Ignore disconnected UEs
						if !isUeConnected(name) || !isInLocality(name) {
							continue
						}
					ipName := net.ParseIP(name)
					if ueNetIP.Contains(ipName) {
						if ipName.String() == name {
							log.Info("Provided source IP range is valid against the existing UE IPs")
							ipFound = true
							break
@@ -857,6 +852,7 @@ func checkSrcIP(requestBody *MtsSessionInfo) (err error) {
							ipFound = false
						}
					}
				}
				// Return error if IP not in ueNameList
				if !ipFound {
					log.Error("Provided source IP range is not valid against the existing UE IPs")
@@ -881,19 +877,14 @@ func checkDstIP(requestBody *MtsSessionInfo) (err error) {
		for _, ip := range requestBody.FlowFilter {
			ipFound := true
			if ip.DstIp != "" {
				_, ueNetIP, _ := net.ParseCIDR(ip.DstIp)
				if ueNetIP == nil {
					log.Error("IP not provided in the CIDR notation")
					err = errors.New("IP not provided in the CIDR notation in the request body.")
					return err
				}
				ipName := net.ParseIP(ip.DstIp)
				if ipName != nil {
					for _, name := range ueNameList {
						// Ignore disconnected UEs
						if !isUeConnected(name) || !isInLocality(name) {
							continue
						}
					ipName := net.ParseIP(name)
					if ueNetIP.Contains(ipName) {
						if ipName.String() == name {
							log.Info("Provided destination IP range is valid against the existing UE IPs")
							ipFound = true
							break
@@ -901,6 +892,7 @@ func checkDstIP(requestBody *MtsSessionInfo) (err error) {
							ipFound = false
						}
					}
				}
				// Return error if IP not in ueNameList
				if !ipFound {
					log.Error("Provided destination IP range is not valid against the existing UE IPs")
@@ -1088,7 +1080,7 @@ func mtsSessionPut(w http.ResponseWriter, r *http.Request) {

	if *requestBodyPut.RequestType == 1 && requestBodyPut.FlowFilter != nil {
		for _, flowFilterVal := range requestBodyPut.FlowFilter {
			if flowFilterVal.SourceIp == "" && len(*flowFilterVal.SourcePort) == 0 && flowFilterVal.DstIp == "" && len(*flowFilterVal.DstPort) == 0 && flowFilterVal.Protocol == nil && flowFilterVal.Dscp == nil && flowFilterVal.Flowlabel == nil {
			if flowFilterVal.SourceIp == "" && *flowFilterVal.SourcePort == 0 && flowFilterVal.DstIp == "" && *flowFilterVal.DstPort == 0 && flowFilterVal.Protocol == nil && flowFilterVal.Dscp == nil && flowFilterVal.Flowlabel == nil {
				log.Error("At least one of flowFilter subfields shall be included")
				errHandlerProblemDetails(w, "At least one of flowFilter subfields shall be included in the request body.", http.StatusBadRequest)
				return