// HandlePFCPMsg handles different types of PFCP messages.
HandlePFCPMsg handles different types of PFCP messages.
// HandlePFCPMsg handles different types of PFCP messages .
func (pConn *PFCPConn) HandlePFCPMsg(buf []byte) {
	var (
		reply message.Message
		err   error
	)
	msg, err := message.Parse(buf)
	if err != nil {
		log.Errorln("Ignoring undecodable message: ", buf, " error: ", err)
		return
	}
	addr := pConn.RemoteAddr().String()
	msgType := msg.MessageTypeName()
	m := metrics.NewMessage(msgType, "Incoming")
	switch msg.MessageType() {
	case message.MsgTypeHeartbeatRequest:
		reply, err = pConn.handleHeartbeatRequest(msg)
	case message.MsgTypePFDManagementRequest:
		reply, err = pConn.handlePFDMgmtRequest(msg)
	case message.MsgTypeAssociationSetupRequest:
		reply, err = pConn.handleAssociationSetupRequest(msg)
		if reply != nil && err == nil && pConn.upf.enableHBTimer {
			go pConn.startHeartBeatMonitor()
		}
	case message.MsgTypeAssociationReleaseRequest:
		reply, err = pConn.handleAssociationReleaseRequest(msg)
		defer pConn.Shutdown()
	case message.MsgTypeSessionEstablishmentRequest:
		reply, err = pConn.handleSessionEstablishmentRequest(msg)
	case message.MsgTypeSessionModificationRequest:
		reply, err = pConn.handleSessionModificationRequest(msg)
	case message.MsgTypeSessionDeletionRequest:
		reply, err = pConn.handleSessionDeletionRequest(msg)
	case message.MsgTypeSessionReportResponse:
		err = pConn.handleSessionReportResponse(msg)
	case message.MsgTypeAssociationSetupResponse, message.MsgTypeHeartbeatResponse:
		pConn.handleIncomingResponse(msg)
	default:
		log.Errorln("Message type: ", msgType, " is currently not supported")
		return
	}
	nodeID := pConn.nodeID.remote
	if err != nil {
		m.Finish(nodeID, "Failure")
		log.Errorln("Error handling PFCP message type", msgType, "from:", addr, "nodeID:", nodeID, err)
	} else {
		m.Finish(nodeID, "Success")
		log.Traceln("Successfully processed", msgType, "from", addr, "nodeID:", nodeID)
	}
	pConn.SaveMessages(m)
	if reply != nil {
		pConn.SendPFCPMsg(reply)
	}
}
func ( pConn * PFCPConn ) HandlePFCPMsg ( buf [ ] byte ) { var ( reply message . Message err error ) msg , err := message . Parse ( buf ) if err != nil { log . Errorln ( " " , buf , " " , err ) return } addr := pConn . RemoteAddr ( ) . String ( ) msgType := msg . MessageTypeName ( ) m := metrics . NewMessage ( msgType , " " ) switch msg . MessageType ( ) { case message . MsgTypeHeartbeatRequest : reply , err = pConn . handleHeartbeatRequest ( msg ) case message . MsgTypePFDManagementRequest : reply , err = pConn . handlePFDMgmtRequest ( msg ) case message . MsgTypeAssociationSetupRequest : reply , err = pConn . handleAssociationSetupRequest ( msg ) if reply != nil && err == nil && pConn . upf . enableHBTimer { go pConn . startHeartBeatMonitor ( ) } case message . MsgTypeAssociationReleaseRequest : reply , err = pConn . handleAssociationReleaseRequest ( msg ) defer pConn . Shutdown ( ) case message . MsgTypeSessionEstablishmentRequest : reply , err = pConn . handleSessionEstablishmentRequest ( msg ) case message . MsgTypeSessionModificationRequest : reply , err = pConn . handleSessionModificationRequest ( msg ) case message . MsgTypeSessionDeletionRequest : reply , err = pConn . handleSessionDeletionRequest ( msg ) case message . MsgTypeSessionReportResponse : err = pConn . handleSessionReportResponse ( msg ) case message . MsgTypeAssociationSetupResponse , message . MsgTypeHeartbeatResponse : pConn . handleIncomingResponse ( msg ) default : log . Errorln ( " " , msgType , " " ) return } nodeID := pConn . nodeID . remote if err != nil { m . Finish ( nodeID , " " ) log . Errorln ( " " , msgType , " " , addr , " " , nodeID , err ) } else { m . Finish ( nodeID , " " ) log . Traceln ( " " , msgType , " " , addr , " " , nodeID ) } pConn . SaveMessages ( m ) if reply != nil { pConn . SendPFCPMsg ( reply ) } }
HandlePFCPMsg handles different types of PFCP messages.
HandlePFCPMsg handles different types of PFCP messages .
// Connection related messages // TODO: Cleanup sessions // Session related messages // Incoming response messages // TODO: Session Report Request // Check for errors in handling the message