Skip to content

Commit

Permalink
fix handling of nil IE given to grouped IE (wmnsk#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmnsk committed Aug 20, 2020
1 parent 208f6e0 commit 5a0d220
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ie/ie.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,22 @@ func newStringIE(t uint16, v string) *IE {

func newGroupedIE(itype, eid uint16, ies ...*IE) *IE {
i := NewVendorSpecificIE(itype, eid, make([]byte, 0))
i.ChildIEs = ies
for _, ie := range i.ChildIEs {

for _, ie := range ies {
if ie == nil {
continue
}

i.ChildIEs = append(i.ChildIEs, ie)

serialized, err := ie.Marshal()
if err != nil {
// TODO: log error
return nil
}
i.Payload = append(i.Payload, serialized...)
}

i.SetLength()

return i
Expand Down
56 changes: 56 additions & 0 deletions ie/ie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,62 @@ func TestIEs(t *testing.T) {
0x64, 0x64, 0x64, // FL
0xff, 0xff, 0xff, 0xff, // BID
},
}, {
"PDI/WithNIL",
ie.NewPDI(
ie.NewSourceInterface(ie.SrcInterfaceAccess),
ie.NewFTEID(0x11111111, net.ParseIP("127.0.0.1"), nil, nil),
ie.NewNetworkInstance("some.instance.example"),
ie.NewRedundantTransmissionParametersInPDI(
ie.NewFTEID(0x11111111, net.ParseIP("127.0.0.1"), nil, nil),
ie.NewNetworkInstance("some.instance.example"),
),
ie.NewUEIPAddress(0x02, "127.0.0.1", "", 0),
ie.NewTrafficEndpointID(0x01),
nil,
ie.NewApplicationID("https://github.com/wmnsk/go-pfcp/"),
ie.NewEthernetPDUSessionInformation(0x01),
ie.NewEthernetPacketFilter(
ie.NewEthernetFilterID(0xffffffff),
ie.NewEthernetFilterProperties(0x01),
ie.NewMACAddress(mac1, mac2, mac3, mac4),
ie.NewEthertype(0xffff),
ie.NewCTAG(0x07, 1, 1, 4095),
ie.NewSTAG(0x07, 1, 1, 4095),
ie.NewSDFFilter("aaaaaaaa", "bb", "cccc", "ddd", 0xffffffff),
),
),
[]byte{
0x00, 0x02, 0x00, 0xec,
0x00, 0x14, 0x00, 0x01, 0x00,
0x00, 0x15, 0x00, 0x09, 0x01, 0x11, 0x11, 0x11, 0x11, 0x7f, 0x00, 0x00, 0x01,
0x00, 0x16, 0x00, 0x15, 0x73, 0x6f, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65,
0x00, 0xff, 0x00, 0x26,
0x00, 0x15, 0x00, 0x09, 0x01, 0x11, 0x11, 0x11, 0x11, 0x7f, 0x00, 0x00, 0x01,
0x00, 0x16, 0x00, 0x15, 0x73, 0x6f, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65,
0x00, 0x5d, 0x00, 0x05, 0x02, 0x7f, 0x00, 0x00, 0x01,
0x00, 0x83, 0x00, 0x01, 0x01,
0x00, 0x18, 0x00, 0x21, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x6d, 0x6e, 0x73, 0x6b, 0x2f, 0x67, 0x6f, 0x2d, 0x70, 0x66, 0x63, 0x70, 0x2f,
0x00, 0x8e, 0x00, 0x01, 0x01,
0x00, 0x84, 0x00, 0x5b,
0x00, 0x8a, 0x00, 0x04, 0xff, 0xff, 0xff, 0xff,
0x00, 0x8b, 0x00, 0x01, 0x01,
0x00, 0x85, 0x00, 0x19, 0x0f,
0x12, 0x34, 0x56, 0x78, 0x90, 0x01,
0x12, 0x34, 0x56, 0x78, 0x90, 0x02,
0x12, 0x34, 0x56, 0x78, 0x90, 0x03,
0x12, 0x34, 0x56, 0x78, 0x90, 0x04,
0x00, 0x88, 0x00, 0x02, 0xff, 0xff,
0x00, 0x86, 0x00, 0x03, 0x07, 0xf9, 0xff,
0x00, 0x87, 0x00, 0x03, 0x07, 0xf9, 0xff,
0x00, 0x17, 0x00, 0x19,
0x1f, 0x00, // Flags & Spare octet
0x00, 0x08, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, // FD
0x62, 0x62, // TTC
0x63, 0x63, 0x63, 0x63, // SPI
0x64, 0x64, 0x64, // FL
0xff, 0xff, 0xff, 0xff, // BID
},
}, {
"CreateFAR",
ie.NewCreateFAR(
Expand Down

0 comments on commit 5a0d220

Please sign in to comment.