From 3eecc25d7b58229f942740e52f72e4b5c695089b Mon Sep 17 00:00:00 2001 From: Louis Royer Date: Wed, 4 Sep 2024 18:37:50 +0200 Subject: [PATCH] Allow creation of FARMap with a FAR that have no Forwarding Parameter and no FORW Flag Closes #5 --- pfcp/far_map.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/pfcp/far_map.go b/pfcp/far_map.go index 5dec9e7..386973e 100644 --- a/pfcp/far_map.go +++ b/pfcp/far_map.go @@ -154,26 +154,37 @@ func NewFARMap(fars []*ie.IE) (farmap *FARMap, err error, cause uint8, offending } } - fp, err := far.ForwardingParameters() // This IE shall be present when the Apply Action requests // the packets to be forwarded. It may be present otherwise. - if err != nil { - // XXX: Updating FAR should not be done like that - fp, err = far.UpdateForwardingParameters() + mustHaveFP := false + hasFP := false + if far.HasFORW() { + mustHaveFP = true + } + fp, err := far.ForwardingParameters() + if err != nil && mustHaveFP { + fp, err = far.ForwardingParameters() if err != nil { //XXX: workaround for a free5gc-smf bug: Forwarding Parameters are missing sometimes fp = make([]*ie.IE, 0) + hasFP = true // if err == io.ErrUnexpectedEOF { // return nil, err, ie.CauseInvalidLength, ie.ForwardingParameters // } // if ie.NewApplyAction(aa).HasFORW() && err == ie.ErrIENotFound { // return nil, err, ie.CauseConditionalIEMissing, ie.ForwardingParameters // } + } else if err == nil { + hasFP = true } } - err = f.Add(NewFAR(ie.NewFARID(id), ie.NewApplyAction(aa...), ie.NewForwardingParameters(fp...))) + if !hasFP { + err = f.Add(NewFAR(ie.NewFARID(id), ie.NewApplyAction(aa...), nil)) + } else { + err = f.Add(NewFAR(ie.NewFARID(id), ie.NewApplyAction(aa...), ie.NewForwardingParameters(fp...))) + } if err != nil { return nil, err, ie.CauseMandatoryIEIncorrect, ie.CreateFAR }