Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UPF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UPF
Commits
b8e615f4
Commit
b8e615f4
authored
Mar 25, 2021
by
吴洲洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update server.go support new smf
parent
b6f4048c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
22 deletions
+28
-22
src/upf-n4/pkg/upf/controller/server.go
src/upf-n4/pkg/upf/controller/server.go
+28
-22
No files found.
src/upf-n4/pkg/upf/controller/server.go
View file @
b8e615f4
...
@@ -11,6 +11,7 @@ import (
...
@@ -11,6 +11,7 @@ import (
"n4/pkg/log"
"n4/pkg/log"
"n4/pkg/pfcp/ie"
"n4/pkg/pfcp/ie"
"n4/pkg/pfcp/message"
"n4/pkg/pfcp/message"
"n4/pkg/upf/sql"
"n4/pkg/upf/vpp"
"n4/pkg/upf/vpp"
"n4/pkg/vpp/binapi/upf"
"n4/pkg/vpp/binapi/upf"
"net"
"net"
...
@@ -98,6 +99,8 @@ func handleClient(config *conf.Config, conn *net.UDPConn) {
...
@@ -98,6 +99,8 @@ func handleClient(config *conf.Config, conn *net.UDPConn) {
func
handleMsg
(
config
*
conf
.
Config
,
msgType
uint8
,
msgContent
message
.
Message
)
[]
byte
{
func
handleMsg
(
config
*
conf
.
Config
,
msgType
uint8
,
msgContent
message
.
Message
)
[]
byte
{
switch
msgType
{
switch
msgType
{
case
message
.
MsgTypeAssociationSetupRequest
:
return
handleAssociationSetupRequest
(
msgContent
)
case
message
.
MsgTypeHeartbeatRequest
:
case
message
.
MsgTypeHeartbeatRequest
:
return
handleHeartBeatMsg
(
msgContent
)
return
handleHeartBeatMsg
(
msgContent
)
case
message
.
MsgTypeSessionEstablishmentRequest
:
case
message
.
MsgTypeSessionEstablishmentRequest
:
...
@@ -110,6 +113,27 @@ func handleMsg(config *conf.Config, msgType uint8, msgContent message.Message) [
...
@@ -110,6 +113,27 @@ func handleMsg(config *conf.Config, msgType uint8, msgContent message.Message) [
return
nil
return
nil
}
}
func
handleAssociationSetupRequest
(
msgContent
message
.
Message
)
[]
byte
{
msg
,
ok
:=
msgContent
.
(
*
message
.
AssociationSetupRequest
)
if
!
ok
{
log
.
Warn
(
"got unexpected message: "
+
msg
.
MessageTypeName
())
}
smfIP
,
_
:=
msg
.
NodeID
.
NodeID
()
log
.
Info
(
"Get association request from "
+
smfIP
)
sql
.
InsertIP
(
smfIP
,
sql
.
ASSOCIATIONTRUE
)
nodeID
:=
ie
.
NewNodeID
(
"192.168.2.216"
,
""
,
""
)
ts
:=
ie
.
NewRecoveryTimeStamp
(
time
.
Now
())
cp
:=
ie
.
NewCPFunctionFeatures
(
16
)
response
,
err
:=
message
.
NewAssociationSetupResponse
(
0
,
0
,
0
,
nodeID
,
ts
,
cp
)
.
Marshal
()
if
err
!=
nil
{
log
.
Warn
(
"Encapsulate Association Setup Response is failed, info is "
+
err
.
Error
())
}
return
response
}
func
handleHeartBeatMsg
(
msgContent
message
.
Message
)
[]
byte
{
func
handleHeartBeatMsg
(
msgContent
message
.
Message
)
[]
byte
{
msg
,
ok
:=
msgContent
.
(
*
message
.
HeartbeatRequest
)
msg
,
ok
:=
msgContent
.
(
*
message
.
HeartbeatRequest
)
...
@@ -137,12 +161,6 @@ func handleHeartBeatMsg(msgContent message.Message) []byte {
...
@@ -137,12 +161,6 @@ func handleHeartBeatMsg(msgContent message.Message) []byte {
func
handleSessionEstablishmentMsg
(
config
*
conf
.
Config
,
msgContent
message
.
Message
)
[]
byte
{
func
handleSessionEstablishmentMsg
(
config
*
conf
.
Config
,
msgContent
message
.
Message
)
[]
byte
{
msg
,
ok
:=
msgContent
.
(
*
message
.
SessionEstablishmentRequest
)
msg
,
ok
:=
msgContent
.
(
*
message
.
SessionEstablishmentRequest
)
defer
func
()
{
err
:=
recover
()
if
err
!=
nil
{
log
.
Error
(
"Panicing %s
\n
"
,
err
)
}
}()
if
!
ok
{
if
!
ok
{
log
.
Warn
(
"got unexpected message: "
+
msg
.
MessageTypeName
())
log
.
Warn
(
"got unexpected message: "
+
msg
.
MessageTypeName
())
...
@@ -166,9 +184,9 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
...
@@ -166,9 +184,9 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
sourceInterface
,
_
:=
pdiIEs
[
0
]
.
SourceInterface
()
sourceInterface
,
_
:=
pdiIEs
[
0
]
.
SourceInterface
()
//fteid, _ := pdiIEs[1].FTEID()
//fteid, _ := pdiIEs[1].FTEID()
ueipaddress
,
_
:=
pdiIEs
[
2
]
.
UEIPAddress
()
ueipaddress
,
_
:=
pdiIEs
[
2
]
.
UEIPAddress
()
farid
,
_
:=
createPDR
[
3
]
.
FARID
()
createFAR
,
_
:=
msg
.
CreateFAR
[
0
]
.
CreateFAR
()
createFAR
,
_
:=
msg
.
CreateFAR
[
0
]
.
CreateFAR
()
farid
,
_
:=
createFAR
[
0
]
.
FARID
()
applyAction
,
_
:=
createFAR
[
1
]
.
ApplyAction
()
applyAction
,
_
:=
createFAR
[
1
]
.
ApplyAction
()
forwardingParameters
,
_
:=
createFAR
[
2
]
.
ForwardingParameters
()
forwardingParameters
,
_
:=
createFAR
[
2
]
.
ForwardingParameters
()
destinationInterface
,
_
:=
forwardingParameters
[
0
]
.
DestinationInterface
()
destinationInterface
,
_
:=
forwardingParameters
[
0
]
.
DestinationInterface
()
...
@@ -199,7 +217,6 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
...
@@ -199,7 +217,6 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
Flags
:
1
,
Flags
:
1
,
Teid
:
ueUpTeid
[
ueipaddress
.
IPv4Address
.
String
()],
Teid
:
ueUpTeid
[
ueipaddress
.
IPv4Address
.
String
()],
IP
:
upf
.
BuptNodeValueIP4
(
ip4ToUint
(
config
.
Gnb
)),
IP
:
upf
.
BuptNodeValueIP4
(
ip4ToUint
(
config
.
Gnb
)),
//IP: upf.BuptNodeValueIP4([4]uint8{192, 168, 2, 137}),
},
},
UeAddr
:
upf
.
BuptPfcpUeIPAddress
{
UeAddr
:
upf
.
BuptPfcpUeIPAddress
{
Flags
:
2
,
Flags
:
2
,
...
@@ -251,12 +268,6 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
...
@@ -251,12 +268,6 @@ func handleSessionEstablishmentMsg(config *conf.Config, msgContent message.Messa
func
handleSessionModificationMsg
(
config
*
conf
.
Config
,
msgContent
message
.
Message
)
[]
byte
{
func
handleSessionModificationMsg
(
config
*
conf
.
Config
,
msgContent
message
.
Message
)
[]
byte
{
msg
,
ok
:=
msgContent
.
(
*
message
.
SessionModificationRequest
)
msg
,
ok
:=
msgContent
.
(
*
message
.
SessionModificationRequest
)
defer
func
()
{
err
:=
recover
()
if
err
!=
nil
{
log
.
Error
(
"Panicing %s
\n
"
,
err
)
}
}()
if
!
ok
{
if
!
ok
{
log
.
Warn
(
"got unexpected message: "
+
msg
.
MessageTypeName
())
log
.
Warn
(
"got unexpected message: "
+
msg
.
MessageTypeName
())
...
@@ -269,12 +280,8 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
...
@@ -269,12 +280,8 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
createPDR
,
_
:=
msg
.
CreatePDR
[
0
]
.
CreatePDR
()
createPDR
,
_
:=
msg
.
CreatePDR
[
0
]
.
CreatePDR
()
pdrid
,
_
:=
createPDR
[
0
]
.
PacketDetectionRuleID
()
pdrid
,
_
:=
createPDR
[
0
]
.
PacketDetectionRuleID
()
//precedence, _ := createPDR[1].Precedence()
pdiIEs
,
_
:=
createPDR
[
2
]
.
PDI
()
pdiIEs
,
_
:=
createPDR
[
2
]
.
PDI
()
//sourceInterface, _ := pdiIEs[0].SourceInterface()
//fteid, _ := pdiIEs[1].FTEID()
ueipaddress
,
_
:=
pdiIEs
[
1
]
.
UEIPAddress
()
ueipaddress
,
_
:=
pdiIEs
[
1
]
.
UEIPAddress
()
farid
,
_
:=
createPDR
[
3
]
.
FARID
()
modReqIP
=
ueipaddress
.
IPv4Address
.
String
()
modReqIP
=
ueipaddress
.
IPv4Address
.
String
()
...
@@ -282,9 +289,8 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
...
@@ -282,9 +289,8 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
ueSeid
[
msg
.
SEID
()]
=
ueipaddress
.
IPv4Address
.
String
()
ueSeid
[
msg
.
SEID
()]
=
ueipaddress
.
IPv4Address
.
String
()
createFAR
,
_
:=
msg
.
CreateFAR
[
0
]
.
CreateFAR
()
createFAR
,
_
:=
msg
.
CreateFAR
[
0
]
.
CreateFAR
()
//applyAction, _ := createFAR[1].ApplyAction
()
farid
,
_
:=
createFAR
[
0
]
.
FARID
()
forwardingParameters
,
_
:=
createFAR
[
2
]
.
ForwardingParameters
()
forwardingParameters
,
_
:=
createFAR
[
2
]
.
ForwardingParameters
()
//destinationInterface, _ := forwardingParameters[0].DestinationInterface()
outerHeaderCreation
,
_
:=
forwardingParameters
[
1
]
.
OuterHeaderCreation
()
outerHeaderCreation
,
_
:=
forwardingParameters
[
1
]
.
OuterHeaderCreation
()
ueIP
:=
ueipaddress
.
IPv4Address
.
String
()
ueIP
:=
ueipaddress
.
IPv4Address
.
String
()
...
@@ -292,6 +298,7 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
...
@@ -292,6 +298,7 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
log
.
Info
(
"SEID:%d"
,
msg
.
SEID
())
log
.
Info
(
"SEID:%d"
,
msg
.
SEID
())
log
.
Info
(
"TEID 0x%x"
,
outerHeaderCreation
.
TEID
)
log
.
Info
(
"TEID 0x%x"
,
outerHeaderCreation
.
TEID
)
log
.
Info
(
"UE IP: %s"
,
ueSeid
[
msg
.
SEID
()])
log
.
Info
(
"UE IP: %s"
,
ueSeid
[
msg
.
SEID
()])
log
.
Info
(
"PDR ID: %d"
,
pdrid
)
log
.
Info
(
"FAR ID:%d"
,
farid
)
log
.
Info
(
"FAR ID:%d"
,
farid
)
log
.
Info
(
"UE IPv4:%s"
,
ueIP
)
log
.
Info
(
"UE IPv4:%s"
,
ueIP
)
log
.
Info
(
"GNB GTPU IP:%s"
,
gnbIP
)
log
.
Info
(
"GNB GTPU IP:%s"
,
gnbIP
)
...
@@ -334,7 +341,6 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
...
@@ -334,7 +341,6 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
log
.
Info
(
"pdrid: %d"
,
farid
)
log
.
Info
(
"pdrid: %d"
,
farid
)
log
.
Info
(
"ueip %s:index %d"
,
ueip
,
updateUeIndex
[
ueip
])
log
.
Info
(
"ueip %s:index %d"
,
ueip
,
updateUeIndex
[
ueip
])
log
.
Info
(
"TEID 0x%x"
,
outerHeaderCreation
.
TEID
)
log
.
Info
(
"TEID 0x%x"
,
outerHeaderCreation
.
TEID
)
log
.
Info
(
"GNB GTPu: %s"
,
outerHeaderCreation
.
IPv4Address
.
String
())
req
:=
&
upf
.
UpfSsmReq
{
req
:=
&
upf
.
UpfSsmReq
{
CpSeid
:
msg
.
SEID
(),
CpSeid
:
msg
.
SEID
(),
...
@@ -350,7 +356,7 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
...
@@ -350,7 +356,7 @@ func handleSessionModificationMsg(config *conf.Config, msgContent message.Messag
FTeid
:
upf
.
BuptPfcpFTeid
{
FTeid
:
upf
.
BuptPfcpFTeid
{
Flags
:
1
,
Flags
:
1
,
Teid
:
outerHeaderCreation
.
TEID
,
Teid
:
outerHeaderCreation
.
TEID
,
IP
:
upf
.
BuptNodeValueIP4
(
ip4ToUint
(
outerHeaderCreation
.
IPv4Address
.
String
()
)),
IP
:
upf
.
BuptNodeValueIP4
(
ip4ToUint
(
config
.
Gnb
)),
},
},
UeAddr
:
upf
.
BuptPfcpUeIPAddress
{
UeAddr
:
upf
.
BuptPfcpUeIPAddress
{
Flags
:
2
,
Flags
:
2
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment