Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFCPEntity.Close() #29

Merged
merged 8 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

```golang
upNode := NewPFCPEntityUP(UPF_NODE_ID, UPF_IP_ADDR) // node id can be an IP Address or a FQDN
upNode.Start()
go upNode.ListenAndServe()
defer upNode.Close()
// Access list of associations
associations := upNode.GetPFCPAssociations()
// Access list of sessions
Expand All @@ -22,7 +23,8 @@ sessions := upNode.GetPFCPSessions()

```golang
cpNode := NewPFCPEntityCP(SMF_NODE_ID, SMF_IP_ADDR) // node id can be an IP Address or a FQDN
cpNode.Start()
go cpNode.ListenAndServe()
defer cpNode.Close()
association, _ := cpNode.NewEstablishedPFCPAssociation(ie.NewNodeIDHeuristic(UPFADDR))
session, _ := a.CreateSession(pdrs, fars)

Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/nextmn/go-pfcp-networking

go 1.22
go 1.22.1

require github.com/wmnsk/go-pfcp v0.0.24
require (
github.com/sirupsen/logrus v1.9.3
github.com/wmnsk/go-pfcp v0.0.24
)

require golang.org/x/sys v0.24.0 // indirect
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/wmnsk/go-pfcp v0.0.24 h1:sv4F3U/IphsPUMXMkTJW877CRvXZ1sF5onWHGBvxx/A=
github.com/wmnsk/go-pfcp v0.0.24/go.mod h1:8EUVvOzlz25wkUs9D8STNAs5zGyIo5xEUpHQOUZ/iSg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5 changes: 1 addition & 4 deletions pfcp/api/entity_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package api

import (
"net"

"github.com/wmnsk/go-pfcp/ie"
)

Expand All @@ -19,10 +17,9 @@ type PFCPEntityInterface interface {
NewEstablishedPFCPAssociation(nodeID *ie.IE) (association PFCPAssociationInterface, err error)
RemovePFCPAssociation(association PFCPAssociationInterface) error
GetPFCPAssociation(nid string) (association PFCPAssociationInterface, err error)
SendTo(msg []byte, dst net.Addr) error
GetPFCPSessions() []PFCPSessionInterface
GetPFCPSession(localIP string, seid SEID) (PFCPSessionInterface, error)
AddEstablishedPFCPSession(session PFCPSessionInterface) error
PrintPFCPRules()
LogPFCPRules()
Options() EntityOptionsInterface
}
6 changes: 3 additions & 3 deletions pfcp/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package pfcp_networking

import (
"fmt"
"log"
"net"
"time"

"github.com/nextmn/go-pfcp-networking/pfcp/api"
"github.com/sirupsen/logrus"
"github.com/wmnsk/go-pfcp/ie"
"github.com/wmnsk/go-pfcp/message"
)
Expand Down Expand Up @@ -74,7 +74,7 @@ func (association *PFCPAssociation) SetupInitiatedByCP() error {
}
asres, ok := resp.(*message.AssociationSetupResponse)
if !ok {
log.Printf("got unexpected message: %s\n", resp.MessageTypeName())
logrus.WithFields(logrus.Fields{"message-type": resp.MessageTypeName()}).Debug("Got unexpected message")
}
cause, err := asres.Cause.Cause()
if err != nil {
Expand All @@ -86,7 +86,7 @@ func (association *PFCPAssociation) SetupInitiatedByCP() error {
go association.heartMonitoring()
return nil
}
return fmt.Errorf("Associaton setup request rejected")
return fmt.Errorf("Association setup request rejected")
default:
return fmt.Errorf("Local PFCP entity is not a UP function, neither a CP function.")
}
Expand Down
Loading
Loading