Skip to content

Commit

Permalink
Allow creation of FARMap with a FAR that have no Forwarding Parameter…
Browse files Browse the repository at this point in the history
… and no FORW Flag

Closes #5
  • Loading branch information
louisroyer committed Sep 4, 2024
1 parent 60beb02 commit 3eecc25
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pfcp/far_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3eecc25

Please sign in to comment.