Skip to content

Commit

Permalink
chore: version bump to go1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed May 31, 2024
1 parent 9d2a6bb commit 9ce0615
Show file tree
Hide file tree
Showing 13 changed files with 147 additions and 164 deletions.
54 changes: 43 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
module github.com/free5gc/n3iwue

go 1.14
go 1.21

require (
github.com/antonfisher/nested-logrus-formatter v1.3.1
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/calee0219/fatal v0.0.1
github.com/davecgh/go-spew v1.1.1
github.com/free5gc/aper v1.0.4
github.com/free5gc/n3iwf v1.1.1-0.20220401140259-74fb84b2c3be
github.com/free5gc/aper v1.0.5
github.com/free5gc/n3iwf v1.2.2
github.com/free5gc/nas v1.0.7
github.com/free5gc/ngap v1.0.6
github.com/free5gc/openapi v1.0.4
github.com/free5gc/util v1.0.1
github.com/free5gc/ngap v1.0.8
github.com/free5gc/openapi v1.0.8
github.com/free5gc/util v1.0.6
github.com/go-ping/ping v0.0.0-20211014180314-6e2b003bffdd
github.com/sirupsen/logrus v1.8.1
github.com/ugorji/go v1.2.1 // indirect
github.com/vishvananda/netlink v1.1.0
golang.org/x/net v0.7.0
golang.org/x/sys v0.5.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
golang.org/x/net v0.17.0
golang.org/x/sys v0.15.0
gopkg.in/yaml.v3 v3.0.1
)

replace github.com/free5gc/n3iwue => ./
require (
github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/free5gc/sctp v1.0.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
github.com/wmnsk/go-gtp v0.8.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
205 changes: 78 additions & 127 deletions go.sum

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ func init() {
}

func LogFileHook(filename string) error {
if fullPath, err := logger_util.CreateNfLogFile("./", filename); err == nil {
selfLogHook, hookErr := logger_util.NewFileHook(fullPath, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666)
if hookErr != nil {
return hookErr
}
if selfLogHook, err := logger_util.NewFileHook("./"+filename, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666); err == nil {
log.Hooks.Add(selfLogHook)
} else {
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/nwucp/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func HandleRegistrationAccept(n3ueSelf *context.N3UE, nasMsg *nas.Message) {

// send NAS Registration Complete Msg
pdu := nasPacket.GetRegistrationComplete(nil)
SendNasMsg(n3ueSelf.RanUeContext, n3ueSelf.N3IWFUe.TCPConnection, pdu)
SendNasMsg(n3ueSelf.RanUeContext, n3ueSelf.N3IWFRanUe.TCPConnection, pdu)

time.Sleep(500 * time.Millisecond)
n3ueSelf.CurrentState <- uint8(context.PduSessionEst)
Expand Down
4 changes: 2 additions & 2 deletions internal/nwucp/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func serveConn(n3ueSelf *context.N3UE, errChan chan<- error) {
nwucpLog.Error(err)
errChan <- errors.New("nwup serveConn failed")
}
n3ueSelf.N3IWFUe.TCPConnection = tcpConnWithN3IWF
n3ueSelf.N3IWFRanUe.TCPConnection = tcpConnWithN3IWF

close(errChan)

Expand All @@ -67,7 +67,7 @@ func serveConn(n3ueSelf *context.N3UE, errChan chan<- error) {
if err != nil {
if err.Error() == "EOF" {
nwucpLog.Warn("Connection close by peer")
n3ueSelf.N3IWFUe.TCPConnection = nil
n3ueSelf.N3IWFRanUe.TCPConnection = nil
return
} else {
nwucpLog.Errorf("Read TCP connection failed: %+v", err)
Expand Down
5 changes: 3 additions & 2 deletions internal/util/initContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ func InitN3UEContext() {
n3ueContext.N3ueInfo = factory.N3ueConfig.Configuration.N3UEInfo
n3ueContext.N3iwfInfo = factory.N3ueConfig.Configuration.N3IWFInfo

n3ueContext.N3IWFUe = new(n3iwfContext.N3IWFUe)
n3ueContext.N3IWFUe.PduSessionList = make(map[int64]*n3iwfContext.PDUSession)
n3ueContext.N3IWFUe = new(n3iwfContext.N3IWFIkeUe)
n3ueContext.N3IWFRanUe = new(n3iwfContext.N3IWFRanUe)
n3ueContext.N3IWFRanUe.PduSessionList = make(map[int64]*n3iwfContext.PDUSession)
n3ueContext.N3IWFUe.N3IWFChildSecurityAssociation = make(map[uint32]*n3iwfContext.ChildSecurityAssociation)
n3ueContext.N3IWFUe.TemporaryExchangeMsgIDChildSAMapping = make(map[uint32]*n3iwfContext.ChildSecurityAssociation)
n3ueContext.PduSessionCount = 1
Expand Down
3 changes: 2 additions & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const (
)

type N3UE struct {
N3IWFUe *context.N3IWFUe
N3IWFUe *context.N3IWFIkeUe
N3IWFRanUe *context.N3IWFRanUe
N3ueInfo factory.N3UEInfo
N3iwfInfo factory.N3IWFInfo
RanUeContext *security.RanUeContext
Expand Down
3 changes: 1 addition & 2 deletions pkg/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package factory
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"

Expand All @@ -21,7 +20,7 @@ var filePath string

func InitConfigFactory(f string) error {
filePath = f
if content, err := ioutil.ReadFile(filePath); err != nil {
if content, err := os.ReadFile(filePath); err != nil {
return err
} else {
N3ueConfig = Config{}
Expand Down
11 changes: 6 additions & 5 deletions pkg/ike/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func HandleIKESAINIT(
DiffieHellmanGroup: n3ueSelf.Proposal.DiffieHellmanGroup[0],
ConcatenatedNonce: append(n3ueSelf.LocalNonce, remoteNonce...),
DiffieHellmanSharedKey: sharedKeyExchangeData,
LocalUnsignedAuthentication: append(n3ueSelf.N3IWFUe.N3IWFIKESecurityAssociation.
LocalUnsignedAuthentication, remoteNonce...),
ResponderSignedOctets: append(n3ueSelf.N3IWFUe.N3IWFIKESecurityAssociation.
ResponderSignedOctets, remoteNonce...),
}

if err := GenerateKeyForIKESA(ikeSecurityAssociation); err != nil {
Expand Down Expand Up @@ -464,8 +464,8 @@ func HandleIKEAUTH(
ikeLog.Errorf("Pseudorandom function write error: %+v", err)
return
}
ikeSecurityAssociation.LocalUnsignedAuthentication = append(
ikeSecurityAssociation.LocalUnsignedAuthentication,
ikeSecurityAssociation.ResponderSignedOctets = append(
ikeSecurityAssociation.ResponderSignedOctets,
pseudorandomFunction.Sum(nil)...)

transformPseudorandomFunction := ikeSecurityAssociation.PseudorandomFunction
Expand Down Expand Up @@ -496,7 +496,7 @@ func HandleIKEAUTH(
return
}
pseudorandomFunction.Reset()
if _, err = pseudorandomFunction.Write(ikeSecurityAssociation.LocalUnsignedAuthentication); err != nil {
if _, err = pseudorandomFunction.Write(ikeSecurityAssociation.ResponderSignedOctets); err != nil {
ikeLog.Errorf("Pseudorandom function write error: %+v", err)
return
}
Expand Down Expand Up @@ -727,6 +727,7 @@ func HandleCREATECHILDSA(
n3ueSelf.N3IWFUe.CreateHalfChildSA(
ikeSecurityAssociation.ResponderMessageID,
binary.BigEndian.Uint32(inboundSPI),
-1,
)
childSecurityAssociationContextUserPlane, err := n3ueSelf.N3IWFUe.CompleteChildSA(
ikeSecurityAssociation.ResponderMessageID, OutboundSPI, responseSecurityAssociation)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ike/handler/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func GenerateKeyForChildSA(
return nil
}

func GenerateSPI(n3ue *context.N3IWFUe) []byte {
func GenerateSPI(n3ue *context.N3IWFIkeUe) []byte {
var spi uint32
spiByte := make([]byte, 4)
for {
Expand Down
3 changes: 2 additions & 1 deletion pkg/ike/handler/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func SendIKESAINIT() {
}

ikeSecurityAssociation := &n3iwfContext.IKESecurityAssociation{
LocalUnsignedAuthentication: realMessage1,
ResponderSignedOctets: realMessage1,
}
n3ueContext.N3IWFUe.N3IWFIKESecurityAssociation = ikeSecurityAssociation
}
Expand Down Expand Up @@ -170,6 +170,7 @@ func SendIKEAUTH() {
n3ueContext.N3IWFUe.CreateHalfChildSA(
n3ueContext.N3IWFUe.N3IWFIKESecurityAssociation.InitiatorMessageID,
factory.N3ueInfo.IPSecSaCpSPI,
-1,
)
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/ike/xfrm/xfrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"github.com/vishvananda/netlink"

n3iwf_context "github.com/free5gc/n3iwf/pkg/context"
"github.com/free5gc/n3iwf/pkg/ike/handler"
context "github.com/free5gc/n3iwue/pkg/context"

"github.com/free5gc/n3iwf/pkg/ike/xfrm"
)

// Log
Expand All @@ -34,23 +35,23 @@ func ApplyXFRMRule(
var xfrmEncryptionAlgorithm, xfrmIntegrityAlgorithm *netlink.XfrmStateAlgo
if ue_is_initiator {
xfrmEncryptionAlgorithm = &netlink.XfrmStateAlgo{
Name: handler.XFRMEncryptionAlgorithmType(childSecurityAssociation.EncryptionAlgorithm).String(),
Name: xfrm.XFRMEncryptionAlgorithmType(childSecurityAssociation.EncryptionAlgorithm).String(),
Key: childSecurityAssociation.ResponderToInitiatorEncryptionKey,
}
if childSecurityAssociation.IntegrityAlgorithm != 0 {
xfrmIntegrityAlgorithm = &netlink.XfrmStateAlgo{
Name: handler.XFRMIntegrityAlgorithmType(childSecurityAssociation.IntegrityAlgorithm).String(),
Name: xfrm.XFRMIntegrityAlgorithmType(childSecurityAssociation.IntegrityAlgorithm).String(),
Key: childSecurityAssociation.ResponderToInitiatorIntegrityKey,
}
}
} else {
xfrmEncryptionAlgorithm = &netlink.XfrmStateAlgo{
Name: handler.XFRMEncryptionAlgorithmType(childSecurityAssociation.EncryptionAlgorithm).String(),
Name: xfrm.XFRMEncryptionAlgorithmType(childSecurityAssociation.EncryptionAlgorithm).String(),
Key: childSecurityAssociation.InitiatorToResponderEncryptionKey,
}
if childSecurityAssociation.IntegrityAlgorithm != 0 {
xfrmIntegrityAlgorithm = &netlink.XfrmStateAlgo{
Name: handler.XFRMIntegrityAlgorithmType(childSecurityAssociation.IntegrityAlgorithm).String(),
Name: xfrm.XFRMIntegrityAlgorithmType(childSecurityAssociation.IntegrityAlgorithm).String(),
Key: childSecurityAssociation.InitiatorToResponderIntegrityKey,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/procedure/Procedure.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func StartProcedure() {
for !done {
err := nwucp_handler.
SendPduSessionEstablishmentRequest(n3ueSelf.RanUeContext,
n3ueSelf.N3IWFUe.TCPConnection, n3ueSelf.PduSessionCount)
n3ueSelf.N3IWFRanUe.TCPConnection, n3ueSelf.PduSessionCount)
if err != nil {
AppLog.Errorf("Send PduSession Establishment Request failed: %+v", err)
} else {
Expand Down

0 comments on commit 9ce0615

Please sign in to comment.