-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'upnode-interface' into improve_config_validation
- Loading branch information
Showing
24 changed files
with
1,138 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package context | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/uuid" | ||
|
||
"github.com/free5gc/smf/internal/logger" | ||
) | ||
|
||
// embeds the UPNode struct ("inheritance") | ||
// implements UPNodeInterface | ||
type GNB struct { | ||
*UPNode | ||
} | ||
|
||
func (gNB *GNB) GetName() string { | ||
return gNB.Name | ||
} | ||
|
||
func (gNB *GNB) GetID() uuid.UUID { | ||
return gNB.ID | ||
} | ||
|
||
func (gNB *GNB) GetType() UPNodeType { | ||
return gNB.Type | ||
} | ||
|
||
func (gNB *GNB) String() string { | ||
str := "gNB {\n" | ||
prefix := " " | ||
str += prefix + fmt.Sprintf("Name: %s\n", gNB.Name) | ||
str += prefix + fmt.Sprintf("ID: %s\n", gNB.ID) | ||
str += prefix + fmt.Sprintln("Links:") | ||
for _, link := range gNB.Links { | ||
str += prefix + fmt.Sprintf("-- %s: %s\n", link.GetName(), link.GetName()) | ||
} | ||
str += "}" | ||
return str | ||
} | ||
|
||
func (gNB *GNB) GetLinks() UPPath { | ||
return gNB.Links | ||
} | ||
|
||
func (gNB *GNB) AddLink(link UPNodeInterface) bool { | ||
for _, existingLink := range gNB.Links { | ||
if link.GetName() == existingLink.GetName() { | ||
logger.CfgLog.Warningf("UPLink [%s] <=> [%s] already exists, skip\n", existingLink.GetName(), link.GetName()) | ||
return false | ||
} | ||
} | ||
gNB.Links = append(gNB.Links, link) | ||
return true | ||
} | ||
|
||
func (gNB *GNB) RemoveLink(link UPNodeInterface) bool { | ||
for i, existingLink := range gNB.Links { | ||
if link.GetName() == existingLink.GetName() && existingLink.GetName() == link.GetName() { | ||
logger.CfgLog.Warningf("Remove UPLink [%s] <=> [%s]\n", existingLink.GetName(), link.GetName()) | ||
gNB.Links = append(gNB.Links[:i], gNB.Links[i+1:]...) | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (gNB *GNB) RemoveLinkByIndex(index int) bool { | ||
gNB.Links[index] = gNB.Links[len(gNB.Links)-1] | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.