Skip to content

Commit

Permalink
fix: fix line length < 120
Browse files Browse the repository at this point in the history
fix: fix line length

fix: fix line length

fix: fix line length

fix: fix length
  • Loading branch information
a3828162 authored and andy89923 committed Apr 18, 2024
1 parent 5fc6ef5 commit 54a4740
Show file tree
Hide file tree
Showing 14 changed files with 1,037 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ linters-settings:
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
line-length: 140
# tab width in spaces. Default to 1.
tab-width: 1
maligned:
Expand Down
6 changes: 5 additions & 1 deletion internal/nwucp/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ func Dispatch(conn net.Conn, nasEnv []byte) {

// Decap Nas envelope
nasEnv, _ = ngapPacket.DecapNasPduFromEnvelope(nasEnv[:])
nasMsg, err := n3ue_security.NASDecode(n3ueSelf.RanUeContext, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, nasEnv[:len((nasEnv))])
nasMsg, err := n3ue_security.NASDecode(
n3ueSelf.RanUeContext,
nas.SecurityHeaderTypeIntegrityProtectedAndCiphered,
nasEnv[:],
)
if err != nil {
naslog.Errorf("NAS Decode Fail: %+v", err)
return
Expand Down
8 changes: 7 additions & 1 deletion internal/nwucp/handler/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import (
)

func SendNasMsg(ue *security.RanUeContext, conn net.Conn, msg []byte) {
pdu, err := ngapPacket.EncodeNasPduInEnvelopeWithSecurity(ue, msg, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false)
pdu, err := ngapPacket.EncodeNasPduInEnvelopeWithSecurity(
ue,
msg,
nas.SecurityHeaderTypeIntegrityProtectedAndCiphered,
true,
false,
)
if err != nil {
naslog.Errorf("EncodeNasPduWithSecurity: %+v", err)
return
Expand Down
12 changes: 10 additions & 2 deletions internal/packet/nasPacket/nasPduDl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ import (
"github.com/free5gc/nas/nasMessage"
)

func DecodePDUSessionEstablishmentAccept(ue *n3ue_security.RanUeContext, length int, buffer []byte) (*nas.Message, error) {
func DecodePDUSessionEstablishmentAccept(
ue *n3ue_security.RanUeContext,
length int,
buffer []byte,
) (*nas.Message, error) {
if length == 0 {
return nil, fmt.Errorf("Empty buffer")
}

nasEnv, n := ngapPacket.DecapNasPduFromEnvelope(buffer[:length])
nasMsg, err := n3ue_security.NASDecode(ue, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, nasEnv[:n])
nasMsg, err := n3ue_security.NASDecode(
ue,
nas.SecurityHeaderTypeIntegrityProtectedAndCiphered,
nasEnv[:n],
)
if err != nil {
return nil, fmt.Errorf("NAS Decode Fail: %+v", err)
}
Expand Down
39 changes: 29 additions & 10 deletions internal/packet/nasPacket/nasPduUl.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,17 @@ func GetPduSessionEstablishmentRequest(pduSessionId uint8) []byte {
pduSessionEstablishmentRequest.IntegrityProtectionMaximumDataRate.
SetMaximumDataRatePerUEForUserPlaneIntegrityProtectionForUpLink(0xff)

pduSessionEstablishmentRequest.PDUSessionType = nasType.NewPDUSessionType(nasMessage.PDUSessionEstablishmentRequestPDUSessionTypeType)
pduSessionEstablishmentRequest.PDUSessionType = nasType.NewPDUSessionType(
nasMessage.PDUSessionEstablishmentRequestPDUSessionTypeType,
)
pduSessionEstablishmentRequest.PDUSessionType.SetPDUSessionTypeValue(uint8(0x01)) // IPv4 type

pduSessionEstablishmentRequest.SSCMode = nasType.NewSSCMode(nasMessage.PDUSessionEstablishmentRequestSSCModeType)
pduSessionEstablishmentRequest.SSCMode.SetSSCMode(uint8(0x01)) // SSC Mode 1

pduSessionEstablishmentRequest.ExtendedProtocolConfigurationOptions = nasType.NewExtendedProtocolConfigurationOptions(
nasMessage.PDUSessionEstablishmentRequestExtendedProtocolConfigurationOptionsType)
nasMessage.PDUSessionEstablishmentRequestExtendedProtocolConfigurationOptionsType,
)
protocolConfigurationOptions := nasConvert.NewProtocolConfigurationOptions()
protocolConfigurationOptions.AddIPAddressAllocationViaNASSignallingUL()
protocolConfigurationOptions.AddDNSServerIPv4AddressRequest()
Expand Down Expand Up @@ -154,7 +157,9 @@ func GetUlNasTransport_PduSessionEstablishmentRequest(pduSessionId uint8, reques
ulNasTransport.SNSSAI.SetSD(sdTemp)
}

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(pduSessionEstablishmentRequest)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(pduSessionEstablishmentRequest)

Expand Down Expand Up @@ -207,7 +212,9 @@ func GetUlNasTransport_PduSessionModificationRequest(pduSessionId uint8, request
ulNasTransport.SNSSAI.SetSD(sdTemp)
}

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(pduSessionModificationRequest)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(pduSessionModificationRequest)

Expand Down Expand Up @@ -422,7 +429,9 @@ func GetUlNasTransport_PduSessionCommonData(pduSessionId uint8, types string) []
ulNasTransport.PduSessionID2Value.SetIei(nasMessage.ULNASTransportPduSessionID2ValueType)
ulNasTransport.PduSessionID2Value.SetPduSessionID2Value(pduSessionId)

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(payload)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(payload)

Expand Down Expand Up @@ -733,7 +742,9 @@ func GetDeregistrationRequest(accessType uint8, switchOff uint8, ngKsi uint8,
deregistrationRequest.NgksiAndDeregistrationType.SetTSC(ngKsi)
deregistrationRequest.NgksiAndDeregistrationType.SetNasKeySetIdentifiler(ngKsi)
deregistrationRequest.MobileIdentity5GS.SetLen(mobileIdentity5GS.GetLen())
deregistrationRequest.MobileIdentity5GS.SetMobileIdentity5GSContents(mobileIdentity5GS.GetMobileIdentity5GSContents())
deregistrationRequest.MobileIdentity5GS.SetMobileIdentity5GSContents(
mobileIdentity5GS.GetMobileIdentity5GSContents(),
)

m.GmmMessage.DeregistrationRequestUEOriginatingDeregistration = deregistrationRequest

Expand Down Expand Up @@ -776,7 +787,9 @@ func GetStatus5GMM(cause uint8) []byte {
m.GmmHeader.SetMessageType(nas.MsgTypeStatus5GMM)

status5GMM := nasMessage.NewStatus5GMM(0)
status5GMM.ExtendedProtocolDiscriminator.SetExtendedProtocolDiscriminator(nasMessage.Epd5GSMobilityManagementMessage)
status5GMM.ExtendedProtocolDiscriminator.SetExtendedProtocolDiscriminator(
nasMessage.Epd5GSMobilityManagementMessage,
)
status5GMM.SpareHalfOctetAndSecurityHeaderType.SetSecurityHeaderType(nas.SecurityHeaderTypePlainNas)
status5GMM.SpareHalfOctetAndSecurityHeaderType.SetSpareHalfOctet(0)
status5GMM.STATUSMessageIdentity5GMM.SetMessageType(nas.MsgTypeStatus5GMM)
Expand Down Expand Up @@ -832,7 +845,9 @@ func GetUlNasTransport_Status5GSM(pduSessionId uint8, cause uint8) []byte {
ulNasTransport.PduSessionID2Value.SetIei(nasMessage.ULNASTransportPduSessionID2ValueType)
ulNasTransport.PduSessionID2Value.SetPduSessionID2Value(pduSessionId)

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(payload)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(payload)

Expand Down Expand Up @@ -863,7 +878,9 @@ func GetUlNasTransport_PduSessionReleaseRequest(pduSessionId uint8) []byte {
ulNasTransport.PduSessionID2Value.SetIei(nasMessage.ULNASTransportPduSessionID2ValueType)
ulNasTransport.PduSessionID2Value.SetPduSessionID2Value(pduSessionId)

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(pduSessionReleaseRequest)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(pduSessionReleaseRequest)

Expand Down Expand Up @@ -916,7 +933,9 @@ func GetUlNasTransport_PduSessionReleaseComplete(pduSessionId uint8, requestType
ulNasTransport.SNSSAI.SetSD(sdTemp)
}

ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(nasMessage.PayloadContainerTypeN1SMInfo)
ulNasTransport.SpareHalfOctetAndPayloadContainerType.SetPayloadContainerType(
nasMessage.PayloadContainerTypeN1SMInfo,
)
ulNasTransport.PayloadContainer.SetLen(uint16(len(pduSessionReleaseRequest)))
ulNasTransport.PayloadContainer.SetPayloadContainerContents(pduSessionReleaseRequest)

Expand Down
Loading

0 comments on commit 54a4740

Please sign in to comment.