Skip to content

Commit

Permalink
Expose default handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed May 23, 2024
1 parent 498658b commit 1897250
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions pfcp/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"github.com/wmnsk/go-pfcp/message"
)

type PFCPMessageHandler = func(receivedMessage ReceivedMessage) error

type PFCPEntity struct {
nodeID *ie.IE
recoveryTimeStamp *ie.IE
Expand Down Expand Up @@ -66,7 +64,7 @@ func (e *PFCPEntity) RecoveryTimeStamp() *ie.IE {

func newDefaultPFCPEntityHandlers() map[pfcputil.MessageType]PFCPMessageHandler {
m := make(map[pfcputil.MessageType]PFCPMessageHandler)
m[message.MsgTypeHeartbeatRequest] = handleHeartbeatRequest
m[message.MsgTypeHeartbeatRequest] = DefaultHeartbeatRequestHandler
return m
}

Expand Down
6 changes: 3 additions & 3 deletions pfcp/entity_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func NewPFCPEntityUP(nodeID string) *PFCPEntityUP {
}

func (e *PFCPEntityUP) initDefaultHandlers() error {
if err := e.AddHandler(message.MsgTypeAssociationSetupRequest, handleAssociationSetupRequest); err != nil {
if err := e.AddHandler(message.MsgTypeAssociationSetupRequest, DefaultAssociationSetupRequestHandler); err != nil {
return err
}
if err := e.AddHandler(message.MsgTypeSessionEstablishmentRequest, handleSessionEstablishmentRequest); err != nil {
if err := e.AddHandler(message.MsgTypeSessionEstablishmentRequest, DefaultSessionEstablishmentRequestHandler); err != nil {
return err
}
if err := e.AddHandler(message.MsgTypeSessionModificationRequest, handleSessionModificationRequest); err != nil {
if err := e.AddHandler(message.MsgTypeSessionModificationRequest, DefaultSessionModificationRequestHandler); err != nil {
return err
}
return nil
Expand Down
10 changes: 6 additions & 4 deletions pfcp/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import (
"github.com/wmnsk/go-pfcp/message"
)

func handleHeartbeatRequest(msg ReceivedMessage) error {
type PFCPMessageHandler = func(receivedMessage ReceivedMessage) error

func DefaultHeartbeatRequestHandler(msg ReceivedMessage) error {
log.Println("Received Heartbeat Request")
res := message.NewHeartbeatResponse(msg.Sequence(), msg.Entity.RecoveryTimeStamp())
return msg.ReplyTo(res)
}

func handleAssociationSetupRequest(msg ReceivedMessage) error {
func DefaultAssociationSetupRequestHandler(msg ReceivedMessage) error {
log.Println("Received Association Setup Request")
m, ok := msg.Message.(*message.AssociationSetupRequest)
if !ok {
Expand Down Expand Up @@ -50,7 +52,7 @@ func handleAssociationSetupRequest(msg ReceivedMessage) error {
return msg.ReplyTo(res)
}

func handleSessionEstablishmentRequest(msg ReceivedMessage) error {
func DefaultSessionEstablishmentRequestHandler(msg ReceivedMessage) error {
log.Println("Received Session Establishment Request")
m, ok := msg.Message.(*message.SessionEstablishmentRequest)
if !ok {
Expand Down Expand Up @@ -152,7 +154,7 @@ func handleSessionEstablishmentRequest(msg ReceivedMessage) error {
return msg.ReplyTo(res)
}

func handleSessionModificationRequest(msg ReceivedMessage) error {
func DefaultSessionModificationRequestHandler(msg ReceivedMessage) error {
log.Println("Received Session Modification Request")
m, ok := msg.Message.(*message.SessionModificationRequest)
if !ok {
Expand Down

0 comments on commit 1897250

Please sign in to comment.