Skip to content

Commit 333b38e

Browse files
authored
Merge pull request #27 from Alonza0314/fix/additional-tnl-aper-tag-miss
Fix/additional tnl aper tag miss
2 parents 11e9cda + 7e02a83 commit 333b38e

4 files changed

Lines changed: 155 additions & 2 deletions

File tree

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ require (
88
github.com/sirupsen/logrus v1.9.3
99
github.com/stretchr/testify v1.9.0
1010
github.com/tim-ywliu/nested-logrus-formatter v1.3.2
11+
gotest.tools/v3 v3.5.2
1112
)
1213

1314
require (
1415
github.com/davecgh/go-spew v1.1.1 // indirect
1516
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
17+
github.com/google/go-cmp v0.5.9 // indirect
1618
github.com/kr/pretty v0.1.0 // indirect
1719
github.com/pmezard/go-difflib v1.0.0 // indirect
1820
golang.org/x/sys v0.31.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ github.com/free5gc/openapi v1.2.2 h1:SoWkuI/QOWA22UgNuqtkeoKeLEjThziJYGQFh/1gxSQ
77
github.com/free5gc/openapi v1.2.2/go.mod h1:5HbgGqlhaTBwcOrXQLCOmpbQoX/ogKSg6+TAsR1VxUM=
88
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
99
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
10+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1012
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
1113
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
1214
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -31,3 +33,5 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
3133
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3234
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3335
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
36+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
37+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=

ngapType/ProtocolExtensionField.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ const (
11331133

11341134
type PathSwitchRequestAcknowledgeTransferExtIEsExtensionValue struct {
11351135
Present int
1136-
AdditionalNGUUPTNLInformation *UPTransportLayerInformationPairList /* Do not find the Reference Field Value */
1136+
AdditionalNGUUPTNLInformation *UPTransportLayerInformationPairList `aper:"referenceFieldValue:154"`
11371137
}
11381138

11391139
type PathSwitchRequestSetupFailedTransferExtIEs struct {
@@ -1163,7 +1163,7 @@ const (
11631163

11641164
type PathSwitchRequestTransferExtIEsExtensionValue struct {
11651165
Present int
1166-
AdditionalDLQosFlowPerTNLInformation *QosFlowPerTNLInformationList /* Do not find the Reference Field Value */
1166+
AdditionalDLQosFlowPerTNLInformation *QosFlowPerTNLInformationList `aper:"referenceFieldValue:155"`
11671167
}
11681168

11691169
type PathSwitchRequestUnsuccessfulTransferExtIEs struct {

ngap_test.go

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/require"
9+
"gotest.tools/v3/assert"
910

1011
"github.com/free5gc/aper"
12+
"github.com/free5gc/ngap/ngapConvert"
1113
"github.com/free5gc/ngap/ngapType"
1214
)
1315

@@ -347,3 +349,148 @@ func TestDecoder(t *testing.T) {
347349
})
348350
}
349351
}
352+
353+
func TestCorrectAperReferenceFieldValueSetting(t *testing.T) {
354+
testCases := []struct {
355+
name string
356+
pdu interface{}
357+
}{
358+
{
359+
name: "PathSwitchRequestTransferWithAdditionalDLQosFlowPerTNLInformation",
360+
pdu: ngapType.PathSwitchRequestTransfer{
361+
DLNGUUPTNLInformation: ngapType.UPTransportLayerInformation{
362+
Present: ngapType.UPTransportLayerInformationPresentGTPTunnel,
363+
GTPTunnel: &ngapType.GTPTunnel{
364+
GTPTEID: ngapType.GTPTEID{
365+
Value: aper.OctetString{0x00, 0x00, 0x00, 0x01},
366+
},
367+
TransportLayerAddress: ngapConvert.IPAddressToNgap("127.0.0.1", ""),
368+
},
369+
},
370+
QosFlowAcceptedList: ngapType.QosFlowAcceptedList{
371+
List: []ngapType.QosFlowAcceptedItem{
372+
{
373+
QosFlowIdentifier: ngapType.QosFlowIdentifier{
374+
Value: 1,
375+
},
376+
},
377+
},
378+
},
379+
IEExtensions: &ngapType.ProtocolExtensionContainerPathSwitchRequestTransferExtIEs{
380+
List: []ngapType.PathSwitchRequestTransferExtIEs{
381+
{
382+
Id: ngapType.ProtocolExtensionID{
383+
Value: ngapType.ProtocolIEIDAdditionalDLQosFlowPerTNLInformation,
384+
},
385+
Criticality: ngapType.Criticality{
386+
Value: ngapType.CriticalityPresentIgnore,
387+
},
388+
ExtensionValue: ngapType.PathSwitchRequestTransferExtIEsExtensionValue{
389+
Present: ngapType.PathSwitchRequestTransferExtIEsPresentAdditionalDLQosFlowPerTNLInformation,
390+
AdditionalDLQosFlowPerTNLInformation: &ngapType.QosFlowPerTNLInformationList{
391+
List: []ngapType.QosFlowPerTNLInformationItem{
392+
{
393+
QosFlowPerTNLInformation: ngapType.QosFlowPerTNLInformation{
394+
UPTransportLayerInformation: ngapType.UPTransportLayerInformation{
395+
Present: ngapType.UPTransportLayerInformationPresentGTPTunnel,
396+
GTPTunnel: &ngapType.GTPTunnel{
397+
GTPTEID: ngapType.GTPTEID{
398+
Value: aper.OctetString{0x00, 0x00, 0x00, 0x01},
399+
},
400+
TransportLayerAddress: ngapConvert.IPAddressToNgap("127.0.0.1", ""),
401+
},
402+
},
403+
AssociatedQosFlowList: ngapType.AssociatedQosFlowList{
404+
List: []ngapType.AssociatedQosFlowItem{
405+
{
406+
QosFlowIdentifier: ngapType.QosFlowIdentifier{
407+
Value: 1,
408+
},
409+
},
410+
},
411+
},
412+
},
413+
},
414+
},
415+
},
416+
},
417+
},
418+
},
419+
},
420+
},
421+
},
422+
{
423+
name: "PathSwitchRequestAcknowledgeTransferWithAdditionalNGUUPTNLInformation",
424+
pdu: ngapType.PathSwitchRequestAcknowledgeTransfer{
425+
ULNGUUPTNLInformation: &ngapType.UPTransportLayerInformation{
426+
Present: ngapType.UPTransportLayerInformationPresentGTPTunnel,
427+
GTPTunnel: &ngapType.GTPTunnel{
428+
GTPTEID: ngapType.GTPTEID{
429+
Value: aper.OctetString{0x00, 0x00, 0x00, 0x01},
430+
},
431+
TransportLayerAddress: ngapConvert.IPAddressToNgap("127.0.0.1", ""),
432+
},
433+
},
434+
IEExtensions: &ngapType.ProtocolExtensionContainerPathSwitchRequestAcknowledgeTransferExtIEs{
435+
List: []ngapType.PathSwitchRequestAcknowledgeTransferExtIEs{
436+
{
437+
Id: ngapType.ProtocolExtensionID{
438+
Value: ngapType.ProtocolIEIDAdditionalNGUUPTNLInformation,
439+
},
440+
Criticality: ngapType.Criticality{
441+
Value: ngapType.CriticalityPresentIgnore,
442+
},
443+
ExtensionValue: ngapType.PathSwitchRequestAcknowledgeTransferExtIEsExtensionValue{
444+
Present: ngapType.PathSwitchRequestAcknowledgeTransferExtIEsPresentAdditionalNGUUPTNLInformation,
445+
AdditionalNGUUPTNLInformation: &ngapType.UPTransportLayerInformationPairList{
446+
List: []ngapType.UPTransportLayerInformationPairItem{
447+
{
448+
ULNGUUPTNLInformation: ngapType.UPTransportLayerInformation{
449+
Present: ngapType.UPTransportLayerInformationPresentGTPTunnel,
450+
GTPTunnel: &ngapType.GTPTunnel{
451+
GTPTEID: ngapType.GTPTEID{
452+
Value: aper.OctetString{0x00, 0x00, 0x00, 0x01},
453+
},
454+
TransportLayerAddress: ngapConvert.IPAddressToNgap("127.0.0.1", ""),
455+
},
456+
},
457+
DLNGUUPTNLInformation: ngapType.UPTransportLayerInformation{
458+
Present: ngapType.UPTransportLayerInformationPresentGTPTunnel,
459+
GTPTunnel: &ngapType.GTPTunnel{
460+
GTPTEID: ngapType.GTPTEID{
461+
Value: aper.OctetString{0x00, 0x00, 0x00, 0x01},
462+
},
463+
TransportLayerAddress: ngapConvert.IPAddressToNgap("127.0.0.1", ""),
464+
},
465+
},
466+
},
467+
},
468+
},
469+
},
470+
},
471+
},
472+
},
473+
},
474+
},
475+
}
476+
477+
for _, testCase := range testCases {
478+
t.Run(testCase.name, func(t *testing.T) {
479+
t.Parallel()
480+
481+
marshaledData, err := aper.MarshalWithParams(testCase.pdu, "valueExt")
482+
if err != nil {
483+
t.Fatalf("Failed to marshal data: %v", err)
484+
}
485+
486+
unmarshaledDataPtr := reflect.New(reflect.TypeOf(testCase.pdu)).Interface()
487+
err = aper.UnmarshalWithParams(marshaledData, unmarshaledDataPtr, "valueExt")
488+
if err != nil {
489+
t.Fatalf("Failed to unmarshal data: %v", err)
490+
}
491+
492+
unmarshaledData := reflect.ValueOf(unmarshaledDataPtr).Elem().Interface()
493+
assert.DeepEqual(t, testCase.pdu, unmarshaledData)
494+
})
495+
}
496+
}

0 commit comments

Comments
 (0)