This repository has been archived by the owner on Apr 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
handler.go
71 lines (65 loc) · 2.08 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package n3iwf_handler
import (
"free5gc/src/n3iwf/n3iwf_context"
"free5gc/src/n3iwf/n3iwf_data_relay"
"free5gc/src/n3iwf/n3iwf_ike"
"free5gc/src/n3iwf/n3iwf_ngap/ngap_message"
"time"
"github.com/sirupsen/logrus"
"free5gc/src/n3iwf/logger"
"free5gc/src/n3iwf/n3iwf_handler/n3iwf_message"
"free5gc/src/n3iwf/n3iwf_ngap"
"free5gc/src/n3iwf/n3iwf_ngap/ngap_handler"
)
var handlerLog *logrus.Entry
func init() {
// init pool
handlerLog = logger.HandlerLog
}
func Handle() {
for {
select {
case msg, ok := <-n3iwf_message.N3iwfChannel:
if ok {
switch msg.Event {
case n3iwf_message.EventSCTPConnectMessage:
ngap_handler.HandleEventSCTPConnect(msg.SCTPAddr)
case n3iwf_message.EventNGAPMessage:
n3iwf_ngap.Dispatch(msg.SCTPAddr, msg.Value.([]byte))
case n3iwf_message.EventTimerSendRanConfigUpdateMessage:
handlerLog.Infof("Re-send Ran Configuration Update Message when waiting time expired")
self := n3iwf_context.N3IWFSelf()
self.AMFReInitAvailableList[msg.SCTPAddr] = true
ngap_message.SendRANConfigurationUpdate(self.AMFPool[msg.SCTPAddr])
case n3iwf_message.EventN1UDPMessage:
n3iwf_ike.Dispatch(msg.UDPSendInfo, msg.Value.([]byte))
case n3iwf_message.EventN1TunnelUPMessage:
self := n3iwf_context.N3IWFSelf()
ue, ok := self.AllocatedUEIPAddress[msg.UEInnerIP]
if !ok {
handlerLog.Error("UE context not found")
continue
}
n3iwf_data_relay.ForwardUPTrafficFromN1(ue, msg.Value.([]byte))
case n3iwf_message.EventGTPMessage:
self := n3iwf_context.N3IWFSelf()
ue, ok := self.AllocatedUETEID[msg.TEID]
if !ok {
handlerLog.Error("UE context not found")
continue
}
n3iwf_data_relay.ForwardUPTrafficFromN3(ue, msg.Value.([]byte))
case n3iwf_message.EventN1TunnelCPMessage:
self := n3iwf_context.N3IWFSelf()
ue, ok := self.AllocatedUEIPAddress[msg.UEInnerIP]
if !ok {
handlerLog.Error("UE context not found")
continue
}
n3iwf_data_relay.ForwardCPTrafficFromN1(ue, msg.Value.([]byte))
}
}
case <-time.After(1 * time.Second):
}
}
}