Commit 9170c989 authored by Simon Pastor's avatar Simon Pastor
Browse files

beta test issues

parent a25c190c
Loading
Loading
Loading
Loading
+41 −14
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ const USER_TRACKING_AND_ZONAL_TRAFFIC = 1
const ZONE_STATUS = 2

type UeUserData struct {
	queryZoneId  string
	queryApId    string
	queryAddress string
	queryZoneId  []string
	queryApId    []string
	queryAddress []string
	userList     *UserList
}

@@ -619,9 +619,9 @@ func usersGet(w http.ResponseWriter, r *http.Request) {
	u, _ := url.Parse(r.URL.String())
	log.Info("url: ", u.RequestURI())
	q := u.Query()
	userData.queryZoneId = q.Get("zoneId")
	userData.queryApId = q.Get("accessPointId")
	userData.queryAddress = q.Get("address")
	userData.queryZoneId = q["zoneId"]
	userData.queryApId = q["accessPointId"]
	userData.queryAddress = q["address"]

	// Get user list from DB
	var response InlineUserList
@@ -668,17 +668,45 @@ func populateUserList(key string, jsonInfo string, userData interface{}) error {
		return nil
	}

	//query parameters looked through using OR within same query parameter and AND between different query parameters
	//example returning users matching zoneId : (zone01 OR zone02) AND accessPointId : (ap1 OR ap2 OR ap3) AND address: (ipAddress1 OR ipAddress2)
	foundAMatch := false
	// Filter using query params
	if data.queryZoneId != "" && userInfo.ZoneId != data.queryZoneId {
	if len(data.queryZoneId) > 0 {
		foundAMatch = false
		for _, queryZoneId := range data.queryZoneId {
			if userInfo.ZoneId == queryZoneId {
				foundAMatch = true
			}
		}
		if !foundAMatch {
			return nil
		}
	if data.queryApId != "" && userInfo.AccessPointId != data.queryApId {
	}

	if len(data.queryApId) > 0 {
		foundAMatch = false
		for _, queryApId := range data.queryApId {
			if userInfo.AccessPointId == queryApId {
				foundAMatch = true
			}
		}
		if !foundAMatch {
			return nil
		}
	}

	if data.queryAddress != "" && userInfo.Address != data.queryAddress {
	if len(data.queryAddress) > 0 {
		foundAMatch = false
		for _, queryAddress := range data.queryAddress {
			if userInfo.Address == queryAddress {
				foundAMatch = true
			}
		}
		if !foundAMatch {
			return nil
		}
	}

	// Add user info to list
	data.userList.User = append(data.userList.User, userInfo)
@@ -1510,9 +1538,8 @@ func updateUserInfo(address string, zoneId string, accessPointId string, longitu
	} else {
		if userInfo.LocationInfo == nil {
			userInfo.LocationInfo = new(LocationInfo)
			userInfo.LocationInfo.Accuracy = 1
		}
		//we only support shape != 7 in locationInfo
		//we only support shape == 2 in locationInfo, so we ignore any conditional parameters based on shape
		userInfo.LocationInfo.Shape = 2
		userInfo.LocationInfo.Longitude = nil
		userInfo.LocationInfo.Longitude = append(userInfo.LocationInfo.Longitude, *longitude)
+119 −98
Original line number Diff line number Diff line
@@ -511,6 +511,12 @@ func isMatchRabRelFilterCriteriaAppInsId(filterCriteria interface{}, appId strin
	return (appId == filter.AppInstanceId)
}

func isMatchRabRelFilterCriteriaErabId(filterCriteria interface{}, erabId int32) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	return (erabId == filter.ErabId)
}

func isMatchCcFilterCriteriaAssociateId(filterCriteria interface{}, assocId *AssociateId) bool {
	filter := filterCriteria.(*CellChangeSubscriptionFilterCriteriaAssocHo)

@@ -547,7 +553,7 @@ func isMatchRabFilterCriteriaAssociateId(filterCriteria interface{}, assocId *As
}
*/

func isMatchCcFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn) bool {
func isMatchCcFilterCriteriaEcgi(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*CellChangeSubscriptionFilterCriteriaAssocHo)

	//if filter criteria is not set, it acts as a wildcard and accepts all
@@ -555,86 +561,69 @@ func isMatchCcFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, oldP
		return true
	}

	//either of the Plmn should match the filter,
	var matchingPlmn bool
	for _, ecgi := range filter.Ecgi {

		matchingPlmn = false
		if ecgi.Plmn == nil {
			matchingPlmn = true
		} else {
			if newPlmn != nil {
				if newPlmn.Mnc == ecgi.Plmn.Mnc && newPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
					matchingPlmn = true
				}
			}
			if oldPlmn != nil {
				if oldPlmn.Mnc == ecgi.Plmn.Mnc && oldPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
			}
					matchingPlmn = true
				}
			}

	return false
		}

func isMatchRabFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn) bool {
	filter := filterCriteria.(*RabEstSubscriptionFilterCriteriaQci)

	//if filter criteria is not set, it acts as a wildcard and accepts all
	if filter.Ecgi == nil {
		if matchingPlmn {
			if ecgi.CellId == "" {
				return true
			}

	//either of the Plmn should match the filter,
	for _, ecgi := range filter.Ecgi {

		if newPlmn != nil {
			if newPlmn.Mnc == ecgi.Plmn.Mnc && newPlmn.Mcc == ecgi.Plmn.Mcc {
			if newCellId == ecgi.CellId {
				return true
			}
		}
		if oldPlmn != nil {
			if oldPlmn.Mnc == ecgi.Plmn.Mnc && oldPlmn.Mcc == ecgi.Plmn.Mcc {
			if oldCellId == ecgi.CellId {
				return true
			}
		}

	}

	return false
}

func isMatchRabRelFilterCriteriaPlmn(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)
func isMatchRabFilterCriteriaEcgi(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*RabEstSubscriptionFilterCriteriaQci)

	//if filter criteria is not set, it acts as a wildcard and accepts all
	if filter.Ecgi == nil {
		return true
	}

	//either of the Plmn should match the filter,
	var matchingPlmn bool
	for _, ecgi := range filter.Ecgi {

		matchingPlmn = false
		if ecgi.Plmn == nil {
			matchingPlmn = true
		} else {
			if newPlmn != nil {
				if newPlmn.Mnc == ecgi.Plmn.Mnc && newPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
					matchingPlmn = true
				}
			}
			if oldPlmn != nil {
				if oldPlmn.Mnc == ecgi.Plmn.Mnc && oldPlmn.Mcc == ecgi.Plmn.Mcc {
				return true
			}
					matchingPlmn = true
				}
			}

	return false
		}

func isMatchCcFilterCriteriaCellId(filterCriteria interface{}, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*CellChangeSubscriptionFilterCriteriaAssocHo)

	if filter.Ecgi == nil {
		if matchingPlmn {
			if ecgi.CellId == "" {
				return true
			}

	//either the old of new cellId should match one of the cellId in the filter list
	for _, ecgi := range filter.Ecgi {

			if newCellId == ecgi.CellId {
				return true
			}
@@ -643,38 +632,40 @@ func isMatchCcFilterCriteriaCellId(filterCriteria interface{}, newCellId string,
			}
		}

	}

	return false
}

func isMatchRabFilterCriteriaCellId(filterCriteria interface{}, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*RabEstSubscriptionFilterCriteriaQci)
func isMatchRabRelFilterCriteriaEcgi(filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	//if filter criteria is not set, it acts as a wildcard and accepts all
	if filter.Ecgi == nil {
		return true
	}

	//either the old of new cellId should match one of the cellId in the filter list
	var matchingPlmn bool
	for _, ecgi := range filter.Ecgi {
		if newCellId == ecgi.CellId {
			return true
		matchingPlmn = false
		if ecgi.Plmn == nil {
			matchingPlmn = true
		} else {
			if newPlmn != nil {
				if newPlmn.Mnc == ecgi.Plmn.Mnc && newPlmn.Mcc == ecgi.Plmn.Mcc {
					matchingPlmn = true
				}
		if oldCellId == ecgi.CellId {
			return true
			}
			if oldPlmn != nil {
				if oldPlmn.Mnc == ecgi.Plmn.Mnc && oldPlmn.Mcc == ecgi.Plmn.Mcc {
					matchingPlmn = true
				}

	return false
			}

func isMatchRabRelFilterCriteriaCellId(filterCriteria interface{}, newCellId string, oldCellId string) bool {
	filter := filterCriteria.(*RabModSubscriptionFilterCriteriaQci)

	if filter.Ecgi == nil {
		}
		if matchingPlmn {
			if ecgi.CellId == "" {
				return true
			}

	//either the old of new cellId should match one of the cellId in the filter list
	for _, ecgi := range filter.Ecgi {
			if newCellId == ecgi.CellId {
				return true
			}
@@ -683,6 +674,8 @@ func isMatchRabRelFilterCriteriaCellId(filterCriteria interface{}, newCellId str
			}
		}

	}

	return false
}

@@ -708,6 +701,19 @@ func isMatchFilterCriteriaAssociateId(subscriptionType string, filterCriteria in
	return true
}

func isMatchFilterCriteriaEcgi(subscriptionType string, filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn, newCellId string, oldCellId string) bool {
	switch subscriptionType {
	case cellChangeSubscriptionType:
		return isMatchCcFilterCriteriaEcgi(filterCriteria, newPlmn, oldPlmn, newCellId, oldCellId)
	case rabEstSubscriptionType:
		return isMatchRabFilterCriteriaEcgi(filterCriteria, newPlmn, oldPlmn, newCellId, oldCellId)
	case rabRelSubscriptionType:
		return isMatchRabRelFilterCriteriaEcgi(filterCriteria, newPlmn, oldPlmn, newCellId, oldCellId)
	}
	return true
}

/*
func isMatchFilterCriteriaPlmn(subscriptionType string, filterCriteria interface{}, newPlmn *Plmn, oldPlmn *Plmn) bool {
	switch subscriptionType {
	case cellChangeSubscriptionType:
@@ -731,7 +737,7 @@ func isMatchFilterCriteriaCellId(subscriptionType string, filterCriteria interfa
	}
	return true
}

*/
func checkCcNotificationRegisteredSubscriptions(appId string, assocId *AssociateId, newPlmn *Plmn, oldPlmn *Plmn, hoStatus string, newCellId string, oldCellId string) {

	//no cell change if no cellIds present (cell change within 3gpp elements only)
@@ -753,11 +759,7 @@ func checkCcNotificationRegisteredSubscriptions(appId string, assocId *Associate
			}

			if match {
				match = isMatchFilterCriteriaPlmn(cellChangeSubscriptionType, sub.FilterCriteriaAssocHo, newPlmn, oldPlmn)
			}

			if match {
				match = isMatchFilterCriteriaCellId(cellChangeSubscriptionType, sub.FilterCriteriaAssocHo, newCellId, oldCellId)
				match = isMatchFilterCriteriaEcgi(cellChangeSubscriptionType, sub.FilterCriteriaAssocHo, newPlmn, oldPlmn, newCellId, oldCellId)
			}

			//we ignore hoStatus
@@ -841,11 +843,7 @@ func checkReNotificationRegisteredSubscriptions(appId string, assocId *Associate
			}

			if match {
				match = isMatchFilterCriteriaPlmn(rabEstSubscriptionType, sub.FilterCriteriaQci, newPlmn, nil)
			}

			if match {
				match = isMatchFilterCriteriaCellId(rabEstSubscriptionType, sub.FilterCriteriaQci, newCellId, oldCellId)
				match = isMatchFilterCriteriaEcgi(rabEstSubscriptionType, sub.FilterCriteriaQci, newPlmn, nil, newCellId, oldCellId)
			}

			//we ignore qci
@@ -918,13 +916,12 @@ func checkRrNotificationRegisteredSubscriptions(appId string, assocId *Associate
			}

			if match {
				match = isMatchFilterCriteriaPlmn(rabRelSubscriptionType, sub.FilterCriteriaQci, nil, oldPlmn)
				match = isMatchFilterCriteriaEcgi(rabRelSubscriptionType, sub.FilterCriteriaQci, nil, oldPlmn, newCellId, oldCellId)
			}

			if match {
				match = isMatchFilterCriteriaCellId(rabRelSubscriptionType, sub.FilterCriteriaQci, "", oldCellId)
				match = isMatchRabRelFilterCriteriaErabId(sub.FilterCriteriaQci, erabId)
			}

			//we ignore qci

			if match {
@@ -1161,6 +1158,14 @@ func subscriptionsPost(w http.ResponseWriter, r *http.Request) {
			subscription.FilterCriteriaAssocHo.HoStatus = append(subscription.FilterCriteriaAssocHo.HoStatus, 3 /*COMPLETED*/)
		}

		for _, ecgi := range subscription.FilterCriteriaAssocHo.Ecgi {
			if ecgi.Plmn == nil || ecgi.CellId == "" {
				log.Error("For non null ecgi, plmn and cellId are mandatory")
				http.Error(w, "For non null ecgi,  plmn and cellId are mandatory", http.StatusInternalServerError)
				return
			}
		}

		//registration
		registerCc(&subscription, subsIdStr)
		_ = rc.JSONSetEntry(baseKey+"subscriptions:"+subsIdStr, ".", convertCellChangeSubscriptionToJson(&subscription))
@@ -1184,6 +1189,14 @@ func subscriptionsPost(w http.ResponseWriter, r *http.Request) {
			return
		}

		for _, ecgi := range subscription.FilterCriteriaQci.Ecgi {
			if ecgi.Plmn == nil || ecgi.CellId == "" {
				log.Error("For non null ecgi, plmn and cellId are mandatory")
				http.Error(w, "For non null ecgi,  plmn and cellId are mandatory", http.StatusInternalServerError)
				return
			}
		}

		//registration
		registerRe(&subscription, subsIdStr)
		_ = rc.JSONSetEntry(baseKey+"subscriptions:"+subsIdStr, ".", convertRabEstSubscriptionToJson(&subscription))
@@ -1207,6 +1220,14 @@ func subscriptionsPost(w http.ResponseWriter, r *http.Request) {
			return
		}

		for _, ecgi := range subscription.FilterCriteriaQci.Ecgi {
			if ecgi.Plmn == nil || ecgi.CellId == "" {
				log.Error("For non null ecgi, plmn and cellId are mandatory")
				http.Error(w, "For non null ecgi,  plmn and cellId are mandatory", http.StatusInternalServerError)
				return
			}
		}

		//registration
		registerRr(&subscription, subsIdStr)
		_ = rc.JSONSetEntry(baseKey+"subscriptions:"+subsIdStr, ".", convertRabRelSubscriptionToJson(&subscription))