From 1897250c73bcc92415e2bf45e700b9bd56021ae2 Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Thu, 23 May 2024 17:40:04 +0200 Subject: [PATCH] Expose default handlers --- pfcp/entity.go | 4 +--- pfcp/entity_up.go | 6 +++--- pfcp/handlers.go | 10 ++++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pfcp/entity.go b/pfcp/entity.go index 4a7f18c..75da8ca 100644 --- a/pfcp/entity.go +++ b/pfcp/entity.go @@ -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 @@ -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 } diff --git a/pfcp/entity_up.go b/pfcp/entity_up.go index cac2e0f..63c2e58 100644 --- a/pfcp/entity_up.go +++ b/pfcp/entity_up.go @@ -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 diff --git a/pfcp/handlers.go b/pfcp/handlers.go index a0456ea..bfe29d9 100644 --- a/pfcp/handlers.go +++ b/pfcp/handlers.go @@ -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 { @@ -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 { @@ -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 {