From acb9e2b5a06e4bdd00d0ec282c581f96b1ed0d50 Mon Sep 17 00:00:00 2001 From: HIRONO Koji Date: Thu, 31 Mar 2022 10:26:09 +0900 Subject: [PATCH] Add support for handle PFCP heartbeat request --- internal/pfcp/heartbeat.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/pfcp/heartbeat.go b/internal/pfcp/heartbeat.go index 9a6560e..2081e10 100644 --- a/internal/pfcp/heartbeat.go +++ b/internal/pfcp/heartbeat.go @@ -3,9 +3,27 @@ package pfcp import ( "net" + "github.com/wmnsk/go-pfcp/ie" "github.com/wmnsk/go-pfcp/message" ) -func (s *PfcpServer) handleHeartbeatRequest(msg *message.HeartbeatRequest, addr net.Addr) { +func (s *PfcpServer) handleHeartbeatRequest(req *message.HeartbeatRequest, addr net.Addr) { s.log.Infoln("handleHeartbeatRequest") + + rsp := message.NewHeartbeatResponse( + req.Header.SequenceNumber, + ie.NewRecoveryTimeStamp(s.recoveryTime), + ) + + b, err := rsp.Marshal() + if err != nil { + s.log.Errorln(err) + return + } + + _, err = s.conn.WriteTo(b, addr) + if err != nil { + s.log.Errorln(err) + return + } }