Skip to content

Commit

Permalink
feat: add local sctp address config
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-ywliu committed Jul 26, 2024
1 parent 0c97140 commit 0758594
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/ngap/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *Server) Run(wg *sync.WaitGroup) error {
// n3iwf context
cfg := s.Config()

localAddr := new(sctp.SCTPAddr)
localAddr := cfg.GetLocalSctpAddr()

for _, remoteAddr := range cfg.GetAmfSctpAddrs() {
errChan := make(chan error)
Expand Down
22 changes: 20 additions & 2 deletions pkg/factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ type Info struct {
}

type Configuration struct {
N3IWFInfo *N3IWFNFInfo `yaml:"N3IWFInformation" valid:"required"`
AMFSCTPAddresses []AMFSCTPAddresses `yaml:"AMFSCTPAddresses" valid:"required"`
N3IWFInfo *N3IWFNFInfo `yaml:"N3IWFInformation" valid:"required"`
LocalSctpAddr string `yaml:"localSctpAddr,omitempty" valid:"optional,host"`
AMFSCTPAddresses []AMFSCTPAddresses `yaml:"AMFSCTPAddresses" valid:"required"`

TCPPort int `yaml:"NASTCPPort" valid:"required,port"`
IKEBindAddr string `yaml:"IKEBindAddress" valid:"required,host"`
Expand Down Expand Up @@ -255,6 +256,23 @@ func (c *Config) GetRanNodeName() string {
return c.Configuration.N3IWFInfo.RanNodeName
}

func (c *Config) GetLocalSctpAddr() *sctp.SCTPAddr {
c.RLock()
defer c.RUnlock()

sctpAddr := new(sctp.SCTPAddr)
localAddr := c.Configuration.LocalSctpAddr
if localAddr != "" {
ipAddr, err := net.ResolveIPAddr("ip", localAddr)
if err == nil {
sctpAddr = &sctp.SCTPAddr{
IPAddrs: []net.IPAddr{*ipAddr},
}
}
}
return sctpAddr
}

func (c *Config) GetAmfSctpAddrs() []*sctp.SCTPAddr {
c.RLock()
defer c.RUnlock()
Expand Down

0 comments on commit 0758594

Please sign in to comment.