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

Enable go vet in CI #116

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,10 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
# enable or disable analyzers by name
enable:
- atomicalign
enable-all: false
# enable all analyzers
enable-all: true
disable:
- shadow
disable-all: false
- fieldalignment
depguard:
list-type: blacklist
include-go-root: false
Expand Down Expand Up @@ -219,7 +216,7 @@ linters-settings:
linters:
enable:
- gofmt
# - govet
- govet
# - errcheck
# - staticcheck
# - unused
Expand Down
14 changes: 7 additions & 7 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,55 +122,55 @@ func (c *Config) Validate() (err error) {
PIter.ProcMap[1] = common.GetProcId(x[0])
PIter.WaitMap[1], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Second) > 0 {
x := strings.Fields(v1.Second)
PIter.ProcMap[2] = common.GetProcId(x[0])
PIter.WaitMap[2], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Third) > 0 {
x := strings.Fields(v1.Third)
PIter.ProcMap[3] = common.GetProcId(x[0])
PIter.WaitMap[3], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Fourth) > 0 {
x := strings.Fields(v1.Fourth)
PIter.ProcMap[4] = common.GetProcId(x[0])
PIter.WaitMap[4], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Fifth) > 0 {
x := strings.Fields(v1.Fifth)
PIter.ProcMap[5] = common.GetProcId(x[0])
PIter.WaitMap[5], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Sixth) > 0 {
x := strings.Fields(v1.Sixth)
PIter.ProcMap[6] = common.GetProcId(x[0])
PIter.WaitMap[6], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
if len(v1.Seventh) > 0 {
x := strings.Fields(v1.Seventh)
PIter.ProcMap[7] = common.GetProcId(x[0])
PIter.WaitMap[7], err = strconv.Atoi(x[1])
if err != nil {
fmt.Errorf("Value is not converted to integer: %v\n", err)
return fmt.Errorf("Value is not converted to integer: %v\n", err)
}
}
v.PIterations[v1.Name] = PIter // add iterations in the custom profile
Expand Down
3 changes: 2 additions & 1 deletion gnodeb/transport/cptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (cpTprt *GnbCpTransport) ConnectToPeer(peer transportcommon.TransportPeer)
if amf.AmfHostName == "" {
return fmt.Errorf("amf ip or host name not configured")
}
addrs, err := net.LookupHost(amf.AmfHostName)
var addrs []string
addrs, err = net.LookupHost(amf.AmfHostName)
if err != nil {
return fmt.Errorf("failed to resolve amf host name: %v, err: %v",
amf.AmfHostName, err)
Expand Down
61 changes: 34 additions & 27 deletions gnodeb/worker/gnbamfworker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ import (
// HandleNGSetupResponse processes the NG Setup Response and updates GnbAmf
// context
func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) {
if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing NG Setup Response")
var amfName *ngapType.AMFName
var servedGUAMIList *ngapType.ServedGUAMIList
var relativeAMFCapacity *ngapType.RelativeAMFCapacity
var plmnSupportList *ngapType.PLMNSupportList
// TODO Process optional IEs

if amf == nil {
amf.Log.Errorln("ran is nil")
return
}
if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -159,13 +160,14 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) {
}

func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) {
amf.Log.Traceln("Processing NG Setup Failure")
var cause *ngapType.Cause

if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing NG Setup Failure")
var cause *ngapType.Cause

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -205,13 +207,14 @@ func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) {
func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
pdu *ngapType.NGAPPDU) {

amf.Log.Traceln("Processing Downlink Nas Transport")
var gnbUeNgapId *ngapType.RANUENGAPID

if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing Downlink Nas Transport")
var gnbUeNgapId *ngapType.RANUENGAPID

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -257,13 +260,14 @@ func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
pdu *ngapType.NGAPPDU) {

amf.Log.Traceln("Processing Initial Context Setup Request")
var gnbUeNgapId *ngapType.RANUENGAPID

if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing Initial Context Setup Request")
var gnbUeNgapId *ngapType.RANUENGAPID

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -308,13 +312,14 @@ func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
// TODO : Much of the code is repeated in each handler
func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
pdu *ngapType.NGAPPDU) {
amf.Log.Traceln("Processing Pdu Session Resource Setup Request")
var gnbUeNgapId *ngapType.RANUENGAPID

if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing Pdu Session Resource Setup Request")
var gnbUeNgapId *ngapType.RANUENGAPID

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -357,13 +362,14 @@ func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,

func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
pdu *ngapType.NGAPPDU) {
amf.Log.Traceln("Processing Pdu Session Resource Release Command")
var gnbUeNgapId *ngapType.RANUENGAPID

if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}
amf.Log.Traceln("Processing Pdu Session Resource Release Command")
var gnbUeNgapId *ngapType.RANUENGAPID

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand Down Expand Up @@ -406,12 +412,14 @@ func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,

func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
pdu *ngapType.NGAPPDU) {

amf.Log.Traceln("Processing Ue Context Release Command")
if amf == nil {
amf = new(gnbctx.GnbAmf)
amf.Log.Errorln("ran is nil")
return
}

amf.Log.Traceln("Processing Ue Context Release Command")

if pdu == nil {
amf.Log.Errorln("NGAP Message is nil")
return
Expand All @@ -422,7 +430,6 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
}

var ueNgapIds *ngapType.UENGAPIDs
var ranUeNgapId *ngapType.RANUENGAPID

initiatingMessage := pdu.InitiatingMessage
if initiatingMessage == nil {
Expand All @@ -449,20 +456,20 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
}

if ueNgapIds.Present == ngapType.UENGAPIDsPresentUENGAPIDPair {
ranUeNgapId = &ueNgapIds.UENGAPIDPair.RANUENGAPID
if ranUeNgapId == nil {
amf.Log.Errorln("RANUENGAPID is nil")
if ueNgapIds.UENGAPIDPair == nil {
amf.Log.Errorln("UENGAPIDPair is nil")
return
}
} else {
/*TODO: Should add mapping for AMFUENGAPID vs GnbCpUeContext*/
amf.Log.Errorln("No RANUENGAPID received")
return
}

ngapId := ranUeNgapId.Value
ngapId := ueNgapIds.UENGAPIDPair.RANUENGAPID.Value
gnbue := gnb.GnbUes.GetGnbCpUe(ngapId)
if gnbue == nil {
amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:")
amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:", ngapId)
return
}

Expand Down
7 changes: 4 additions & 3 deletions profile/context/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm
time.Sleep(time.Millisecond * time.Duration(itp.WaitMap[pCtx.CurrentProcIndex]))
}
nextProcIndex := pCtx.CurrentProcIndex + 1
nextProcedure, found := itp.ProcMap[nextProcIndex]
var found bool
nextProcedure, found = itp.ProcMap[nextProcIndex]
if found == true {
pCtx.Log.Infof("Next Procedure Index %v and next Procedure = %v ", nextProcIndex, nextProcedure)
pCtx.Procedure = nextProcedure
Expand All @@ -361,7 +362,7 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm
pCtx.Repeat = pCtx.Repeat - 1
pCtx.Log.Infoln("Repeat current iteration : ", itp.Name, ", Repeat Count ", pCtx.Repeat)
pCtx.CurrentProcIndex = 1
nextProcedure := itp.ProcMap[1]
nextProcedure = itp.ProcMap[1]
pCtx.Procedure = nextProcedure
return nextProcedure
}
Expand All @@ -373,7 +374,7 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm
pCtx.CurrentItr = nItr.Name
pCtx.CurrentProcIndex = 1
pCtx.Repeat = nItr.Repeat
nextProcedure := nItr.ProcMap[1]
nextProcedure = nItr.ProcMap[1]
pCtx.Procedure = nextProcedure
return nextProcedure
}
Expand Down
3 changes: 2 additions & 1 deletion realue/nas/nas_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func NASEncode(ue *realuectx.RealUe, msg *nas.Message, securityContextAvailable
// add sequence number
payload = append([]byte{ue.ULCount.SQN()}, payload[:]...)

mac32, err := security.NASMacCalculate(ue.IntegrityAlg, ue.KnasInt, ue.ULCount.Get(),
var mac32 []byte
mac32, err = security.NASMacCalculate(ue.IntegrityAlg, ue.KnasInt, ue.ULCount.Get(),
security.Bearer3GPP, security.DirectionUplink, payload)
if err != nil {
return nil, fmt.Errorf("nas mac calcuate failed: %+v", err)
Expand Down
2 changes: 1 addition & 1 deletion util/ngapTestpacket/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ func BuildUERadioCapabilityInfoIndication() (pdu ngapType.NGAPPDU) {
ie.Value.Present = ngapType.UERadioCapabilityInfoIndicationIEsPresentUERadioCapability
ie.Value.UERadioCapability = new(ngapType.UERadioCapability)

uERadioCapability := ngapType.UERadioCapability{}
uERadioCapability := ie.Value.UERadioCapability
uERadioCapability.Value = aper.OctetString("\x00\x00\x01")

uERadioCapabilityInfoIndicationIEs.List = append(uERadioCapabilityInfoIndicationIEs.List, ie)
Expand Down