Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 65 additions & 31 deletions simapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ type Configuration struct {
}

type DevGroup struct {
Name string `yaml:"name,omitempty"`
SiteInfo string `yaml:"site-info,omitempty" json:"site-info,omitempty"`
Imsis []string `yaml:"imsis,omitempty" json:"imsis,omitempty"`
IpDomainName string `yaml:"ip-domain-name,omitempty" json:"ip-domain-name,omitempty"`
IpDomain *IpDomain `yaml:"ip-domain-expanded,omitempty" json:"ip-domain-expanded,omitempty"`
Name string `yaml:"name,omitempty"`
SiteInfo string `yaml:"site-info,omitempty" json:"site-info,omitempty"`
Imsis []string `yaml:"imsis,omitempty" json:"imsis,omitempty"`
Msisdns []string `yaml:"msisdns,omitempty" json:"msisdns,omitempty"`
IpDomainName string `yaml:"ip-domain-name,omitempty" json:"ip-domain-name,omitempty"`
IpDomains []IpDomain `yaml:"ip-domains,omitempty" json:"ip-domains,omitempty"`
visited bool
}

Expand Down Expand Up @@ -586,6 +587,13 @@ func compareGroup(groupNew *DevGroup, groupOld *DevGroup) bool {
logger.SimappLog.Infoln("number of Imsis changed")
return true
}

// Compare MSISDN list length
if !reflect.DeepEqual(groupNew.Msisdns, groupOld.Msisdns) {
logger.SimappLog.Infoln("msisdns list has changed")
return true
}

var allimsiNew string
for _, imsi := range groupNew.Imsis {
allimsiNew = allimsiNew + imsi
Expand All @@ -609,26 +617,41 @@ func compareGroup(groupNew *DevGroup, groupOld *DevGroup) bool {
return true
}

oldipdomain := groupOld.IpDomain
newipdomain := groupNew.IpDomain
if oldipdomain.Dnn != newipdomain.Dnn {
return true
}
if oldipdomain.Mtu != newipdomain.Mtu {
return true
}
if oldipdomain.UePool != newipdomain.UePool {
return true
}
if oldipdomain.UeDnnQos != nil && newipdomain.UeDnnQos != nil {
if oldipdomain.UeDnnQos.TrafficClass != nil &&
newipdomain.UeDnnQos.TrafficClass != nil {
if (oldipdomain.UeDnnQos.TrafficClass.Name != newipdomain.UeDnnQos.TrafficClass.Name) ||
(oldipdomain.UeDnnQos.TrafficClass.Qci != newipdomain.UeDnnQos.TrafficClass.Qci) ||
(oldipdomain.UeDnnQos.TrafficClass.Arp != newipdomain.UeDnnQos.TrafficClass.Arp) ||
(oldipdomain.UeDnnQos.TrafficClass.Pdb != newipdomain.UeDnnQos.TrafficClass.Pdb) ||
(oldipdomain.UeDnnQos.TrafficClass.Pelr != newipdomain.UeDnnQos.TrafficClass.Pelr) {
return true
for i := range groupNew.IpDomains {
if i >= len(groupOld.IpDomains) {
// If groupOld doesn't have enough IpDomains
return true
}

oldIpDomain := groupOld.IpDomains[i]
newIpDomain := groupNew.IpDomains[i]

Comment on lines +620 to +628
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison logic doesn't account for cases where groupOld has more IpDomains than groupNew. If groupOld.IpDomains has 3 entries and groupNew.IpDomains has 2, the function will only compare the first 2 and miss the deletion. Add a length comparison before the loop to check if len(groupNew.IpDomains) != len(groupOld.IpDomains).

Suggested change
for i := range groupNew.IpDomains {
if i >= len(groupOld.IpDomains) {
// If groupOld doesn't have enough IpDomains
return true
}
oldIpDomain := groupOld.IpDomains[i]
newIpDomain := groupNew.IpDomains[i]
// Check if the number of IpDomains has changed
if len(groupNew.IpDomains) != len(groupOld.IpDomains) {
logger.SimappLog.Infoln("Number of IpDomains changed")
return true
}
for i := range groupNew.IpDomains {
if i >= len(groupOld.IpDomains) {
// If groupOld doesn't have enough IpDomains
return true
}

Copilot uses AI. Check for mistakes.
if oldIpDomain.Dnn != newIpDomain.Dnn {
logger.SimappLog.Infoln("DNN changed")
return true
}

if oldIpDomain.Mtu != newIpDomain.Mtu {
logger.SimappLog.Infoln("MTU changed")
return true
}

if oldIpDomain.UePool != newIpDomain.UePool {
logger.SimappLog.Infoln("UePool changed")
return true
}

// Compare UeDnnQos if not nil
if oldIpDomain.UeDnnQos != nil && newIpDomain.UeDnnQos != nil {
Comment on lines +644 to +645
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison doesn't detect changes when UeDnnQos transitions from nil to non-nil or vice versa. If oldIpDomain.UeDnnQos is nil but newIpDomain.UeDnnQos has a value (or vice versa), the function returns false when it should return true. Add an XOR check to detect when one is nil and the other isn't.

Suggested change
// Compare UeDnnQos if not nil
if oldIpDomain.UeDnnQos != nil && newIpDomain.UeDnnQos != nil {
// Detect changes in presence of UeDnnQos (nil vs non-nil)
if (oldIpDomain.UeDnnQos == nil) != (newIpDomain.UeDnnQos == nil) {
logger.SimappLog.Infoln("UeDnnQos presence changed (nil vs non-nil)")
return true
}
// Compare UeDnnQos fields when both are non-nil
if oldIpDomain.UeDnnQos != nil && newIpDomain.UeDnnQos != nil {
// Detect changes in presence of TrafficClass (nil vs non-nil)
if (oldIpDomain.UeDnnQos.TrafficClass == nil) != (newIpDomain.UeDnnQos.TrafficClass == nil) {
logger.SimappLog.Infoln("TrafficClass presence changed (nil vs non-nil)")
return true
}

Copilot uses AI. Check for mistakes.
Comment on lines +644 to +645
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to UeDnnQos, the TrafficClass comparison doesn't detect transitions between nil and non-nil states. If one TrafficClass is nil and the other isn't, this represents a configuration change that should be detected.

Suggested change
// Compare UeDnnQos if not nil
if oldIpDomain.UeDnnQos != nil && newIpDomain.UeDnnQos != nil {
// Compare UeDnnQos, including nil/non-nil transitions and TrafficClass
if (oldIpDomain.UeDnnQos == nil) != (newIpDomain.UeDnnQos == nil) {
logger.SimappLog.Infoln("UeDnnQos presence changed")
return true
}
if oldIpDomain.UeDnnQos != nil && newIpDomain.UeDnnQos != nil {
// Detect nil/non-nil transitions for TrafficClass itself
if (oldIpDomain.UeDnnQos.TrafficClass == nil) != (newIpDomain.UeDnnQos.TrafficClass == nil) {
logger.SimappLog.Infoln("TrafficClass presence changed")
return true
}

Copilot uses AI. Check for mistakes.
if oldIpDomain.UeDnnQos.TrafficClass != nil && newIpDomain.UeDnnQos.TrafficClass != nil {
if oldIpDomain.UeDnnQos.TrafficClass.Name != newIpDomain.UeDnnQos.TrafficClass.Name ||
oldIpDomain.UeDnnQos.TrafficClass.Qci != newIpDomain.UeDnnQos.TrafficClass.Qci ||
oldIpDomain.UeDnnQos.TrafficClass.Arp != newIpDomain.UeDnnQos.TrafficClass.Arp ||
oldIpDomain.UeDnnQos.TrafficClass.Pdb != newIpDomain.UeDnnQos.TrafficClass.Pdb ||
oldIpDomain.UeDnnQos.TrafficClass.Pelr != newIpDomain.UeDnnQos.TrafficClass.Pelr {
Comment on lines +647 to +651
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TrafficClass comparison doesn't check the UeDnnQos bitrate fields (dnn-mbr-downlink, dnn-mbr-uplink, bitrate-unit shown in the PR description). Changes to these QoS parameters won't be detected, leading to stale configurations. Include comparisons for all relevant UeDnnQos fields.

Copilot uses AI. Check for mistakes.
logger.SimappLog.Infoln("TrafficClass or its properties changed")
return true
}
}
}
}
Expand Down Expand Up @@ -948,12 +971,23 @@ func dispatchGroup(configMsgChan chan configMessage, group *DevGroup, msgOp int)
logger.SimappLog.Debugln("imsi", imsi)
}
logger.SimappLog.Infoln("IpDomainName", group.IpDomainName)
ipDomain := group.IpDomain
if group.IpDomain != nil {
logger.SimappLog.Infoln("IpDomain Dnn", ipDomain.Dnn)
logger.SimappLog.Infoln("IpDomain Dns Primary", ipDomain.DnsPrimary)
logger.SimappLog.Infoln("IpDomain Mtu", ipDomain.Mtu)
logger.SimappLog.Infoln("IpDomain UePool", ipDomain.UePool)
// Check if IpDomains is nil or not
if group.IpDomains != nil {
for _, ipDomain := range group.IpDomains {
logger.SimappLog.Infoln(" IpDomain Dnn:", ipDomain.Dnn)
logger.SimappLog.Infoln(" IpDomain Dns Primary:", ipDomain.DnsPrimary)
logger.SimappLog.Infoln(" IpDomain Mtu:", ipDomain.Mtu)
logger.SimappLog.Infoln(" IpDomain UePool:", ipDomain.UePool)

// Check for UeDnnQos field if it's populated
if ipDomain.UeDnnQos != nil {
logger.SimappLog.Infoln(" UeDnnQos:", ipDomain.UeDnnQos)
} else {
logger.SimappLog.Warnln(" UeDnnQos is nil")
}
}
} else {
logger.SimappLog.Warnln(" IpDomains is nil")
}
b, err := json.Marshal(group)
if err != nil {
Expand Down
Loading