Skip to content

Commit

Permalink
Fix bug with ForwardingParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
louisroyer committed Sep 5, 2024
1 parent 0292c9a commit c5a0aed
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pfcp/api/far_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ type FARID = uint32
type FARInterface interface {
ID() (FARID, error)
ApplyAction() *ie.IE
ForwardingParameters() *ie.IE
ForwardingParameters() (*ie.IE, error)
NewCreateFAR() *ie.IE
}
59 changes: 34 additions & 25 deletions pfcp/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,36 +397,45 @@ func (e *PFCPEntity) LogPFCPRules() {
}
}

ForwardingParametersIe := far.ForwardingParameters()
isFP := true
ForwardingParametersIe, err := far.ForwardingParameters()
if err != nil {
isFP = false

}
OuterHeaderCreationLabel := "No"
if ohc, err := ForwardingParametersIe.OuterHeaderCreation(); err == nil {
ohcb, _ := ohc.Marshal()
ohcIe := ie.New(ie.OuterHeaderCreation, ohcb)
switch {
case ohcIe.HasTEID() && ohcIe.HasIPv4():
OuterHeaderCreationLabel = fmt.Sprintf("[%s (%d)]", ohc.IPv4Address.String(), ohc.TEID)
case ohcIe.HasTEID() && ohcIe.HasIPv6():
OuterHeaderCreationLabel = fmt.Sprintf("[%s (%d)]", ohc.IPv6Address.String(), ohc.TEID)
default:
OuterHeaderCreationLabel = "Other"
if isFP {
if ohc, err := ForwardingParametersIe.OuterHeaderCreation(); err == nil {
ohcb, _ := ohc.Marshal()
ohcIe := ie.New(ie.OuterHeaderCreation, ohcb)
switch {
case ohcIe.HasTEID() && ohcIe.HasIPv4():
OuterHeaderCreationLabel = fmt.Sprintf("[%s (%d)]", ohc.IPv4Address.String(), ohc.TEID)
case ohcIe.HasTEID() && ohcIe.HasIPv6():
OuterHeaderCreationLabel = fmt.Sprintf("[%s (%d)]", ohc.IPv6Address.String(), ohc.TEID)
default:
OuterHeaderCreationLabel = "Other"
}
}
}

DestinationInterfaceLabel := "Not defined"
if destination, err := ForwardingParametersIe.DestinationInterface(); err == nil {
switch destination {
case ie.DstInterfaceAccess:
DestinationInterfaceLabel = "Access"
case ie.DstInterfaceCore:
DestinationInterfaceLabel = "Core"
case ie.DstInterfaceSGiLANN6LAN:
DestinationInterfaceLabel = "SGi-LAN/N6-LAN"
case ie.DstInterfaceCPFunction:
DestinationInterfaceLabel = "CP Function"
case ie.DstInterfaceLIFunction:
DestinationInterfaceLabel = "LI Function"
case ie.DstInterface5GVNInternal:
DestinationInterfaceLabel = "5G VN Internal"
if isFP {
if destination, err := ForwardingParametersIe.DestinationInterface(); err == nil {
switch destination {
case ie.DstInterfaceAccess:
DestinationInterfaceLabel = "Access"
case ie.DstInterfaceCore:
DestinationInterfaceLabel = "Core"
case ie.DstInterfaceSGiLANN6LAN:
DestinationInterfaceLabel = "SGi-LAN/N6-LAN"
case ie.DstInterfaceCPFunction:
DestinationInterfaceLabel = "CP Function"
case ie.DstInterfaceLIFunction:
DestinationInterfaceLabel = "LI Function"
case ie.DstInterface5GVNInternal:
DestinationInterfaceLabel = "5G VN Internal"
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions pfcp/far.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package pfcp_networking

import (
"fmt"
"github.com/nextmn/go-pfcp-networking/pfcp/api"
"github.com/wmnsk/go-pfcp/ie"
)
Expand All @@ -32,8 +33,14 @@ func (far *FAR) ApplyAction() *ie.IE {
return far.applyAction
}

func (far *FAR) ForwardingParameters() *ie.IE {
return far.forwardingParameters
func (far *FAR) ForwardingParameters() (*ie.IE, error) {
// This IE shall be present when the Apply Action requests
// the packets to be forwarded. It may be present otherwise.
if far.ForwardingParameters == nil {
return nil, fmt.Errorf("No forwarding parameters ie")
}
return far.forwardingParameters, nil

}

func (far *FAR) NewCreateFAR() *ie.IE {
Expand Down

0 comments on commit c5a0aed

Please sign in to comment.