Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add CreatedPDR into Session Establishment Response #58

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 67 additions & 4 deletions internal/pfcp/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,24 @@ func (s *PfcpServer) handleSessionEstablishmentRequest(
}
}

CreatedPDRList := make([]*ie.IE, 0)

for _, i := range req.CreatePDR {
err = sess.CreatePDR(i)
if err != nil {
sess.log.Errorf("Est CreatePDR error: %+v", err)
}

ueIPAddress := getUEAddressFromPDR(i)
pdrId := getPDRIDFromPDR(i)

if ueIPAddress != nil {
ueIPv4 := ueIPAddress.IPv4Address.String()
CreatedPDRList = append(CreatedPDRList, ie.NewCreatedPDR(
ie.NewPDRID(pdrId),
ie.NewUEIPAddress(2, ueIPv4, "", 0, 0),
))
}
}

var v4 net.IP
Expand All @@ -91,16 +104,20 @@ func (s *PfcpServer) handleSessionEstablishmentRequest(
// TODO: support v6
var v6 net.IP

ies := make([]*ie.IE, 0)
ies = append(ies, CreatedPDRList...)
ies = append(ies,
newIeNodeID(s.nodeID),
ie.NewCause(ie.CauseRequestAccepted),
ie.NewFSEID(sess.LocalID, v4, v6))

rsp := message.NewSessionEstablishmentResponse(
0, // mp
0, // fo
sess.RemoteID, // seid
req.Header.SequenceNumber,
0, // pri
newIeNodeID(s.nodeID),
ie.NewCause(ie.CauseRequestAccepted),
ie.NewFSEID(sess.LocalID, v4, v6),
ie.NewCreatePDR(req.CreatePDR...),
ies...,
)

err = s.sendRspTo(rsp, addr)
Expand Down Expand Up @@ -417,3 +434,49 @@ func (s *PfcpServer) handleSessionReportRequestTimeout(
s.log.Warnf("handleSessionReportRequestTimeout: SEID[%#x]", req.SEID())
// TODO?
}

// getUEAddressFromPDR returns the UEIPaddress() from the PDR IE.
func getUEAddressFromPDR(pdr *ie.IE) *ie.UEIPAddressFields {
ies, err := pdr.CreatePDR()
if err != nil {
return nil
}

for _, i := range ies {
// only care about PDI
if i.Type == ie.PDI {
ies, err := i.PDI()
if err != nil {
return nil
}
for _, x := range ies {
if x.Type == ie.UEIPAddress {
fields, err := x.UEIPAddress()
if err != nil {
return nil
}
return fields
}
}
}
}
return nil
}

func getPDRIDFromPDR(pdr *ie.IE) uint16 {
ies, err := pdr.CreatePDR()
if err != nil {
return 0
}

for _, i := range ies {
if i.Type == ie.PDRID {
id, err := i.PDRID()
if err != nil {
return 0
}
return id
}
}
return 0
}
Loading